Jump to content

Updating.. Can someone do it for me?


Im Jake

Recommended Posts

<?php
include("includes/connection.inc.php");
$results = @mysql_query("SELECT id, name, ip, port, uptime, status FROM servers") or die();
while($values = mysql_fetch_array($results)){
list($online, $offline) = explode(',', $values['uptime']);
$socket = @fsockopen(stripslashes($values['ip']), stripslashes($values['port']), $errno, $errstr, 1);
if($socket){
	$status = 'online';
	$online = intval($online) + 1;
} else{
	$status = 'offline';
	$offline = intval($offline) + 1;
}
$uptime = $online . ',' . $offline;
echo 'Server: ' . $values['name'] . ' is ' . $status . '<br />';
$resultsUpdate = @mysql_query("UPDATE servers SET uptime='$uptime', status='$status' WHERE id=" . $values['id']) or die();
}
$time = time();
$resultsTime = @mysql_query("UPDATE config SET lastupdate='$time'") or die();
?>

 

Thats my updating script.. server 10 mins it updates a server by pinging them for 1 second after 30 seconds the script times out :(. Will someone fix so that it pings more than one server or after pinging 20 servers it will take a short break and go again..?

 

EDIT: Also, I'm asking you to do it for me because I have a hard time understanding programming languages and web languages and I don't know any of it... (except basic HTML) and I didn't make that script above.

Link to comment
https://forums.phpfreaks.com/topic/118017-updating-can-someone-do-it-for-me/
Share on other sites

Were not hear to write code for people but that is beside the point. If you really want this script to execute every second or so continuously you would need to look into a server side scheduler such as cron. PHP scripts wont run forever.

not that -.- i need it to time out after pinging then pick up again i got cron jobs set every 10 mins

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.