Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2. // connect to the database
  3. $dbhost = "localhost";
  4. $dbuser = "bnetweb_misc";
  5. $dbpass = "";
  6. $dbname = "bnetweb_misc";
  7.  
  8. // Connect
  9. $db = mysql_pconnect($dbhost,$dbuser,$dbpass) or die ('Error: ' . mysql_error());
  10. mysql_select_db("$dbname",$db);
  11.  
  12. // run the query and put the results in an array variable called $result
  13. $result = mysql_query("SELECT * FROM BNLS ORDER BY id");
  14.  
  15. // Start the counter
  16. $i = 0;
  17.  
  18. // Let's start the loop!
  19. while ($row = mysql_fetch_array($result)) {
  20.  
  21.   print "'{$row['id']}'";
  22.   print "<p>{$row['server']}</p>\n";
  23.   print "<p>{$row['port']}</p><hr />\n";
  24.  
  25. // Check BNLS Server's
  26. $status =  GetServerStatus($row['server'],$row['port']);
  27. $date = GETDATE();
  28.  
  29. // Write Status Results to MySQL
  30. $query = "UPDATE BNLS SET status='".$status."' WHERE id='{$row['id']}'";
  31. mysql_query($query) or die (mysql_error());
  32.  
  33. // add 1 to the count, close the loop, and the mysql connection
  34. ++$i;
  35. }
  36. mysql_close();
  37.  
  38. // Get Server Status'
  39. function GetServerStatus($site, $port)
  40. {
  41.      $status = array("offline", "online");
  42.      $fp = @fsockopen($site, $port, $errno, $errstr, 2);
  43.      if (!$fp)
  44.      {
  45.           return $status[0];
  46.      }
  47.      else
  48.      {
  49.           return $status[1];
  50.      }
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement