Panel/modules/status/include/uptime.php
copilot-swe-agent[bot] 898018d204 Complete license header replacement with file purpose descriptions (675 files)
Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
2025-09-05 22:46:27 +00:00

53 lines
No EOL
1.7 KiB
PHP

<?php
/*
* Component of the status module
*/
include_once("modules/status/config.php");
if ($os == "windows")
{
$upsince = filemtime($pagefilelocation);
$uptime = (time() - $upsince);
}
elseif ($os == "linux" or $os == "cygwin")
{
if( isset($_GET['remote_server_id']) )
{
require_once('includes/lib_remote.php');
$rhost_id = $_GET['remote_server_id'];
$remote_server = $db->getRemoteServer($rhost_id);
$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
list($uptime,$upsince) = $remote->shell_action('get_uptime', 'seconds');
}
else
{
$uptime = round(current(explode(" ", exec("cat /proc/uptime"))));
$upsince = (time() - $uptime);
}
}
$days = floor($uptime / (24 * 3600));
$uptime = $uptime - ($days * (24 * 3600));
$hours = floor($uptime / (3600));
$uptime = $uptime - ($hours * (3600));
$minutes = floor($uptime / (60));
$uptime = $uptime - ($minutes * 60);
$seconds = $uptime;
$days = $days != 1 ? $days . ' ' . get_lang('days_word') : $days . ' ' . get_lang('day_word');
$hours = $hours != 1 ? $hours . ' ' . get_lang('hours_word') : $hours . ' ' . get_lang('hour_word');
$minutes = $minutes != 1 ? $minutes . ' ' . get_lang('minutes_word') : $minutes . ' ' . get_lang('minute_word');
$seconds = $seconds != 1 ? $seconds . ' ' . get_lang('seconds_word') : $seconds . ' ' . get_lang('second_word');
if ($days == 0) {
$days = "";
}
if ($hours == 0) {
$hours = "";
}
if ($minutes == 0) {
$minutes = "";
}
if ($seconds == 0) {
$seconds = "";
}
$indexuptime = $days . ' ' . $hours . ' ' . $minutes . ' ' . $seconds;
$indexuptimesince = date('F jS, Y. h:i A', $upsince);
?>