function GetServerUptime() { # DESCRIPTION: Checks and converts a given value. # FUNCTION RELEASE: 5.0.0 # FUNCTION AUTHOR: Bobby Allen (ballen@zpanel.co.uk) $OS = strtolower(PHP_OS); if ($OS == "linux") { $data = shell_exec('uptime'); $uptime = explode(' up ', $data); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0] . ', ' . $uptime[1]; $loadavg_array = explode(" ", exec("cat /proc/loadavg")); $loadavg = $loadavg_array[2]; $fretval = $uptime; } elseif ($OS == "winnt") { $pagefile = "" . GetSystemOption('windows_drive') . ":\\pagefile.sys"; $upsince = filemtime($pagefile); $gettime = time() - filemtime($pagefile); $days = floor($gettime / (24 * 3600)); $gettime = $gettime - $days * (24 * 3600); $hours = floor($gettime / 3600); $gettime = $gettime - $hours * 3600; $minutes = floor($gettime / 60); $gettime = $gettime - $minutes * 60; $seconds = $gettime; $days = CheckForNullValue($days != 1, $days . ' days', $hours . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $seconds = CheckForNullValue($seconds != 1, $seconds . ' seconds', $seconds . ' second'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } else { $fretval = "Unsupported Operating System"; } return $fretval; }
function GetServerUptime() { # DESCRIPTION: Checks and converts a given value. # FUNCTION RELEASE: 5.0.0 # FUNCTION AUTHOR: Bobby Allen (ballen@zpanel.co.uk) if (ShowServerPlatform() == "Linux") { #BEGIN UPTIME $uptime = trim(exec("cat /proc/uptime")); $uptime = explode(" ", $uptime); $uptime = $uptime[0]; $day = 86400; $days = floor($uptime / $day); $utdelta = $uptime - $days * $day; $hour = 3600; $hours = floor($utdelta / $hour); $utdelta -= $hours * $hour; $minute = 60; $minutes = floor($utdelta / $minute); $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } elseif (ShowServerPlatform() == "Windows") { $pagefile = "" . GetSystemOption('windows_drive') . ":\\pagefile.sys"; $upsince = filemtime($pagefile); $gettime = time() - filemtime($pagefile); $days = floor($gettime / (24 * 3600)); $gettime = $gettime - $days * (24 * 3600); $hours = floor($gettime / 3600); $gettime = $gettime - $hours * 3600; $minutes = floor($gettime / 60); $gettime = $gettime - $minutes * 60; $seconds = $gettime; $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } elseif (ShowServerPlatform() == "FreeBSD") { $uptime = explode(" ", exec("/sbin/sysctl -n kern.boottime")); $uptime = str_replace(",", "", $uptime[3]); $uptime = time() - $uptime; $min = $uptime / 60; $hours = $min / 60; $days = floor($hours / 24); $hours = floor($hours - $days * 24); $minutes = floor($min - $days * 60 * 24 - $hours * 60); $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } else { $fretval = "Unsupported Operating System"; } return $fretval; }