logging cleanup
This commit is contained in:
@@ -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,8 +81,14 @@ 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);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -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 ;
|
||||
global $SETTINGS, $FUNCTION, $config_file, $fullConfPath, $configFolderPath, $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);
|
||||
@@ -298,8 +326,8 @@ function saveSettings()
|
||||
fwrite($newConfig, $txt);
|
||||
fclose($newConfig);
|
||||
|
||||
displayMessage("<br/>Settings saved to the <code>".$config_file."</code> file.
|
||||
Backup of ".$config_file." created: <code>".$new_name."</code>.<br/>
|
||||
displayMessage("<br/>Settings saved to the <code>".$config_file."</code> file.
|
||||
<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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">×</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;">
|
||||
|
||||
Reference in New Issue
Block a user