network and other small enhancements
This commit is contained in:
@@ -263,7 +263,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
|
|||||||
<textarea class="form-control" rows="3" id="txtComments"></textarea>
|
<textarea class="form-control" rows="3" id="txtComments"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Network -->
|
||||||
|
<h4 class="bottom-border-aqua"><?php echo $pia_lang['DevDetail_MainInfo_Network_Title'];?></h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label>
|
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
|||||||
@@ -10,11 +10,16 @@
|
|||||||
require 'php/server/db.php';
|
require 'php/server/db.php';
|
||||||
require 'php/server/util.php';
|
require 'php/server/util.php';
|
||||||
|
|
||||||
global $pia_lang;
|
// online / offline badges HTML snippets
|
||||||
|
define('badge_online', '<div class="badge bg-green text-white" style="width: 60px;">Online</div>');
|
||||||
|
define('badge_offline', '<div class="badge bg-red text-white" style="width: 60px;">Offline</div>');
|
||||||
|
define('circle_online', '<div class="badge bg-green text-white" style="width: 10px; height: 10px; padding:2px; margin-top: -25px;"> </div>');
|
||||||
|
define('circle_offline', '<div class="badge bg-red text-white" style="width: 10px; height: 10px; padding:2px; margin-top: -25px;"> </div>');
|
||||||
|
|
||||||
|
|
||||||
$DBFILE = '../db/pialert.db';
|
$DBFILE = '../db/pialert.db';
|
||||||
$NETWORKTYPES = getNetworkTypes();
|
$NETWORKTYPES = getNetworkTypes();
|
||||||
|
|
||||||
OpenDB();
|
OpenDB();
|
||||||
|
|
||||||
// #####################################
|
// #####################################
|
||||||
@@ -46,7 +51,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Create top-level node (network devices) tabs
|
// Create top-level node (network devices) tabs
|
||||||
function createDeviceTabs($node_mac, $node_name, $node_type, $node_ports_count, $activetab) {
|
function createDeviceTabs($node_mac, $node_name, $node_status, $node_type, $node_ports_count, $activetab) {
|
||||||
|
global $pia_lang; //language strings
|
||||||
|
|
||||||
// prepare string with port number in brackets if available
|
// prepare string with port number in brackets if available
|
||||||
$str_port = "";
|
$str_port = "";
|
||||||
@@ -54,11 +60,20 @@
|
|||||||
$str_port = ' ('.$node_ports_count.')';
|
$str_port = ' ('.$node_ports_count.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// online/offline status circle (red/green)
|
||||||
|
$node_badge = "";
|
||||||
|
if($node_status == 1) // 1 means online, 0 offline
|
||||||
|
{
|
||||||
|
$node_badge = circle_online;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$node_badge = circle_offline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$str_tab_header = '<li class="'.$activetab.'">
|
$str_tab_header = '<li class="'.$activetab.'">
|
||||||
<a href="#'.str_replace(":", "_", $node_mac).'" data-toggle="tab">'
|
<a href="#'.str_replace(":", "_", $node_mac).'" data-toggle="tab">'
|
||||||
.$node_name.' / '.$node_type. ' ' .$str_port.
|
.$node_name.' ' .$str_port.$node_badge.
|
||||||
'</a>
|
'</a>
|
||||||
</li>';
|
</li>';
|
||||||
|
|
||||||
@@ -66,16 +81,58 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPane($node_mac, $node_name, $node_type, $node_ports_count, $activetab){
|
// Create pane content (displayed inside of the tabs)
|
||||||
|
function createPane($node_mac, $node_name, $node_status, $node_type, $node_ports_count, $activetab){
|
||||||
|
global $pia_lang; //language strings
|
||||||
|
|
||||||
|
// online/offline status circle (red/green)
|
||||||
|
$node_badge = "";
|
||||||
|
if($node_status == 1) // 1 means online, 0 offline
|
||||||
|
{
|
||||||
|
$node_badge = badge_online;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$node_badge = badge_offline;
|
||||||
|
}
|
||||||
|
|
||||||
$str_tab_pane = '<div class="tab-pane '.$activetab.'" id="'.str_replace(":", "_", $node_mac).'">
|
$str_tab_pane = '<div class="tab-pane '.$activetab.'" id="'.str_replace(":", "_", $node_mac).'">
|
||||||
<h4>'.$node_name.' (ID: '.str_replace(":", "_", $node_mac).')</h4>
|
<a href="./deviceDetails.php?mac='.$node_mac.'">
|
||||||
|
<h4>'.$node_name.'</h4>
|
||||||
|
</a>
|
||||||
|
<table class="table table-striped" style="width:200px;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>MAC:</b>
|
||||||
|
</td>
|
||||||
|
<td>'
|
||||||
|
.$node_mac.
|
||||||
|
'</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>'.$pia_lang['Device_TableHead_Type'].'</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
' .$node_type. '
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>'.$pia_lang['Network_Table_State'].':</b>
|
||||||
|
</td>
|
||||||
|
<td> '
|
||||||
|
.$node_badge.
|
||||||
|
'</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<div class="box-body no-padding">';
|
<div class="box-body no-padding">';
|
||||||
|
|
||||||
|
$str_table = ' <h4>
|
||||||
|
'.$pia_lang['Device_Title'].'
|
||||||
|
</h4>
|
||||||
$str_table = '
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -97,8 +154,9 @@
|
|||||||
dev_PresentLastScan as online,
|
dev_PresentLastScan as online,
|
||||||
dev_Name as name,
|
dev_Name as name,
|
||||||
dev_DeviceType as type,
|
dev_DeviceType as type,
|
||||||
dev_LastIP as last_ip
|
dev_LastIP as last_ip,
|
||||||
FROM "Devices" WHERE "dev_Network_Node_MAC" = "'.$node_mac.'"';
|
(select dev_DeviceType from Devices a where dev_MAC = "'.$node_mac.'") as node_type
|
||||||
|
FROM Devices WHERE dev_Network_Node_MAC = "'.$node_mac.'" order by port asc';
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
$func_result = $db->query($func_sql);
|
$func_result = $db->query($func_sql);
|
||||||
@@ -112,7 +170,8 @@
|
|||||||
'online' => $row['online'],
|
'online' => $row['online'],
|
||||||
'name' => $row['name'],
|
'name' => $row['name'],
|
||||||
'type' => $row['type'],
|
'type' => $row['type'],
|
||||||
'last_ip' => $row['last_ip']);
|
'last_ip' => $row['last_ip'],
|
||||||
|
'node_type' => $row['node_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control no rows
|
// Control no rows
|
||||||
@@ -125,18 +184,17 @@
|
|||||||
foreach ($tableData as $row) {
|
foreach ($tableData as $row) {
|
||||||
|
|
||||||
if ($row['online'] == 1) {
|
if ($row['online'] == 1) {
|
||||||
$port_state = '<div class="badge bg-green text-white" style="width: 60px;">Online</div>';
|
$port_state = badge_online;
|
||||||
} else {
|
} else {
|
||||||
$port_state = '<div class="badge bg-red text-white" style="width: 60px;">Offline</div>';
|
$port_state = badge_offline;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUG: TODO fix icons - I'll need to fix the SQL query to add the type of the node on line 95
|
|
||||||
// prepare HTML for the port table column cell
|
// prepare HTML for the port table column cell
|
||||||
$port_content = "N/A";
|
$port_content = "N/A";
|
||||||
|
|
||||||
if ($row['type'] == "WLAN" || $row['type'] == "AP" ) {
|
if ($row['node_type'] == "WLAN" || $row['node_type'] == "AP" ) {
|
||||||
$port_content = '<i class="fa fa-wifi"></i>';
|
$port_content = '<i class="fa fa-wifi"></i>';
|
||||||
} elseif ($row['type'] == "Powerline")
|
} elseif ($row['node_type'] == "Powerline")
|
||||||
{
|
{
|
||||||
$port_content = '<i class="fa fa-flash"></i>';
|
$port_content = '<i class="fa fa-flash"></i>';
|
||||||
} elseif ($row['port'] != NULL && $row['port'] != "")
|
} elseif ($row['port'] != NULL && $row['port'] != "")
|
||||||
@@ -167,16 +225,23 @@
|
|||||||
$str_table_close = '</tbody>
|
$str_table_close = '</tbody>
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
// no connected device - don't render table
|
// no connected device - don't render table, just dispaly some info
|
||||||
if($str_table_rows == "")
|
if($str_table_rows == "")
|
||||||
{
|
{
|
||||||
$str_table = "";
|
$str_table = "<div>
|
||||||
|
<h4>
|
||||||
|
".$pia_lang['Device_Title']."
|
||||||
|
</h4>
|
||||||
|
<div>
|
||||||
|
This network device (node) doesn't have any assigned devices (leaf nodes).
|
||||||
|
Go to <a href='./devices.php'><b>".$pia_lang['Device_Title']."</b></a>, select a device you want to attach to this node and assign it in the <b>Details</b> tab by selecting it in the <b>".$pia_lang['DevDetail_MainInfo_Network'] ."</b> dropdown.
|
||||||
|
</div>
|
||||||
|
</div>";
|
||||||
$str_table_close = "";
|
$str_table_close = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_close_pane = '</div>
|
$str_close_pane = '</div>
|
||||||
</div>
|
</div>';
|
||||||
<div class="aaaaaaa"></div>';
|
|
||||||
|
|
||||||
// write the HTML
|
// write the HTML
|
||||||
echo ''.$str_tab_header.
|
echo ''.$str_tab_header.
|
||||||
@@ -197,11 +262,12 @@
|
|||||||
// \
|
// \
|
||||||
// PC (leaf)
|
// PC (leaf)
|
||||||
|
|
||||||
$sql = "SELECT node_name, node_mac, node_type, node_ports_count
|
$sql = "SELECT node_name, node_mac, online, node_type, node_ports_count
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT a.dev_Name as node_name,
|
SELECT a.dev_Name as node_name,
|
||||||
a.dev_MAC as node_mac,
|
a.dev_MAC as node_mac,
|
||||||
|
a.dev_PresentLastScan as online,
|
||||||
a.dev_DeviceType as node_type
|
a.dev_DeviceType as node_type
|
||||||
FROM Devices a
|
FROM Devices a
|
||||||
WHERE a.dev_DeviceType in ('AP', 'Gateway', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet')
|
WHERE a.dev_DeviceType in ('AP', 'Gateway', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet')
|
||||||
@@ -224,6 +290,7 @@
|
|||||||
// Push row data
|
// Push row data
|
||||||
$tableData[] = array( 'node_mac' => $row['node_mac'],
|
$tableData[] = array( 'node_mac' => $row['node_mac'],
|
||||||
'node_name' => $row['node_name'],
|
'node_name' => $row['node_name'],
|
||||||
|
'online' => $row['online'],
|
||||||
'node_type' => $row['node_type'],
|
'node_type' => $row['node_type'],
|
||||||
'node_ports_count' => $row['node_ports_count']);
|
'node_ports_count' => $row['node_ports_count']);
|
||||||
}
|
}
|
||||||
@@ -240,6 +307,7 @@
|
|||||||
foreach ($tableData as $row) {
|
foreach ($tableData as $row) {
|
||||||
createDeviceTabs( $row['node_mac'],
|
createDeviceTabs( $row['node_mac'],
|
||||||
$row['node_name'],
|
$row['node_name'],
|
||||||
|
$row['online'],
|
||||||
$row['node_type'],
|
$row['node_type'],
|
||||||
$row['node_ports_count'],
|
$row['node_ports_count'],
|
||||||
$activetab);
|
$activetab);
|
||||||
@@ -254,6 +322,7 @@
|
|||||||
foreach ($tableData as $row) {
|
foreach ($tableData as $row) {
|
||||||
createPane($row['node_mac'],
|
createPane($row['node_mac'],
|
||||||
$row['node_name'],
|
$row['node_name'],
|
||||||
|
$row['online'],
|
||||||
$row['node_type'],
|
$row['node_type'],
|
||||||
$row['node_ports_count'],
|
$row['node_ports_count'],
|
||||||
$activetab);
|
$activetab);
|
||||||
@@ -262,6 +331,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!-- /.tab-pane -->
|
<!-- /.tab-pane -->
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require 'php/server/db.php';
|
||||||
|
$DBFILE = '../db/pialert.db';
|
||||||
|
OpenDB();
|
||||||
|
|
||||||
$Pia_Graph_Device_Time = array();
|
$Pia_Graph_Device_Time = array();
|
||||||
$Pia_Graph_Device_All = array();
|
$Pia_Graph_Device_All = array();
|
||||||
$Pia_Graph_Device_Online = array();
|
$Pia_Graph_Device_Online = array();
|
||||||
$Pia_Graph_Device_Down = array();
|
$Pia_Graph_Device_Down = array();
|
||||||
$Pia_Graph_Device_Arch = array();
|
$Pia_Graph_Device_Arch = array();
|
||||||
$db = new SQLite3('../db/pialert.db');
|
|
||||||
|
//$db = new SQLite3('../db/pialert.db');
|
||||||
$results = $db->query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 144');
|
$results = $db->query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 144');
|
||||||
while ($row = $results->fetchArray()) {
|
while ($row = $results->fetchArray()) {
|
||||||
$time_raw = explode(' ', $row['Scan_Date']);
|
$time_raw = explode(' ', $row['Scan_Date']);
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ $pia_lang['DevDetail_MainInfo_Favorite'] = 'Favorite';
|
|||||||
$pia_lang['DevDetail_MainInfo_Group'] = 'Group';
|
$pia_lang['DevDetail_MainInfo_Group'] = 'Group';
|
||||||
$pia_lang['DevDetail_MainInfo_Location'] = 'Location';
|
$pia_lang['DevDetail_MainInfo_Location'] = 'Location';
|
||||||
$pia_lang['DevDetail_MainInfo_Comments'] = 'Comments';
|
$pia_lang['DevDetail_MainInfo_Comments'] = 'Comments';
|
||||||
|
$pia_lang['DevDetail_MainInfo_Network_Title'] = 'Network';
|
||||||
$pia_lang['DevDetail_MainInfo_Network'] = 'Network Node (MAC)';
|
$pia_lang['DevDetail_MainInfo_Network'] = 'Network Node (MAC)';
|
||||||
$pia_lang['DevDetail_MainInfo_Network_Port'] = 'Connected to Port';
|
$pia_lang['DevDetail_MainInfo_Network_Port'] = 'Connected to Port';
|
||||||
$pia_lang['DevDetail_SessionInfo_Title'] = 'Session Info';
|
$pia_lang['DevDetail_SessionInfo_Title'] = 'Session Info';
|
||||||
|
|||||||
Reference in New Issue
Block a user