Ok well i've been working on a script which will become a cron job , which will select all the completed servers from a database, and then ping each of those, and if online change the online column to 1 and if offline change it to 0.
Also i am trying to insert the time and date into a datetime field in the database but i think i am calling it wrongly or something as it never changes.
I thought i had the script completed, but it seems there are a few flaws, such as the script does not seem to check the servers at all....
Any help would be appreciated , even if it is modding a previously created script of which you can point me in the direction of.
My script :happysad::
Thanks
-fedexer-
Also i am trying to insert the time and date into a datetime field in the database but i think i am calling it wrongly or something as it never changes.
I thought i had the script completed, but it seems there are a few flaws, such as the script does not seem to check the servers at all....
Any help would be appreciated , even if it is modding a previously created script of which you can point me in the direction of.
My script :happysad::
Code:
<?php
require_once("../connection/connect.php");
header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache");
$query = "SELECT * FROM serverlist WHERE serverCompleted = '1'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$query = "SELECT * FROM serverlistglobal WHERE ID = '1'";
$result = mysql_query($query);
$globalVars = mysql_fetch_array($result);
$lastGlobCheck = $globalVars['serverChecks'];
$newGlobCheck = $lastGlobCheck + 1;
$query = "UPDATE serverlistglobal SET serverChecks = '$newGlobCheck' WHERE ID = '1'";
$result = mysql_query($query);
do{
//check for socket open
$checkSock = @fsockopen($row['serverIP'], $row['serverPort'], $errno, $errstr, 30);
if(!$checkSock){
$uptime = (($row['serverChecks'] / $globalVars['serverChecks']) * 100);
$query = "UPDATE serverlist SET serverOnline = '0', serverUptime = '$uptime' WHERE serverID = '".$row['serverID']."'";
$result = mysql_query($query);
}else{
$lastChecks = $row['serverChecks'];
$newChecks = $lastChecks + 1;
$query = "UPDATE serverlist SET serverOnline = '1', serverChecks = '$newChecks' WHERE serverID = '".$row['serverID']."'";
$result = mysql_query($query);
$uptime = (($row['serverChecks'] / $globalVars['serverChecks']) * 100);
$query = "UPDATE serverlist SET serverOnline = '1', serverChecks = '$newChecks' WHERE serverID = '".$row['serverID']."'";
$result = mysql_query($query);
}
@fclose($checkSock);
}while($row = mysql_fetch_array($result));
$query = "SELECT * FROM serverlistglobal WHERE ID = '1'";
$result = mysql_query($query);
$globalVars = mysql_fetch_array($result);
$time = date('Y/m/d g:i:s');
$query = "UPDATE serverlistglobal SET lastCheckTime = '$time' WHERE ID = '1'";
$result = mysql_query($query);
exit;
?>
Thanks
-fedexer-
Last edited: