diff --git a/back/pialert.py b/back/pialert.py index 0321b70d..30e6613d 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -266,12 +266,16 @@ def cleanup_database (): print ('Cleanup Database') print (' Timestamp:', startTime ) - openDB() - + openDB() + strdaystokeepEV = str(365) # str(DAYS_TO_KEEP_EVENTS) # Cleanup Online History print ('\nCleanup Online_History...') - sql.execute ("""DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')""") + sql.execute ("DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')") print ('\nOptimize Database...') + print ('\nCleanup Events, up to the lastest '+strdaystokeepEV+' days...') + sql.execute ("DELETE FROM Events WHERE eve_DateTime <= date('now', '-"+strdaystokeepEV+" day')") + # Shrink DB + print ('\nShrink Database...') sql.execute ("VACUUM;") closeDB() diff --git a/config/pialert.conf b/config/pialert.conf index cbb6420a..404aca20 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -17,11 +17,12 @@ PIALERT_WEB_PROTECTION = False PIALERT_WEB_PASSWORD = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92' # EMAIL settings +# ---------------------- SMTP_SERVER = 'smtp.gmail.com' SMTP_PORT = 587 SMTP_USER = 'user@gmail.com' SMTP_PASS = 'password' -SMTP_SKIP_TLS = False +SMTP_SKIP_TLS = False SMTP_SKIP_LOGIN = False REPORT_MAIL = False @@ -31,14 +32,18 @@ REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac=' REPORT_DASHBOARD_URL = 'http://pi.alert/' # NTFY (https://ntfy.sh/) settings +# ---------------------- REPORT_NTFY = False NTFY_TOPIC = 'replace_my_secure_topicname_91h889f28' REPORT_DASHBOARD_URL = 'http://pi.alert/' # PUSHSAFER (https://www.pushsafer.com/) settings +# ---------------------- REPORT_PUSHSAFER = False PUSHSAFER_TOKEN = 'ApiKey' +# DynDNS +# ---------------------- # QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip' QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com' DDNS_ACTIVE = False @@ -48,6 +53,7 @@ DDNS_PASSWORD = 'A0000000B0000000C0000000D0000000' DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?' # PIHOLE settings +# ---------------------- PIHOLE_ACTIVE = False PIHOLE_DB = '/etc/pihole/pihole-FTL.db' DHCP_ACTIVE = False @@ -65,3 +71,7 @@ DHCP_LEASES = '/etc/pihole/dhcp.leases' # SCAN_SUBNETS = '--localnet --interface=eth0' SCAN_SUBNETS = '--localnet' + +# Maintenance Tasks Cron +# ---------------------- +DAYS_TO_KEEP_EVENTS = 90 \ No newline at end of file diff --git a/docs/img/1_devices.jpg b/docs/img/1_devices.jpg index 4f0a499c..83fce54e 100644 Binary files a/docs/img/1_devices.jpg and b/docs/img/1_devices.jpg differ diff --git a/docs/img/2_3_device_presence.jpg b/docs/img/2_3_device_presence.jpg index b74fd744..7ab0123e 100644 Binary files a/docs/img/2_3_device_presence.jpg and b/docs/img/2_3_device_presence.jpg differ diff --git a/docs/img/2_4_device_nmap.jpg b/docs/img/2_4_device_nmap.jpg index 301b6744..d9f295fe 100644 Binary files a/docs/img/2_4_device_nmap.jpg and b/docs/img/2_4_device_nmap.jpg differ diff --git a/docs/img/2_5_device_nmap_ready.jpg b/docs/img/2_5_device_nmap_ready.jpg index 6184fa49..8d6baa70 100644 Binary files a/docs/img/2_5_device_nmap_ready.jpg and b/docs/img/2_5_device_nmap_ready.jpg differ diff --git a/front/index.php b/front/index.php index dc5a9fe6..c4b5c3db 100644 --- a/front/index.php +++ b/front/index.php @@ -3,10 +3,16 @@ session_start(); if ($_REQUEST['action'] == 'logout') { session_destroy(); + setcookie("PiAler_SaveLogin", "", time() - 3600); header('Location: index.php'); } +// ################################################## +// ## Login Processing start +// ################################################## +$config_file = "../config/pialert.conf"; +$config_file_lines = file($config_file); // ################################### -// ## Login settings locale start +// ## Login language settings // ################################### if (file_exists('../db/setting_darkmode')) { $ENABLED_DARKMODE = True; @@ -21,14 +27,7 @@ if ($_REQUEST['action'] == 'logout') { } if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';} require 'php/templates/language/'.$pia_lang_selected.'.php'; -// ################################### -// ## Login settings locale end -// ################################### -// ################################################## -// ## Login Processing start -// ################################################## -$config_file = "../config/pialert.conf"; -$config_file_lines = file($config_file); + // ################################### // ## PIALERT_WEB_PROTECTION FALSE @@ -38,7 +37,7 @@ $config_file_lines_bypass = array_values(preg_grep('/^PIALERT_WEB_PROTECTION\s.* $protection_line = explode("=", $config_file_lines_bypass[0]); $Pia_WebProtection = strtolower(trim($protection_line[1])); -if ($Pia_WebProtection == 'false') +if ($Pia_WebProtection != 'true') { header('Location: devices.php'); $_SESSION["login"] = 1; @@ -57,24 +56,30 @@ if ($Pia_Password == hash('sha256',$_POST["loginpassword"])) { header('Location: devices.php'); $_SESSION["login"] = 1; + if (isset($_POST['PWRemember'])) {setcookie("PiAler_SaveLogin", hash('sha256',$_POST["loginpassword"]), time()+604800);} } -if ($_SESSION["login"] == 1) +// active Session or valid cookie (cookie not extends) +if (($_SESSION["login"] == 1) || ($Pia_Password == $_COOKIE["PiAler_SaveLogin"])) { header('Location: devices.php'); + $_SESSION["login"] = 1; } +// no active session, cookie not checked if ($_SESSION["login"] != 1) { if (file_exists('../db/setting_darkmode')) {$ENABLED_DARKMODE = True;} if ($Pia_Password == '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92') { $login_info = 'Defaultpassword "123456" is still active'; $login_mode = 'danger'; - $login_headline = 'Password Alert!'; + $login_display_mode = 'display: block;'; + $login_headline = $pia_lang['Login_Toggle_Alert_headline']; $login_icon = 'fa-ban'; } else { $login_mode = 'info'; - $login_headline = 'Password Information'; + $login_display_mode = 'display: none;'; + $login_headline = $pia_lang['Login_Toggle_Info_headline']; $login_icon = 'fa-info'; } @@ -132,22 +137,31 @@ if ($ENABLED_DARKMODE === True) {