Fix PHP notices

This commit is contained in:
billz 2020-03-24 18:48:35 +00:00
parent cb65a66ee3
commit 422a46e92c
4 changed files with 49 additions and 50 deletions

View file

@ -1,59 +1,59 @@
<?php
class System {
public function hostname() {
return shell_exec("hostname -f");
}
public function uptime() {
$uparray = explode(" ", exec("cat /proc/uptime"));
$seconds = round($uparray[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));
$uptime= '';
if ($days != 0) {
$uptime .= $days . ' day' . (($days > 1)? 's ':' ');
}
if ($hours != 0) {
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
}
if ($minutes != 0) {
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
public function hostname() {
return shell_exec("hostname -f");
}
return $uptime;
}
public function uptime() {
$uparray = explode(" ", exec("cat /proc/uptime"));
$seconds = round($uparray[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));
$uptime= '';
if ($days != 0) {
$uptime .= $days . ' day' . (($days > 1)? 's ':' ');
}
if ($hours != 0) {
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
}
if ($minutes != 0) {
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
}
public function usedMemory() {
$used = shell_exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'");
return floor($used);
}
return $uptime;
}
public function processorCount() {
$procs = shell_exec("nproc --all");
return intval($proc);
}
public function usedMemory() {
$used = shell_exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'");
return floor($used);
}
public function loadAvg1Min() {
$load = exec("awk '{print $1}' /proc/loadavg");
return floatval($load);
}
public function processorCount() {
$procs = shell_exec("nproc --all");
return intval($procs);
}
public function systemLoadPercentage() {
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
}
public function loadAvg1Min() {
$load = exec("awk '{print $1}' /proc/loadavg");
return floatval($load);
}
public function systemTemperature() {
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format($cpuTemp/1000, 1);
}
public function systemLoadPercentage() {
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
}
public function hostapdStatus() {
exec('pidof hostapd | wc -l', $status);
return $status;
}
public function systemTemperature() {
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format((float)$cpuTemp/1000, 1);
}
public function hostapdStatus() {
exec('pidof hostapd | wc -l', $status);
return $status;
}
}

View file

@ -28,7 +28,7 @@ if ($cpuload > 90) {
$cpuload_status = "danger";
} elseif ($cpuload > 75) {
$cpuload_status = "warning";
} elseif ($cpuload > 0) {
} elseif ($cpuload >= 0) {
$cpuload_status = "success";
}

View file

@ -108,7 +108,7 @@ $bridgedEnabled = $arrHostapdConf['BridgedEnable'];
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo $toggleState; ?>" id="accordionSidebar">
<ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo (isset($toggleState)) ? $toggleState : null ; ?>" id="accordionSidebar">
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.php?page=wlan0_info">
<div class="sidebar-brand-text ml-1">RaspAP</div>

View file

@ -59,8 +59,7 @@
<div class="row">
<div class="form-group col-md-8">
<?php
$log = file_get_contents('/tmp/openvpn.log');
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
echo '<textarea class="logoutput"></textarea>';
?>
</div>
</div>