logging cleanup

This commit is contained in:
Jokob-sk
2022-12-25 14:25:45 +11:00
parent d6a5f23345
commit 8c8eaeb92f
10 changed files with 266 additions and 133 deletions

View File

@@ -234,6 +234,7 @@ mqtt_thread_up = False
# timestamps of last execution times
time_now = datetime.datetime.now()
log_timestamp = time_now
startTime = time_now
now_minus_24h = time_now - timedelta(hours = 24)
last_network_scan = now_minus_24h
@@ -275,12 +276,11 @@ def main ():
reporting = False
# Header
file_print('\nLoop start')
file_print('---------------------------')
file_print('[', time_now.replace (microsecond=0), '] Loop start ')
# Timestamp
startTime = time_now
startTime = startTime.replace (second=0, microsecond=0)
startTime = startTime.replace (microsecond=0)
# re-load user configuration
importConfig()
@@ -317,16 +317,14 @@ def main ():
# Final menssage
if cycle != "":
file_print('\nFinished cycle: ', cycle, '\n')
file_print('[', time_now.replace (microsecond=0), '] Last action: ', cycle)
cycle = ""
# Footer
file_print('\nLoop end')
file_print('---------------------------')
file_print('[', time_now.replace (microsecond=0), '] Loop end')
else:
# do something
cycle = ""
file_print('\n Wait 20s')
#loop - recursion
time.sleep(20) # wait for N seconds
@@ -339,11 +337,10 @@ def check_internet_IP ():
reporting = False
# Header
file_print('Check Internet IP')
file_print(' Timestamp:', startTime )
file_print('[', startTime, '] Check Internet IP:')
# Get Internet IP
file_print('\n Retrieving Internet IP...')
file_print(' Retrieving Internet IP:')
internet_IP = get_internet_IP()
# TESTING - Force IP
# internet_IP = "1.2.3.4"
@@ -351,12 +348,12 @@ def check_internet_IP ():
# Check result = IP
if internet_IP == "" :
file_print(' Error retrieving Internet IP')
file_print(' Exiting...\n')
file_print(' Exiting...')
return False
file_print(' ', internet_IP)
# Get previous stored IP
file_print('\n Retrieving previous IP...')
file_print(' Retrieving previous IP:')
openDB()
previous_IP = get_previous_internet_IP ()
file_print(' ', previous_IP)
@@ -373,26 +370,26 @@ def check_internet_IP ():
# Get Dynamic DNS IP
if DDNS_ACTIVE :
file_print('\n Retrieving Dynamic DNS IP...')
file_print(' Retrieving Dynamic DNS IP')
dns_IP = get_dynamic_DNS_IP()
# Check Dynamic DNS IP
if dns_IP == "" :
file_print(' Error retrieving Dynamic DNS IP')
file_print(' Exiting...\n')
file_print(' Exiting...')
return False
file_print(' ', dns_IP)
# Check DNS Change
if dns_IP != internet_IP :
file_print(' Updating Dynamic DNS IP...')
file_print(' Updating Dynamic DNS IP')
message = set_dynamic_DNS_IP ()
file_print(' ', message)
reporting = True
else :
file_print(' No changes to perform')
else :
file_print('\n Skipping Dynamic DNS update...')
file_print(' Skipping Dynamic DNS update')
return reporting
@@ -470,7 +467,7 @@ def get_previous_internet_IP ():
def save_new_internet_IP (pNewIP):
# Log new IP into logfile
append_line_to_file (logPath + '/IP_changes.log',
str(startTime) +'\t'+ pNewIP +'\n')
'['+str(startTime) +']\t'+ pNewIP +'\n')
# Save event
sql.execute ("""INSERT INTO Events (eve_MAC, eve_IP, eve_DateTime,
@@ -508,22 +505,21 @@ def check_IP_format (pIP):
#===============================================================================
def cleanup_database ():
# Header
file_print('Cleanup Database')
file_print(' Timestamp:', startTime )
file_print('[', startTime, '] Cleanup Database:' )
openDB()
# Cleanup Online History
file_print(' Cleanup Online_History...')
file_print(' Cleanup Online_History')
sql.execute ("DELETE FROM Online_History WHERE Scan_Date <= date('now', '-1 day')")
file_print(' Optimize Database...')
file_print(' Optimize Database')
# Cleanup Events
file_print(' Cleanup Events, up to the lastest '+str(DAYS_TO_KEEP_EVENTS)+' days...')
file_print(' Cleanup Events, up to the lastest '+str(DAYS_TO_KEEP_EVENTS)+' days')
sql.execute ("DELETE FROM Events WHERE eve_DateTime <= date('now', '-"+str(DAYS_TO_KEEP_EVENTS)+" day')")
# Shrink DB
file_print(' Shrink Database...')
file_print(' Shrink Database')
sql.execute ("VACUUM;")
closeDB()
@@ -533,11 +529,10 @@ def cleanup_database ():
#===============================================================================
def update_devices_MAC_vendors (pArg = ''):
# Header
file_print('Update HW Vendors')
file_print(' Timestamp:', startTime )
file_print('[', startTime, '] Update HW Vendors:' )
# Update vendors DB (iab oui)
file_print('\nUpdating vendors DB (iab & oui)...')
file_print('\nUpdating vendors DB (iab & oui)')
# update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', ' > ', logPath + '/update_vendors.log', '2>&1']
update_args = ['sh', PIALERT_BACK_PATH + '/update_vendors.sh', pArg]
@@ -654,12 +649,12 @@ def scan_network ():
# # devtest end
# Header
file_print('Scan Devices')
file_print('[', startTime, '] Scan Devices:' )
file_print(' ScanCycle:', cycle)
file_print(' Timestamp:', startTime )
# # Query ScanCycle properties
print_log ('Query ScanCycle confinguration...')
print_log ('Query ScanCycle confinguration')
scanCycle_data = query_ScanCycle_Data (True)
if scanCycle_data is None:
file_print('\n*************** ERROR ***************')
@@ -671,9 +666,7 @@ def scan_network ():
cycle_interval = scanCycle_data['cic_EveryXmin']
# arp-scan command
file_print('\nScanning...')
file_print(' arp-scan Method...')
print_log ('arp-scan starts...')
file_print(' arp-scan start')
arpscan_devices = execute_arpscan ()
print_log ('arp-scan ends')
@@ -681,18 +674,16 @@ def scan_network ():
# file_print('aspr-scan result:', len(arpscan_devices))
# Pi-hole method
file_print(' Pi-hole Method...')
file_print(' Pi-hole start')
openDB()
print_log ('Pi-hole copy starts...')
reporting = copy_pihole_network() or reporting
# DHCP Leases method
file_print(' DHCP Leases Method...')
file_print(' DHCP Leases start')
reporting = read_DHCP_leases () or reporting
# Load current scan data
file_print('\nProcessing scan results...')
print_log ('Save scanned devices')
file_print('Processing scan results')
save_scanned_devices (arpscan_devices, cycle_interval)
# Print stats
@@ -701,37 +692,37 @@ def scan_network ():
print_log ('Stats end')
# Create Events
file_print('\nUpdating DB Info...')
file_print(' Sessions Events (connect / discconnect) ...')
file_print('Updating DB Info')
file_print(' Sessions Events (connect / discconnect)')
insert_events()
# Create New Devices
# after create events -> avoid 'connection' event
file_print(' Creating new devices...')
file_print(' Creating new devices')
create_new_devices ()
# Update devices info
file_print(' Updating Devices Info...')
file_print(' Updating Devices Info')
update_devices_data_from_scan ()
# Resolve devices names
print_log (' Resolve devices names...')
print_log (' Resolve devices names')
update_devices_names()
# Void false connection - disconnections
file_print(' Voiding false (ghost) disconnections...')
file_print(' Voiding false (ghost) disconnections')
void_ghost_disconnections ()
# Pair session events (Connection / Disconnection)
file_print(' Pairing session events (connection / disconnection) ...')
file_print(' Pairing session events (connection / disconnection) ')
pair_sessions_events()
# Sessions snapshot
file_print(' Creating sessions snapshot...')
file_print(' Creating sessions snapshot')
create_sessions_snapshot ()
# Skip repeated notifications
file_print(' Skipping repeated notifications...')
file_print(' Skipping repeated notifications')
skip_repeated_notifications ()
# Commit changes
@@ -949,13 +940,13 @@ def print_scan_stats ():
sql.execute ("""SELECT COUNT(*) FROM CurrentScan
WHERE cur_ScanMethod='arp-scan' AND cur_ScanCycle = ? """,
(cycle,))
file_print(' arp-scan Method....:', 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 Method.....: +' + str (sql.fetchone()[0]) )
file_print(' Pi-hole detected.....: +' + str (sql.fetchone()[0]) )
# New Devices
sql.execute ("""SELECT COUNT(*) FROM CurrentScan
@@ -1299,7 +1290,7 @@ def update_devices_names ():
notFound = 0
# Devices without name
file_print(' Trying to resolve devices without name...')
file_print(' Trying to resolve devices without name')
# BUGFIX #97 - Updating name of Devices w/o IP
for device in sql.execute ("SELECT * FROM Devices WHERE dev_Name IN ('(unknown)','') AND dev_LastIP <> '-'") :
# Resolve device name
@@ -1313,7 +1304,6 @@ def update_devices_names ():
recordsToUpdate.append ([newName, device['dev_MAC']])
# Print log
file_print('')
file_print(" Names updated: ", len(recordsToUpdate) )
# DEBUG - print list of record to update
# file_print(recordsToUpdate)
@@ -1523,7 +1513,7 @@ def email_reporting ():
global mail_text
global mail_html
# Reporting section
file_print('\nCheck if something to report...')
file_print('\nCheck if something to report')
openDB()
# prepare variables for JSON construction
@@ -1708,43 +1698,43 @@ def email_reporting ():
# Send Mail
if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != []:
file_print('\nChanges detected, sending reports...')
file_print('\nChanges detected, sending reports')
if REPORT_MAIL and check_config('email'):
file_print(' Sending report by email...')
file_print(' Sending report by email')
send_email (mail_text, mail_html)
else :
file_print(' Skip mail...')
file_print(' Skip mail')
if REPORT_APPRISE and check_config('apprise'):
file_print(' Sending report by Apprise...')
file_print(' Sending report by Apprise')
send_apprise (mail_html)
else :
file_print(' Skip Apprise...')
file_print(' Skip Apprise')
if REPORT_WEBHOOK and check_config('webhook'):
file_print(' Sending report by webhook...')
file_print(' Sending report by webhook')
send_webhook (json_final, mail_text)
else :
file_print(' Skip webhook...')
file_print(' Skip webhook')
if REPORT_NTFY and check_config('ntfy'):
file_print(' Sending report by NTFY...')
file_print(' Sending report by NTFY')
send_ntfy (mail_text)
else :
file_print(' Skip NTFY...')
file_print(' Skip NTFY')
if REPORT_PUSHSAFER and check_config('pushsafer'):
file_print(' Sending report by PUSHSAFER...')
file_print(' Sending report by PUSHSAFER')
send_pushsafer (mail_text)
else :
file_print(' Skip PUSHSAFER...')
file_print(' Skip PUSHSAFER')
# Update MQTT entities
if REPORT_MQTT and check_config('mqtt'):
file_print(' Establishing MQTT thread...')
file_print(' Establishing MQTT thread')
# mqtt_thread_up = True # prevent this code to be run multiple times concurrently
# start_mqtt_thread ()
mqtt_start()
else :
file_print(' Skip MQTT...')
file_print(' Skip MQTT')
else :
file_print(' No changes to report...')
file_print(' No changes to report')
openDB()
@@ -1757,7 +1747,7 @@ def email_reporting ():
WHERE eve_PendingAlertEmail = 1""")
# DEBUG - print number of rows updated
file_print(' Notifications:', sql.rowcount)
file_print(' Notifications: ', sql.rowcount)
# Commit changes
sql_connection.commit()
@@ -2428,7 +2418,7 @@ def openDB ():
return
# Log
print_log ('Opening DB...')
print_log ('Opening DB')
# Open DB and Cursor
@@ -2448,7 +2438,7 @@ def closeDB ():
return
# Log
print_log ('Closing DB...')
print_log ('Closing DB')
# Close DB
sql_connection.commit()

View File

@@ -24,6 +24,16 @@
{
color:white;
background-color: black;
font-family: 'Courier New', monospace;
}
.logs-small
{
height: 100px;
}
.span-padding
{
padding:10px;
}
.text-center {
text-align: center;

View File

@@ -67,6 +67,14 @@ function deleteAllCookies() {
// -----------------------------------------------------------------------------
function showModalOk (title, message) {
// set captions
$('#modal-ok-title').html (title);
$('#modal-ok-message').html (message);
// Show modal
$('#modal-ok').modal('show');
}
function showModalDefault (title, message, btnCancel, btnOK, callbackFunction) {
// set captions
$('#modal-default-title').html (title);

View File

@@ -172,16 +172,6 @@ if (submit && isset($_POST['langselector_set'])) {
}
}
// Set Tab ----------------------------------------------------------------------------
if ($_REQUEST['tab'] == '1') {
$pia_tab_setting = 'active'; $pia_tab_tool = ''; $pia_tab_backup = '';
} elseif ($_REQUEST['tab'] == '2') {
$pia_tab_setting = ''; $pia_tab_tool = 'active'; $pia_tab_backup = '';
} elseif ($_REQUEST['tab'] == '3') {
$pia_tab_setting = ''; $pia_tab_tool = ''; $pia_tab_backup = 'active';
} else { $pia_tab_setting = 'active'; $pia_tab_tool = ''; $pia_tab_backup = '';}
?>
<div class="row">
@@ -230,10 +220,18 @@ if ($_REQUEST['tab'] == '1') {
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_Settings" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Settings'];?></a></li>
<li><a href="#tab_DBTools" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Tools'];?></a></li>
<li><a href="#tab_BackupRestore" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_BackupRestore'];?></a></li>
<li><a href="#tab_Logging" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Logging'];?></a></li>
<li class="active">
<a id="tab_Settings_id" href="#tab_Settings" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Settings'];?></a>
</li>
<li>
<a id="tab_DBTools_id" href="#tab_DBTools" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Tools'];?></a>
</li>
<li>
<a id="tab_BackupRestore_id" href="#tab_BackupRestore" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_BackupRestore'];?></a>
</li>
<li>
<a id="tab_Logging_id" href="#tab_Logging" data-toggle="tab"><?php echo $pia_lang['Maintenance_Tools_Tab_Logging'];?></a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_Settings">
@@ -378,46 +376,51 @@ if ($_REQUEST['tab'] == '1') {
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
pialert.log
<div><label>pialert.log</label><span class="span-padding"><a href="./log/pialert.log"><i class="fa fa-download"></i> </a></span></div>
<div><button class="btn btn-primary" onclick="logManage('pialert.log','cleanLog')"><?php echo $pia_lang['Gen_Purge'];?></button></div>
</div>
<div class="db_tools_table_cell_b">
<textarea id="pialert_log" class="logs" cols="70" rows="10" ><?php echo file_get_contents( "./log/pialert.log" ); ?>
<textarea id="pialert_log" class="logs" cols="70" rows="10" readonly ><?php echo file_get_contents( "./log/pialert.log" ); ?>
</textarea>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
pialert_front.log
<div><label>pialert_front.log</label><span class="span-padding"><a href="./log/pialert_front.log"><i class="fa fa-download"></i> </a></span></div>
<div><button class="btn btn-primary" onclick="logManage('pialert_front.log','cleanLog')"><?php echo $pia_lang['Gen_Purge'];?></button></div>
</div>
<div class="db_tools_table_cell_b">
<textarea id="pialert_log" class="logs" cols="70" rows="10" ><?php echo file_get_contents( "./log/pialert_front.log" ); ?>
<textarea id="pialert_log" class="logs" cols="70" rows="10" readonly><?php echo file_get_contents( "./log/pialert_front.log" ); ?>
</textarea>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
IP_changes.log
<div><label>IP_changes.log</label><span class="span-padding"><a href="./log/IP_changes.log"><i class="fa fa-download"></i> </a></span></div>
<div><button class="btn btn-primary" onclick="logManage('IP_changes.log','cleanLog')"><?php echo $pia_lang['Gen_Purge'];?></button></div>
</div>
<div class="db_tools_table_cell_b">
<textarea id="IP_changes_log" class="logs" cols="70" rows="10" ><?php echo file_get_contents( "./log/IP_changes.log" ); ?>
<textarea id="IP_changes_log" class="logs logs-small" cols="70" rows="10" readonly><?php echo file_get_contents( "./log/IP_changes.log" ); ?>
</textarea>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
stdout.log
<div><label>stdout.log</label><span class="span-padding"><a href="./log/stdout.log"><i class="fa fa-download"></i> </a></span></div>
<div><button class="btn btn-primary" onclick="logManage('stdout.log','cleanLog')"><?php echo $pia_lang['Gen_Purge'];?></button></div>
</div>
<div class="db_tools_table_cell_b">
<textarea id="stdout_log" class="logs" cols="70" rows="10" ><?php echo file_get_contents( "./log/stdout.log" ); ?>
<textarea id="stdout_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stdout.log" ); ?>
</textarea>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
stderr.log
<div><label>stderr.log</label><span class="span-padding"><a href="./log/stderr.log"><i class="fa fa-download"></i> </a></span></div>
<div><button class="btn btn-primary" onclick="logManage('stderr.log','cleanLog')"><?php echo $pia_lang['Gen_Purge'];?></button></div>
</div>
<div class="db_tools_table_cell_b">
<textarea id="stderr_log" class="logs" cols="70" rows="10" ><?php echo file_get_contents( "./log/stderr.log" ); ?>
<textarea id="stderr_log" class="logs logs-small" cols="70" rows="10" wrap='off' readonly><?php echo file_get_contents( "./log/stderr.log" ); ?>
</textarea>
</div>
</div>
@@ -463,20 +466,10 @@ if ($_REQUEST['tab'] == '1') {
<script>
function scrollDown()
{
temp = $('#pialert_log');
$temp.scrollTop($text[0].scrollHeight);
var emptyArr = ['undefined', "", undefined, null];
var selectedTab = 'tab_Settings_id';
temp = $('#IP_changes_log');
$temp.scrollTop($text[0].scrollHeight);
temp = $('#stdout_log');
$temp.scrollTop($text[0].scrollHeight);
temp = $('#stderr_log');
$temp.scrollTop($text[0].scrollHeight);
}
initializeTabs();
// delete devices with emty macs
function askDeleteDevicesWithEmptyMACs () {
@@ -658,12 +651,97 @@ function PiaToggleArpScan()
});
}
// Clean log file
var targetLogFile = "";
var logFileAction = "";
function logManage(callback) {
targetLogFile = arguments[0]; // target
logFileAction = arguments[1]; // action
// Ask
showModalWarning('<?php echo $pia_lang['Gen_Purge'];?>' + ' ' + arguments[1], '<?php echo $pia_lang['Gen_AreYouSure'];?>',
'<?php echo $pia_lang['Gen_Cancel'];?>', '<?php echo $pia_lang['Gen_Okay'];?>', "performLogManage");
}
function performLogManage() {
// Execute
console.log("targetLogFile:" + targetLogFile)
console.log("logFileAction:" + logFileAction)
$.ajax({
method: "POST",
url: "php/server/util.php",
data: { function: logFileAction, settings: targetLogFile },
success: function(data, textStatus) {
showModalOk ('Result', data );
}
})
}
function scrollDown()
{
var tempArea = $('#pialert_log');
$(tempArea[0]).scrollTop(tempArea[0].scrollHeight);
tempArea = $('#IP_changes_log');
$(tempArea[0]).scrollTop(tempArea[0].scrollHeight);
tempArea = $('#stdout_log');
$(tempArea[0]).scrollTop(tempArea[0].scrollHeight);
tempArea = $('#stderr_log');
$(tempArea[0]).scrollTop(tempArea[0].scrollHeight);
}
function initializeTabs () {
// Activate panel
if(!emptyArr.includes(getCache("activeMaintenanceTab")))
{
selectedTab = getCache("activeMaintenanceTab");
}
$('.nav-tabs a[id='+ selectedTab +']').tab('show');
// When changed save new current tab
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
setCache("activeMaintenanceTab", $(e.target).attr('id'))
});
// events on tab change
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab
//alert(target);
if(target == "#tab_Logging")
{
scrollDown();
}
});
}
function getCache(key)
{
// check cache
if(sessionStorage.getItem(key))
{
return sessionStorage.getItem(key);
} else
{
return "";
}
}
function setCache(key, data)
{
sessionStorage.setItem(key, data);
}
// load footer asynchronously not to block the page load/other sections
window.onload = function asyncFooter()
{
// scrollDown();
$("#lastCommit").append('<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/jokob-sk/pi.alert/main?logo=github">');
$("#lastDockerUpdate").append(
@@ -671,8 +749,6 @@ window.onload = function asyncFooter()
}
</script>

View File

@@ -70,8 +70,9 @@ require '/home/pi/pialert/front/php/templates/language/'.$pia_lang_selected.'.ph
$FUNCTION = [];
$SETTINGS = [];
// init request params
if(array_key_exists('function', $_REQUEST) != FALSE)
{echo 'here'.$timestamp ;
{
$FUNCTION = $_REQUEST['function'];
}
@@ -80,9 +81,15 @@ if(array_key_exists('settings', $_REQUEST) != FALSE)
$SETTINGS = $_REQUEST['settings'];
}
if ($FUNCTION == 'savesettings') {
// call functions based on requested params
if ($FUNCTION == 'savesettings')
{
saveSettings();
}
elseif ($FUNCTION == 'cleanLog')
{
cleanLog($SETTINGS);
}
//------------------------------------------------------------------------------
// Formatting data functions
@@ -157,6 +164,7 @@ function checkPermissions($files)
}
}
// ----------------------------------------------------------------------------------------
function displayMessage($message, $logAlert = FALSE, $logConsole = TRUE, $logFile = TRUE, $logEcho = FALSE)
{
@@ -205,19 +213,39 @@ function displayMessage($message, $logAlert = FALSE, $logConsole = TRUE, $logFil
}
// ----------------------------------------------------------------------------------------
function cleanLog($logFile)
{
global $logFolderPath, $timestamp;
$path = "";
$allowedFiles = ['pialert.log', 'pialert_front.log', 'IP_changes.log', 'stdout.log', 'stderr.log'];
if(in_array($logFile, $allowedFiles))
{
$path = $logFolderPath.$logFile;
}
if($path != "")
{
// purge content
$file = fopen($path, "w") or die("Unable to open file!");
fwrite($file, "[".$timestamp. "] Log file manually purged" .PHP_EOL."");
fclose($file);
displayMessage('File <code>'.$logFile.'</code> purged.', FALSE, TRUE, TRUE, TRUE);
}
}
// ----------------------------------------------------------------------------------------
function saveSettings()
{
global $SETTINGS, $FUNCTION, $config_file, $fullConfPath, $configFolderPath, $timestamp;
echo 'here'.$timestamp ;
// save in the file
$new_name = $config_file.'_'.$timestamp.'.backup';
$new_location = $configFolderPath.$new_name;
// chmod($fullConfPath, 0755);
if(file_exists( $fullConfPath) != 1)
{
displayMessage('File "'.$fullConfPath.'" not found or missing read permissions. Creating a new <code>'.$config_file.'</code> file.', FALSE, TRUE, TRUE, TRUE);
@@ -299,7 +327,7 @@ function saveSettings()
fclose($newConfig);
displayMessage("<br/>Settings saved to the <code>".$config_file."</code> file.
Backup of ".$config_file." created: <code>".$new_name."</code>.<br/>
<br/><br/>Backup of the previous ".$config_file." created here: <br/><br/><code>".$new_name."</code><br/><br/>
<b>Restart the container for the changes to take effect.</b>",
FALSE, TRUE, TRUE, TRUE);

View File

@@ -16,6 +16,7 @@ $pia_lang['Gen_Purge'] = 'Aufräumen';
$pia_lang['Gen_Backup'] = 'Sichern';
$pia_lang['Gen_Restore'] = 'Wiederherstellen';
$pia_lang['Gen_Switch'] = 'Umschalten';
$pia_lang['Gen_AreYouSure'] = 'Sind Sie sich sicher?';
//////////////////////////////////////////////////////////////////
// Login Page - Update by @TeroRERO 03ago2022

View File

@@ -16,6 +16,7 @@ $pia_lang['Gen_Purge'] = 'Purge';
$pia_lang['Gen_Backup'] = 'Run Backup';
$pia_lang['Gen_Restore'] = 'Run Restore';
$pia_lang['Gen_Switch'] = 'Switch';
$pia_lang['Gen_AreYouSure'] = 'Are you sure?';
//////////////////////////////////////////////////////////////////
// Login Page - Update by @TeroRERO 03ago2022

View File

@@ -16,6 +16,7 @@ $pia_lang['Gen_Purge'] = 'Purgar';
$pia_lang['Gen_Backup'] = 'Ejecutar copia de seguridad';
$pia_lang['Gen_Restore'] = 'Ejecutar restauración';
$pia_lang['Gen_Switch'] = 'Cambiar';
$pia_lang['Gen_AreYouSure'] = '¿Estás seguro de';
//////////////////////////////////////////////////////////////////
// Login Page - Update by @TeroRERO 03ago2022

View File

@@ -7,6 +7,26 @@
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<!-- Modal Ok -->
<div class="modal fade" id="modal-ok" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" >
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 id="modal-ok-title" class="modal-title"> Modal Default Title </h4>
</div>
<div id="modal-ok-message" class="modal-body"> Modal Default message </div>
<div class="modal-footer">
<button id="modal-ok-OK" type="button" class="btn btn-primary" style="min-width: 80px;" data-dismiss="modal"> OK </button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- Modal Default -->
<div class="modal fade" id="modal-default" style="display: none;">

View File

@@ -108,8 +108,6 @@ $db->close();
$html = $html.getString ($set['Code_Name'].'_description', $set['Description'], $pia_lang);
$html = $html.
'</div>
<div class="table_cell setting_input" >';
@@ -254,7 +252,7 @@ $db->close();
if(ipMask == "" || ipInterface == "")
{
showModalDefault ('Validation error', 'Specify both, the network mask and the interface');
modalDefaultOK ('Validation error', 'Specify both, the network mask and the interface');
} else {
$('#SCAN_SUBNETS').append($('<option disabled></option>').attr('value', full).text(full));
@@ -315,7 +313,7 @@ $db->close();
success: function(data, textStatus) {
// $("#result").html(data);
// console.log(data);
showModalDefault ('Result', data );
showModalOk ('Result', data );
}
})
}