diff --git a/back/pialert.py b/back/pialert.py index be91a372..64e6f206 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1215,8 +1215,8 @@ def email_reporting (): mail_text = mail_text.replace ('', timeFormated) mail_html = mail_html.replace ('', timeFormated) - mail_text = mail_text.replace ('', cycle ) - mail_html = mail_html.replace ('', cycle ) + # mail_text = mail_text.replace ('', cycle ) + # mail_html = mail_html.replace ('', cycle ) mail_text = mail_text.replace ('', socket.gethostname() ) mail_html = mail_html.replace ('', socket.gethostname() ) diff --git a/back/report_template.html b/back/report_template.html index e6b340ad..4ef981db 100644 --- a/back/report_template.html +++ b/back/report_template.html @@ -24,9 +24,7 @@ - - - +
Report Date: Scan Cycle: Report Date:
diff --git a/back/report_template.txt b/back/report_template.txt index 9a2d72e3..a25c9af0 100644 --- a/back/report_template.txt +++ b/back/report_template.txt @@ -1,5 +1,4 @@ Report Date: -Scan Cycle: Server: diff --git a/config/version.conf b/config/version.conf index 60c442de..9607d21e 100644 --- a/config/version.conf +++ b/config/version.conf @@ -1,3 +1,3 @@ -VERSION = '3.5_leiweibau' +VERSION = '3.6_leiweibau' VERSION_YEAR = '2022' -VERSION_DATE = '2022-07-07' +VERSION_DATE = '2022-07-27' diff --git a/front/css/pialert.css b/front/css/pialert.css index 9f329b8d..6d44a6e1 100644 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -541,4 +541,4 @@ height: 50px; .infobox_label { font-size: 16px !important; -} \ No newline at end of file +} diff --git a/front/deviceDetails.php b/front/deviceDetails.php index aefd7542..df4ff459 100644 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -17,6 +17,7 @@ if ($_SESSION["login"] != 1) } require 'php/templates/header.php'; + require 'php/server/db.php'; ?> @@ -263,6 +264,20 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D +
+ +
+ +
+
+
+ +
+ +
+
+ + @@ -412,6 +427,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
+ +
- - - + + + -
+
  • @@ -1090,33 +1107,35 @@ function getDeviceData (readAllData=false) { $('#deviceStatus')[0].className = 'text-gray'; $('#deviceStatusIcon')[0].className = ''; - $('#deviceSessions').html ('--'); - $('#deviceDownAlerts').html ('--'); - $('#deviceEvents').html ('--'); + $('#deviceSessions').html ('--'); + $('#deviceDownAlerts').html ('--'); + $('#deviceEvents').html ('--'); - $('#txtMAC').val ('--'); - $('#txtName').val ('--'); - $('#txtOwner').val ('--'); - $('#txtDeviceType').val ('--'); - $('#txtVendor').val ('--'); + $('#txtMAC').val ('--'); + $('#txtName').val ('--'); + $('#txtOwner').val ('--'); + $('#txtDeviceType').val ('--'); + $('#txtVendor').val ('--'); - $('#chkFavorite').iCheck ('uncheck'); - $('#txtGroup').val ('--'); - $('#txtLocation').val ('--'); - $('#txtComments').val ('--'); + $('#chkFavorite').iCheck ('uncheck'); + $('#txtGroup').val ('--'); + $('#txtLocation').val ('--'); + $('#txtComments').val ('--'); + $('#txtInfrastructure').val ('--'); + $('#txtInfrastructurePort').val ('--'); - $('#txtFirstConnection').val ('--'); - $('#txtLastConnection').val ('--'); - $('#txtLastIP').val ('--'); - $('#txtStatus').val ('--'); - $('#chkStaticIP').iCheck ('uncheck'); + $('#txtFirstConnection').val ('--'); + $('#txtLastConnection').val ('--'); + $('#txtLastIP').val ('--'); + $('#txtStatus').val ('--'); + $('#chkStaticIP').iCheck ('uncheck'); - $('#txtScanCycle').val ('--'); - $('#chkAlertEvents').iCheck ('uncheck') - $('#chkAlertDown').iCheck ('uncheck') - $('#txtSkipRepeated').val ('--'); - $('#chkNewDevice').iCheck ('uncheck'); - $('#chkArchived').iCheck ('uncheck'); + $('#txtScanCycle').val ('--'); + $('#chkAlertEvents').iCheck ('uncheck') + $('#chkAlertDown').iCheck ('uncheck') + $('#txtSkipRepeated').val ('--'); + $('#chkNewDevice').iCheck ('uncheck'); + $('#chkArchived').iCheck ('uncheck'); $('#iconRandomMACactive').addClass ('hidden'); $('#iconRandomMACinactive').removeClass ('hidden'); @@ -1184,6 +1203,8 @@ function getDeviceData (readAllData=false) { $('#txtGroup').val (deviceData['dev_Group']); $('#txtLocation').val (deviceData['dev_Location']); $('#txtComments').val (deviceData['dev_Comments']); + $('#txtInfrastructure').val (deviceData['dev_Infrastructure']); + $('#txtInfrastructurePort').val (deviceData['dev_Infrastructure_port']); $('#txtFirstConnection').val (deviceData['dev_FirstConnection']); $('#txtLastConnection').val (deviceData['dev_LastConnection']); @@ -1292,6 +1313,8 @@ function setDeviceData (refreshCallback='') { + '&group=' + $('#txtGroup').val() + '&location=' + $('#txtLocation').val() + '&comments=' + $('#txtComments').val() + + '&infrastructure=' + $('#txtInfrastructure').val() + + '&infrastructureport=' + $('#txtInfrastructurePort').val() + '&staticIP=' + ($('#chkStaticIP')[0].checked * 1) + '&scancycle=' + $('#txtScanCycle').val().split(' ')[0] + '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1) @@ -1324,7 +1347,7 @@ function askSkipNotifications () { if ($('#chkArchived')[0].checked && $('#txtScanCycle').val().split(' ')[0] != "0") { // Ask skip notifications showModalDefault ('Device Archived', 'Do you want to skip all notifications for this device?', - 'Cancel', 'Ok', 'skipNotifications'); + '', '', 'skipNotifications'); } } @@ -1340,6 +1363,33 @@ function skipNotifications () { activateSaveRestoreData(); } +// ----------------------------------------------------------------------------- +function askDeleteDeviceEvents () { + // Check MAC + if (mac == '') { + return; + } + + // Ask delete device Events + showModalWarning ('', '', + '', '', 'deleteDeviceEvents'); +} + +function deleteDeviceEvents () { + // Check MAC + if (mac == '') { + return; + } + + // Delete device events + $.get('php/server/devices.php?action=deleteDeviceEvents&mac='+ mac, function(msg) { + showMessage (msg); + }); + + // Deactivate controls + $('#panDetails :input').attr('disabled', true); +} + // ----------------------------------------------------------------------------- function askDeleteDevice () { // Check MAC @@ -1349,7 +1399,7 @@ function askDeleteDevice () { // Ask delete device showModalWarning ('Delete Device', 'Are you sure you want to delete this device?
    (maybe you prefer to archive it)', - 'Cancel', 'Delete', 'deleteDevice'); + '', '', 'deleteDevice'); } diff --git a/front/maintenance.php b/front/maintenance.php index 7616919e..f28cd515 100644 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -310,8 +310,6 @@ if (submit && isset($_POST['langselector_set'])) {
- -
@@ -379,7 +377,7 @@ function deleteDevicesWithEmptyMACs() function askDeleteAllDevices () { // Ask showModalWarning('', '', - 'Cancel', 'Delete', 'deleteAllDevices'); + '', '', 'deleteAllDevices'); } function deleteAllDevices() { @@ -393,7 +391,7 @@ function deleteAllDevices() function askDeleteUnknown () { // Ask showModalWarning('', '', - 'Cancel', 'Delete', 'deleteUnknownDevices'); + '', '', 'deleteUnknownDevices'); } function deleteUnknownDevices() { @@ -407,7 +405,7 @@ function deleteUnknownDevices() function askDeleteEvents () { // Ask showModalWarning('', '', - 'Cancel', 'Delete', 'deleteEvents'); + '', '', 'deleteEvents'); } function deleteEvents() { @@ -421,7 +419,7 @@ function deleteEvents() function askDeleteActHistory () { // Ask showModalWarning('', '', - 'Cancel', 'Delete', 'deleteActHistory'); + '', '', 'deleteActHistory'); } function deleteActHistory() { @@ -435,7 +433,7 @@ function deleteActHistory() function askPiaBackupDBtoArchive () { // Ask showModalWarning('', '', - 'Cancel', 'Run Backup', 'PiaBackupDBtoArchive'); + '', '', 'PiaBackupDBtoArchive'); } function PiaBackupDBtoArchive() { @@ -449,7 +447,7 @@ function PiaBackupDBtoArchive() function askPiaRestoreDBfromArchive () { // Ask showModalWarning('', '', - 'Cancel', 'Run Restore', 'PiaRestoreDBfromArchive'); + '', '', 'PiaRestoreDBfromArchive'); } function PiaRestoreDBfromArchive() { @@ -463,7 +461,7 @@ function PiaRestoreDBfromArchive() function askPiaPurgeDBBackups() { // Ask showModalWarning('', '', - 'Cancel', 'Purge', 'PiaPurgeDBBackups'); + '', '', 'PiaPurgeDBBackups'); } function PiaPurgeDBBackups() { @@ -477,7 +475,7 @@ function PiaPurgeDBBackups() function askPiaEnableDarkmode() { // Ask showModalWarning('', '', - 'Cancel', 'Switch', 'PiaEnableDarkmode'); + '', '', 'PiaEnableDarkmode'); } function PiaEnableDarkmode() { @@ -491,7 +489,7 @@ function PiaEnableDarkmode() function askPiaToggleArpScan () { // Ask showModalWarning('', '', - 'Cancel', 'Switch', 'PiaToggleArpScan'); + '', '', 'PiaToggleArpScan'); } function PiaToggleArpScan() { diff --git a/front/network.php b/front/network.php new file mode 100644 index 00000000..16696be1 --- /dev/null +++ b/front/network.php @@ -0,0 +1,374 @@ +query($sql); +// ##################################### +// ## Expand Devices Table +// ##################################### +$sql = 'ALTER TABLE "Devices" ADD "dev_Infrastructure" INTEGER'; +$result = $db->query($sql); +$sql = 'ALTER TABLE "Devices" ADD "dev_Infrastructure_port" INTEGER'; +$result = $db->query($sql); +// ##################################### +// Add New Network Devices +// ##################################### +if ($_REQUEST['Networkinsert'] == "yes") { + if (isset($_REQUEST['NetworkDeviceName']) && isset($_REQUEST['NetworkDeviceTyp'])) + { + $sql = 'INSERT INTO "network_infrastructure" ("net_device_name", "net_device_typ", "net_device_port") VALUES("'.$_REQUEST['NetworkDeviceName'].'", "'.$_REQUEST['NetworkDeviceTyp'].'", "'.$_REQUEST['NetworkDevicePort'].'")'; + $result = $db->query($sql); + } +} +// ##################################### +// Add New Network Devices +// ##################################### +if ($_REQUEST['Networkedit'] == "yes") { + if (isset($_REQUEST['NewNetworkDeviceName']) && isset($_REQUEST['NewNetworkDeviceTyp'])) + { + $sql = 'UPDATE "network_infrastructure" SET "net_device_name" = "'.$_REQUEST['NewNetworkDeviceName'].'", "net_device_typ" = "'.$_REQUEST['NewNetworkDeviceTyp'].'", "net_device_port" = "'.$_REQUEST['NewNetworkDevicePort'].'" WHERE "device_id"="'.$_REQUEST['NetworkDeviceID'].'"'; + //$sql = 'INSERT INTO "network_infrastructure" ("net_device_name", "net_device_typ", "net_device_port") VALUES("'.$_REQUEST['NetworkDeviceName'].'", "'.$_REQUEST['NetworkDeviceTyp'].'", "'.$_REQUEST['NetworkDevicePort'].'")'; + $result = $db->query($sql); + } +} +// ##################################### +// remove Network Devices +// ##################################### +if ($_REQUEST['Networkdelete'] == "yes") { + if (isset($_REQUEST['NetworkDeviceID'])) + { + $sql = 'DELETE FROM "network_infrastructure" WHERE "device_id"="'.$_REQUEST['NetworkDeviceID'].'"'; + $result = $db->query($sql); + } +} + +?> + +
+ + +
+ +

+ +

+
+ + + +
+
+
+

+
+ +
+
+ +
+
+
+

+
+
+ + +
+ +
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+ +
+

+
+
+ + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +'.$pia_func_netdevname.' / '.$pia_func_netdevtyp; + if ($pia_func_netdevport != "") {echo ' ('.$pia_func_netdevport.')';} + echo ''; +} +function createnetworktabcontent($pia_func_netdevid, $pia_func_netdevname, $pia_func_netdevtyp, $pia_func_netdevport, $activetab) { + global $pia_lang; + echo '
+

'.$pia_func_netdevname.' (ID: '.$pia_func_netdevid.')


'; + echo '
+ + + + + + + '; + // Prepare Array for Devices with Port value + // If no Port is set, the Port number is set to 1 + if ($pia_func_netdevport == "") {$pia_func_netdevport = 1;} + // Create Array with specific length + $network_device_portname = array(); + $network_device_portmac = array(); + $network_device_portip = array(); + $network_device_portstate = array(); + // make sql query for Network Hardware ID + global $db; + $func_sql = 'SELECT * FROM "Devices" WHERE "dev_Infrastructure" = "'.$pia_func_netdevid.'"'; + $func_result = $db->query($func_sql);//->fetchArray(SQLITE3_ASSOC); + while($func_res = $func_result->fetchArray(SQLITE3_ASSOC)) { + //if(!isset($func_res['dev_Name'])) continue; + if ($func_res['dev_PresentLastScan'] == 1) {$port_state = '
Online
';} else {$port_state = '
Offline
';} + // Prepare Table with Port > push values in array + if ($pia_func_netdevport > 1) + { + if (stristr($func_res['dev_Infrastructure_port'], ',') == '') { + if ($network_device_portname[$func_res['dev_Infrastructure_port']] != '') {$network_device_portname[$func_res['dev_Infrastructure_port']] = $network_device_portname[$func_res['dev_Infrastructure_port']].','.$func_res['dev_Name'];} else {$network_device_portname[$func_res['dev_Infrastructure_port']] = $func_res['dev_Name'];} + if ($network_device_portmac[$func_res['dev_Infrastructure_port']] != '') {$network_device_portmac[$func_res['dev_Infrastructure_port']] = $network_device_portmac[$func_res['dev_Infrastructure_port']].','.$func_res['dev_MAC'];} else {$network_device_portmac[$func_res['dev_Infrastructure_port']] = $func_res['dev_MAC'];} + if ($network_device_portip[$func_res['dev_Infrastructure_port']] != '') {$network_device_portip[$func_res['dev_Infrastructure_port']] = $network_device_portip[$func_res['dev_Infrastructure_port']].','.$func_res['dev_LastIP'];} else {$network_device_portip[$func_res['dev_Infrastructure_port']] = $func_res['dev_LastIP'];} + if (isset($network_device_portstate[$func_res['dev_Infrastructure_port']])) {$network_device_portstate[$func_res['dev_Infrastructure_port']] = $network_device_portstate[$func_res['dev_Infrastructure_port']].','.$func_res['dev_PresentLastScan'];} else {$network_device_portstate[$func_res['dev_Infrastructure_port']] = $func_res['dev_PresentLastScan'];} + } else { + $multiport = array(); + $multiport = explode(',',$func_res['dev_Infrastructure_port']); + foreach($multiport as $row) { + $network_device_portname[trim($row)] = $func_res['dev_Name']; + $network_device_portmac[trim($row)] = $func_res['dev_MAC']; + $network_device_portip[trim($row)] = $func_res['dev_LastIP']; + $network_device_portstate[trim($row)] = $func_res['dev_PresentLastScan']; + } + unset($multiport); + } + } else { + // Table without Port > echo values + // Specific icon for devicetype + if ($pia_func_netdevtyp == "WLAN") {$dev_port_icon = 'fa-wifi';} + if ($pia_func_netdevtyp == "Powerline") {$dev_port_icon = 'fa-flash';} + echo ''; + } + } + // Create table with Port + if ($pia_func_netdevport > 1) + { + for ($x=1; $x<=$pia_func_netdevport; $x++) + { + // Prepare online/offline badge for later functions + $online_badge = '
Online
'; + $offline_badge = '
Offline
'; + // Set online/offline badge + echo ''; + echo ''; + // Set online/offline badge + // Check if multiple badges necessary + if (stristr($network_device_portstate[$x],',') == '') { + // Set single online/offline badge + if ($network_device_portstate[$x] == 1) {$port_state = $online_badge;} else {$port_state = $offline_badge;} + echo ''; + } else { + // Set multiple online/offline badges + $multistate = array(); + $multistate = explode(',',$network_device_portstate[$x]); + echo ''; + unset($multistate); + } + // Check if multiple Hostnames are set + // print single hostname + if (stristr($network_device_portmac[$x],',') == '') { + echo ''; + } else { + // print multiple hostnames with separate links + $multimac = array(); + $multimac = explode(',',$network_device_portmac[$x]); + $multiname = array(); + $multiname = explode(',',$network_device_portname[$x]); + echo ''; + unset($multiname, $multimac); + } + // Check if multiple IP are set + // print single IP + if (stristr($network_device_portip[$x],',') == '') { + echo ''; + } else { + // print multiple IPs + $multiip = array(); + $multiip = explode(',',$network_device_portip[$x]); + echo ''; + unset($multiip); + } + echo ''; + } + } + echo '
Port'.$pia_lang['Network_Table_State'].''.$pia_lang['Network_Table_Hostname'].''.$pia_lang['Network_Table_IP'].'
'.$port_state.''.$func_res['dev_Name'].''.$func_res['dev_LastIP'].'
'.$x.''.$port_state.''; + foreach($multistate as $key => $value) { + if ($value == 1) {$port_state = $online_badge;} else {$port_state = $offline_badge;} + echo $port_state.'
'; + } + echo '
'.$network_device_portname[$x].''; + foreach($multiname as $key => $value) { + echo ''.$value.'
'; + } + echo '
'.$network_device_portip[$x].''; + foreach($multiip as $key => $value) { + echo $value.'
'; + } + echo '
+
'; + echo '
'; +} +// ##################################### +// ## End Function Setup +// ##################################### + +// ##################################### +// ## Create Tabs +// ##################################### +$sql = 'SELECT "device_id", "net_device_name", "net_device_typ", "net_device_port" FROM "network_infrastructure"'; +$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC); +?> + +
+
+ + +
+ + + + \ No newline at end of file diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 406acf37..aa7c4bca 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -44,6 +44,7 @@ if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';} case 'deleteUnknownDevices': deleteUnknownDevices(); break; case 'deleteEvents': deleteEvents(); break; case 'deleteActHistory': deleteActHistory(); break; + case 'deleteDeviceEvents': deleteDeviceEvents(); break; case 'PiaBackupDBtoArchive': PiaBackupDBtoArchive(); break; case 'PiaRestoreDBfromArchive': PiaRestoreDBfromArchive(); break; case 'PiaPurgeDBBackups': PiaPurgeDBBackups(); break; @@ -86,6 +87,8 @@ function getDeviceData() { $deviceData = $row; $mac = $deviceData['dev_MAC']; + $deviceData['dev_Infrastructure'] = $row['dev_Infrastructure']; + $deviceData['dev_Infrastructure_port'] = $row['dev_Infrastructure_port']; $deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated $deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated @@ -153,6 +156,8 @@ function setDeviceData() { dev_Group = "'. quotes($_REQUEST['group']) .'", dev_Location = "'. quotes($_REQUEST['location']) .'", dev_Comments = "'. quotes($_REQUEST['comments']) .'", + dev_Infrastructure = "'. quotes($_REQUEST['infrastructure']).'", + dev_Infrastructure_port = "'. quotes($_REQUEST['infrastructureport']).'", dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'", dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'", dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'", @@ -233,7 +238,25 @@ function deleteUnknownDevices() { } } +//------------------------------------------------------------------------------ +// Delete Device Events +//------------------------------------------------------------------------------ +function deleteDeviceEvents() { + global $db; + global $pia_lang; + // sql + $sql = 'DELETE FROM Events WHERE eve_MAC="' . $_REQUEST['mac'] .'"'; + // execute sql + $result = $db->query($sql); + + // check result + if ($result == TRUE) { + echo $pia_lang['BackDevices_DBTools_DelEvents']; + } else { + echo $pia_lang['BackDevices_DBTools_DelEventsError']."\n\n$sql \n\n". $db->lastErrorMsg(); + } +} //------------------------------------------------------------------------------ // Delete all devices diff --git a/front/php/templates/footer.php b/front/php/templates/footer.php index ae604c36..0bc35294 100644 --- a/front/php/templates/footer.php +++ b/front/php/templates/footer.php @@ -24,7 +24,7 @@ ('. $conf_data['VERSION_DATE'] .')'; + echo 'Pi.Alert  '. $conf_data['VERSION'] .'  ('. $conf_data['VERSION_DATE'] .')'; ?>
diff --git a/front/php/templates/header.php b/front/php/templates/header.php index ce9284b1..37e7a688 100644 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -92,6 +92,7 @@ require 'php/templates/language/'.$pia_lang_selected.'.php'; + -