From de7c0f7d79ef37400671c5013d974ab04060daf7 Mon Sep 17 00:00:00 2001 From: zlolz Date: Sun, 12 Jun 2016 00:17:44 +0000 Subject: [PATCH] Add System Info and System Control (foundation) --- README.md | 7 +- dist/css/custom.css | 7 +- includes/functions.php | 174 +++++++++++++++++++++++++++++++---------- index.php | 6 ++ 4 files changed, 144 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 4f27261..68c55df 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,7 @@ So what I have done is added the `www-data` user to the sudoers file, but with r Add the following to the end of `/etc/sudoers`: ```sh -www-data ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0,/sbin/ifup wlan0,/bin/cat -/etc/wpa_supplicant/wpa_supplicant.conf,/bin/cp /tmp/wifidata -/etc/wpa_supplicant/wpa_supplicant.conf,/sbin/wpa_cli scan_results, -/sbin/wpa_cli scan,/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf, -/etc/init.d/hostapd start,/etc/init.d/hostapd stop,/etc/init.d/dnsmasq start, -/etc/init.d/dnsmasq stop,/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf +www-data ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0,/sbin/ifup wlan0,/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf,/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf,/sbin/wpa_cli scan_results, /sbin/wpa_cli scan,/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf, /etc/init.d/hostapd start,/etc/init.d/hostapd stop,/etc/init.d/dnsmasq start, /etc/init.d/dnsmasq stop,/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf, /sbin/shutdown -h now, /sbin/reboot ``` Once those modifications are done, git clone the files to `/var/www`. diff --git a/dist/css/custom.css b/dist/css/custom.css index ea237b1..72498bc 100644 --- a/dist/css/custom.css +++ b/dist/css/custom.css @@ -27,4 +27,9 @@ .btn-primary:hover { background-color: #c61931; border-color: #c61931; -} \ No newline at end of file +} + +.info-item { + width: 160px; + float: left; +} diff --git a/includes/functions.php b/includes/functions.php index 9354c55..325dbb1 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -161,50 +161,53 @@ function DisplayDashboard(){

-
-
-
-

Interface Information

- Interface Name : wlan0
- IP Address :
- Subnet Mask :
- Mac Address :
- -

Interface Statistics

- Received Packets :
- Received Bytes :

- Transferred Packets :
- Transferred Bytes :
-
-
-
- -
-
-
+
+
+
+

Interface Information

+
Interface Name
wlan0
+
IP Address

+
Subnet Mask

+
Mac Address


+ +

Interface Statistics

+
Received Packets

+
Received Bytes


+
Transferred Packets

+
Transferred Bytes

+
+
+
+ +
+
+

Wireless Information

- Connected To :
- AP Mac Address :
- Bitrate :
- Transmit Power :
- Frequency :
- Link Quality : -
-
- % -
-
- Signal Level : -
-
- % -
-
-
-
- -
-
+
Connected To

+
AP Mac Address

+
Bitrate

+
Transmit Power

+
Frequency


+
Link Quality
+
+
% +
+
+
Signal Level
+
+
% +
+
+
+
+
+
@@ -982,6 +985,91 @@ function DisplayTorProxyConfig(){ 1)? 's':'') . ' '; + } + if ($hours != 0){ + $uptime .= $hours . ' hour' . (($hours > 1)? 's':'') . ' '; + } + if ($minutes != 0){ + $uptime .= $minutes . ' minute' . (($minutes > 1)? 's':'' ) . ' '; + } + + // mem used + exec("free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { print used/total*100}'", $memarray); + $memused = floor($memarray[0]); + + ?> +
+
+
+
System
+
+ + System Rebooting Now!
'; + $result = shell_exec("sudo /sbin/reboot"); + } + if (isset($_POST['system_shutdown'])) { + echo '
System Shutting Down Now!
'; + $result = shell_exec("sudo /sbin/shutdown -h now"); + } + ?> + +
+
+
+
+

System Information

+
Hostname

+
Uptime

+
Memory Used
+
+
% +
+
+ +
+
+
+
+ +
+ + + +
+ +
+
+
+
+ Configure RaspAP +
  • + System +
  • @@ -176,6 +179,9 @@ $page = $_GET['page']; case "save_hostapd_conf": SaveHostAPDConfig(); break; + case "system_info": + DisplaySystem(); + break; default: DisplayDashboard(); }