diff --git a/dist/js/functions.js b/dist/js/functions.js deleted file mode 100644 index e9164308..00000000 --- a/dist/js/functions.js +++ /dev/null @@ -1,9 +0,0 @@ -function CheckPSK(psk, id) { - if(psk.value.length < 8 || psk.value.length > 63) { - psk.style.background='#FFD0D0'; - document.getElementById(id).disabled = true; - } else { - psk.style.background='#D0FFD0'; - document.getElementById(id).disabled = false; - } -} diff --git a/includes/about.php b/includes/about.php index 33e7ee7d..d675619a 100755 --- a/includes/about.php +++ b/includes/about.php @@ -1,34 +1,11 @@ -
-
-
-
-
- -

-
GNU General Public License v3.0
-

-

RaspAP is a co-creation of @billz and @SirLagz
- with the contributions of our community.

-

https://github.com/billz/raspap-webgui

- -
- -
-
-
-addMessage('Old password does not match', 'danger'); } } -?> -
-
-
-
-
-

showMessages(); ?>

-
- -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- " /> -
-
-
-
-
- + echo renderTemplate("configure_client", compact("status")); -
-
-
-
- -
-

showMessages(); ?>

-

-
- -
- -
- - - - -
- -
-
- -
-
-
- diff --git a/includes/dashboard.php b/includes/dashboard.php index 33a87869..6a751c0d 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -170,114 +170,17 @@ function DisplayDashboard() } else { $status->addMessage(sprintf(_('Interface is %s.'), strtolower($interfaceState)), $classMsgDevicestatus); } - ?> -
-
-
-
-
-

showMessages(); ?>

-
-
-
-
-

-

-

-

-

-


-
-
-
-
-

-

-


-

-

-
-
-
-
-
-
-

-

-

-

-

-

-


-
-
-
% -
-
-
-
-
-
-

-
- - - - - - - - - -'.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; - echo ''.PHP_EOL; -}; -?> - -
'.htmlspecialchars($client_items[3], ENT_QUOTES).''.htmlspecialchars($client_items[2], ENT_QUOTES).''.htmlspecialchars($client_items[1], ENT_QUOTES).'
-
-
-
-
-
-
-
-
- - '; -} else { - echo ''; -} - ?> - " onclick="document.location.reload(true)" /> -
-
-
- -
- -
-
-
- -
-
-
-
-
- - - -
-
-
-
-

- - - -
-
-
-
-
-
-
-
-

- - - -
-
-
-
-
-
-
-
-

- - - -
-
-
-
-
-
- -
- -
-
-
- - - $interfacesWlo ]); $extraFooterScripts[] = array('src'=>'vendor/raphael/raphael.min.js', 'defer'=>false); @@ -105,4 +14,3 @@ t['receive'] = ''; $extraFooterScripts[] = array('src'=>'vendor/datatables/js/jquery.dataTables.min.js', 'defer'=>false); $extraFooterScripts[] = array('src'=>'js/bandwidthcharts.js', 'defer'=>false); } - diff --git a/includes/dhcp.php b/includes/dhcp.php index 81bf14c8..7536cca0 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -132,195 +132,16 @@ function DisplayDHCPConfig() } } -?> -
-
-
-
- - dnsmasq -
- -
-

showMessages(); ?>

-
- - - - -
-
-

DHCP server settings

-
-
- - -
-
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
- - -
-
- - " name="savedhcpdsettings" /> - '; - } else { - echo''; - } - ?> -
- -
-

Client list

-
-
-
-
- -
-
- - - - - - - - - - - -'.PHP_EOL; - $lease_items = explode(' ', $lease); - foreach ($lease_items as $lease_item) { - echo ' '.PHP_EOL; - } - echo ' '.PHP_EOL; -}; -?> - -
'.htmlspecialchars($lease_item, ENT_QUOTES).'
-
-
-
-
-
-
- -
-
- - -
-
- " class="form-control"> -
-
- " class="form-control"> -
-
- -
-
- -
- -
-
-
- " class="form-control" autofocus="autofocus"> -
-
- " class="form-control"> -
-
- -
-
- - - - " name="savedhcpdsettings" /> - '; - } else { - echo''; - } - ?> -
- -
-
-
- -
-
-
- -
-
-
-
- - hostapd -
- -
-

