This commit is contained in:
Jokob-sk
2022-12-28 22:02:42 +11:00
parent 29131e39d2
commit 89ffaff64d
5 changed files with 314 additions and 91 deletions

View File

@@ -58,6 +58,7 @@
case 'getDeviceTypes': getDeviceTypes(); break;
case 'getGroups': getGroups(); break;
case 'getLocations': getLocations(); break;
case 'getPholus': getPholus(); break;
default: logServerConsole ('Action: '. $action); break;
}
@@ -900,6 +901,49 @@ function getLocations() {
echo (json_encode ($tableData));
}
//------------------------------------------------------------------------------
// Query the List of locations
//------------------------------------------------------------------------------
function getPholus() {
global $db;
// SQL
$mac = $_REQUEST['mac'];
if (false === filter_var($mac , FILTER_VALIDATE_MAC)) {
throw new Exception('Invalid mac address');
}
else{
$sql = 'SELECT * from Pholus_Scan where MAC ="'.$mac.'"';
// array
$tableData = array();
// execute query
$result = $db->query($sql);
while ($row = $result -> fetchArray (SQLITE3_ASSOC)){
// Push row data
$tableData[] = array( 'Index' => $row['Index'],
'Info' => $row['Info'],
'Time' => $row['Time'],
'MAC' => $row['MAC'],
'IP_v4_or_v6' => $row['IP_v4_or_v6'],
'Record_Type' => $row['Record_Type'],
'Value' => $row['Value'],
'Extra' => $row['Extra']);
}
$db->close();
if(count($tableData) == 0)
{
echo "false";
} else{
// Return json
echo (json_encode ($tableData));
}
}
}
//------------------------------------------------------------------------------
// Status Where conditions
@@ -917,4 +961,4 @@ function getDeviceCondition ($deviceStatus) {
}
?>
?>

View File

@@ -98,11 +98,12 @@ if ($ENABLED_DARKMODE === True) {
setTimeout("show_pia_servertime()", 1000);
}
document.addEventListener("visibilitychange",()=>{
if(document.visibilityState==="visible"){
window.location.href = window.location.href.split('#')[0];
}
})
// refresh page on focus - adds a lot of SQL queries overhead onto the DB - disabling for now
// document.addEventListener("visibilitychange",()=>{
// if(document.visibilityState==="visible"){
// window.location.href = window.location.href.split('#')[0];
// }
// })
</script>

View File

@@ -152,6 +152,7 @@ $lang['en_us'] = array(
'DevDetail_Tab_Sessions' => 'Sessions',
'DevDetail_Tab_Presence' => 'Presence',
'DevDetail_Tab_Events' => 'Events',
'DevDetail_Tab_Pholus' => 'Pholus',
'DevDetail_MainInfo_Title' => 'Main Info',
'DevDetail_MainInfo_mac' => 'MAC',
'DevDetail_MainInfo_Name' => 'Name',
@@ -551,7 +552,7 @@ the scan will take hours to complete instead of seconds.
'PHOLUS_ACTIVE_name' => 'Enable Pholus scan',
'PHOLUS_ACTIVE_description' => '<a href="https://github.com/jokob-sk/Pi.Alert/tree/main/pholus" target="_blank" >Pholus</a> is a sniffing tool to discover additional information about the devices on the network, including the device name. Please be aware it can spam the network with unnecessary traffic.',
'PHOLUS_TIMEOUT_name' => 'Pholus timeout',
'PHOLUS_TIMEOUT_description' => 'How long (s) should Pholus be sniffing the network. Tested with <code>60</code>s on a network with 50 devices.',
'PHOLUS_TIMEOUT_description' => 'How long (s) should Pholus be sniffing the network. Only used if an <code>(unknown)</code> device is found. The longer you leave it on, the more likely devices would broadcast more info.',
);