Bonsoir
alors voici une autre solution pour afficher les heures et les minutes en plus des jours de fonctionnement du serveur
dans index.php se trouvant dans le dossier admin remplacé ceci
<body style="background-image: url("../assets/img/bg1.jpg");">
<?php include_once('../statsServ.php');
$uptime = getUpTime()[0];
if(getUpTime()[0] === 1): $uppy = $uptime . " jour"; else: $uppy = $uptime . " jours"; endif;
$json = file_get_contents('./service.json');
$data = json_decode($json, true);
?>
par cela
<body style="background-image: url(../assets/img/bg1.jpg);">
<?php include_once('../statsServ.php');
//$uppy = getUpTime()[0];
$uppy = uptime ();
$json = file_get_contents('./service.json');
$data = json_decode($json, true);
?>
dans statsServ.php
il faut remplacé ceci
function getUpTime() {
// UPTIME
exec("uptime", $system); // get the uptime stats
$string = $system[0]; // this might not be necessary
$uptime = explode(" ", $string); // break up the stats into an array
$up_days = $uptime[3]; // grab the days from the array
$hours = explode(":", $uptime[6]); // split up the hour:min in the stats
$up_hours = $hours[0]; // grab the hours
$mins = $hours[1]; // get the mins
$up_mins = str_replace(",", "", $mins); // strip the comma from the mins
return [$up_days, $up_hours, $up_mins];
}
par cela
function uptime () {
// UPTIME
$fd = fopen('/proc/uptime', 'r');
$ar_buf = split(' ', fgets($fd, 4096));
fclose($fd);
$sys_ticks = trim($ar_buf[0]);
$min = $sys_ticks / 60;
$hours = $min / 60;
$days = floor($hours / 24) ;
$hours = floor($hours - ($days * 24));
$min = floor($min - ($days * 60 * 24) - ($hours * 60));
if ($days != 0) {
$result = "$days " . "jours ";
}
if ($hours != 0) {
$result .= "$hours " . "heures ";
}
if ($min != 0) {
$result .= "$min " . "minutes ";
}
return $result;
}
pour finir dans le dossier tardistart il faut modifier le fichier index.php
soit ceci
<?php include_once('./statsServ.php');
$uptime = getUpTime()[0];
if(getUpTime()[0] === 1): $uppy = $uptime . " jour"; else: $uppy = $uptime . " jours"; endif;
$json = file_get_contents('admin/service.json');
$data = json_decode($json, true);
?>
par cela
<?php include_once('./statsServ.php');
//$uppy = getUpTime()[0];
$uppy = uptime ();
$json = file_get_contents('admin/service.json');
$data = json_decode($json, true);
//echo "Server Uptime: <b>".uptime()."</b>";
?>
là je pense que ça devrait fonctionner,
j'ai essayé en modifiant les données du texte original du fichier statsServ.php par celui ci
/function getUpTime() {
// UPTIME
exec("uptime", $system); // get the uptime stats
$string = $system[0]; // this might not be necessary
$uptime = explode(" ", $string); // break up the stats into an array
$up_days = $uptime[3]; // grab the days from the array
$hours = explode(":", $uptime[5]); // split up the hour:min in the stats
$up_hours = $hours[0]; // grab the hours
$mins = $hours[1]; // get the mins
$up_mins = str_replace(",", "", $mins); // strip the comma from the mins
$result = [$up_days . " jour(s), " . $up_hours . " Heure(s) et " . $up_mins . " minute(s)."];
return $result;
}
mais avec cette config ça ne fonctionne que par intermitence, il y a des heures ou il n'y a que les jours qui s'affichent, et je n'ai pas trouvé ou ça coince.
Ta solution fait le job Xavier mais je ne l'a trouve pas top.
Bonne fin de soirée