Jak w temacie szukam czegoś takiego że bedzie sprawdzaiło działanie serwera od jakiegoś czasu.
Przykład:
-Sprawdza datę rozpoczęcia np w pliku (12:00)
-I odejmuje czas rozpoczęcia od teraźniejszego.
I wyskoczy np :
Uptime: 09:34
ale bedzie sie zmieniało samo co 1min
Mój coś nie chce działać"
<?php
function getinfo($host='94.23.150.254',$port=21){
// connects to server
$socket = @fsockopen($host, $port, $errorCode, $errorString, 1
); $data = '';
// if connected then checking statistics
if($socket)
{
// sets 1 second timeout for reading and writing
// sends packet with request
// 06 - length of packet, 255, 255 is the comamnd identifier, 'info' is a request
fwrite($socket, chr
(6).chr
(0).chr
(255).chr
(255).'info');
// reads respond
$data .= fread($socket, 128
); }
// closing connection to current server
}
return $data;
}
if ($cfg['status_update_interval'] < 60) $cfg['status_update_interval'] = 60;
if (time() - $modtime > $cfg['status_update_interval'] || $modtime > time()){ $info = getinfo($cfg['server_ip'], $cfg['server_port']);
if (!empty($info)) file_put_contents
('status.xml',$info); $infoXML = simplexml_load_string($info);
$up = (int)$infoXML->serverinfo['uptime'];
$up = $up - $h*3600;
$up = $up - $m*60;
if ($h < 10) {$h = "0".$h;}
if ($m < 10) {$m = "0".$m;}
echo "<span class=\"online\">Online</span><br/>\n"; echo "<span class=\"uptime\">Uptime: <b>$h:$m</b></span><br/>\n"; } else {
echo "<span class=\"offline\">Offline</span>\n"; }
?>
XML:
<?xml version="1.0"?>
<serverinfo uptime="0" ip="94.23.150.254" port="21" />