diff --git a/ajax/networking/do_sys_reset.php b/ajax/networking/do_sys_reset.php new file mode 100644 index 00000000..05f36615 --- /dev/null +++ b/ajax/networking/do_sys_reset.php @@ -0,0 +1,35 @@ + $path .'/hostapd.conf', "tmp" => "/tmp/hostapddata", "dest" => RASPI_HOSTAPD_CONFIG), + array("src" => $path .'/dhcpcd.conf', "tmp" => "/tmp/dhcpddata", "dest" => RASPI_DHCPCD_CONFIG), + array("src" => $path .'/090_wlan0.conf', "tmp" => "/tmp/dnsmasqdata", "dest" => RASPI_DNSMASQ_PREFIX.'wlan0.conf'), + array("src" => $path .'/090_raspap.conf', "tmp" => "/tmp/dnsmasqdata", "dest" => RASPI_DNSMASQ_PREFIX.'raspap.conf'), + ); + + foreach ($configs as $config) { + try { + $tmp = file_get_contents($config["src"]); + file_put_contents($config["tmp"], $tmp); + system("sudo cp ".$config["tmp"]. " ".$config["dest"]); + } catch (Exception $e) { + $return = $e->getCode(); + } + } + $jsonData = ['return'=>$return]; + echo json_encode($jsonData); + +} else { + handleInvalidCSRFToken(); +} + diff --git a/app/js/custom.js b/app/js/custom.js index 3bae9432..40e181bc 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -20,7 +20,6 @@ function createNetmaskAddr(bitCount) { function loadSummary(strInterface) { $.post('ajax/networking/get_ip_summary.php',{interface:strInterface},function(data){ jsonData = JSON.parse(data); - console.log(jsonData); if(jsonData['return'] == 0) { $('#'+strInterface+'-summary').html(jsonData['output'].join('
')); } else if(jsonData['return'] == 2) { @@ -322,6 +321,27 @@ $('#ovpn-userpw,#ovpn-certs').on('click', function (e) { } }); +$('#js-system-reset-confirm').on('click', function (e) { + var progressText = $('#js-system-reset-confirm').attr('data-message'); + var successHtml = $('#system-reset-message').attr('data-message'); + var closeHtml = $('#js-system-reset-cancel').attr('data-message'); + var csrfToken = $('meta[name=csrf_token]').attr('content'); + var progressHtml = $('
').text(progressText).html() + ''; + $('#system-reset-message').html(progressHtml); + $.post('ajax/networking/do_sys_reset.php?',{'csrf_token':csrfToken},function(data){ + setTimeout(function(){ + jsonData = JSON.parse(data); + if(jsonData['return'] == 0) { + $('#system-reset-message').text(successHtml); + } else { + $('#system-reset-message').text('Error occured: '+ jsonData['return']); + } + $("#js-system-reset-confirm").hide(); + $("#js-system-reset-cancel").text(closeHtml); + },750); + }); +}); + $(document).ready(function(){ $("#PanelManual").hide(); }); @@ -464,7 +484,6 @@ window.addEventListener('load', function() { // Loop over them and prevent submission var validation = Array.prototype.filter.call(forms, function(form) { form.addEventListener('submit', function(event) { - //console.log(event.submitter); if (form.checkValidity() === false) { event.preventDefault(); event.stopPropagation(); diff --git a/locale/en_US/LC_MESSAGES/messages.mo b/locale/en_US/LC_MESSAGES/messages.mo index c1a7c5c7..a534b424 100644 Binary files a/locale/en_US/LC_MESSAGES/messages.mo and b/locale/en_US/LC_MESSAGES/messages.mo differ diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index fd1ff0c1..2a4672c8 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -758,7 +758,36 @@ msgstr "OS" msgid "Kernel" msgstr "Kernel" -#: includes/themes.php +msgid "System reset" +msgstr "System reset" + +msgid "Reset RaspAP to its initial configuration? This action cannot be undone." +msgstr "Reset RaspAP to its initial configuration? This action cannot be undone." + +msgid "Reset complete. Restart the hotspot for the changes to take effect." +msgstr "Reset complete. Restart the hotspot for the changes to take effect." + +msgid "System reset in progress..." +msgstr "System reset in progress..." + +msgid "Reset" +msgstr "Reset" + +msgid "Restore settings" +msgstr "Restore settings" + +msgid "To reset RaspAP to its initial configuration, click or tap the button below." +msgstr "To reset RaspAP to its initial configuration, click or tap the button below." + +msgid "Custom files for optional components such as Ad Blocking, WireGuard or OpenVPN will remain on the system." +msgstr "Custom files for optional components such as Ad Blocking, WireGuard or OpenVPN will remain on the system." + +msgid "Perform reset" +msgstr "Perform reset" + +msgid "Restores all access point (AP) service settings to their default values. This applies to hostapd, dhcpcd and dnsmasq." +msgstr "Restores all access point (AP) service settings to their default values. This applies to hostapd, dhcpcd and dnsmasq." + msgid "Theme settings" msgstr "Theme settings" diff --git a/templates/system.php b/templates/system.php index b939930d..65a3834e 100755 --- a/templates/system.php +++ b/templates/system.php @@ -17,6 +17,7 @@ +
@@ -24,6 +25,7 @@ +
@@ -31,3 +33,22 @@ + + + + diff --git a/templates/system/reset.php b/templates/system/reset.php new file mode 100644 index 00000000..bb598059 --- /dev/null +++ b/templates/system/reset.php @@ -0,0 +1,21 @@ + +
+

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