Skip to content

Commit

Permalink
Pholus cleanup + conversion v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Aug 24, 2023
1 parent 9edbe8a commit 57aefdf
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 148 deletions.
73 changes: 3 additions & 70 deletions front/deviceDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@
<li> <a id="tabNmap" href="#panNmap" data-toggle="tab"> <?php echo $DevDetail_Tap_temp;?> </a></li>
<li> <a id="tabSessions" href="#panSessions" data-toggle="tab"> <?= lang('DevDetail_Tab_Sessions');?> </a></li>
<li> <a id="tabPresence" href="#panPresence" data-toggle="tab"> <?= lang('DevDetail_Tab_Presence');?> </a></li>
<li> <a id="tabEvents" href="#panEvents" data-toggle="tab"> <?= lang('DevDetail_Tab_Events');?> </a></li>
<li> <a id="tabPholus" href="#panPholus" data-toggle="tab"> <?= lang('DevDetail_Tab_Pholus');?> </a></li>
<li> <a id="tabEvents" href="#panEvents" data-toggle="tab"> <?= lang('DevDetail_Tab_Events');?> </a></li>
<li> <a id="tabPlugins" href="#panPlugins" data-toggle="tab"> <?= lang('DevDetail_Tab_Plugins');?> </a></li>

<div class="btn-group pull-right">
Expand Down Expand Up @@ -628,8 +627,7 @@ function manualnmapscan(targetip, mode) {
<th><?= lang("DevDetail_Tab_NmapTableExtra");?></th>
</tr>
</thead>
<!-- Comment out tbody when trying to implement better table with datatables here -->
<!-- IDEA: Show unmatched pholus entries? -->
<!-- Comment out tbody when trying to implement better table with datatables here -->
<tbody id="tableNmapBody">
<tr id="tableNmapPlc" class="text-center"><td colspan='7'><span><?= lang("DevDetail_Tab_NmapEmpty"); ?></span></td></tr>
</tbody>
Expand Down Expand Up @@ -684,28 +682,6 @@ function manualnmapscan(targetip, mode) {
</thead>
</table>
</div>
<!-- tab page 6 ------------------------------------------------------------ -->
<div class="tab-pane fade table-responsive" id="panPholus">
<!-- Datatable Events -->
<table id="tablePholus" class="table table-bordered table-hover table-striped ">
<thead>
<tr>
<th><?= lang("DevDetail_Tab_PholusTableIndex");?></th>
<th><?= lang("DevDetail_Tab_PholusTableInfo");?></th>
<th><?= lang("DevDetail_Tab_PholusTableTime");?></th>
<th><?= lang("DevDetail_Tab_PholusTableIP");?></th>
<th><?= lang("DevDetail_Tab_PholusTableEntry");?></th>
<th><?= lang("DevDetail_Tab_PholusTableValue");?></th>
<th><?= lang("DevDetail_Tab_PholusTableExtra");?></th>
</tr>
</thead>
<!-- Comment out tbody when trying to implement better table with datatables here -->
<!-- IDEA: Show unmatched pholus entries? -->
<tbody id="tablePholusBody">
<tr id="tablePholusPlc" class="text-center"><td colspan='7'><span><?= lang("DevDetail_Tab_PholusEmpty"); ?></span></td></tr>
</tbody>
</table>
</div>

<!-- tab page 7 ------------------------------------------------------------ -->
<div class="tab-pane fade table-responsive" id="panPlugins">
Expand Down Expand Up @@ -1897,12 +1873,7 @@ function initializeTabsNew () {
// events on tab change
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab

// load tab data only when needed (tab change)
if(target == "#panPholus")
{
loadPholus();
}

if(target == "#panNmap")
{
loadNmap();
Expand Down Expand Up @@ -1960,40 +1931,6 @@ function loadNmap()
});
}

// -----------------------------------------------------------------------------

function loadPholus()
{
$(".deviceSpecific").remove(); // remove any previous data listed in teh table

$.get('php/server/devices.php?action=getPholus&mac='+ mac, function(data) {

data = sanitize(data);

if(data != "false" && $.trim(data) != [])
{
var listData = JSON.parse(data);
var order = 1;

tableRows = "";

// for each item
listData.forEach(function (item, index) {
tableRows += '<tr class="deviceSpecific"><td>'+item.Index+'</td><td>'+item.Info+'</td><td>'+item.Time+'</td><td>'+item.IP_v4_or_v6+'</td><td>'+item.Record_Type+'</td><td>'+item.Value+'</td><td>'+ item.Extra +'</td></tr>';
});

$("#tablePholusBody").html($("#tablePholusBody").html()+tableRows);
$("#tablePholusPlc").hide();
}
else
{
// console.log("else")
$("#tablePholusPlc").show();
$(".deviceSpecific").remove();
}
});
}

//-----------------------------------------------------------------------------------

function initTable(tableId, mac){
Expand Down Expand Up @@ -2064,10 +2001,6 @@ function initTable(tableId, mac){
function reloadTab()
{
// tab loaded without switching
if(getCache("activeDevicesTab") == "tabPholus")
{
loadPholus();
}

if(getCache("activeDevicesTab") == "tabNmap")
{
Expand Down
50 changes: 1 addition & 49 deletions front/php/server/devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
case 'getOwners': getOwners(); break;
case 'getDeviceTypes': getDeviceTypes(); break;
case 'getGroups': getGroups(); break;
case 'getLocations': getLocations(); break;
case 'getPholus': getPholus(); break;
case 'getLocations': getLocations(); break;
case 'getNmap': getNmap(); break;
case 'saveNmapPort': saveNmapPort(); break;
case 'updateNetworkLeaf': updateNetworkLeaf(); break;
Expand Down Expand Up @@ -1010,53 +1009,6 @@ function getLocations() {
echo (json_encode ($tableData));
}

//------------------------------------------------------------------------------
// Query the List of Pholus entries
//------------------------------------------------------------------------------
function getPholus() {
global $db;

// SQL
$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.'" and Record_Type not in ("Question")';

// 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']);
}

if(count($tableData) == 0)
{
echo "false";
} else{
// Return json
echo (json_encode ($tableData));
}
}
}

//------------------------------------------------------------------------------
// Query the List of Nmap entries
Expand Down
9 changes: 1 addition & 8 deletions front/php/templates/language/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,7 @@
"DevDetail_Tab_EventsTableDate" : "Datum",
"DevDetail_Tab_EventsTableEvent" : "Ereignistype",
"DevDetail_Tab_EventsTableIP" : "IP",
"DevDetail_Tab_EventsTableInfo" : "Zusätzliche Informationen",
"DevDetail_Tab_PholusTableIndex" : "Index",
"DevDetail_Tab_PholusTableInfo" : "Info",
"DevDetail_Tab_PholusTableTime" : "Zeit",
"DevDetail_Tab_PholusTableIP" : "IP",
"DevDetail_Tab_PholusTableEntry" : "Eintragstyp",
"DevDetail_Tab_PholusTableValue" : "Wert",
"DevDetail_Tab_PholusTableExtra" : "Extra",
"DevDetail_Tab_EventsTableInfo" : "Zusätzliche Informationen",
"DevDetail_Internet_Speedtest" : "Online Speedtest",
"DevDetail_Internet_Speedtest_Start" : "Speedtest starten",
"DevDetail_MainInfo_Title" : "Haupt Infos",
Expand Down
11 changes: 1 addition & 10 deletions front/php/templates/language/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,7 @@
"DevDetail_Tab_EventsTableDate" : "Date",
"DevDetail_Tab_EventsTableEvent" : "Event type",
"DevDetail_Tab_EventsTableIP" : "IP",
"DevDetail_Tab_EventsTableInfo" : "Additional info",
"DevDetail_Tab_Pholus" : "<i class=\"fa fa-search\"></i> Pholus",
"DevDetail_Tab_PholusEmpty" : "Nothing sniffed out with Pholus for this device.",
"DevDetail_Tab_PholusTableIndex" : "Index",
"DevDetail_Tab_PholusTableInfo" : "Info",
"DevDetail_Tab_PholusTableTime" : "Time",
"DevDetail_Tab_PholusTableIP" : "IP",
"DevDetail_Tab_PholusTableEntry" : "Entry Type",
"DevDetail_Tab_PholusTableValue" : "Value",
"DevDetail_Tab_PholusTableExtra" : "Extra",
"DevDetail_Tab_EventsTableInfo" : "Additional info",
"DevDetail_Tab_Plugins" : "<i class=\"fa fa-plug\"></i> Plugins",
"DevDetail_Tab_NmapTableHeader" : "Scheduled scan results",
"DevDetail_Tab_NmapTableText" : "Set up a schedule in <a href=\"/settings.php#NMAP_ACTIVE\">Settings</a>",
Expand Down
11 changes: 1 addition & 10 deletions front/php/templates/language/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,7 @@
"DevDetail_Tab_EventsTableDate" : "Fecha",
"DevDetail_Tab_EventsTableEvent" : "Tipo de evento",
"DevDetail_Tab_EventsTableIP" : "IP",
"DevDetail_Tab_EventsTableInfo" : "Información adicional",
"DevDetail_Tab_Pholus" : "<i class=\"fa fa-search\"></i> Pholus",
"DevDetail_Tab_PholusEmpty" : "No se ha encontrado nada para este dispositivo con Pholus.",
"DevDetail_Tab_PholusTableIndex": "Índice",
"DevDetail_Tab_PholusTableInfo": "Información",
"DevDetail_Tab_PholusTableTime": "Hora",
"DevDetail_Tab_PholusTableIP": "IP",
"DevDetail_Tab_PholusTableEntry": "Tipo de entrada",
"DevDetail_Tab_PholusTableValue": "Valor",
"DevDetail_Tab_PholusTableExtra": "Extra",
"DevDetail_Tab_EventsTableInfo" : "Información adicional",
"DevDetail_Tab_Plugins" : "<i class=\"fa fa-plug\"></i> Plugins",
"DevDetail_Tab_NmapTableHeader" : "Resultados del escaneo programado",
"DevDetail_Tab_NmapTableText" : "Establece la programación en los <a href=\"/settings.php#NMAP_ACTIVE\">Ajustes</a>",
Expand Down
2 changes: 1 addition & 1 deletion front/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function initSettingsPage(settingsData){
const settingGroups = [];
const settingKeyOfLists = [];
// core groups are the ones not generated by plugins
const settingCoreGroups = ['General', 'NewDeviceDefaults', 'Email', 'Webhooks', 'Apprise', 'NTFY', 'PUSHSAFER', 'MQTT', 'DynDNS', 'Pholus', 'Nmap', 'API'];
const settingCoreGroups = ['General', 'NewDeviceDefaults', 'Email', 'Webhooks', 'Apprise', 'NTFY', 'PUSHSAFER', 'MQTT', 'DynDNS', 'Nmap', 'API'];


// Loop through the settingsArray and collect unique settingGroups
Expand Down

0 comments on commit 57aefdf

Please sign in to comment.