+ Reply to Thread
Results 1 to 3 of 3

Thread: little help? on server Status.Php file.

  1. #1
    sm3xy is offline x10Hosting Member sm3xy is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    2

    Cool little help? on server Status.Php file.

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Server Status Page</title>
    </head>
    <body>
    <center>
    <b>Server Status</b><br />
    <img src="rslogo.png" alt="logo" /><br /><br />
    <?php
        
    if ($_GET['id'] == "register") {
            echo 
    "<form action=\"?id=submit\" method=\"post\">You can only add online servers to this list.<br /><br />Server Name:<br /><input type=\"text\" name=\"name\" /><br />Server IP:<br /><input type=\"text\" name=\"ip\" /><br />Port:<br /><input type=\"text\" name=\"port\" /><br /><br /><input type=\"submit\" value=\"Submit\" /></form><p><br />Click <a href=\"Server_Status.php\">here</a> to go to the main page.<br /></p>";
        } else if(
    $_GET['id'] == "submit") {
            
    $Server_Name $_POST['name'];
            
    $Server_IP $_POST['ip'];
            
    $Server_Port $_POST['port'];
            if ((
    $Server_Name != NULL) && ($Server_IP != NULL) && ($Server_Port != NULL)) {
            
    $checkReg = @fsockopen("$Server_IP""$Server_Port"$errno$errstr1);
            if(
    $checkReg) {
                
    $con mysql_connect("localhost""Username""Password") or die(mysql_error());
                if (!
    $con) {
                    die(
    'Could not connect: ' mysql_error());
                }
                
    mysql_select_db("Database") or die(mysql_error());
                
    mysql_query("INSERT INTO `serverstatus` (`Name`, `IP`, `Port`, `Uptime`, `Total`) VALUES ('$Server_Name', '$Server_IP', '$Server_Port', '1', '1')");
                
    mysql_close($con);
                echo 
    "<br />Your Server has been successfully added to the list!";
            } else {
                echo 
    "Invalid information or the server is down.<br />";
            }
            } else {
            echo 
    "You did not fill in all of the required information!";
            }
            echo 
    "<p><br />Click <a href=\"Server_Status.php?id=register\">here</a> to add your own server or <a href=\"Server_Status.php\">here</a> to check the list.<br /></p>";
        } else {
            echo 
    "<table><tr><td class=\"header\"><u>Server Name</u></td><td class=\"header\"><u>Server Status</u></td><td class=\"header\"><u>IP Address</u></td><td class=\"header\"><u>Port</u></td><td class=\"header\"><u>Uptime</u></td></tr>";
            
    $Host "localhost";
            
    $User "Username";
            
    $Password "Password";
            
    $DBName "Database";
            
    $Link mysql_connect ($Host$User$Password);
            
    $Query "SELECT * from `serverstatus`";
            
    $Result mysql_db_query ($DBName$Query$Link);
            if (
    $Result) {
                while (
    $Row mysql_fetch_array ($Result)) {
                    @
    mysql_connect($Host$User$Password) or die(mysql_error());
                    @
    mysql_select_db ($DBName) or die(mysql_error());
                    
    $checkCurr = @fsockopen("$Row[IP]""$Row[Port]"$errno$errstr1);
                    
    $total $Row[Total] + 1;
                    echo 
    "<tr><td class=\"lista\">";
                    echo 
    "$Row[Name]";
                    echo 
    "</td><td class=\"lista\">";
                    if(
    $checkCurr) {
                        
    $uptime $Row[Uptime] + 1;
                        echo 
    "<img src=\"online.gif\" alt=\"online\" />";
                        
    $UpdateDB mysql_query("UPDATE `serverstatus` SET Uptime = $uptime WHERE Uptime = $Row[Uptime]");
                    } else {
                        echo 
    "<img src=\"offline.gif\" alt=\"offline\" />";
                    }
                    
    $UpdateDB2 mysql_query("UPDATE `serverstatus` SET Total = $total WHERE Total = $Row[Total]");
                    echo 
    "</td><td class=\"lista\">";
                    echo 
    "$Row[IP]";
                    echo 
    "</td><td class=\"lista\">";
                    echo 
    "$Row[Port]";
                    echo 
    "</td><td class=\"lista\">";
                    
    $accuracy $uptime/$total;
                    if (
    $accuracy == 1) {
                        
    $accuracy $accuracy 100;
                    } else {
                        
    $accuracy 100 $uptime/$total;
                    }
                    echo 
    "$accuracy%";
                    echo 
    "</td></tr>";
                }
            } else {
                
    $create 'CREATE TABLE `serverstatus` (
                `Name` VARCHAR (20) NOT NULL,
                `IP` VARCHAR (50) NOT NULL,
                `Port` VARCHAR (6) NOT NULL,
                `Uptime` VARCHAR (999999) NOT NULL,
                `Total` VARCHAR (999999) NOT NULL,
                PRIMARY KEY (`Name`)
                )'
    ;
                
    mysql_query($create);
                
    mysql_close();
            }
            echo 
    "</table><p><br />Click <a href=\"Server_Status.php?id=register\">here</a> to add your own server to the above list.<br /></p>";
        }
    ?>
    </center>
    <center>
    <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>
    </center>
    </body>
    </html>
    i made a .php file with all that in, i uploaded it and it doesn't work, can someone give me step-to-step tutorial to add this from my cp panel?

    I dont really understand php or html much, sorry for the bother.

  2. #2
    Synkc's Avatar
    Synkc is offline Lord Of The Keys Synkc is an unknown quantity at this point
    Join Date
    Jun 2007
    Location
    Hervey Bay, Australia
    Posts
    1,765

    Re: little help? on server Status.Php file.

    $Host = "localhost";
    $User = "Username";
    $Password = "Password";
    $DBName = "Database";
    You may have to set the Database variables, and/or create a database ;)



    If it is only a script to check the server's online/offline status, you can use this instead if you like:
    Server is:
    <?php
    $checkCHAR = @fsockopen('ip-address-of-domain', 'port-number', $ERRNO, $ERRSTR, 1);
    if($checkCHAR) {
    echo('<font color=green>Online</font>');
    } else {
    echo('<font color=red>Offline</font>');
    }
    ?>
    Last edited by Synkc; 11-19-2007 at 06:11 PM.
    E-mail: synkc[at]x10hosting[dot]com
    Hirokima.com

  3. #3
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: little help? on server Status.Php file.

    The one he's using is better, it has more stats than if its just on / off line

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


+ Reply to Thread

Similar Threads

  1. AV and file scanners
    By fireput in forum Computers & Technology
    Replies: 4
    Last Post: 10-16-2007, 01:05 PM
  2. Free Tools to create an SFTP or FTPS Server
    By Kakarot888 in forum Computers & Technology
    Replies: 0
    Last Post: 10-09-2007, 10:50 PM
  3. Internal Server Error
    By repusmod in forum Free Hosting
    Replies: 16
    Last Post: 06-19-2006, 01:53 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