Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Mine
Saturday, January 13th, 2007 at 10:48:11pm MST 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  6. <title>Mopar's Server Status Checker</title>
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. </head>
  9. <body>
  10. <hr style="width: 100%;" noshade="noshade" />
  11.  
  12.  
  13. <center>
  14.  
  15. <table>
  16. <td>
  17. <script type="text/javascript"><!--
  18. google_ad_client = "pub-3055920918910714";
  19. google_ad_width = 160;
  20. google_ad_height = 600;
  21. google_ad_format = "160x600_as";
  22. google_ad_channel ="";
  23. google_color_border = "FFFFFF";
  24. google_color_bg = "FFFFFF";
  25. google_color_link = "0000FF";
  26. google_color_url = "000000";
  27. google_color_text = "000000";
  28. //--></script>
  29. <script type="text/javascript"
  30.   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  31. </script>
  32. </td>
  33.  
  34. <td>
  35. <center>
  36. Click <a href="http://www.moparscape.org/index.php">here</a> to play the MoparScape 3.2 webclient.<br />
  37. Click <a href="http://www.moparscape.org/moparscape.html">here</a> to download MoparScape 3.2.<br />
  38. Click <a href="http://www.moparscape.org/smf/index.php">here</a> to go to the forums.
  39. <div style="margin-left: 5px;">
  40. <?php
  41.   /*
  42. CREATE TABLE `servers` (
  43.   `id` int(11) NOT NULL auto_increment,
  44.   `online` tinyint(1) NOT NULL default '1',
  45.   `Name` varchar(50) default NULL,
  46.   `IP` varchar(30) default NULL,
  47.   `ipfield` varchar(30) default NULL,
  48.   `Port` int(5) default NULL,
  49.   `date` text NOT NULL,
  50.   `oncount` int(11) NOT NULL default '1',
  51.   `totalcount` int(11) NOT NULL default '1',
  52.   `uptime` float NOT NULL default '100',
  53.   `ipaddress` varchar(64) NOT NULL default '',
  54.   PRIMARY KEY  (`id`),
  55.   KEY `online` (`online`),
  56.   KEY `Name` (`Name`)
  57. ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
  58.    */
  59.   function mysql_con()
  60.   {     
  61.       $host = 'localhost';
  62.       $user = 'root';
  63.       $pass = '';
  64.       $db = 'serverstat';
  65.      
  66.       $link = mysql_connect($host, $user, $pass) or die('Could not connect: ' . mysql_error());
  67.       mysql_select_db($db) or die('Could not select db: ' . mysql_error());
  68.      
  69.       return $link;
  70.   }
  71.  
  72.   function stamp_time()
  73.   {
  74.       $timeslot = time();
  75.       $fp = fopen("timestamp", "w");
  76.       fwrite($fp, $timeslot);
  77.       fclose($fp);
  78.   }
  79.  
  80.   function getTimeStamp()
  81.   {
  82.       $contents = file_get_contents("timestamp") or die("Some horrible error!!!!");
  83.       return $contents;
  84.   }
  85.  
  86.   function checkRows($sql)
  87.   {
  88.       $q = mysql_query($sql) or die(mysql_error());
  89.       $num_rows = mysql_num_rows($q);
  90.       mysql_free_result($q);
  91.       return($num_rows > 0);
  92.   }
  93.  
  94.   function addServer($name, $ip, $port)
  95.   {
  96.       $name = trim($name);
  97.       $ip = strtolower(trim($ip));
  98.       if (strlen($name) > 25) {
  99.           echo "The name cannot exceed 25 characters.";
  100.           return;
  101.       }
  102.       if (preg_match("@</?[^>]*>*@", $name)) {
  103.           echo "The name cannot contain HTML.";
  104.           return;
  105.       }
  106.       if ($port == 80 || $port == 21 || $port > 65535 || $port < 1) {
  107.           echo "Please enter a valid port number.";
  108.           return;
  109.       }
  110.       if ((($pos = strstr($ip, "sunscape")) !== false) || (($pos = strstr($ip, "runescape.co")) !== false) || (($pos = strstr($ip, "345.org")) !== false) || (($pos = strstr($ip, "vtip.org")) !== false) || (($pos = strstr($ip, "myscape.servegame.com")) !== false) || (($pos = strstr($ip, "88.202.")) !== false)) {
  111.           echo '<meta http-equiv="refresh" content="0;url=http://www.meatspin.com">';
  112.           return;
  113.       }
  114.      
  115.       $fp = fsockopen($ip, $port, $errno, $errstr, 4);
  116.       if (!$fp) {
  117.           echo "The server " . $name . " is offline, it must be online before you can register it here.";
  118.           return;
  119.       }
  120.       fclose($fp);
  121.      
  122.       $ipfield = gethostbyname($ip);
  123.      
  124.       if (checkRows("SELECT * FROM `servers` WHERE `IP` = '$ip' OR `ipfield` = '$ipfield'")) {
  125.           echo "This server has already been posted, look again.";
  126.           return;
  127.       }
  128.      
  129.       $sql = "INSERT INTO `servers` SET `Name` = '$name', `IP` = '$ip', `ipfield` = '$ipfield', `Port` = '$port', `date` = '" . date("m-d-y") . "', `ipaddress` = '" . $_SERVER['REMOTE_ADDR'] . "'";
  130.      
  131.       $query = mysql_query($sql) or die(mysql_error());
  132.      
  133.       if (mysql_affected_rows() == 1) {
  134.           echo "New server $name succesfully inserted.";
  135.       }
  136.      
  137.       mysql_free_result($query);
  138.   }
  139.  
  140.   function updateServers()
  141.   {
  142.       stamp_time();
  143.       ignore_user_abort(true);
  144.      
  145.       $sql = "SELECT * from `servers` WHERE `Name` != '0'";
  146.       $result = mysql_query($sql) or die(mysql_error());
  147.      
  148.       while ($r = mysql_fetch_array($result)) {
  149.           $id = $r['id'];
  150.           $port = $r['Port'];
  151.           $oncount = $r['oncount'] + 1;
  152.           $totalcount = $r['totalcount'] + 1;
  153.          
  154.           //1 originally 4
  155.           $fp = fsockopen($ip, $port, $errno, $errstr, 1);
  156.           if (!$fp) {
  157.               //offline
  158.               $uptime = round(($oncount - 1) / $totalcount * 100, 2);
  159.               $sql = "UPDATE `servers` SET `online`= '0', `totalcount`= '$totalcount', `uptime`= '$uptime' WHERE `id` = '$id'";
  160.           } else {
  161.               //online
  162.               $ipfield = gethostbyname($r['IP']);
  163.               $uptime = round(($oncount) / $totalcount * 100, 2);
  164.               $sql = "UPDATE `servers` SET `online`= '1', `ipfield`= '$ipfield', `totalcount`= '$totalcount', `oncount`= '$oncount', `uptime`= '$uptime' WHERE `id` = '$id'";
  165.           }
  166.           fclose($fp);
  167.           if ($uptime < 20) {
  168.               $sql = "DELETE FROM `servers` WHERE `id` = '$id'";
  169.           }
  170.           $query = mysql_query($sql) or die(mysql_error());
  171.           mysql_free_result($query);
  172.       }
  173.       mysql_free_result($result);
  174.   }
  175.  
  176.   error_reporting(0);
  177.  
  178.   $link = mysql_con();
  179.  
  180.   if ($_GET['action'] == "register") {
  181.       if (isset($_POST['Submit']) && !empty($_POST['name']) && !empty($_POST['ip']) && !empty($_POST['port'])) {
  182.           $ip = $_SERVER['REMOTE_ADDR'];
  183.           if (checkRows("SELECT * FROM `servers` WHERE `ipaddress` = '$ip'"))
  184.               echo "You only get to post one server, sorry.";
  185.           else
  186.               addServer($_POST['name'], $_POST['ip'], $_POST['port']);
  187.       } else {
  188.           echo 'NO HAMACHI SERVERS, ITS STUPID, PLUS THIS WILL NOT WORK ON THEM.<br />';
  189.           echo 'The server must be online to add it to this list.<br />';
  190.           echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?action=" . $_GET['action'] . "\">";
  191.           echo 'Name: <input name="name"><br />';
  192.           echo 'IP: <input name="ip"><br />';
  193.           echo 'Port: <input name="port" value="43594"><br />';
  194.           echo '<input type="Submit" name="Submit" value="Submit">';
  195.           echo '</form>';
  196.       }
  197.   }
  198.  
  199.   if (($_GET['user'] == "silab") && ($_GET['pass'] == "hybridtong")) {
  200.       echo 'The server must be online to add it to this list.<br />';
  201.       echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?user=" . $_GET['user'] . "&pass=" . $_GET['pass'] . "\">";
  202.       echo 'Name: <input name="name"><br />';
  203.       echo 'IP: <input name="ip"><br />';
  204.       echo 'Port: <input name="port" value="43594"><br />';
  205.       echo '<input type="Submit" name="Submit" value="Submit">';
  206.       echo '</form>';
  207.       if (isset($_GET['delete'])) {
  208.           $servername = $_GET['delete'];
  209.           $sql = "DELETE FROM `servers` WHERE `id`='$servername'";
  210.           $query = mysql_query($sql) or die(mysql_error());
  211.           if (mysql_affected_rows() == 1)
  212.               echo "server $servername succesfully deleted";
  213.           mysql_free_result($query);
  214.       } elseif (isset($_GET['remove'])) {
  215.           $servername = $_GET['remove'];
  216.           $sql = "UPDATE `servers` SET `Name` = 0 WHERE `id` = '$servername'";
  217.           $query = mysql_query($sql) or die(mysql_error());
  218.           if (mysql_affected_rows() == 1)
  219.               echo "server $servername succesfully removed/banned";
  220.           mysql_free_result($query);
  221.       } elseif (isset($_POST['Submit']) && !empty($_POST['name']) && !empty($_POST['ip']) && !empty($_POST['port'])) {
  222.           addServer($_POST['name'], $_POST['ip'], $_POST['port']);
  223.       }
  224.       $resolved = '<td class="header">Resolved:</td>';
  225.       $delete = '<td class="header">CheckIP:</td>
  226.      <td class="header">Delete:</td>
  227.      <td class="header">Ban:</td>';
  228.       $admin = 1;
  229.   }
  230.   echo '<table class="lista">
  231.   <thead>
  232.   <td class="header">Name:</td>
  233.   <td class="header">IP:</td>
  234.   ' . $resolved . '
  235.   <td class="header">Port:</td>
  236.   <td class="header">Uptime:</td>
  237.   <td class="header">Since:</td>
  238.   <td class="header">Status:</td>
  239.   ' . $delete . '
  240.   </thead>
  241.   <tbody>';
  242.   echo "\n\n";
  243.  
  244.   $timedif = time() - getTimeStamp();
  245.   $timeMinutes = 30;
  246.   $timelimit = $timeMinutes * 60;
  247.   if ($timedif > $timelimit) {
  248.       updateServers();
  249.   }
  250.  
  251.   $mysql_query = "SELECT * FROM `servers` WHERE `online` = '1' AND `Name` != '0' ORDER BY `uptime` DESC";
  252.  
  253.   $result = mysql_query($mysql_query);
  254.  
  255.   while ($r = mysql_fetch_array($result)) {
  256.       if ($admin == 1)
  257.           $resolve = '<td class="lista"> ' . $r['ipfield'] . ' </td>';
  258.      
  259.       $color = ($i % 2 == 1) ? "#DFDFDF" : "#DDDDDD";
  260.      
  261.       echo '<tr style="background-color:' . $color . ';">
  262.       <td class="lista"> ' . $r['Name'] . ' </td>
  263.       <td class="lista"> <span style=\"background-color:' . $color . ';\">' . $r['IP'] . '</span> </td>
  264.       ' . $resolve . '
  265.       <td class="lista"> ' . $r['Port'] . ' </td>
  266.       <td class="lista"> ' . $r['uptime'] . '% </td>
  267.       <td class="lista"> ' . $r['date'] . ' </td>';
  268.       echo "<td class=\"lista\"><span style=\"background-color:'.$color.';\"><font color=green><b> Server Online! </b></font></span></td>";
  269.      
  270.       if ($admin == 1) {
  271.           $id = $r['id'];
  272.           echo "<td class=\"lista\"><a href=\"http://www.moparscape.org/smf/index.php?action=trackip;searchip=" . $r['ipaddress'] . "\" target=\"popup\"> " . $r['ipaddress'] . " </a></td>
  273.       <td class=\"lista\"><a href=\"" . $_SERVER['PHP_SELF'] . "?user=" . $_GET['user'] . "&pass=" . $_GET['pass'] . "&delete=$id\"> X </a></td>
  274.       <td class=\"lista\"><a href=\"" . $_SERVER['PHP_SELF'] . "?user=" . $_GET['user'] . "&pass=" . $_GET['pass'] . "&remove=$id\"> X </a></td>";
  275.       }
  276.       echo "\n</tr>\n\n";
  277.   }
  278.  
  279.   mysql_close($link);
  280.  
  281.   $lastupdated = round($timedif / 60, 2);
  282.   if ($lastupdated >= $timeMinutes)
  283.       $lastupdated = 0;
  284.   echo "</tbody>
  285.       </table>
  286.       </div>
  287.       Last updated $lastupdated minutes ago, next update in " . ($timeMinutes - $lastupdated) . " minutes.<br />
  288.       Click <a href=\"" . $_SERVER['PHP_SELF'] . "?action=register\">here</a> to register your own server.<br />
  289.     This keeps servers in the database until their uptime drops below 20%, but doesn't show offline servers.";
  290. ?>
  291. <div align="center"><img border="0" src="http://c6.amazingcounters.com/counter.php?i=1398751&c=4196566" alt="Amazing Free Counter"></div> Hits Since 8-23-06
  292. </center>
  293. </td>
  294.  
  295. <td>
  296. <script type="text/javascript"><!--
  297. google_ad_client = "pub-3055920918910714";
  298. google_ad_width = 160;
  299. google_ad_height = 600;
  300. google_ad_format = "160x600_as";
  301. google_ad_channel ="";
  302. google_color_border = "FFFFFF";
  303. google_color_bg = "FFFFFF";
  304. google_color_link = "0000FF";
  305. google_color_url = "000000";
  306. google_color_text = "000000";
  307. //--></script>
  308. <script type="text/javascript"
  309.   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  310. </script>
  311. </td>
  312.  
  313. </table>
  314.  
  315. <hr noshade="noshade" />
  316. </center>
  317. </body>
  318. </html>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
worth-right