diff --git a/back/pialert.py b/back/pialert.py
index 0a66d465..af98c5b4 100755
--- a/back/pialert.py
+++ b/back/pialert.py
@@ -34,8 +34,8 @@ import requests
from base64 import b64encode
from paho.mqtt import client as mqtt_client
import threading
-from ssdpy import SSDPClient
-import upnpclient
+# from ssdpy import SSDPClient
+# import upnpclient
#===============================================================================
# PATHS
@@ -233,6 +233,7 @@ mqtt_thread_up = False
# timestamps of last execution times
time_now = datetime.datetime.now()
+log_timestamp = time_now
now_minus_24h = time_now - timedelta(hours = 24)
last_network_scan = now_minus_24h
@@ -275,9 +276,7 @@ def main ():
# Header
file_print('\nLoop start')
- file_print('---------------------------')
-
- log_timestamp = time_now
+ file_print('---------------------------')
# Timestamp
startTime = time_now
@@ -2388,25 +2387,31 @@ def upgradeDB ():
ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER
""")
- # Missing parameters in the Parameters table
- missingSettings = len(sql.execute ("""
- SELECT * FROM Parameters WHERE par_ID='Front_Events_Period'
- """).fetchall()) == 0
+ # Re-creating Parameters table
+ file_print("[upgradeDB] Re-creating Parameters table")
+ sql.execute("DROP TABLE Parameters;")
- if missingSettings:
- file_print("[upgradeDB] Adding missing values into the Parameters table")
+ sql.execute("""
+ CREATE TABLE "Parameters" (
+ "par_ID" INTEGER,
+ "par_Value" TEXT
+ );
+ """)
- params = [
- # General
- ('Front_Events_Period', 'Subnets to scan'),
- ('Front_Details_Sessions_Rows', '50'),
- ('Front_Details_Events_Rows', '50'),
- ('Front_Details_Events_Hide', 'True'),
- ('Front_Events_Rows', '50'),
- ('Front_Details_Period', '1 day')
- ]
+ params = [
+ # General
+ ('Front_Events_Period', '1 day'),
+ ('Front_Details_Sessions_Rows', '50'),
+ ('Front_Details_Events_Rows', '50'),
+ ('Front_Details_Events_Hide', 'True'),
+ ('Front_Events_Rows', '50'),
+ ('Front_Details_Period', '1 day'),
+ ('Front_Devices_Order', '[[3,"desc"],[0,"asc"]]'),
+ ('Front_Devices_Rows', '100'),
+ ('Front_Details_Tab', 'tabDetails')
+ ]
- sql.executemany ("""INSERT INTO Parameters ("Par_ID", "Par_Value") VALUES (?, ?)""", params)
+ sql.executemany ("""INSERT INTO Parameters ("par_ID", "par_Value") VALUES (?, ?)""", params)
# don't hog DB access
@@ -2489,7 +2494,7 @@ def print_log (pText):
log_timestamp2 = datetime.datetime.now()
# Print line + time + elapsed time + text
- file_print('--------------------> ',
+ file_print('[LOG_PRINT] > ',
log_timestamp2, ' ',
log_timestamp2 - log_timestamp, ' ',
pText)
diff --git a/docker-compose.yml b/docker-compose.yml
index 437dee27..c1d199bb 100755
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -16,7 +16,7 @@ services:
# comment out / delete below lines, they are only for development purposes
- ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py
- ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh
- # - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
+ - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
- ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js
- ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php
diff --git a/front/php/server/parameters.php b/front/php/server/parameters.php
index 7ffef05d..129eba32 100755
--- a/front/php/server/parameters.php
+++ b/front/php/server/parameters.php
@@ -46,7 +46,7 @@ function getParameter() {
WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"';
$result = $db->query($sql);
- $row = $result -> fetchArray (SQLITE3_NUM);
+ $row = $result -> fetchArray (SQLITE3_NUM);
$value = $row[0];
echo (json_encode ($value));
diff --git a/front/php/server/util.php b/front/php/server/util.php
index 7627e8c3..1486460d 100755
--- a/front/php/server/util.php
+++ b/front/php/server/util.php
@@ -70,13 +70,12 @@ require '/home/pi/pialert/front/php/templates/language/'.$pia_lang_selected.'.ph
$FUNCTION = [];
$SETTINGS = [];
-
-if(array_search('function', $FUNCTION) != FALSE)
-{
+if(array_key_exists('function', $_REQUEST) != FALSE)
+{echo 'here'.$timestamp ;
$FUNCTION = $_REQUEST['function'];
}
-if(array_search('function', $SETTINGS) != FALSE)
+if(array_key_exists('settings', $_REQUEST) != FALSE)
{
$SETTINGS = $_REQUEST['settings'];
}
@@ -211,7 +210,7 @@ function saveSettings()
{
global $SETTINGS, $FUNCTION, $config_file, $fullConfPath, $configFolderPath, $timestamp;
-
+ echo 'here'.$timestamp ;
// save in the file
$new_name = $config_file.'_'.$timestamp.'.backup';
@@ -233,6 +232,8 @@ function saveSettings()
// generate a clean pialert.conf file
$groups = [];
+ $txt = "";
+
$txt = $txt."#-----------------AUTOGENERATED FILE-----------------#\n";
$txt = $txt."# #\n";
$txt = $txt."# Generated: ".$timestamp." #\n";
@@ -299,7 +300,7 @@ function saveSettings()
displayMessage("
Settings saved to the ".$config_file." file.
Backup of ".$config_file." created: ".$new_name.".
- Restart the container for the chanegs to take effect.",
+ Restart the container for the changes to take effect.",
FALSE, TRUE, TRUE, TRUE);
}
diff --git a/front/settings.php b/front/settings.php
index 97852784..b6cada5f 100644
--- a/front/settings.php
+++ b/front/settings.php
@@ -96,16 +96,20 @@ $db->close();
{
$html = $html.
'
'.$set['Code_Name'].'