unrealircd / unrealircd-webpanel

An administration webpanel for UnrealIRCd
https://www.unrealircd.org/docs/UnrealIRCd_webpanel
GNU General Public License v3.0
22 stars 10 forks source link

Blank page on a new installation (php 8.2) #30

Closed Madriix closed 1 year ago

Madriix commented 1 year ago

Hello,

I did a fresh installation of UnrealIRCd-webpanel, so I deleted the directory from my FTP and removed all SQL tables. I also updated my PHP server to 8.2 and installed:

git clone https://github.com/unrealircd/unrealircd-webpanel cd unrealircd-webpanel composer install

(I am using cPanel and CentOS, so no need to set special permissions for the database)

On the first page, I filled out the form with my database information, and the connection was successfully established. Then, on the next page for the admin password and email, as soon as I submit it, I receive a blank page and cannot continue.

What could be causing this problem?

Best regards.

Sans titre-1

ValwareIRC commented 1 year ago

Thank you for your report. Please can you provide any relevant error logs from your apache/nginx error log?

Madriix commented 1 year ago

@ValwareIRC Ah it's good I see, I left the default configuration of Php 8.2, I just made sure to check things like fopen and to display the error logs and I increased the upload size as d Usually, I had forgotten all that. It's ok I get an error, and in fact I have to activate this module in php: Fatal error: Uncaught Error: Call to undefined function sodium_crypto_aead_xchacha20poly1305_ietf_keygen() in It is not noted that in https://www.unrealircd.org/docs/UnrealIRCd_webpanel

Madriix commented 1 year ago

@ValwareIRC it is solved. Under Cpanel I must activate the "mod_sodium".

Madriix commented 1 year ago

@ValwareIRC The list of users is not displayed in the "Users" section, but it works when I remove this code in common_api.php:

// Flush and stop output buffering (eg fastcgi w/NGINX)
/*while (1)
{
    try {
        $ret = @ob_end_flush();
        if ($ret === false)
            break;
    } catch(Exception $e)
    {
        break;
    }
};*/

I'm on apache

All lists are displayed on the other pages. On the other hand I have to look for the problem for "Channels" because it does not appear

Madriix commented 1 year ago

It's good I found, it's line 38 of the /api/channels.php file that is wrong

<b>Deprecated</b>: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in <b>/home/.../unrealircd-webpanel/api/channels.php</b> on line <b>38</b><br />

The line 38 is: usort($out, "custom_sort");

Madriix commented 1 year ago

The problem is solved, I replaced this:

function custom_sort($a,$b)
{
    return ($b["Users"] > $a["Users"]) ? true : false;
}

by :

function custom_sort($a, $b) {
    if ($b["Users"] > $a["Users"]) {
        return 1;
    } else if ($b["Users"] < $a["Users"]) {
        return -1;
    } else {
        return 0;
    }
}

I asked ChatGPT why I was getting this error with this function, and it gave me this function which fixes the problem

syzop commented 1 year ago

Both issues fixed now. Thanks!

By the way, @Madriix i believe you have PHP display_errors turned on. We talked about this before. It is good for developing stuff but will cause issues on production or indeed things like this webpanel where it would print a HTML warning in the middle of JSON output.

As they say in the PHP documentation:

Note: This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).