mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Fix PHP notices
This commit is contained in:
parent
cb65a66ee3
commit
422a46e92c
@ -1,59 +1,59 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class System {
|
class System {
|
||||||
public function hostname() {
|
public function hostname() {
|
||||||
return shell_exec("hostname -f");
|
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 ':' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
return $uptime;
|
||||||
$used = shell_exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'");
|
}
|
||||||
return floor($used);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processorCount() {
|
public function usedMemory() {
|
||||||
$procs = shell_exec("nproc --all");
|
$used = shell_exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'");
|
||||||
return intval($proc);
|
return floor($used);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadAvg1Min() {
|
public function processorCount() {
|
||||||
$load = exec("awk '{print $1}' /proc/loadavg");
|
$procs = shell_exec("nproc --all");
|
||||||
return floatval($load);
|
return intval($procs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function systemLoadPercentage() {
|
public function loadAvg1Min() {
|
||||||
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
|
$load = exec("awk '{print $1}' /proc/loadavg");
|
||||||
}
|
return floatval($load);
|
||||||
|
}
|
||||||
|
|
||||||
public function systemTemperature() {
|
public function systemLoadPercentage() {
|
||||||
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
|
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
|
||||||
return number_format($cpuTemp/1000, 1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function hostapdStatus() {
|
public function systemTemperature() {
|
||||||
exec('pidof hostapd | wc -l', $status);
|
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
|
||||||
return $status;
|
return number_format((float)$cpuTemp/1000, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hostapdStatus() {
|
||||||
|
exec('pidof hostapd | wc -l', $status);
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ if ($cpuload > 90) {
|
|||||||
$cpuload_status = "danger";
|
$cpuload_status = "danger";
|
||||||
} elseif ($cpuload > 75) {
|
} elseif ($cpuload > 75) {
|
||||||
$cpuload_status = "warning";
|
$cpuload_status = "warning";
|
||||||
} elseif ($cpuload > 0) {
|
} elseif ($cpuload >= 0) {
|
||||||
$cpuload_status = "success";
|
$cpuload_status = "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ $bridgedEnabled = $arrHostapdConf['BridgedEnable'];
|
|||||||
<!-- Page Wrapper -->
|
<!-- Page Wrapper -->
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<!-- Sidebar -->
|
<!-- 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 -->
|
<!-- Sidebar - Brand -->
|
||||||
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.php?page=wlan0_info">
|
<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>
|
<div class="sidebar-brand-text ml-1">RaspAP</div>
|
||||||
|
@ -59,8 +59,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-8">
|
<div class="form-group col-md-8">
|
||||||
<?php
|
<?php
|
||||||
$log = file_get_contents('/tmp/openvpn.log');
|
echo '<textarea class="logoutput"></textarea>';
|
||||||
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user