mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
difficult to describe
I want to display an assignment of individual network nodes to specific network devices (which device is connected to which switch, router or wlan). It is still in the experimental phase, but is already usable in principle. Whether this "feature" will make it into the main fork, I can't say yet. Wegen der aktuellen Entwicklungsphase ist dieser teil ausschließlich deutsch.
This commit is contained in:
@@ -17,6 +17,7 @@ if ($_SESSION["login"] != 1)
|
||||
}
|
||||
|
||||
require 'php/templates/header.php';
|
||||
require 'php/server/db.php';
|
||||
?>
|
||||
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
@@ -263,6 +264,14 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Infrastructure</label>
|
||||
<div class="col-sm-9">
|
||||
<input class="form-control" id="txtInfrastructure" type="text" value="--">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -453,7 +462,7 @@ if ($_REQUEST['mac'] == 'Internet') {
|
||||
?>
|
||||
<h4 class="">Online Speedtest</h4>
|
||||
<div style="width:100%; text-align: center; margin-bottom: 50px;">
|
||||
<button type="button" id="speedtestcli" class="btn btn-default pa-btn" style="margin: auto;" onclick="speedtestcli()">Start Speedtest</button>
|
||||
<button type="button" id="speedtestcli" class="btn btn-primary pa-btn" style="margin: auto;" onclick="speedtestcli()">Start Speedtest</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -483,11 +492,11 @@ if ($_REQUEST['mac'] == 'Internet') {
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
<button type="button" id="piamanualnmap_fast" class="btn btn-default pa-btn" style="margin: auto;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'fast')">Loading...</button>
|
||||
<button type="button" id="piamanualnmap_normal" class="btn btn-default pa-btn" style="margin: auto;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'normal')">Loading...</button>
|
||||
<button type="button" id="piamanualnmap_detail" class="btn btn-default pa-btn" style="margin: auto;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'detail')">Loading...</button>
|
||||
<button type="button" id="piamanualnmap_fast" class="btn btn-primary pa-btn" style="margin-bottom: 20px; margin-left: 10px; margin-right: 10px;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'fast')">Loading...</button>
|
||||
<button type="button" id="piamanualnmap_normal" class="btn btn-primary pa-btn" style="margin-bottom: 20px; margin-left: 10px; margin-right: 10px;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'normal')">Loading...</button>
|
||||
<button type="button" id="piamanualnmap_detail" class="btn btn-primary pa-btn" style="margin-bottom: 20px; margin-left: 10px; margin-right: 10px;" onclick="manualnmapscan(document.getElementById('txtLastIP').value, 'detail')">Loading...</button>
|
||||
|
||||
<div style="margin-top: 20px; text-align: left;">
|
||||
<div style="text-align: left;">
|
||||
<ul style="padding:20px;">
|
||||
<li><?php echo $pia_lang['DevDetail_Nmap_buttonFast_text'];?></li>
|
||||
<li><?php echo $pia_lang['DevDetail_Nmap_buttonDefault_text'];?></li>
|
||||
@@ -1104,6 +1113,7 @@ function getDeviceData (readAllData=false) {
|
||||
$('#txtGroup').val ('--');
|
||||
$('#txtLocation').val ('--');
|
||||
$('#txtComments').val ('--');
|
||||
$('#txtInfrastructure').val ('--');
|
||||
|
||||
$('#txtFirstConnection').val ('--');
|
||||
$('#txtLastConnection').val ('--');
|
||||
@@ -1184,6 +1194,7 @@ function getDeviceData (readAllData=false) {
|
||||
$('#txtGroup').val (deviceData['dev_Group']);
|
||||
$('#txtLocation').val (deviceData['dev_Location']);
|
||||
$('#txtComments').val (deviceData['dev_Comments']);
|
||||
$('#txtInfrastructure').val (deviceData['dev_Infrastructure']);
|
||||
|
||||
$('#txtFirstConnection').val (deviceData['dev_FirstConnection']);
|
||||
$('#txtLastConnection').val (deviceData['dev_LastConnection']);
|
||||
@@ -1292,6 +1303,7 @@ function setDeviceData (refreshCallback='') {
|
||||
+ '&group=' + $('#txtGroup').val()
|
||||
+ '&location=' + $('#txtLocation').val()
|
||||
+ '&comments=' + $('#txtComments').val()
|
||||
+ '&infrastructure=' + $('#txtInfrastructure').val()
|
||||
+ '&staticIP=' + ($('#chkStaticIP')[0].checked * 1)
|
||||
+ '&scancycle=' + $('#txtScanCycle').val().split(' ')[0]
|
||||
+ '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1)
|
||||
|
||||
191
front/network.php
Normal file
191
front/network.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
session_start();
|
||||
if ($_SESSION["login"] != 1)
|
||||
{
|
||||
header('Location: /pialert/index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'php/templates/header.php';
|
||||
require 'php/server/db.php';
|
||||
|
||||
|
||||
$DBFILE = '../db/pialert.db';
|
||||
OpenDB();
|
||||
// Create Table if not exists'
|
||||
$sql = 'CREATE TABLE IF NOT EXISTS "network_infrastructure" (
|
||||
"device_id" INTEGER,
|
||||
"net_device_name" TEXT NOT NULL,
|
||||
"net_device_typ" TEXT NOT NULL,
|
||||
PRIMARY KEY("device_id" AUTOINCREMENT)
|
||||
)';
|
||||
$result = $db->query($sql);
|
||||
// Expand Devices Table
|
||||
$sql = 'ALTER TABLE "Devices" ADD "dev_Infrastructure" INTEGER';
|
||||
$result = $db->query($sql);
|
||||
$sql = 'ALTER TABLE "Devices" ADD "dev_Infrastructure_port" INTEGER';
|
||||
$result = $db->query($sql);
|
||||
|
||||
|
||||
if ($_REQUEST['Networkinsert'] == "yes") {
|
||||
if (isset($_REQUEST['NetworkDeviceName']) && isset($_REQUEST['NetworkDeviceTyp']))
|
||||
{
|
||||
$sql = 'INSERT INTO "network_infrastructure" ("net_device_name", "net_device_typ") VALUES("'.$_REQUEST['NetworkDeviceName'].'", "'.$_REQUEST['NetworkDeviceTyp'].'")';
|
||||
$result = $db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST['Networkdelete'] == "yes") {
|
||||
if (isset($_REQUEST['NetworkDeviceID']))
|
||||
{
|
||||
$sql = 'DELETE FROM "network_infrastructure" WHERE "device_id"="'.$_REQUEST['NetworkDeviceID'].'"';
|
||||
$result = $db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
<div class="content-wrapper">
|
||||
|
||||
<!-- Content header--------------------------------------------------------- -->
|
||||
<section class="content-header">
|
||||
<?php require 'php/templates/notification.php'; ?>
|
||||
<h1 id="pageTitle">
|
||||
Netzwerkvisualisierung
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
<?php
|
||||
echo $_REQUEST['device_id'];
|
||||
?>
|
||||
<!-- Main content ---------------------------------------------------------- -->
|
||||
<section class="content">
|
||||
<div class="box box-default collapsed-box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Verwalte Netzwerk-Geräte</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
|
||||
<!-- <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button> -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body" style="">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<form role="form" method="post" action="./network.php">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Netzwerk Gerät hinzufügen:</label>
|
||||
<input type="text" class="form-control" id="NetworkDeviceName" name="NetworkDeviceName" placeholder="Name">
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
<div class="form-group">
|
||||
<label>Typ</label>
|
||||
<select class="form-control" name="NetworkDeviceTyp">
|
||||
<option value="">-- Select Typ --</option>
|
||||
<option value="Router">Router</option>
|
||||
<option value="Switch">Switch</option>
|
||||
<option value="SSID">SSID</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-success" name="Networkinsert" value="yes">Hinzufügen</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- /.form-group -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-md-6">
|
||||
<form role="form" method="post" action="./network.php">
|
||||
<div class="form-group">
|
||||
<label>Netzwerk Gerät entfernen:</label>
|
||||
<select class="form-control" name="NetworkDeviceID">
|
||||
<option value="">-- Select Typ --</option>
|
||||
<?php
|
||||
|
||||
$sql = 'SELECT "device_id", "net_device_name", "net_device_typ" FROM "network_infrastructure"';
|
||||
$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC);
|
||||
while($res = $result->fetchArray(SQLITE3_ASSOC)){
|
||||
if(!isset($res['device_id'])) continue;
|
||||
echo '<option value="'.$res['device_id'].'">'.$res['net_device_name'].' / '.$res['net_device_typ'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- /.form-group -->
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-danger" name="Networkdelete" value="yes">Entfernen</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- /.form-group -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
function createnetworktab($pia_func_netdevid, $pia_func_netdevname, $pia_func_netdevtyp, $activetab) {
|
||||
echo '<li class="'.$activetab.'"><a href="#'.$pia_func_netdevid.'" data-toggle="tab">'.$pia_func_netdevname.' / '.$pia_func_netdevtyp.'</a></li>';
|
||||
}
|
||||
function createnetworktabcontent($pia_func_netdevid, $pia_func_netdevname, $pia_func_netdevtyp, $activetab) {
|
||||
echo '<div class="tab-pane '.$activetab.'" id="'.$pia_func_netdevid.'">
|
||||
<h4>'.$pia_func_netdevname.' (ID: '.$pia_func_netdevid.')</h4><br>';
|
||||
global $db;
|
||||
$func_sql = 'SELECT * FROM "Devices" WHERE "dev_Infrastructure" = "'.$pia_func_netdevid.'"';
|
||||
$func_result = $db->query($func_sql);//->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
while($func_res = $func_result->fetchArray(SQLITE3_ASSOC)){
|
||||
if(!isset($func_res['dev_Name'])) continue;
|
||||
echo $func_res['dev_Name'].' - '.$func_res['dev_LastIP'].' - '.$func_res['dev_PresentLastScan'].'<br>';
|
||||
}
|
||||
|
||||
echo '</div> ';
|
||||
}
|
||||
|
||||
$sql = 'SELECT "device_id", "net_device_name", "net_device_typ" FROM "network_infrastructure"';
|
||||
$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC);
|
||||
?>
|
||||
|
||||
<div class="nav-tabs-custom">
|
||||
<ul class="nav nav-tabs">
|
||||
|
||||
<?php
|
||||
$i = 0;
|
||||
while($res = $result->fetchArray(SQLITE3_ASSOC)){
|
||||
if(!isset($res['device_id'])) continue;
|
||||
if ($i == 0) {$active = 'active';} else {$active = '';}
|
||||
createnetworktab($res['device_id'], $res['net_device_name'], $res['net_device_typ'], $active);
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php
|
||||
$i = 0;
|
||||
while($res = $result->fetchArray(SQLITE3_ASSOC)){
|
||||
if(!isset($res['device_id'])) continue;
|
||||
if ($i == 0) {$active = 'active';} else {$active = '';}
|
||||
createnetworktabcontent($res['device_id'], $res['net_device_name'], $res['net_device_typ'], $active);
|
||||
$i++;
|
||||
}
|
||||
unset($i);
|
||||
?>
|
||||
<!-- /.tab-pane -->
|
||||
</div>
|
||||
<!-- /.tab-content -->
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- /.content -->
|
||||
</div>
|
||||
<!-- /.content-wrapper -->
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<?php
|
||||
require 'php/templates/footer.php';
|
||||
?>
|
||||
@@ -86,6 +86,7 @@ function getDeviceData() {
|
||||
$deviceData = $row;
|
||||
$mac = $deviceData['dev_MAC'];
|
||||
|
||||
$deviceData['dev_Infrastructure'] = $row['dev_Infrastructure'];
|
||||
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
|
||||
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
|
||||
|
||||
@@ -153,6 +154,7 @@ function setDeviceData() {
|
||||
dev_Group = "'. quotes($_REQUEST['group']) .'",
|
||||
dev_Location = "'. quotes($_REQUEST['location']) .'",
|
||||
dev_Comments = "'. quotes($_REQUEST['comments']) .'",
|
||||
dev_Infrastructure = "'. quotes($_REQUEST['infrastructure']).'",
|
||||
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
|
||||
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
|
||||
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
|
||||
|
||||
Reference in New Issue
Block a user