Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // connect to the database
- $dbhost = "localhost";
- $dbuser = "bnetweb_misc";
- $dbpass = "";
- $dbname = "bnetweb_misc";
- // Connect
- $db = mysql_pconnect($dbhost,$dbuser,$dbpass) or die ('Error: ' . mysql_error());
- mysql_select_db("$dbname",$db);
- // run the query and put the results in an array variable called $result
- $result = mysql_query("SELECT * FROM BNLS ORDER BY id");
- // Start the counter
- $i = 0;
- // Let's start the loop!
- while ($row = mysql_fetch_array($result)) {
- print "'{$row['id']}'";
- print "<p>{$row['server']}</p>\n";
- print "<p>{$row['port']}</p><hr />\n";
- // Check BNLS Server's
- $status = GetServerStatus($row['server'],$row['port']);
- $date = GETDATE();
- // Write Status Results to MySQL
- $query = "UPDATE BNLS SET status='".$status."' WHERE id='{$row['id']}'";
- mysql_query($query) or die (mysql_error());
- // add 1 to the count, close the loop, and the mysql connection
- ++$i;
- }
- mysql_close();
- // Get Server Status'
- function GetServerStatus($site, $port)
- {
- $status = array("offline", "online");
- $fp = @fsockopen($site, $port, $errno, $errstr, 2);
- if (!$fp)
- {
- return $status[0];
- }
- else
- {
- return $status[1];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement