Thread: Server Status Page!

Results 1 to 8 of 8
  1. #1 Server Status Page! 
    Banned

    Join Date
    Feb 2008
    Age
    29
    Posts
    998
    Thanks given
    1
    Thanks received
    11
    Rep Power
    0
    Mod please delete or lock this
     

  2. #2  
    Project No*

    Join Date
    Aug 2007
    Age
    30
    Posts
    375
    Thanks given
    0
    Thanks received
    0
    Rep Power
    25
     

  3. #3  
    Banned

    Join Date
    Feb 2008
    Age
    29
    Posts
    998
    Thanks given
    1
    Thanks received
    11
    Rep Power
    0
    Oops didn't realize it was already posted + i made changes to it
     

  4. #4  
    Project No*

    Join Date
    Aug 2007
    Age
    30
    Posts
    375
    Thanks given
    0
    Thanks received
    0
    Rep Power
    25
    shows us a demo to prove that plz
     

  5. #5  
    Banned

    Join Date
    Feb 2008
    Age
    29
    Posts
    998
    Thanks given
    1
    Thanks received
    11
    Rep Power
    0
    Ok as soon as i have time to get one up....
     

  6. #6  
    FutureDesigner
    Guest
    Quote Originally Posted by MrMoney View Post
    This will make you your own server status page!
    Result: An awesome server status page
    If you need help, post here

    Step One: Make a new php file, call it Server_Status.php

    Step Two: Make a SQL Database, and remember the username and password and database name.

    Step Three: Open your php file, and place this in

    Code:
    <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 bgcolor="#000000" text="#FFFFFF">
    <?
    session_set_cookie_params(1200);
    session_start();
    // This function is to connect to the database
    function connectDB() {
    	$con = mysql_connect("localhost", "SQLUSER", "SQLPASSWORD") or die(mysql_error());
    	if (!$con) {
    		die('Could not connect: ' . mysql_error());
    	}
    	mysql_select_db("SQLDATABASE") or die(mysql_error()); 
    }
    
    $Link = mysql_connect ("localhost", "SQLUSER", "SQLPASSWORD");
    $Result = mysql_db_query ("SQLDATABASE", "SELECT * from `serverstatus`", $Link);
    $User = "USERNAME";
    $Pass = "PASSWORD";
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <p>
    <center>
    <b>Server Status</b><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, $errstr, 1);
    			if($checkReg) {
    				connectDB();
    				mysql_query("SELECT * FROM `serverstatus` WHERE `Name`='$Server_Name' OR `IP`='$Server_IP'");
    				if(mysql_affected_rows() == 1){
    					echo "That server is already on the list!";
    				} else{
    					mysql_query("INSERT INTO `serverstatus` (`Name`, `IP`, `Port`, `Uptime`, `Total`) VALUES ('$Server_Name', '$Server_IP', '$Server_Port', '1', '1')");
    					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!";
    		}
    	} else if($_GET['id'] == "login") {
    		echo "<form action=\"?id=admin\" method=\"post\"><input type=\"text\" name=\"user\" /> Username<br /><br /><input type=\"password\" name=\"pass\" /> Password<br /><br /><input type=\"submit\" value=\"Submit\" /></form>";
    	} else if($_GET['id'] == "admin") {
    		if ($_SESSION['admin'] == 1) {
    			echo "<table><tr><td class=\"header\"><u>Server Name</u></td><td class=\"header\"><u>Server Status</u></td></tr>";
    			while ($Row = mysql_fetch_array ($Result)) {
    				$checkCurr = @fsockopen("$Row[IP]", "$Row[Port]", $errno, $errstr, 1);
    				echo "<tr><td class=\"lista\">$Row[Name]</td><td class=\"lista\">";
    				if($checkCurr) {
    					echo "<form action=\"Server_Status.php?id=delete_$Row[Name]\" method=\"post\"><input type=\"submit\" value=\" Online - Delete\" /></form></td></tr>";
    				} else {
    					echo "<form action=\"Server_Status.php?id=delete_$Row[Name]\" method=\"post\"><input type=\"submit\" value=\" Offline - Delete\" /></form></td></tr>";
    				}
    			}
    			echo "</table>";
    		} else {
    			$Username = $_POST['user']; $Password = $_POST['pass'];
    			if ((isset($Username)) && (isset($Password)) && ($Username != NULL) && ($Password != NULL) && ($Username == $User) && ($Password == $Pass)) {
    				$_SESSION['admin'] = 1;
    				echo "Login successful!<br />Reload this page to continue.";
    			} else {
    				echo "Incorrect login information, please try again.";
    			}
    		}
    	} else {
    		$IDVAR = $_GET['id'];
    		if (isset($IDVAR)) {
    			if ($_SESSION['admin'] == 1) {
    				$remove = "delete_";
    				$ServName = str_replace($remove, "", $IDVAR);
    				connectDB();
    				mysql_query("DELETE FROM `serverstatus` WHERE `Name`='$ServName'") or die(mysql_error());
    				echo "Deleted successfully";
    			}
    		} 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>";
    		if ($Result) {
    			while ($Row = mysql_fetch_array ($Result)) {
    				connectDB();
    				$checkCurr = @fsockopen("$Row[IP]", "$Row[Port]", $errno, $errstr, 1);
    				$total = $Row[Total] + 1;
    				echo "<tr><td class=\"lista\">$Row[Name]</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\">$Row[IP]</td><td class=\"lista\">$Row[Port]</td><td class=\"lista\">";
    				$accuracy = $uptime/$total;
    				if ($accuracy == 1) {
    					$accuracy = $accuracy * 100;
    				} else {
    					$accuracy = 100 - $uptime/$total;
    				}
    				echo "$accuracy%</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);
    		}
    		echo "</table>";
    		}
    	}
    ?>
    <p>
    <b></b><br />
    <a href="Server_Status.php?id=register">Click Here to add your server to the List</a><br />
    <a href="Server_Status.php">Refresh</a><br />
    <? if($_SESSION['admin'] == 1) { echo "<a href=\"Server_Status.php?id=admin\">Administrator Panel</a><br />"; } else { echo "<a href=\"Server_Status.php?id=login\">Administrator Login</a><br />"; } ?>
    <a href="smf">Visit the Fourms</a>
    <br />
    </a>
    </p>
    </center>
    
    </body>
    </html>
    Now,
    SQLUSERNAME = Your sql username, fill it in both times
    SQLPASSWORD = The password, fill it in both times
    SQLDATABASE= Your sql databse, fill it in both times

    USERNAME = The admin username//Make one up
    PASSWORD = The admin password // make one up

    Step Four
    Save the following images



    As online.gif and offline.gif

    Step Five:
    Upload them to your website! Make sure they are in the same place.
    Example
    public html
    -> Server_Status.php
    -> online.gif
    -> offline.gif

    Thats the required structure.

    Please Note: Bashscape is not my site it is a friends
    Enjoy
    so what else have you leeched?
     

  7. #7  
    Project No*

    Join Date
    Aug 2007
    Age
    30
    Posts
    375
    Thanks given
    0
    Thanks received
    0
    Rep Power
    25
    Agreed with DHAReauxK
     

  8. #8  
    Banned

    Join Date
    Feb 2008
    Age
    29
    Posts
    998
    Thanks given
    1
    Thanks received
    11
    Rep Power
    0
    Ehh, I share the stuff i find
    Please Note: I never take credit for this work. I only take credit for my own
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •