<?php
/*****************************************************************************
* Kod : Destan YILANCI *
* eposta : destan@sdu.edu.tr /S.D.Ü. Sistem Grubu/ *
* Konu : Bilgisayarin surekli olarak acik oldugu *
* (calisir durumda) zamani PHP de gostermek *
* Not : Linux veya unix turevi sistemlerde calisir *
* Calisir hali : http://destan.sdu.edu.tr/uptime.php *
*****************************************************************************/
$uptime_array = explode(" ", exec("cat /proc/uptime"));
$seconds = round($uptime_array[0], 0);
$minutes = $seconds / 60;
$hours = $minutes / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
$seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) -
($minutes * 60));
$uptime_array = array($days, $hours, $minutes, $seconds);
if ($uptime_array[0] == 0) {
if ($uptime_array[1] == 0) {
if ($uptime_array[2] == 0) {
print("Bilgisayarin surekli acik oldugu sure: <b>" . $uptime_array[3] . " saniye</b>");
}
else {
print("Bilgisayarin surekli acik oldugu sure: <b>" . $uptime_array[2] . " dakika</b>");
}
}
else {
print("Bilgisayarin surekli acik oldugu sure: <b>" . $uptime_array[1] . " saat</b>");
}
}
else {
print("Bilgisayarin surekli acik oldugu sure: <b>" . $uptime_array[0] . " gun</b>");
}
?>