query($sql); $sql = 'ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER'; $result = $db->query($sql); ?>

' .$node_name.' / '.$node_type. ' ' .$str_port. ' '; echo $str_tab_header; } function createPane($node_mac, $node_name, $node_type, $node_ports_count, $activetab){ $str_tab_pane = '

'.$node_name.' (ID: '.str_replace(":", "_", $node_mac).')


'; $str_table = ' '; // Prepare Array for Devices with Port value // If no Port is set, the Port number is set to 0 if ($node_ports_count == "") { $node_ports_count = 0; } // Get all leafs connected to a node based on the node_mac $func_sql = 'SELECT dev_Network_Node_port as port, dev_MAC as mac, dev_PresentLastScan as online, dev_Name as name, dev_DeviceType as type, dev_LastIP as last_ip FROM "Devices" WHERE "dev_Network_Node_MAC" = "'.$node_mac.'"'; global $db; $func_result = $db->query($func_sql); // array $tableData = array(); while ($row = $func_result -> fetchArray (SQLITE3_ASSOC)) { // Push row data $tableData[] = array( 'port' => $row['port'], 'mac' => $row['mac'], 'online' => $row['online'], 'name' => $row['name'], 'type' => $row['type'], 'last_ip' => $row['last_ip']); } // Control no rows if (empty($tableData)) { $tableData = []; } $str_table_rows = ""; foreach ($tableData as $row) { if ($row['online'] == 1) { $port_state = '
Online
'; } else { $port_state = '
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 $port_content = "N/A"; if ($row['type'] == "WLAN" || $row['type'] == "AP" ) { $port_content = ''; } elseif ($row['type'] == "Powerline") { $port_content = ''; } elseif ($row['port'] != NULL && $row['port'] != "") { $port_content = $row['port']; } $str_table_rows = $str_table_rows. ''; } $str_table_close = '
Port '.$pia_lang['Network_Table_State'].' '.$pia_lang['Network_Table_Hostname'].' '.$pia_lang['Network_Table_IP'].'
'.$port_content.' ' .$port_state. ' '.$row['name'].' ' .$row['last_ip']. '
'; // no connected device - don't render table if($str_table_rows == "") { $str_table = ""; $str_table_close = ""; } $str_close_pane = '
'; // write the HTML echo ''.$str_tab_header. $str_tab_pane. $str_table. $str_table_rows. $str_table_close. $str_close_pane; } // Create Top level tabs (List of network devices), explanation of the terminology below: // // Switch 1 (node) // /(p1) \ (p2) <----- port numbers // / \ // Smart TV (leaf) Switch 2 (node (for the PC) and leaf (for Switch 1)) // \ // PC (leaf) $sql = "SELECT node_name, node_mac, node_type, node_ports_count FROM ( SELECT a.dev_Name as node_name, a.dev_MAC as node_mac, a.dev_DeviceType as node_type FROM Devices a WHERE a.dev_DeviceType in ('AP', 'Gateway', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet') ) t1 LEFT JOIN ( SELECT b.dev_Network_Node_MAC as node_mac_2, count() as node_ports_count FROM Devices b WHERE b.dev_Network_Node_MAC NOT NULL group by b.dev_Network_Node_MAC ) t2 ON (t1.node_mac = t2.node_mac_2); "; $result = $db->query($sql); // array $tableData = array(); while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { // Push row data $tableData[] = array( 'node_mac' => $row['node_mac'], 'node_name' => $row['node_name'], 'node_type' => $row['node_type'], 'node_ports_count' => $row['node_ports_count']); } // Control no rows if (empty($tableData)) { $tableData = []; } echo '