Closed Thread
Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By Nathan
  • 1 Post By Nathan

Thread: PHP Server Status.

  1. #1
    Nathan Guest

    PHP Server Status.

    The first code I would like to present is a server status code.

    What is it used for?
    The name should be self explanitory, it displays the current status for a server. Status being "Online" and "Offline". It's a very, very, very, simple code to edit. Where the code states, "SERVER IP + PORT" is where you place the server's IP and the port is the port for the service, 80, 6112, etc. Ports are presented by a colon after the IP, i.e., 65.132.65.43:80.


    PHP Code:
    <?
    error_reporting
    (0);
    $IP = array(
    "Login Server" => "SERVER IP + PORT",
    ); while(list(
    $ServerName,$Host)=each($IP)) {
    list(
    $IPAddress,$Port)=explode(":",$Host);
    if(
    $fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
    echo(
    "<font color=\"white\"><b>Login Server</b>&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo (
    "<font color=\"black\"><b>Login Server</b>&nbsp;-&nbsp;<font color=\"red\"><b>Offline</b></font>");
    }
    echo (
    "");
    }
    ?>
    <p></p>
    <?
    error_reporting
    (0);
    $IP = array(
    "Map Server" => "SERVER IP + PORT",
    ); while(list(
    $ServerName,$Host)=each($IP)) {
    list(
    $IPAddress,$Port)=explode(":",$Host);
    if(
    $fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
    echo(
    "<font color=\"white\"><b>Map Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo (
    "<font color=\"black\"><b>Map Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"red\"><b>Offline</b></font>");
    }
    echo (
    "");
    }
    ?>
    <p></p>
    <?
    error_reporting
    (0);
    $IP = array(
    "Char Server" => "SERVER IP + PORT",
    ); while(list(
    $ServerName,$Host)=each($IP)) {
    list(
    $IPAddress,$Port)=explode(":",$Host);
    if(
    $fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
    echo(
    "<font color=\"white\"><b>Char Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo (
    "<font color=\"black\"><b>Char Server</b>&nbsp;&nbsp;-&nbsp;</font><font color=\"red\"><b>Offline</b></font>");
    }
    echo (
    "");
    }
    ?>

    The format of the code is setup for a game server, you can add and remove servers as needed or rename the servers.

    I don't know the server IP.
    Ping the URL. For Windows boxes do the following.
    Start > Run > CMD > type "ping websiteurl.xxx"
    When typing the ping command take away the quotations and do NOT put "type" before the command.

    I don't know the port for the server.
    According to the server type (HTTP/FTP/SQL/ETC) the ports will vary. I have taken the liberty of listing the common ones below.

    HTTP - 80
    FTP - Varies
    SQL - 1186

    For FTP you will need to contact the server administrator, if you are the server administrator then do a port scan.
    Start > Run > CMD > type "netstat -a > C:\myports.txt"
    When typing the command take away the quotations and do NOT put "type" before the command.

    For SQL I'm am completely not sure, that is the general MySQL server port.

    For a more detailed list of server ports, you can visit:
    http://www.iana.org/assignments/port-numbers

    Any questions can be asked in response to this post, please no spam though.


    -Dewayne
    dinomirt96 likes this.

  2. #2
    Vietkid58's Avatar
    Vietkid58 is offline x10 Sophmore Vietkid58 is an unknown quantity at this point
    Join Date
    Jul 2005
    Posts
    225

    Re: PHP Server Status.

    so we just copy this code into a new file and save it as something like "status.php" and edit the SERVER IP + PORT part? do we leave the quotatioins or not?

    edit: i left the quotes and its not working. how do we add/rename servers because mine still isn't working...

    Code:
    <?
    error_reporting(0);
    $IP = array(
    "Login Server" => "70.85.87.52:80",
    ); while(list($ServerName,$Host)=each($IP)) {
    list($IPAddress,$Port)=explode(":",$Host);
    if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR  _STR,(float)0.5)) {
    echo("<font color=\"white\"><b>Login Server</b>&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo ("<font color=\"black\"><b>Login Server</b>&nbsp;-&nbsp;<font color=\"red\"><b>Offline</b></font>");
    }
    echo ("");
    }
    ?>
    <p></p>
    <?
    error_reporting(0);
    $IP = array(
    "Map Server" => "70.85.87.52:80",
    ); while(list($ServerName,$Host)=each($IP)) {
    list($IPAddress,$Port)=explode(":",$Host);
    if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR  _STR,(float)0.5)) {
    echo("<font color=\"white\"><b>Map Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo ("<font color=\"black\"><b>Map Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"red\"><b>Offline</b></font>");
    }
    echo ("");
    }
    ?>
    <p></p>
    <?
    error_reporting(0);
    $IP = array(
    "Char Server" => "70.85.87.52:80",
    ); while(list($ServerName,$Host)=each($IP)) {
    list($IPAddress,$Port)=explode(":",$Host);
    if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR  _STR,(float)0.5)) {
    echo("<font color=\"white\"><b>Char Server</b>&nbsp;&nbsp;-&nbsp;<font color=\"green\"><b>Online</b></font>");
    fclose($fp);
    }
    else {
    echo ("<font color=\"black\"><b>Char Server</b>&nbsp;&nbsp;-&nbsp;</font><font color=\"red\"><b>Offline</b></font>");
    }
    echo ("");
    }
    ?>

  3. #3
    Nathan Guest

    Re: PHP Server Status.

    so we just copy this code into a new file and save it as something like "status.php" and edit the SERVER IP + PORT part? do we leave the quotatioins or not?
    You need to put it inside the body tags of an HTML document and upload it to a server with PHP enabled before you see the results actually taking place.
    karimirt47 likes this.

Closed Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. php Server Status Help
    By Brandon in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-23-2008, 03:09 AM
  4. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  5. Server Load PHP Script
    By TheJeffsta in forum Free Hosting
    Replies: 9
    Last Post: 05-17-2006, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers