mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Maintenance
The source of a used GIF added to README. The source of the used Fonts added to README. Another used tool was added to the "Powered by" section. More translation work was done and the technique used to do the manual Nmap-scans was changed to include a loading animation. A speedtest has been added to the detailed view of the "Internet" device. This is also located under the "Nmap" tab.
This commit is contained in:
@@ -8,18 +8,22 @@
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
foreach (glob("../../../db/setting_language*") as $filename) {
|
||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||
}
|
||||
if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require 'db.php';
|
||||
require 'util.php';
|
||||
|
||||
require '../templates/language/'.$pia_lang_selected.'.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
// Set maximum execution time to 15 seconds
|
||||
ini_set ('max_execution_time','15');
|
||||
ini_set ('max_execution_time','30');
|
||||
|
||||
// Open DB
|
||||
OpenDB();
|
||||
@@ -135,6 +139,7 @@ function getDeviceData() {
|
||||
//------------------------------------------------------------------------------
|
||||
function setDeviceData() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'UPDATE Devices SET
|
||||
@@ -159,9 +164,9 @@ function setDeviceData() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Device updated successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_UpdDev'];
|
||||
} else {
|
||||
echo "Error updating device\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_UpdDevError']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +176,7 @@ function setDeviceData() {
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteDevice() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Devices WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
@@ -179,9 +185,9 @@ function deleteDevice() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Device deleted successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_DelDev_a'];
|
||||
} else {
|
||||
echo "Error deleting device\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_DelDevError_a']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +196,7 @@ function deleteDevice() {
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteAllWithEmptyMACs() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Devices WHERE dev_MAC=""';
|
||||
@@ -198,9 +205,9 @@ function deleteAllWithEmptyMACs() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Devices deleted successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_DelDev_b'];
|
||||
} else {
|
||||
echo "Error deleting devices\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_DelDevError_b']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +216,7 @@ function deleteAllWithEmptyMACs() {
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteUnknownDevices() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Devices WHERE dev_Name="(unknown)"';
|
||||
@@ -217,9 +225,9 @@ function deleteUnknownDevices() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Devices deleted successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_DelDev_b'];
|
||||
} else {
|
||||
echo "Error deleting devices\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_DelDevError_b']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +238,7 @@ function deleteUnknownDevices() {
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteAllDevices() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Devices';
|
||||
@@ -238,9 +247,9 @@ function deleteAllDevices() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Devices deleted successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_DelDev_b'];
|
||||
} else {
|
||||
echo "Error deleting devices\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_DelDevError_b']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +258,7 @@ function deleteAllDevices() {
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteEvents() {
|
||||
global $db;
|
||||
global $pia_lang;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Events';
|
||||
@@ -257,9 +267,9 @@ function deleteEvents() {
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Events deleted successfully";
|
||||
echo $pia_lang['BackDevices_DBTools_DelEvents'];
|
||||
} else {
|
||||
echo "Error deleting Events\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
echo $pia_lang['BackDevices_DBTools_DelEventsError']."\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,10 +280,11 @@ function PiaBackupDBtoArchive() {
|
||||
// prepare fast Backup
|
||||
$file = '../../../db/pialert.db';
|
||||
$newfile = '../../../db/pialert.db.latestbackup';
|
||||
global $pia_lang;
|
||||
|
||||
// copy files as a fast Backup
|
||||
if (!copy($file, $newfile)) {
|
||||
echo "The original database could not be saved.";
|
||||
echo $pia_lang['BackDevices_Backup_CopError'];
|
||||
} else {
|
||||
// Create archive with actual date
|
||||
$Pia_Archive_Name = 'pialertdb_'.date("Ymd_His").'.zip';
|
||||
@@ -281,11 +292,11 @@ function PiaBackupDBtoArchive() {
|
||||
exec('zip -j '.$Pia_Archive_Path.$Pia_Archive_Name.' ../../../db/pialert.db', $output);
|
||||
// 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.')';
|
||||
echo $pia_lang['BackDevices_Backup_okay'].': ('.$Pia_Archive_Name.')';
|
||||
unlink($newfile);
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
} else {
|
||||
echo 'The backup executed partially successfully. The archive could not be created or is empty. (pialert.db.latestbackup)';
|
||||
echo $pia_lang['BackDevices_Backup_Failed'].' (pialert.db.latestbackup)';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,21 +309,22 @@ function PiaRestoreDBfromArchive() {
|
||||
// prepare fast Backup
|
||||
$file = '../../../db/pialert.db';
|
||||
$oldfile = '../../../db/pialert.db.prerestore';
|
||||
global $pia_lang;
|
||||
|
||||
// copy files as a fast Backup
|
||||
if (!copy($file, $oldfile)) {
|
||||
echo 'The original database could not be saved.';
|
||||
echo $pia_lang['BackDevices_Restore_CopError'];
|
||||
} 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';
|
||||
echo $pia_lang['BackDevices_Restore_okay'];
|
||||
unlink($oldfile);
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
} else {
|
||||
echo 'Restore Failed. Please restore the backup manually.';
|
||||
echo $pia_lang['BackDevices_Restore_Failed'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,13 +335,14 @@ function PiaRestoreDBfromArchive() {
|
||||
//------------------------------------------------------------------------------
|
||||
function PiaEnableDarkmode() {
|
||||
$file = '../../../db/setting_darkmode';
|
||||
global $pia_lang;
|
||||
|
||||
if (file_exists($file)) {
|
||||
echo 'Darkmode Disabled';
|
||||
echo $pia_lang['BackDevices_darkmode_disabled'];
|
||||
unlink($file);
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
} else {
|
||||
echo 'Darkmode Enabled';
|
||||
echo $pia_lang['BackDevices_darkmode_enabled'];
|
||||
$darkmode = fopen($file, 'w');
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
}
|
||||
@@ -341,13 +354,14 @@ function PiaEnableDarkmode() {
|
||||
//------------------------------------------------------------------------------
|
||||
function PiaToggleArpScan() {
|
||||
$file = '../../../db/setting_stoparpscan';
|
||||
global $pia_lang;
|
||||
|
||||
if (file_exists($file)) {
|
||||
echo 'Arp-Scan Enabled';
|
||||
echo $pia_lang['BackDevices_Arpscan_enabled'];
|
||||
unlink($file);
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
} else {
|
||||
echo 'Arp-Scan Disabled';
|
||||
echo $pia_lang['BackDevices_Arpscan_disabled'];
|
||||
$startarpscan = fopen($file, 'w');
|
||||
echo("<meta http-equiv='refresh' content='1'>");
|
||||
}
|
||||
|
||||
10
front/php/server/speedtestcli.php
Normal file
10
front/php/server/speedtestcli.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
exec('../../../back/speedtest-cli --secure --simple', $output);
|
||||
|
||||
echo '<h4>Speedtest Results</h4>';
|
||||
echo '<pre style="border: none;">';
|
||||
foreach($output as $line){
|
||||
echo $line . "\n";
|
||||
}
|
||||
echo '</pre>';
|
||||
?>
|
||||
Reference in New Issue
Block a user