Snimi ovo kao naziv.php i okaci na server. Ili include-uj u neku drugu stranicu na sajtu gde zelis da ti prikazuje uptime.
Code:
<? function linuxUptime() {
$ut = strtok( exec( "cat /proc/uptime" ), "." );
$days = sprintf( "%2d", ($ut/(3600*24)) );
$hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
$min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 );
$sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60 );
return array( $days, $hours, $min, $sec );
}
$ut = linuxUptime();
// If you would like to show the seconds as well just add [ , $ut[3] seconds ] after minutes.
echo "<font color=#777777><h4>Server UPTIME: $ut[0] days, $ut[1] hours, $ut[2] minutes, $ut[3] seconds</h4></font>";
?>
Hint: ne radi uvek, zavisi kakva je ogranicenja postavio admin servera..