showMessages(); ?>

-
- - - - - -
-
- -

-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-

-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-

-
-
- '; - } else { - echo "
Logfile output not enabled"; - } - ?> -
-
-
-
-

-
-
-
- - /> - -
-
-
-
-
-
- - /> - -
-
-
-
-
-
- - /> - -
-
-
-
-
- - " aria-describedby="max_num_sta_help"> - max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies.") ?> -
-
-
-
- - - - -
-
-
- " /> - ' , PHP_EOL; - } else { - echo '' , PHP_EOL; - }; -?> - -
- -
-
- - -
-
-
-
-
-
-
- -
-
-

-
- -
-
'.htmlspecialchars($interface, ENT_QUOTES).'
-
-

-                                
-
-
'; - } - ?> -
-
-
- -
-
-
- -
-
-
- ' . CSRFTokenFieldTag() . ' -
-

' . _("Adapter IP Address Settings") . '

-
- - -
-

' . _("Enable Fallback to Static Option") . '

-
- - -
-
-
-

' . _("Static IP Options") . '

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- ' . _("Save settings") . ' - ' . _("Apply settings") . ' -
-
-
-
'; + echo renderTemplate("networking", compact("status", "interfaces")); } -?> -
-
- -
-
- - - diff --git a/includes/system.php b/includes/system.php index ed849237..e7b7e8a2 100755 --- a/includes/system.php +++ b/includes/system.php @@ -1,6 +1,7 @@ 'Türkçe' ); - // hostname - exec("hostname -f", $hostarray); - $hostname = $hostarray[0]; - - // 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 ':' '); - } - - // mem used - $memused_status = "primary"; - exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'", $memarray); - $memused = floor($memarray[0]); - if ($memused > 90) { - $memused_status = "danger"; - } elseif ($memused > 75) { - $memused_status = "warning"; - } elseif ($memused > 0) { - $memused_status = "success"; - } - - // cpu load - $cores = exec("grep -c ^processor /proc/cpuinfo"); - $loadavg = exec("awk '{print $1}' /proc/loadavg"); - $cpuload = floor(($loadavg * 100) / $cores); - if ($cpuload > 90) { - $cpuload_status = "danger"; - } elseif ($cpuload > 75) { - $cpuload_status = "warning"; - } elseif ($cpuload > 0) { - $cpuload_status = "success"; - } - - ?> -
-
-
-
-
- - ' . _("System Rebooting Now!") . '
'; + $status->addMessage("System Rebooting Now!", "warning", false); $result = shell_exec("sudo /sbin/reboot"); } if (isset($_POST['system_shutdown'])) { - echo '
' . _("System Shutting Down Now!") . '
'; + $status->addMessage("System Shutting Down Now!", "warning", false); $result = shell_exec("sudo /sbin/shutdown -h now"); } - ?> -

showMessages(); ?>

-
- - - -
-
-
-
-

-

-

-


-
-
-
% -
-
-
-
-
% -
-
- - - - " /> - " /> - " onclick="document.location.reload(true)" /> - -
-
-
- -
-

-
-
- - -
-
- " /> - " onclick="document.location.reload(true)" /> -
- -
-
-
- -
-
-
- -
- - -
- -
-
- - "RaspAP (default)", + "hackernews" => "HackerNews", + "terminal" => "Terminal" + ]; + $themeFiles = [ + "default" => "custom.css", + "hackernews" => "hackernews.css", + "terminal" => "terminal.css" + ]; + $selectedTheme = array_search($_COOKIE['theme'], $themeFiles); - $cselected = ''; - $hselected = ''; - $tselected = ''; - - switch ($_COOKIE['theme']) { - case "custom.css": - $cselected = ' selected="selected"'; - break; - case "hackernews.css": - $hselected = ' selected="selected"'; - break; - case "terminal.css": - $tselected = ' selected="selected"'; - break; - } - -?> -
-
-
-
-
- -

