diff --git a/front/css/dark-patch.css b/front/css/dark-patch.css index 7863345c..5acac727 100644 --- a/front/css/dark-patch.css +++ b/front/css/dark-patch.css @@ -662,3 +662,5 @@ input[type="password"]::-webkit-caps-lock-indicator { color: #444; } +.db_info_table_cell:nth-child(1) {background: #272c30} +.db_info_table_cell:nth-child(2) {background: #272c30} diff --git a/front/css/pialert.css b/front/css/pialert.css index 6766abbe..e2577ab0 100644 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -456,20 +456,20 @@ margin: 5px; display: inline-block; width: 140px; height: 140px; white-space: normal; word-wrap: break-word; font-size: 16px; border-radius: 10px; } -.table-cell:nth-child(1) {background: #272c30} -.table-cell:nth-child(2) {background: #272c30} +.db_info_table_cell:nth-child(1) {background: white} +.db_info_table_cell:nth-child(2) {background: white} -.table { +.db_info_table { display: table; border-spacing: 0em; font-weight: 400; - font-size: 16px; + font-size: 15px; width: 95%; margin: auto; margin-top: 40px; margin-bottom: 40px; } -.table-row {display: table-row; padding: 3px; } -.table-cell {display: table-cell; padding: 3px; padding-left: 10px;} +.db_info_table_row {display: table-row; padding: 3px; } +.db_info_table_cell {display: table-cell; padding: 3px; padding-left: 10px;} } \ No newline at end of file diff --git a/front/maintenance.php b/front/maintenance.php index 4ed5a0fa..c67e2bbe 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -28,7 +28,7 @@ -
+
-
-
-
Database-Path
-
+
+
+
Database-Path
+
-
-
Database-Size
-
+
+
Database-Size
+
-
-
last Modification
-
+
+
last Modification
+
-
-
DB Backup
-
+
+
DB Backup
+
-
-
Scan Status (arp)
-
scan(s) currently running
+
+
Scan Status (arp)
+
scan(s) currently running
-
-
Scan Status (nmap)
-
scan(s) currently running
+
+
Scan Status (nmap)
+
scan(s) currently running
@@ -95,7 +99,9 @@ if ($files){ - + + +
@@ -199,6 +205,22 @@ function PiaBackupDBtoArchive() } +// Restore DB from Archive +function askPiaRestoreDBfromArchive () { + // Ask + showModalWarning('DB Restore', 'Are you sure you want to exectute the the DB Restore? Be sure that no scan is currently running.', + 'Cancel', 'Run Restore', 'PiaRestoreDBfromArchive'); +} + + +function PiaRestoreDBfromArchive() +{ + // Execute + $.get('php/server/devices.php?action=PiaRestoreDBfromArchive', function(msg) { + showMessage (msg); + }); +} + diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 33034757..8fa5249f 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -40,8 +40,8 @@ case 'deleteUnknownDevices': deleteUnknownDevices(); break; case 'deleteEvents': deleteEvents(); break; case 'PiaBackupDBtoArchive': PiaBackupDBtoArchive(); break; - - + case 'PiaRestoreDBfromArchive': PiaRestoreDBfromArchive(); break; + case 'getDevicesTotals': getDevicesTotals(); break; case 'getDevicesList': getDevicesList(); break; case 'getDevicesListCalendar': getDevicesListCalendar(); break; @@ -265,27 +265,54 @@ function deleteEvents() { // Backup DB to Archiv //------------------------------------------------------------------------------ function PiaBackupDBtoArchive() { - - // $DBFILE = '../../../db/pialert.db'; + // prepare fast Backup $file = '../../../db/pialert.db'; - $newfile = '../../../db/pialert.db.backup'; + $newfile = '../../../db/pialert.db.latestbackup'; + // copy files as a fast Backup if (!copy($file, $newfile)) { - echo "Test Function executed not successfully"; + echo "The Backup executed not successfully"; } else { - $Pia_Archive_Name = 'pialertdb_'.date("Ymd_his").'.zip'; + // Create archive with actual date + $Pia_Archive_Name = 'pialertdb_'.date("Ymd_His").'.zip'; $Pia_Archive_Path = '../../../db/'; exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' ../../../db/pialert.db', $output); - if (file_exists($Pia_Archive_Path.$Pia_Archive_Name)) { - echo 'Test Function executed successfully ('.$Pia_Archive_Name.')'; + // chheck if archive exists + if (file_exists($Pia_Archive_Path.$Pia_Archive_Name) && filesize($Pia_Archive_Path.$Pia_Archive_Name) > 0) { + echo 'The backup executed successfully with the new archive: ('.$Pia_Archive_Name.')'; + unlink($newfile); } else { - echo 'Test Function executed successfully'; + echo 'Test backup executed partially successfully. The archive could not be created or is empty. (pialert.db.latestbackup)'; } - // echo "Test Function executed successfully"; } } +//------------------------------------------------------------------------------ +// Restore DB from Archiv +//------------------------------------------------------------------------------ +function PiaRestoreDBfromArchive() { + // prepare fast Backup + $file = '../../../db/pialert.db'; + $oldfile = '../../../db/pialert.db.prerestore'; + + // copy files as a fast Backup + if (!copy($file, $oldfile)) { + echo "Test Function executed not successfully"; + } else { + // extract latest archive and overwrite the actual pialert.db + $Pia_Archive_Path = '../../../db/'; + exec('/bin/ls -Art '.$Pia_Archive_Path.'*.zip | /bin/tail -n 1 | /usr/bin/xargs -n1 /bin/unzip -o -d ../../../db/', $output); + // check if the pialert.db exists + if (file_exists($file)) { + echo 'Restore executed successfully'; + unlink($oldfile); + } else { + echo 'Restore Failed. Please restore the backup manually.'; + } + } + +} //------------------------------------------------------------------------------ // Query total numbers of Devices by status