diff --git a/front/index.php b/front/index.php
index c95cd519..b84d29f0 100755
--- a/front/index.php
+++ b/front/index.php
@@ -7,7 +7,7 @@ require 'php/templates/security.php';
$CookieSaveLoginName = 'NetAlertX_SaveLogin';
-if ($Pia_WebProtection != 'true')
+if ($nax_WebProtection != 'true')
{
header('Location: devices.php');
$_SESSION["login"] = 1;
@@ -24,7 +24,7 @@ if (isset ($_GET["action"]) && $_GET["action"] == 'logout')
}
// Password without Cookie check -> pass and set initial cookie
-if (isset ($_POST["loginpassword"]) && $Pia_Password == hash('sha256',$_POST["loginpassword"]))
+if (isset ($_POST["loginpassword"]) && $nax_Password == hash('sha256',$_POST["loginpassword"]))
{
header('Location: devices.php');
$_SESSION["login"] = 1;
@@ -32,7 +32,7 @@ if (isset ($_POST["loginpassword"]) && $Pia_Password == hash('sha256',$_POST["lo
}
// active Session or valid cookie (cookie not extends)
-if (( isset ($_SESSION["login"]) && ($_SESSION["login"] == 1)) || (isset ($_COOKIE[$CookieSaveLoginName]) && $Pia_Password == $_COOKIE[$CookieSaveLoginName]))
+if (( isset ($_SESSION["login"]) && ($_SESSION["login"] == 1)) || (isset ($_COOKIE[$CookieSaveLoginName]) && $nax_Password == $_COOKIE[$CookieSaveLoginName]))
{
header('Location: devices.php');
$_SESSION["login"] = 1;
@@ -48,7 +48,7 @@ $login_icon = 'fa-info';
// no active session, cookie not checked
if (isset ($_SESSION["login"]) == FALSE || $_SESSION["login"] != 1)
{
- if ($Pia_Password == '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92')
+ if ($nax_Password == '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92')
{
$login_info = lang('Login_Default_PWD');
$login_mode = 'danger';
diff --git a/front/maintenance.php b/front/maintenance.php
index fdae73c1..d8c4f394 100755
--- a/front/maintenance.php
+++ b/front/maintenance.php
@@ -39,46 +39,17 @@
// Size and last mod of DB ------------------------------------------------------
-$pia_db = str_replace('front', 'db', getcwd()).'/app.db';
-$pia_db_size = number_format((filesize($pia_db) / 1000000),2,",",".") . ' MB';
-$pia_db_mod = date ("F d Y H:i:s", filemtime($pia_db));
+$nax_db = str_replace('front', 'db', getcwd()).'/app.db';
+$nax_db_size = number_format((filesize($nax_db) / 1000000),2,",",".") . ' MB';
+$nax_db_mod = date ("F d Y H:i:s", filemtime($nax_db));
-// Count and Calc Backups -------------------------------------------------------
-
-$Pia_Archive_Path = str_replace('front', 'db', getcwd()).'/';
-$Pia_Archive_count = 0;
-$Pia_Archive_diskusage = 0;
-$files = glob($Pia_Archive_Path."appdb_*.zip");
-if ($files){
- $Pia_Archive_count = count($files);
-}
-foreach ($files as $result) {
- $Pia_Archive_diskusage = $Pia_Archive_diskusage + filesize($result);
-}
-$Pia_Archive_diskusage = number_format(($Pia_Archive_diskusage / 1000000),2,",",".") . ' MB';
-
-// Find latest Backup for restore -----------------------------------------------
-
-$latestfiles = glob($Pia_Archive_Path."appdb_*.zip");
-natsort($latestfiles);
-$latestfiles = array_reverse($latestfiles,False);
-
-$latestbackup = 'none';
-$latestbackup_date = 'no backup';
-
-if (count($latestfiles) > 0)
-{
- $latestbackup = $latestfiles[0];
- $latestbackup_date = date ("Y-m-d H:i:s", filemtime($latestbackup));
-}
-
// Table sizes -----------------------------------------------------------------
$tableSizesHTML = "";
// Open a connection to the SQLite database
-$db = new SQLite3($pia_db);
+$db = new SQLite3($nax_db);
// Retrieve the table names from sqlite_master
$query = "SELECT name FROM sqlite_master WHERE type='table'";
@@ -133,13 +104,13 @@ $db->close();
= lang('Maintenance_database_path');?>
-
+
= lang('Maintenance_database_size');?>
-
+
@@ -151,15 +122,9 @@ $db->close();
= lang('Maintenance_database_lastmod');?>
-
+
-
-
-
= lang('Maintenance_database_backup');?>
-
-
-
-
+
@@ -254,25 +219,7 @@ $db->close();
= lang('Maintenance_Tool_ImportPastedCSV_text');?>
-
-
-
-
-
-
= lang('Maintenance_Tool_backup_text');?>
-
-
-
-
-
-
= lang('Maintenance_Tool_restore_text');?>
-
-
-
-
-
-
= lang('Maintenance_Tool_purgebackup_text');?>
-
+
@@ -458,51 +405,6 @@ function deleteActHistory()
});
}
-// -----------------------------------------------------------
-// Backup DB to Archive
-function askPiaBackupDBtoArchive () {
- // Ask
- showModalWarning('= lang('Maintenance_Tool_backup_noti');?>', '= lang('Maintenance_Tool_backup_noti_text');?>',
- '= lang('Gen_Cancel');?>', '= lang('Gen_Backup');?>', 'PiaBackupDBtoArchive');
-}
-function PiaBackupDBtoArchive()
-{
- // Execute
- $.get('php/server/devices.php?action=PiaBackupDBtoArchive', function(msg) {
- showMessage (msg);
- });
-}
-
-// -----------------------------------------------------------
-// Restore DB from Archive
-function askPiaRestoreDBfromArchive () {
- // Ask
- showModalWarning('= lang('Maintenance_Tool_restore_noti');?>', '= lang('Maintenance_Tool_restore_noti_text');?>',
- '= lang('Gen_Cancel');?>', '= lang('Gen_Restore');?>', 'PiaRestoreDBfromArchive');
-}
-function PiaRestoreDBfromArchive()
-{
- // Execute
- $.get('php/server/devices.php?action=PiaRestoreDBfromArchive', function(msg) {
- showMessage (msg);
- });
-}
-
-// -----------------------------------------------------------
-// Purge Backups
-function askPiaPurgeDBBackups() {
- // Ask
- showModalWarning('= lang('Maintenance_Tool_purgebackup_noti');?>', '= lang('Maintenance_Tool_purgebackup_noti_text');?>',
- '= lang('Gen_Cancel');?>', '= lang('Gen_Purge');?>', 'PiaPurgeDBBackups');
-}
-function PiaPurgeDBBackups()
-{
- // Execute
- $.get('php/server/devices.php?action=PiaPurgeDBBackups', function(msg) {
- showMessage (msg);
- });
-}
-
// -----------------------------------------------------------
// Restart Backend Python Server
diff --git a/front/php/templates/auth.php b/front/php/templates/auth.php
index 5d466f8d..5cc39789 100755
--- a/front/php/templates/auth.php
+++ b/front/php/templates/auth.php
@@ -19,9 +19,9 @@ $config_file = "../../../config/app.conf"; // depends on where this file is call
$config_file_lines = file($config_file);
$config_file_lines = array_values(preg_grep('/^SETPWD_password.*=/', $config_file_lines));
$password_line = explode("'", $config_file_lines[0]);
-$Pia_Password = $password_line[1];
+$nax_Password = $password_line[1];
-if (isset($_COOKIE[$CookieSaveLoginName]) && $Pia_Password == $_COOKIE[$CookieSaveLoginName]) {
+if (isset($_COOKIE[$CookieSaveLoginName]) && $nax_Password == $_COOKIE[$CookieSaveLoginName]) {
$isAuthenticated = true;
}
diff --git a/front/php/templates/security.php b/front/php/templates/security.php
index 879365b3..0cfb5e28 100755
--- a/front/php/templates/security.php
+++ b/front/php/templates/security.php
@@ -21,6 +21,7 @@ if(array_search('action', $_REQUEST) != FALSE)
session_destroy();
setcookie($CookieSaveLoginName, "", time() - 3600);
header('Location: index.php');
+ exit(); // ensure script stops after header redirection
}
}
@@ -28,43 +29,65 @@ if(array_search('action', $_REQUEST) != FALSE)
// ## Login Processing start
// ##################################################
$config_file = $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf";
-$config_file_lines = file($config_file);
+
+if (file_exists($config_file)) {
+ $config_file_lines = file($config_file);
+} else {
+ // handle missing config file
+ die("Configuration file not found.");
+}
+
$CookieSaveLoginName = "NetAlertX_SaveLogin";
// ###################################
// ## SETPWD_enable_password FALSE
// ###################################
+// Find SETPWD_enable_password line
$config_file_lines_bypass = array_values(preg_grep('/^SETPWD_enable_password.*=/', $config_file_lines));
-$protection_line = explode("=", $config_file_lines_bypass[0]);
-$Pia_WebProtection = strtolower(trim($protection_line[1]));
+
+if (!empty($config_file_lines_bypass)) {
+ $protection_line = explode("=", $config_file_lines_bypass[0]);
+ $nax_WebProtection = strtolower(trim($protection_line[1]));
+} else {
+ // Default behavior if SETPWD_enable_password is not found
+ $nax_WebProtection = 'false'; // or another default value
+}
// ###################################
// ## SETPWD_enable_password TRUE
// ###################################
-$config_file_lines = array_values(preg_grep('/^SETPWD_password.*=/', $config_file_lines));
-$password_line = explode("'", $config_file_lines[0]);
-$Pia_Password = $password_line[1];
+// Find SETPWD_password line
+$config_file_lines_password = array_values(preg_grep('/^SETPWD_password.*=/', $config_file_lines));
+
+if (!empty($config_file_lines_password)) {
+ $password_line = explode("'", $config_file_lines_password[0]);
+ $nax_Password = $password_line[1];
+} else {
+ // Default behavior if SETPWD_password is not found
+ $nax_Password = ''; // or handle accordingly
+}
// active Session or valid cookie (cookie not extends)
-if($Pia_WebProtection == 'true')
+if($nax_WebProtection == 'true')
{
- if(isset ($_SESSION["login"]) == FALSE )
+ if(isset($_SESSION["login"]) == FALSE )
{
$_SESSION["login"] = 0;
}
- if ( ($_SESSION["login"] == 1) || $isLogonPage || (( isset($_COOKIE[$CookieSaveLoginName]) && $Pia_Password == $_COOKIE[$CookieSaveLoginName ])))
+ if ($_SESSION["login"] == 1 || $isLogonPage || (isset($_COOKIE[$CookieSaveLoginName]) && $nax_Password == $_COOKIE[$CookieSaveLoginName]))
{
- //Logged in or stay on this page if we are on the index.php already
+ // Logged in or stay on this page if we are on the index.php already
} else
{
// we need to redirect
header('Location: /index.php');
+ exit(); // ensure script stops after header redirection
}
}
-?>
\ No newline at end of file
+?>
diff --git a/front/settings.php b/front/settings.php
index c69f3a5b..7200a674 100755
--- a/front/settings.php
+++ b/front/settings.php
@@ -758,7 +758,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
} else {
- console.error(`[saveSettings] Couldn't determnine how to handle (setCodeName|dataType|inputType):(${setCodeName}|${dataType}|${inputType})`);
+ console.error(`[saveSettings] Couldn't determine how to handle (setCodeName|dataType|inputType):(${setCodeName}|${dataType}|${inputType})`);
value = $('#' + setCodeName).val();
value = applyTransformers(value, transformers);
@@ -794,12 +794,14 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
clearCache()
} else{
- // something went wrong
- // write_notification(data, 'interrupt')
- write_notification("Please screenshot the next popup (or check Monitoring > Notifications), dev console (F12) and submit it as a new issue here: https://github.com/jokob-sk/NetAlertX/issues", 'interrupt')
+ // something went wrong
+ write_notification("[Important] DO NOT REFERSH the page. Open the browser DEV console (F12). Please take a screenshot of it. Submit it (with the nginx and php error logs) as a new issue here: https://github.com/jokob-sk/NetAlertX/issues", 'interrupt')
+
+ console.log("🔽");
console.log(settingsArray);
- console.log(JSON.stringify(settingsArray));
- write_notification(JSON.stringify(settingsArray), 'interrupt')
+ console.log(JSON.stringify(settingsArray));
+ console.log(data);
+ console.log("🔼");
}
}
});