mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
pholus 2
This commit is contained in:
@@ -119,13 +119,13 @@ if ($_SESSION["login"] != 1)
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn btn-default" style="padding: 10px; min-width: 30px;"
|
||||
id="btnPrevious" onclick="previousRecord()"> <i class="fa fa-chevron-left"></i> </button>
|
||||
id="btnPrevious" onclick="recordSwitch('prev')"> <i class="fa fa-chevron-left"></i> </button>
|
||||
|
||||
<div class="btn pa-btn-records" style="padding: 10px; min-width: 30px; margin-left: 1px;"
|
||||
id="txtRecord" > 0 / 0 </div>
|
||||
|
||||
<button type="button" class="btn btn-default" style="padding: 10px; min-width: 30px; margin-left: 1px;"
|
||||
id="btnNext" onclick="nextRecord()"> <i class="fa fa-chevron-right"></i> </button>
|
||||
id="btnNext" onclick="recordSwitch('next')"> <i class="fa fa-chevron-right"></i> </button>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
@@ -666,8 +666,8 @@ if ($ENABLED_DARKMODE === True) {
|
||||
return params.mac
|
||||
}
|
||||
|
||||
mac = getMac()
|
||||
var devicesList = [];
|
||||
mac = getMac() // can also be rowID!! not only mac
|
||||
var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI
|
||||
var pos = -1;
|
||||
var parPeriod = 'Front_Details_Period';
|
||||
var parTab = 'Front_Details_Tab';
|
||||
@@ -1173,8 +1173,11 @@ function getDeviceData (readAllData=false) {
|
||||
// stop timer
|
||||
stopTimerRefreshData();
|
||||
|
||||
// console.log("getDeviceData mac: ", mac)
|
||||
|
||||
// Check MAC
|
||||
if (mac == '') {
|
||||
console.log("getDeviceData mac AA: ", mac)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1325,10 +1328,10 @@ function getDeviceData (readAllData=false) {
|
||||
deactivateSaveRestoreData ();
|
||||
}
|
||||
|
||||
// Check if device is part of the devicesList
|
||||
pos = devicesList.indexOf (deviceData['rowid']);
|
||||
// Check if device is part of the devicesList
|
||||
pos = devicesList.findIndex(item => item.rowid == deviceData['rowid']);
|
||||
if (pos == -1) {
|
||||
devicesList =[deviceData['rowid']];
|
||||
devicesList.push({"rowid" : deviceData['rowid'], "mac" : deviceData['dev_MAC']});
|
||||
pos=0;
|
||||
}
|
||||
}
|
||||
@@ -1363,45 +1366,44 @@ function getDeviceData (readAllData=false) {
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function previousRecord () {
|
||||
// Left (prev) < > (next) Right toggles at the top right of device details to
|
||||
// cycle between devices
|
||||
function recordSwitch(direction) {
|
||||
|
||||
var recordToSave = null;
|
||||
|
||||
// update the global position in the devices list variable 'pos'
|
||||
if(direction == "next")
|
||||
{
|
||||
// Next Record
|
||||
if (pos < (devicesList.length-1) ) {
|
||||
pos++;
|
||||
}
|
||||
}else if (direction == "prev")
|
||||
{
|
||||
if (pos > 0) {
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
// get new mac from the devicesList. Don't change to the commented out line below, the mac query string in the URL isn't updated yet!
|
||||
// mac = params.mac;
|
||||
mac = devicesList[pos].mac.toString();
|
||||
|
||||
// Save Changes
|
||||
if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) {
|
||||
setDeviceData (previousRecord);
|
||||
return;
|
||||
setDeviceData (direction, recordSwitch);
|
||||
}
|
||||
|
||||
getDeviceData (true);
|
||||
|
||||
// Previous Record
|
||||
if (pos > 0) {
|
||||
pos--;
|
||||
mac = devicesList[pos].toString();
|
||||
getDeviceData (true);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function nextRecord () {
|
||||
// Save Changes
|
||||
if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) {
|
||||
setDeviceData (nextRecord);
|
||||
return;
|
||||
}
|
||||
|
||||
// get new mac
|
||||
mac = params.mac;
|
||||
// reload current tab
|
||||
reloadTab()
|
||||
|
||||
// Next Record
|
||||
if (pos < (devicesList.length-1) ) {
|
||||
pos++;
|
||||
mac = devicesList[pos].toString();
|
||||
getDeviceData (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function setDeviceData (refreshCallback='') {
|
||||
function setDeviceData (direction='', refreshCallback='') {
|
||||
// Check MAC
|
||||
if (mac == '') {
|
||||
return;
|
||||
@@ -1441,7 +1443,7 @@ function setDeviceData (refreshCallback='') {
|
||||
|
||||
// Callback fuction
|
||||
if (typeof refreshCallback == 'function') {
|
||||
refreshCallback();
|
||||
refreshCallback(direction);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1621,8 +1623,8 @@ function initializeTabsNew () {
|
||||
|
||||
function loadPholus()
|
||||
{
|
||||
console.log(mac)
|
||||
console.log('php/server/devices.php?action=getPholus&mac='+ mac)
|
||||
// console.log(mac)
|
||||
// console.log('php/server/devices.php?action=getPholus&mac='+ mac)
|
||||
$.get('php/server/devices.php?action=getPholus&mac='+ mac, function(data) {
|
||||
|
||||
data = sanitize(data);
|
||||
@@ -1649,7 +1651,7 @@ function loadPholus()
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("else")
|
||||
// console.log("else")
|
||||
$("#tablePholusPlc").show();
|
||||
$(".deviceSpecific").remove();
|
||||
}
|
||||
@@ -1665,14 +1667,9 @@ window.onload = function async()
|
||||
|
||||
function reloadTab()
|
||||
{
|
||||
// Get the value of "some_key" in eg "https://example.com/?some_key=some_value"
|
||||
mac = getMac(); // "some_value"
|
||||
|
||||
// console.log("aaAAAAAAAAAaa:"+my_mac)
|
||||
// load tab data only when needed (tab change)
|
||||
if(getCache("activeDevicesTab") == "tabPholus")
|
||||
{
|
||||
console.log("herea")
|
||||
loadPholus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,16 +350,35 @@ function initializeDatatable () {
|
||||
|
||||
$('#tableDevices').on( 'order.dt', function () {
|
||||
setParameter (parTableOrder, JSON.stringify (table.order()) );
|
||||
setCookie ('devicesList',JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
setCookie ('devicesList', getDevicesFromTable(table) );
|
||||
} );
|
||||
|
||||
$('#tableDevices').on( 'search.dt', function () {
|
||||
setCookie ('devicesList', JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
setCookie ('devicesList', getDevicesFromTable(table) );
|
||||
} );
|
||||
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Gets a JSON list of rowID and mac from the displayed table in the UI
|
||||
function getDevicesFromTable(table)
|
||||
{
|
||||
rowIDs = table.column(12, { 'search': 'applied' }).data().toArray() // rowID is in hidden column 12
|
||||
rowMACs = table.column(10, { 'search': 'applied' }).data().toArray() // MAC is in hidden column 10
|
||||
|
||||
result = []
|
||||
|
||||
rowIDs.map(function(rowID, index){
|
||||
result.push({"rowid": rowID, "mac":rowMACs[index]})
|
||||
})
|
||||
|
||||
// console.log(rowIDs)
|
||||
// console.log(result)
|
||||
|
||||
return JSON.stringify (result)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function getDevicesTotals () {
|
||||
// stop timer
|
||||
|
||||
@@ -908,13 +908,19 @@ function getPholus() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$mac = $_REQUEST['mac'];
|
||||
$mac = $_REQUEST['mac'];
|
||||
|
||||
if ($mac == "Internet") // Not performing data lookup for router (improvement idea for later maybe)
|
||||
{
|
||||
echo "false";
|
||||
return;
|
||||
}
|
||||
|
||||
if (false === filter_var($mac , FILTER_VALIDATE_MAC)) {
|
||||
throw new Exception('Invalid mac address');
|
||||
}
|
||||
else{
|
||||
$sql = 'SELECT * from Pholus_Scan where MAC ="'.$mac.'"';
|
||||
$sql = 'SELECT * from Pholus_Scan where MAC ="'.$mac.'" and Record_Type not in ("Question")';
|
||||
|
||||
// array
|
||||
$tableData = array();
|
||||
|
||||
@@ -273,7 +273,7 @@ function saveSettings()
|
||||
|
||||
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>Note:</b> Wait <b>20s</b> for the changes to reflect in the UI.",
|
||||
<b>Note:</b> Wait <b>5s</b> for the changes to reflect in the UI.",
|
||||
FALSE, TRUE, TRUE, TRUE);
|
||||
|
||||
}
|
||||
|
||||
@@ -430,11 +430,11 @@ $lang['en_us'] = array(
|
||||
'SCAN_SUBNETS_name' => 'Subnets to scan',
|
||||
'SCAN_SUBNETS_description' => '
|
||||
|
||||
The scan time itself depends on the number of IP addresses to check.
|
||||
The arp-scan time itself depends on the number of IP addresses to check.
|
||||
The number of IPs to check depends on the <a target="_blank" href="https://www.calculator.net/ip-subnet-calculator.html">network mask</a> you set here.
|
||||
For example, a <code>/24</code> mask results in 256 IPs to check, where as a <code>/16</code>
|
||||
mask checks around 65,536. Every IP takes a couple seconds. This means that with an incorrect configuration
|
||||
the scan will take hours to complete instead of seconds.
|
||||
the arp-scan will take hours to complete instead of seconds.
|
||||
<ol>
|
||||
<li>Specify the network mask. For example, the filter <code>192.168.1.0/24</code> covers IP ranges 192.168.1.0 to 192.168.1.255.</li>
|
||||
<li>Run <code>iwconfig</code> in your container to find your interface name(s) (e.g.: <code>eth0</code>, <code>eth1</code>)</li>
|
||||
@@ -451,7 +451,7 @@ the scan will take hours to complete instead of seconds.
|
||||
'INCLUDED_SECTIONS_name' => 'Notify on',
|
||||
'INCLUDED_SECTIONS_description' => 'Specifies which events trigger notifications. Remove the event type(s) you don\'t want to get notified on. This setting overrides device-specific settings in the UI. (CTRL + Click to select / deselect).',
|
||||
'SCAN_CYCLE_MINUTES_name' => 'Scan cycle delay',
|
||||
'SCAN_CYCLE_MINUTES_description' => 'The delay between scans. If using arp-scan, the scan time itself depends on the number of IP addresses to check. This is influenced by the network mask set in the <code>SCAN_SUBNETS</code> setting at the top. Every IP takes a couple seconds to scan.',
|
||||
'SCAN_CYCLE_MINUTES_description' => 'The delay between scans. If using arp-scan, the scan time itself depends on the number of IP addresses to check. This is influenced by the network mask set in the <a href="#SCAN_SUBNETS"><code>SCAN_SUBNETS</code> setting</a> at the top. Every IP takes a couple seconds to scan.',
|
||||
'DAYS_TO_KEEP_EVENTS_name' => 'Delete events older than',
|
||||
'DAYS_TO_KEEP_EVENTS_description' => 'This is a maintenance setting. This specifies the number of days worth of event entries that will be kept. All older events will be deleted periodically.',
|
||||
'REPORT_DASHBOARD_URL_name' => 'Pi.Alert URL',
|
||||
@@ -550,9 +550,19 @@ the scan will take hours to complete instead of seconds.
|
||||
|
||||
// Pholus
|
||||
'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_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. Depends on the <a href="#SCAN_SUBNETS"><code>SCAN_SUBNETS</code> setting</a>.',
|
||||
'PHOLUS_TIMEOUT_name' => 'Pholus timeout',
|
||||
'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.',
|
||||
'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. This timeout adds to the time it takes to perform an arp-scan on your network',
|
||||
'PHOLUS_FORCE_name' => 'Force scan',
|
||||
'PHOLUS_FORCE_description' => 'Force scan every network scan, even if there are no <code>(unknown)</code> devices. Be careful enabling this as the sniffing can easily flood your network.',
|
||||
'PHOLUS_DAYS_DATA_name' => 'Data retention',
|
||||
'PHOLUS_DAYS_DATA_description' => 'How many days of Pholus scan entries should be kept (gloablly, not device specific!). The <a href="/maintenance.php#tab_Logging">pialert_pholus.log</a> file is not touched.',
|
||||
'PHOLUS_RUN_name' => 'Run on schedule',
|
||||
'PHOLUS_RUN_description' => 'Enable a regular Pholus scan / sniff on your network.',
|
||||
'PHOLUS_RUN_TIMEOUT_name' => 'Scheduled run timeout',
|
||||
'PHOLUS_RUN_TIMEOUT_description' => 'The timeout (s) for the scheduled Pholus scan.',
|
||||
'PHOLUS_RUN_SCHD_name' => 'Schedule',
|
||||
'PHOLUS_RUN_SCHD_description' => 'Schedule in cron format. Make sure you enter the schedule in the correct format (e.g. validate your format on <a href="#" onlick="window.open("https://crontab.guru/#" + $(\'#PHOLUS_RUN_SCHD\').val(),replace(\' \', \'_\') , "_blank")" target="_blank">crontab.guru</a>). Will be run NEXT time the time passes.',
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -142,9 +142,18 @@ $db->close();
|
||||
elseif ($set['Type'] == 'selecttext')
|
||||
{
|
||||
$input = '<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'">';
|
||||
|
||||
$values = createArray($set['Value']);
|
||||
$options = createArray($set['Options']);
|
||||
foreach ($options as $option) {
|
||||
$input = $input.'<option value="'.$option.'">'.$option.'</option>';
|
||||
|
||||
foreach ($options as $option) {
|
||||
$selected = "";
|
||||
|
||||
if( in_array( $option , $values) == true) {
|
||||
$selected = "selected";
|
||||
}
|
||||
|
||||
$input = $input.'<option value="'.$option.'" '.$selected.'>'.$option.'</option>';
|
||||
}
|
||||
$input = $input.'</select>';
|
||||
}
|
||||
@@ -152,16 +161,27 @@ $db->close();
|
||||
elseif ($set['Type'] == 'selectinteger')
|
||||
{
|
||||
$input = '<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'">';
|
||||
|
||||
$values = createArray($set['Value']);
|
||||
$options = createArray($set['Options']);
|
||||
foreach ($options as $option) {
|
||||
$input = $input.'<option value="'.$option.'">'.$option.'</option>';
|
||||
|
||||
foreach ($options as $option) {
|
||||
|
||||
$selected = "";
|
||||
|
||||
if( in_array( $option , $values) == true) {
|
||||
$selected = "selected";
|
||||
}
|
||||
|
||||
$input = $input.'<option value="'.$option.'" '.$selected.'>'.$option.'</option>';
|
||||
}
|
||||
$input = $input.'</select>';
|
||||
}
|
||||
// multiselect
|
||||
elseif ($set['Type'] == 'multiselect')
|
||||
{
|
||||
$input = '<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'" multiple>';
|
||||
$input = '<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'" multiple>';
|
||||
|
||||
$values = createArray($set['Value']);
|
||||
$options = createArray($set['Options']);
|
||||
|
||||
@@ -242,7 +262,7 @@ $db->close();
|
||||
<script>
|
||||
|
||||
// number of settings has to be equal to
|
||||
var settingsNumber = 48;
|
||||
var settingsNumber = 53;
|
||||
|
||||
if(<?php echo count($settings)?> != settingsNumber)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user