PHP:
<!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, $errstr, 1);
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, $errstr, 1);
$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.