tltneon / lgsl

LGSL v6.2.1/v7.0.0 for PHP 5.4-8.3+ (Live Game Server List): online status for CS2 (Source Query), Discord, FiveM, Rust, SA:MP, GMOD, Minecraft, Teamspeak and 200+ more games!
GNU General Public License v3.0
153 stars 48 forks source link

PHP fwrite() Function #235

Open Sh4d0wless opened 1 week ago

Sh4d0wless commented 1 week ago

hello few days ago i transfered my web from VPS to shared hosting(with cpanel) on VPS everything was perfect, works well without any erros now im geting this error while cron runs

Notice:  fwrite(): send of 11 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1368
Notice:  fwrite(): send of 11 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1368
Notice:  ob_flush(): failed to flush buffer. No buffer to flush in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 51

[06-Nov-2024 16:25:02 UTC] PHP Notice:  fwrite(): send of 25 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1156
[06-Nov-2024 16:25:02 UTC] PHP Notice:  fwrite(): send of 25 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1156

plz help me solve this problem....

Rosenstein commented 1 week ago

Is fsockopen enabled or disabled on admin page?

If it is disabled, ask your host to enable outbound connections.

BaxAndrei commented 1 week ago

Make sure to use same php version for cron as one that you use for website. Ex: /usr/local/bin/php /home/baxandre/cleanup.php or /usr/local/bin/ea-php80 /home/baxandre/cleanup.php

Sh4d0wless commented 1 week ago

i added simple code in lgsl_cron.php

if(function_exists("fsockopen")) {
 echo "Function Exists";
 } else {
 echo "Function not exists";
}

Result is - Function Exists

CRON: /usr/local/bin/ea-php74 /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php site is on PHP 7.4 with LGSL 6.21

may be issue is in outbound 80/443 ports ?

or any other ideas?

Rosenstein commented 1 week ago

Try this

<?php
if(fsockopen("websistent.com",80))
{
print "I can see port 80";
}
else
{
print "I cannot see port 80";
}
?>
Sh4d0wless commented 1 week ago

can be fwrite() error caused only by fsockopen

Sh4d0wless commented 1 week ago

with ur code i got "I can see port 80"

then i tested with other (game ip:port)

if(fsockopen("80.241.245.222",1337)) { print "I can see port 1337"; } else { print "I cannot see port 1337"; }

and got this

Warning: fsockopen(): unable to connect to 80.241.245.222:1337 
(Connection refused) in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 20
I cannot see port 1337

i doubt fsockopen have to work for websites coz its allowed from php.ini with allow_url_fopen = On

but does not work for game IP:PORTs :(

Rosenstein commented 1 week ago

You should have tested port 27105 instead of 1337 as there is no app listening on that port at the destination IP

Your host whitelisted some ports. Ask them to whitelist the ports that you need

Sh4d0wless commented 1 week ago

Warning: fsockopen(): unable to connect to 80.241.245.222:27105 (Connection refused) in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 20 I cannot see port 1337

same

Rosenstein commented 1 week ago

This is host issue. Since lgsl is on the same box as the game servers it may be a NAT Loopback problem. Send a ticket to your host and ask them (they might need to enable outbound connections). If they refuse, ask them to enable traffic on the specific ports that you need.

Sh4d0wless commented 1 week ago

so as i understend its shld be 80 & 443 outbound ports for fsockopen ? and is fwrite() error caused only by fsockopen ?

Rosenstein commented 6 days ago

so as i understend its shld be 80 & 443 outbound ports for fsockopen ?

Yes and no. Excerpt from faq from one of the hosting companies:

The fsockopen function will work for outbound connections to any URL on port 80 (HTTP) or 443 (HTTPS). If fsockopen attempts to use another port, it will not work until we add that port to the firewall.

is fwrite() error caused only by fsockopen ?

Yes

Sh4d0wless commented 6 days ago

tnx for ur help and time... <3