diff --git a/back/pialert.py b/back/pialert.py index 9af8e129..23104408 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -217,9 +217,6 @@ if (sys.version_info > (3,0)): else: execfile (fullConfPath) - -deviceUrl = REPORT_DASHBOARD_URL + '/deviceDetails.php?mac=' - #=============================================================================== # USER CONFIG VARIABLES - END #=============================================================================== @@ -264,9 +261,13 @@ def main (): upgradeDB() while True: + # update NOW time time_now = datetime.datetime.now() + # re-load user configuration + importConfig() + # proceed if 1 minute passed if last_run + timedelta(minutes=1) < time_now : @@ -280,10 +281,7 @@ def main (): # Timestamp startTime = time_now - startTime = startTime.replace (microsecond=0) - - # re-load user configuration - importConfig() + startTime = startTime.replace (microsecond=0) # determine run/scan type based on passed time if last_internet_IP_scan + timedelta(minutes=3) < time_now: @@ -315,9 +313,12 @@ def main (): # Close SQL closeDB() - # Final menssage + # Final message if cycle != "": - file_print('[', time_now.replace (microsecond=0), '] Last action: ', cycle) + action = str(cycle) + if cycle == "1": + action = "network_scan" + file_print('[', time_now.replace (microsecond=0), '] Last action: ', action) cycle = "" # Footer @@ -565,8 +566,7 @@ def update_devices_MAC_vendors (pArg = ''): else : recordsToUpdate.append ([vendor, device['dev_MAC']]) - # Print log - file_print('') + # Print log file_print(" Devices Ignored: ", ignored) file_print(" Vendors Not Found:", notFound) file_print(" Vendors updated: ", len(recordsToUpdate) ) @@ -934,19 +934,19 @@ def print_scan_stats (): sql.execute ("""SELECT COUNT(*) FROM CurrentScan WHERE cur_ScanCycle = ? """, (cycle,)) - file_print(' Devices Detected.......:', str (sql.fetchone()[0]) ) + file_print(' Devices Detected.......: ', str (sql.fetchone()[0]) ) # Devices arp-scan sql.execute ("""SELECT COUNT(*) FROM CurrentScan WHERE cur_ScanMethod='arp-scan' AND cur_ScanCycle = ? """, (cycle,)) - file_print(' arp-scan detected....: ', str (sql.fetchone()[0]) ) + file_print(' arp-scan detected..: ', str (sql.fetchone()[0]) ) # Devices Pi-hole sql.execute ("""SELECT COUNT(*) FROM CurrentScan WHERE cur_ScanMethod='PiHole' AND cur_ScanCycle = ? """, (cycle,)) - file_print(' Pi-hole detected.....: +' + str (sql.fetchone()[0]) ) + file_print(' Pi-hole detected...: +' + str (sql.fetchone()[0]) ) # New Devices sql.execute ("""SELECT COUNT(*) FROM CurrentScan @@ -961,7 +961,7 @@ def print_scan_stats (): WHERE dev_MAC = cur_MAC AND dev_ScanCycle = cur_ScanCycle AND dev_ScanCycle = ? """, (cycle,)) - file_print('') + file_print(' Devices in this cycle..: ' + str (sql.fetchone()[0]) ) # Down Alerts @@ -1512,8 +1512,11 @@ json_final = [] def email_reporting (): global mail_text global mail_html + + deviceUrl = REPORT_DASHBOARD_URL + '/deviceDetails.php?mac=' + # Reporting section - file_print('\nCheck if something to report') + file_print('Check if something to report') openDB() # prepare variables for JSON construction @@ -2211,9 +2214,20 @@ def start_mqtt_thread (): # DB #=============================================================================== def importConfig (): - openDB() - # file_print('pialertPath:', pialertPath) + # global SCAN_SUBNETS, PRINT_LOG, TIMEZONE, PIALERT_WEB_PROTECTION, PIALERT_WEB_PASSWORD, INCLUDED_SECTIONS, SCAN_CYCLE_MINUTES, DAYS_TO_KEEP_EVENTS, REPORT_DASHBOARD_URL + + # load the variables from pialert.conf + if (sys.version_info > (3,0)): + # file_print(">>>>>oooooo>>>>", PRINT_LOG) + d = {} + exec(open(fullConfPath).read(), d ) #here + else: + execfile (fullConfPath, globals()) + + # file_print(">>>>>>>>>", PRINT_LOG) + + openDB() # Code_Name, Display_Name, Description, Type, Options, Value, Group settings = [ @@ -2484,7 +2498,7 @@ def print_log (pText): log_timestamp2 = datetime.datetime.now() # Print line + time + elapsed time + text - file_print('[LOG_PRINT] > ', + file_print('[LOG_PRINT] ', log_timestamp2, ' ', log_timestamp2 - log_timestamp, ' ', pText) diff --git a/front/css/pialert.css b/front/css/pialert.css index a9252a8e..f1d06e14 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -579,18 +579,18 @@ height: 50px; .setting_name { - width:20%; + width:19%; font-weight: 300; } .setting_description { - width:50%; + width:46%; } .setting_input { - width:30%; + width:35%; } .center @@ -609,7 +609,7 @@ height: 50px; .settings_content { padding: 10px; - background-color: #272c30; + /* background-color: #272c30; */ margin: 10px; } diff --git a/front/devices.php b/front/devices.php index a4b18f82..cc621225 100755 --- a/front/devices.php +++ b/front/devices.php @@ -220,11 +220,16 @@ // ----------------------------------------------------------------------------- function main () { + // get parameter value $.get('php/server/parameters.php?action=get¶meter='+ parTableRows, function(data) { var result = JSON.parse(data); + + result = parseInt(result, 10) + if (Number.isInteger (result) ) { tableRows = result; + } // get parameter value diff --git a/front/events.php b/front/events.php index 677b9f0a..17c24e7b 100755 --- a/front/events.php +++ b/front/events.php @@ -206,6 +206,7 @@ function main () { // get parameter value $.get('php/server/parameters.php?action=get¶meter='+ parTableRows, function(data) { var result = JSON.parse(data); + result = parseInt(result, 10) if (Number.isInteger (result) ) { tableRows = result; } diff --git a/front/maintenance.php b/front/maintenance.php index 7351ef35..b7a8d22a 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -390,7 +390,7 @@ if (submit && isset($_POST['langselector_set'])) {
-
@@ -684,6 +684,9 @@ function scrollDown() var tempArea = $('#pialert_log'); $(tempArea[0]).scrollTop(tempArea[0].scrollHeight); + tempArea = $('#pialert_front_log'); + $(tempArea[0]).scrollTop(tempArea[0].scrollHeight); + tempArea = $('#IP_changes_log'); $(tempArea[0]).scrollTop(tempArea[0].scrollHeight); @@ -741,6 +744,7 @@ function setCache(key, data) // load footer asynchronously not to block the page load/other sections window.onload = function asyncFooter() { + scrollDown(); $("#lastCommit").append('GitHub last commit'); diff --git a/front/php/server/util.php b/front/php/server/util.php index 53773593..b8ac3190 100755 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -51,14 +51,6 @@ $timestamp = $date->format('Y-m-d_H-i-s'); // ################################### // ## GUI settings processing start // ################################### -if (file_exists('../db/setting_darkmode')) { - $ENABLED_DARKMODE = True; -} -foreach (glob("../db/setting_skin*") as $filename) { - $pia_skin_selected = str_replace('setting_','',basename($filename)); -} -if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';} - foreach (glob("../db/setting_language*") as $filename) { $pia_lang_selected = str_replace('setting_language_','',basename($filename)); } diff --git a/front/settings.php b/front/settings.php index df71ed02..ef397df6 100644 --- a/front/settings.php +++ b/front/settings.php @@ -72,7 +72,7 @@ $db->close(); - +
close(); // create settings groups foreach ($groups as $group) { - $html = $html.'
+ $html = $html.'

'.$group.'

'; // populate settings for each group @@ -95,7 +95,7 @@ $db->close(); if($set["Group"] == $group) { $html = $html. - '
+ '
'; @@ -224,6 +224,7 @@ $db->close(); echo $html; ?> +