ציטוט:
נכתב במקור על ידי Israel-Serv.Net
יש איזה סקריפט שעובד בצורה אחרת ויכול להראות את הUPTIME בלי השימוש בפונקציה הזאת..
רק אני לא זוכר את השם שלו....
אם מישהו מכיר במקרה שיביא לו...
עריכה : אחלה  ראיתי שמצאת
|
כן למי שמעוניין הינה הסקריפט:
PHP קוד:
<?php
// format the uptime in case the browser doesn't support dhtml/javascript
// static uptime string
function format_uptime($seconds) {
$secs = intval($seconds % 60);
$mins = intval($seconds / 60 % 60);
$hours = intval($seconds / 3600 % 24);
$days = intval($seconds / 86400);
if ($days > 0) {
$uptimeString .= $days;
$uptimeString .= (($days == 1) ? " יום" : " ימים");
}
if ($hours > 0) {
$uptimeString .= (($days > 0) ? ", " : "") . $hours;
$uptimeString .= (($hours == 1) ? " שעה" : " שעות");
}
if ($mins > 0) {
$uptimeString .= (($days > 0 || $hours > 0) ? ", " : "") . $mins;
$uptimeString .= (($mins == 1) ? " דקה" : " דקות");
}
if ($secs > 0) {
$uptimeString .= (($days > 0 || $hours > 0 || $mins > 0) ? ", " : "") . $secs;
$uptimeString .= (($secs == 1) ? " שניה" : " שניות");
}
return $uptimeString;
}
// read in the uptime (using exec)
$uptime = exec("cat /proc/uptime");
$uptime = split(" ",$uptime);
$uptimeSecs = $uptime[0];
// get the static uptime
$staticUptime = "השרת באוויר רצוף כבר: ".format_uptime($uptimeSecs);
?>
<script language="javascript">
<!--
var upSeconds=<?php echo $uptimeSecs; ?>;
function doUptime() {
var uptimeString = "השרת באוויר רצוף כבר: ";
var secs = parseInt(upSeconds % 60);
var mins = parseInt(upSeconds / 60 % 60);
var hours = parseInt(upSeconds / 3600 % 24);
var days = parseInt(upSeconds / 86400);
if (days > 0) {
uptimeString += days;
uptimeString += ((days == 1) ? " יום" : " ימים");
}
if (hours > 0) {
uptimeString += ((days > 0) ? ", " : "") + hours;
uptimeString += ((hours == 1) ? " שעה" : " שעות");
}
if (mins > 0) {
uptimeString += ((days > 0 || hours > 0) ? ", " : "") + mins;
uptimeString += ((mins == 1) ? " דקה" : " דקות");
}
if (secs > 0) {
uptimeString += ((days > 0 || hours > 0 || mins > 0) ? ", " : "") + secs;
uptimeString += ((secs == 1) ? " שניה" : " שניות");
}
var span_el = document.getElementById("uptime");
var replaceWith = document.createTextNode(uptimeString);
span_el.replaceChild(replaceWith, span_el.childNodes[0]);
upSeconds++;
setTimeout("doUptime()",1000);
}
// -->
</script>
ולהוסיף את הקוד הבא לאיפה שאתם רוצים שיהיה הפלט של הUPTIME:
HTML קוד:
<div id="uptime" class="btext"><?php echo $staticUptime; ?></div>
ועוד משהו קטן, להכניס לתוך תגית ה<body> את הגדרה הבאה:
HTML קוד:
onLoad="doUptime();"