PHP Server Status

johnnei

New Member
Messages
20
Reaction score
0
Points
0
Ey,

Why is this script not working correctly on x10hosting? Cause on my own "beta test" server (the place where i test before putting on) it does work:

PHP:
<?php
    function smallStats() {
    
    $serverip = "CENSORED";
    $serverport    = "27960";
    $fserver = @fsockopen ($serverip ,$serverport, $err, $errstr, 1);
    if ( $fserver )
        $serverstatus = '<font color="#00ff00"><font class="serverOnline">Online</font></font>';
    else {
        $serverstatus = '<font color="#ff0000"><font class="serverOffline">Offline</font></font>';
         }
    
    echo '<h2>#m&m. Fun Server</h2>';
    echo 'Server: ' . $serverstatus;
    }
?>

I filled in multiple ip's to test but none of them gave correct result...

Anybody knows why?

Gr, Johnnei
 

descalzo

Grim Squeaker
Community Support
Messages
9,372
Reaction score
326
Points
83
x10 might not allow fsockopen.

It does allow fsockopen.

Run:


PHP:
<?php
    function smallStats() {
    
    $serverip = "216.245.205.66";
    $serverport    = "2082";
    $fserver = fsockopen ($serverip ,$serverport, $err, $errstr, 1);
    if ( $fserver )
        $serverstatus = '<font color="#00ff00"><font class="serverOnline">Online</font></font>';
    else {
        $serverstatus = '<font color="#ff0000"><font class="serverOffline">Offline</font></font>';
         }
    
    echo '<h2>#m&m. Fun Server</h2>';
    echo 'Server: ' . $serverstatus;
    }
    smallStats() ;
?>

1. Remove the '@' in front of fsocketopen. That way you will see any warnings.
2. With various combinations, you will get 'Connection Refused'. So problem is at one end or the other.
3. Only certain ports are open in x10hosting, which may cause a problem.
 
Last edited:

johnnei

New Member
Messages
20
Reaction score
0
Points
0
I'll test the script and it doesn't search for x10hosting it is searching for my wolfenstein server on my computer where all correct ports are open :) i'll let you know if it worked :)
edit:
It now just says the server is online no matter what any other suggestions?
 
Last edited:
Top