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

updated to work on apache2 #46

Closed Madriix closed 7 months ago

Madriix commented 7 months ago

The lists of users and chat rooms... they are not functioning because users.php, for example, does not execute due to it stopping prematurely because of common_api.php. Disabling this, it works fine with Apache2. The same identical issue occurs on two different servers with Apache2: one before December 2023 on CentOS with Cpanel, and the same on Debian 12 with Apache2 as well.

Madriix commented 7 months ago

As soon as I add "//flush_completely();" to disable it, everything works fine on Apache2. But if I navigate to the homepage, the page becomes sluggish, and I have to restart PHP. Then, if I remove the "//" to enable "flush_completely();", nothing gets displayed at all. The code handling "flush_completely();" seems to be malfunctioning for Apache2. Additionally, I'm unsure about the purpose of "ob_end_flush();"; I've never used it in my scripts. Is it mandatory? Can't we manage without it?

TehPeGaSuS commented 7 months ago

I have no issues using:

Apache2 VirtualHost:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName webpanel.domain.tld

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/unrealircd-webpanel

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/webpanel-error.log
    CustomLog ${APACHE_LOG_DIR}/webpanel-access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

SSLCertificateFile /etc/letsencrypt/live/webpanel.domain.tld/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/webpanel.domain.tld/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Madriix commented 7 months ago

I have php 8.2.17, maybe it's because of that?

TehPeGaSuS commented 7 months ago

I have php 8.2.17, maybe it's because of that?

May as well be that. I can't test right now because I don't have any machine where I can update/upgrade PHP (too many things that I need to keep working reliably).

It wouldn't be the first time that PHP breaks stuff between minor versions without previous warning.

Madriix commented 7 months ago

@TehPeGaSuS ah yes I just looked in the logs:

[07-Apr-2024 15:16:35 Europe/Paris] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/xxx/domains/labs.xxx.com/public_html/unrealircd-webpanel/api/common_api.php:49) in /home/xxx/domains/labs.xxxr.com/public_html/unrealircd-webpanel/api/users.php on line 5

I removed the "//" in front of flush completely(); to generate this error

Madriix commented 7 months ago

Line 5 is this: header("Content-type: application/json; charset=utf-8");

As luck would have it, the line before is: require_once('common_api.php');

Madriix commented 7 months ago
if (!defined('NO_EVENT_STREAM_HEADER'))
flush_completely();

By modifying it like this, it seems to work too, and no need to restart PHP, because it doesn't row like an infinite loop. However, the home page does not display the statistics

Madriix commented 7 months ago

So, with the latest update, everything is working fine now, but it seems that another issue persists. It appears to be different from this 'if (!defined('NO_EVENT_STREAM_HEADER')) flush_completely();'. It concerns the homepage; it doesn't display any numbers, and I'm getting an error in the console: 001

I also noticed that JavaScript codes could load in any order because some are in the header and some are in the footer. Shouldn't we reorganize them using 'addEventListener("DOMContentLoaded", (event) => {});' ?

TehPeGaSuS commented 7 months ago

I'm wondering if PHP 8.2 isn't also a culprit for all those errors. Because I don't have any errors with PHP 8.1.

Madriix commented 7 months ago

Perhaps there's something not enabled in my UnrealIRCd 6.1.1.1, something that might not accept $rpc->log()->subscribe or $rpc->rpc()->add_timer. Is that possible?

Madriix commented 7 months ago

It's working now! It required adding this to php.ini:

output_buffering = Off
zlib.output_compression = Off

I preferred to do it on the subdomain of the site using Virtualmin.

php_value[output_buffering] = Off
php_value[zlib.output_compression] = Off

Sans titre

The info was seen here : https://lucidar.me/en/web-dev/server-sent-event-simple-php-example/

Madriix commented 7 months ago

Finally, I removed the two parameters from the virtualmin configuration, and instead, I placed them at the file common_api.php:

ini_set('output_buffering', 'off');
ini_set('zlib.output_compression', 'off');
Madriix commented 7 months ago

I just double-checked, and only this one needs to be modified:

ini_set('zlib.output_compression', 'off');

No need to touch output_buffering.