- -
-
- - -
-
- -
- - " onclick="document.location.reload(true)" /> -
- -
-
-
-
- - - - diff --git a/js/custom.js b/js/custom.js index 958658b2..6fd77882 100644 --- a/js/custom.js +++ b/js/custom.js @@ -193,6 +193,39 @@ function loadWifiStations(refresh) { $(".js-reload-wifi-stations").on("click", loadWifiStations(true)); +$(document).on("click", ".js-toggle-password", function(e) { + var button = $(e.target) + var field = $(button.data("target")); + if (field.is(":input")) { + e.preventDefault(); + + if (!button.data("__toggle-with-initial")) { + button.data("__toggle-with-initial", button.text()) + } + + if (field.attr("type") === "password") { + button.text(button.data("toggle-with")); + field.attr("type", "text"); + } else { + button.text(button.data("__toggle-with-initial")); + field.attr("type", "password"); + } + } +}); + +$(document).on("keyup", ".js-validate-psk", function(e) { + var field = $(e.target); + var colors = field.data("colors").split(","); + var target = $(field.data("target")); + if (field.val().length < 8 || field.val().length > 63) { + field.css("backgroundColor", colors[0]); + target.attr("disabled", true); + } else { + field.css("backgroundColor", colors[1]); + target.attr("disabled", false); + } +}); + $(document) .ajaxSend(setCSRFTokenHeader) .ready(contentLoaded) diff --git a/lib/system.php b/lib/system.php new file mode 100644 index 00000000..5e6399ac --- /dev/null +++ b/lib/system.php @@ -0,0 +1,48 @@ + 1)? 's ':' '); + } + if ($hours != 0) { + $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' '); + } + if ($minutes != 0) { + $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); + } + + return $uptime; + } + + public function usedMemory() { + $used = shell_exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'"); + return floor($used); + } + + public function processorCount() { + $procs = shell_exec("nproc --all"); + return intval($proc); + } + + public function loadAvg1Min() { + $load = exec("awk '{print $1}' /proc/loadavg"); + return floatval($load); + } + + public function systemLoadPercentage() { + return floor(($this->loadAvg1Min() * 100) / $this->processorCount()); + } +} \ No newline at end of file diff --git a/templates/about.php b/templates/about.php new file mode 100644 index 00000000..50729834 --- /dev/null +++ b/templates/about.php @@ -0,0 +1,18 @@ +
+
+
+
+
+ +

+
GNU General Public License v3.0
+

+

RaspAP is a co-creation of @billz and @SirLagz
+ with the contributions of our community.

+

https://github.com/billz/raspap-webgui

+ +
+ +
+
+
diff --git a/templates/admin.php b/templates/admin.php new file mode 100644 index 00000000..10d08f3e --- /dev/null +++ b/templates/admin.php @@ -0,0 +1,38 @@ +
+
+
+
+
+ showMessages(); ?> +
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ " /> +
+
+
+
+
diff --git a/templates/configure_client.php b/templates/configure_client.php new file mode 100644 index 00000000..053dc452 --- /dev/null +++ b/templates/configure_client.php @@ -0,0 +1,23 @@ +
+
+
+
+ +
+ showMessages(); ?> +

+ +
+ +
+ +
+ + +
+
+
+ +
+
+
diff --git a/templates/dashboard.php b/templates/dashboard.php new file mode 100644 index 00000000..35a4afb5 --- /dev/null +++ b/templates/dashboard.php @@ -0,0 +1,102 @@ + +
+
+
+
+
+ showMessages(); ?> +
+
+
+
+

+

+

+

+

+


+
+
+
+
+

+

+


+

+

+
+
+
+
+
+
+

+

+

+

+

+

+


+
+
+
%
+
+
+
+
+
+

+
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+
+ + + + " name="ifup_wlan0" /> + + " name="ifdown_wlan0" /> + + +
+
+
+ +
+ +
+
+
diff --git a/templates/data_usage.php b/templates/data_usage.php new file mode 100644 index 00000000..a4c67f2b --- /dev/null +++ b/templates/data_usage.php @@ -0,0 +1,84 @@ +
+
+
+
+
+ + + +
+
+
+
+

+ + + +
+
+
+
+
+
+
+
+

+ + + +
+
+
+
+
+
+
+
+

+ + + +
+
+
+
+
+
+ +
+ +
+
+
+ + diff --git a/templates/dhcp.php b/templates/dhcp.php new file mode 100644 index 00000000..8dcce473 --- /dev/null +++ b/templates/dhcp.php @@ -0,0 +1,174 @@ +
+
+
+
+ + dnsmasq +
+ +
+ showMessages(); ?> +
+ + + + +
+
+

DHCP server settings

+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +" name="savedhcpdsettings" /> + + + " name="stopdhcpd" /> + + " name="startdhcpd" /> + +
+ +
+

Client list

+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ + +
+
+ " class="form-control"> +
+
+ " class="form-control"> +
+
+ +
+
+ +
+ +
+
+
+ " class="form-control" autofocus="autofocus"> +
+
+ " class="form-control"> +
+
+ +
+
+ + + + " name="savedhcpdsettings" /> + '; + } else { + echo''; + } + ?> +
+ +
+
+
+ +
+
+
\ No newline at end of file diff --git a/templates/hostapd.php b/templates/hostapd.php new file mode 100644 index 00000000..bd14b2ab --- /dev/null +++ b/templates/hostapd.php @@ -0,0 +1,449 @@ +
+
+
+
+ + hostapd +
+ +
+ showMessages(); ?> +
+ + + + + +
+
+ +

+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+

+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+

+
+
+ '; + } else { + echo "
Logfile output not enabled"; + } + ?> +
+
+
+
+

+
+
+
+ + /> + +
+
+
+
+
+
+ + /> + +
+
+
+
+
+
+ + /> + +
+
+
+
+
+ + " aria-describedby="max_num_sta_help"> + max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies.") ?> +
+
+
+
+ + + + +
+
+
+ " /> + ' , PHP_EOL; + } else { + echo '' , PHP_EOL; + }; +?> + +
+ +
+
diff --git a/templates/networking.php b/templates/networking.php new file mode 100644 index 00000000..ea534842 --- /dev/null +++ b/templates/networking.php @@ -0,0 +1,104 @@ +
+
+
+
+
+
+ +
+ +
+

+
+ + +
+
+
+
+

+                  
+
+
+ +
+
+
+ +
+
+
+ + + +
+
+
+ +
+ +
+

+
+ + +
+

+
+ + +
+
+ +
+ +

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ +
+
+
+ + +
+
+ +
+
+
diff --git a/templates/system.php b/templates/system.php new file mode 100644 index 00000000..9f184ad7 --- /dev/null +++ b/templates/system.php @@ -0,0 +1,105 @@ +hostname(); +$uptime = $system->uptime(); +$cores = $system->processorCount(); + +// mem used +$memused = $system->usedMemory(); +$memused_status = "primary"; +if ($memused > 90) { + $memused_status = "danger"; +} elseif ($memused > 75) { + $memused_status = "warning"; +} elseif ($memused > 0) { + $memused_status = "success"; +} + +// cpu load +$cpuload = $system->systemLoadPercentage(); +if ($cpuload > 90) { + $cpuload_status = "danger"; +} elseif ($cpuload > 75) { + $cpuload_status = "warning"; +} elseif ($cpuload > 0) { + $cpuload_status = "success"; +} + +?> +
+
+
+
+
+showMessages(); ?> +
+ + + +
+
+
+
+

+

+

+


+
+
+
% +
+
+
+
+
% +
+
+ + + + " /> + " /> + + +
+
+
+ +
+

+
+
+ + +
+
+ " /> + +
+ +
+
+
+ +
+
+
+ +
+ + +
+ +
+
+
diff --git a/templates/themes.php b/templates/themes.php new file mode 100644 index 00000000..8920ad00 --- /dev/null +++ b/templates/themes.php @@ -0,0 +1,24 @@ +
+
+
+
+
+ +

+ +
+
+ + +
+
+ +
+ + +
+ +
+
+
+
diff --git a/templates/wifi_stations.php b/templates/wifi_stations.php index a002b85d..7d4f48fa 100644 --- a/templates/wifi_stations.php +++ b/templates/wifi_stations.php @@ -67,9 +67,9 @@ - + - +