Просмотр исходного кода

add firmware for devices
add nagivation for device models
add page for show all devices in auth records

Dmitriev Roman 5 лет назад
Родитель
Сommit
47b7f49dbb

+ 24 - 5
html/admin/devices/devmodels.php

@@ -1,4 +1,6 @@
 <?php
+
+$default_displayed=50;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/vendorfilter.php");
@@ -69,12 +71,31 @@ print_device_submenu($page_url);
 ?>
 <div id="cont">
 <form name="def" action="devmodels.php" method="post">
+
 <table class="data">
 <tr>
-<td colspan=3><b>Список моделей</b></td>
-<td colspan=2><?php print_vendor_select($db_link,'vendor_select',$f_vendor_select); ?></td>
+<td><b>Список моделей</b></td>
+<td><?php print_vendor_select($db_link,'vendor_select',$f_vendor_select); ?></td>
+<td>Отображать:<?php print_row_at_pages('rows',$displayed); ?></td>
 <td><input type="submit" name="OK" value="Показать"></td>
 </tr>
+</table>
+
+<?php
+$v_filter='';
+if (!empty($f_vendor_select)) { $v_filter = "WHERE vendor_id=".$f_vendor_select; }
+
+$countSQL="SELECT Count(*) FROM device_models $v_filter";
+$res = mysqli_query($db_link, $countSQL);
+$count_records = mysqli_fetch_array($res);
+$total=ceil($count_records[0]/$displayed);
+if ($page>$total) { $page=$total; }
+if ($page<1) { $page=1; }
+$start = ($page * $displayed) - $displayed;
+print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+
+?>
+<table class="data">
 <tr align="center">
 <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b>Id</b></td>
@@ -85,9 +106,7 @@ print_device_submenu($page_url);
 <td><input type="submit" name="remove" value="Удалить"></td>
 </tr>
 <?
-$v_filter='';
-if (!empty($f_vendor_select)) { $v_filter = "WHERE vendor_id=".$f_vendor_select; }
-$t_ou = get_records_sql($db_link,'SELECT * FROM device_models '.$v_filter.' ORDER BY vendor_id, model_name');
+$t_ou = get_records_sql($db_link,'SELECT * FROM device_models '.$v_filter." ORDER BY vendor_id, model_name LIMIT $start,$displayed");
 foreach ($t_ou as $row) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";

+ 5 - 2
html/admin/devices/editdevice.php

@@ -43,6 +43,7 @@ if (isset($_POST["editdevice"]) and isset($id)) {
     if (isset($_POST["f_devtype_id"])) { $new['device_type'] = $_POST["f_devtype_id"]*1; }
     if (isset($_POST["f_comment"])) { $new['comment'] = $_POST["f_comment"]; }
     if (isset($_POST["f_SN"])) { $new['SN'] = $_POST["f_SN"]; }
+    if (isset($_POST["f_firmware"])) { $new['firmware'] = $_POST["f_firmware"]; }
     if (isset($_POST["f_ip"])) { $new['ip'] = substr($_POST["f_ip"], 0, 15); }
     if (isset($_POST["f_snmp_version"])) { $new['snmp_version'] = $_POST["f_snmp_version"] * 1; }
     if (isset($_POST["f_community"])) { $new['community'] = substr($_POST["f_community"], 0, 50); }
@@ -105,12 +106,14 @@ print "</tr>\n";
 ?>
 </tr>
 <td colspan=2>Модель</td>
-<td colspan=2>SN</td>
+<td> Firmware</td>
+<td>SN</td>
 
 <?php
 print "<tr>\n";
 print "<td class=\"data\" colspan=2>"; print_device_model_select($db_link,'f_device_model_id',$device['device_model_id']); print "</td>\n";
-print "<td class=\"data\" colspan=2><input type=\"text\" size=50 name='f_SN' value='".$device['SN']."'></td>\n";
+print "<td class=\"data\" ><input type=\"text\" name='f_firmware' value='".$device['firmware']."'></td>\n";
+print "<td class=\"data\" ><input type=\"text\" name='f_SN' value='".$device['SN']."'></td>\n";
 print "</tr>\n";
 
 print "<tr><td>Расположен</td><td colspan=2>Комментарий</td>";

+ 127 - 0
html/admin/devices/index-passive.php

@@ -0,0 +1,127 @@
+<?php
+$default_displayed=500;
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
+$default_sort='ip_int';
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/subnetfilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/vendorfilter.php");
+
+$unknown=1;
+if (!isset($_POST['f_unknown']) and isset($_POST['OK'])) { $unknown=0; }
+if (isset($_POST['f_unknown'])) { $unknown=$_POST['f_unknown']*1; }
+
+$unknown_checked='';
+if ($unknown) { $unknown_checked='checked="checked"'; }
+
+$sort_table = 'A';
+if ($sort_field == 'login') { $sort_table = 'L'; }
+if ($sort_field == 'fio') { $sort_table = 'L'; }
+if ($sort_field == 'model_name') { $sort_table = 'M'; }
+
+$sort_url = "<a href=index-passive.php?ou=" . $rou; 
+global $default_user_id;
+
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
+
+if ($rsubnet == 0) { $subnet_filter = ''; } else {
+    $subnet_range = get_subnet_range($db_link,$rsubnet);
+    if (!empty($subnet_range)) { $subnet_filter = " and User_auth.ip_int>=".$subnet_range['start']." and User_auth.ip_int<=".$subnet_range['stop']; }
+    }
+
+$ip_list_filter = $ou_filter.$subnet_filter;
+
+print_device_submenu($page_url);
+
+?>
+<div id="cont">
+<form name="def" action="index-passive.php" method="post">
+<table class="data">
+	<tr>
+        <td>
+        <b><?php print $list_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
+        Отображать:<?php print_row_at_pages('rows',$displayed); ?>
+        <b><?php print $list_subnet; ?> - </b><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?>
+        Hide unknown:&nbsp <input type=checkbox name=f_unknown value="1" <?php print $unknown_checked; ?>>
+        Vendor: <?php print_vendor_select($db_link,"vendor_select",$f_vendor_select); ?>
+        <input name="OK" type="submit" value="Показать">
+        </td>
+	</tr>
+</table>
+
+<?php
+
+$u_filter='';
+if ($unknown and $f_vendor_select==0) { $u_filter=' AND V.id<>1 '; } else {
+    if (!empty($f_vendor_select) and $f_vendor_select>=1) {
+        $u_filter = " AND V.id=".$f_vendor_select." ";
+        }
+    }
+
+$countSQL="SELECT Count(*) FROM User_auth A, User_list L, device_models M, vendors V 
+WHERE A.user_id = L.id AND A.device_model_id=M.id AND M.vendor_id=V.id
+AND A.deleted=0 $u_filter $ip_list_filter";
+
+$res = mysqli_query($db_link, $countSQL);
+$count_records = mysqli_fetch_array($res);
+$total=ceil($count_records[0]/$displayed);
+if ($page>$total) { $page=$total; }
+if ($page<1) { $page=1; }
+$start = ($page * $displayed) - $displayed; 
+print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+?>
+<br>
+
+<table class="data">
+	<tr>
+		<td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . $cell_login . "</a>"; ?></td>
+		<td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . $cell_ip . "</a>"; ?></td>
+		<td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . $cell_mac . "</a>"; ?></td>
+		<td align=Center><?php print $sort_url . "&sort=model_name&order=$new_order>".$cell_host_model; ?></td>
+		<td align=Center><?php print $cell_comment; ?></td>
+		<td align=Center><?php print $cell_dns_name; ?></td>
+		<td align=Center><?php print $cell_connection; ?></td>
+		<td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>Last</a>"; ?></td>
+	</tr>
+<?php
+
+$sSQL = "SELECT A.id, A.ip, A.mac, A.user_id, L.login, A.comments, A.dns_name, A.dhcp_hostname, A.last_found, V.name, M.model_name
+FROM User_auth A, User_list L, device_models M, vendors V
+WHERE A.user_id = L.id AND A.device_model_id=M.id AND M.vendor_id=V.id
+AND A.deleted =0 $u_filter $ip_list_filter
+ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
+
+$users = get_records_sql($db_link,$sSQL);
+foreach ($users as $user) {
+    if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
+    print "<tr align=center>\n";
+    $cl = "data";
+    print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['login'] . "</a></td>\n";
+    print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
+    print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
+    print "<td class=\"$cl\" >".$user['name'].' '.$user['model_name']."</td>\n";
+    if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
+        print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
+    } else {
+        print "<td class=\"$cl\" >".$user['comments']."</td>\n";
+    }
+    print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
+    print "<td class=\"data\" >" . get_connection($db_link, $user['id']) . "</td>\n";
+    print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
+    print "</tr>\n";
+}
+print "</table>\n";
+print_navigation($page_url,$page,$displayed,$count_records[0],$total);
+?>
+<br>
+<table class="data">
+<tr><td>Цветовая маркировка</td></tr>
+<tr>
+<td class="warn">Пользователь выключен</td>
+<td class="error">Блокировка по трафику</td>
+</table>
+<?php
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
+?>

+ 24 - 13
html/admin/users/editauth.php

@@ -47,8 +47,9 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
             $new['ip'] = $ip;
             $new['ip_int'] = $ip_aton;
             $new['mac'] = mac_dotted($_POST["f_mac"]);
-            $new['clientid'] = $_POST["f_clientid"];
+//            $new['clientid'] = $_POST["f_clientid"];
             $new['comments'] = $_POST["f_comments"];
+            $new['firmware'] = $_POST["f_firmware"];
             $new['WikiName'] = $_POST["f_wiki"];
             $f_dnsname=trim($_POST["f_dns_name"]);
             if (!empty($f_dnsname) and checkValidHostname($f_dnsname) and checkUniqHostname($db_link,$id,$f_dnsname)) { $new['dns_name'] = $f_dnsname; }
@@ -165,7 +166,7 @@ if ($auth_info['last_found'] == '0000-00-00 00:00:00') { $auth_info['last_found'
 ?>
 <div id="cont">
 <?
-print "<b> Адрес доступа пользователя <a href=/admin/users/edituser.php?id=".$auth_info['user_id'].">".$parent_name."</a> <b>";
+print "<b> Адрес доступа пользователя <a href=/admin/users/edituser.php?id=".$auth_info['user_id'].">".$parent_name."</a> </b>";
 ?>
 <form name="def" action="editauth.php?id=<? echo $id; ?>" method="post">
 <input type="hidden" name="id" value=<? echo $id; ?>>
@@ -191,7 +192,7 @@ print "<b> Адрес доступа пользователя <a href=/admin/use
 <tr>
 <td><?php print $cell_ip; ?></td>
 <td><?php print $cell_mac; ?></td>
-<td><?php print $cell_clientid; ?></td>
+<td><?php print $cell_acl; ?></td>
 <td><?php print $cell_dhcp; ?></td>
 <td><?php print $cell_filter; ?></td>
 <td><?php print $cell_shaper; ?></td>
@@ -199,7 +200,7 @@ print "<b> Адрес доступа пользователя <a href=/admin/use
 <tr>
 <td><input type="text" name="f_ip" value="<? echo $auth_info['ip']; ?>" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"></td>
 <td><input type="text" name="f_mac" value="<? echo $auth_info['mac']; ?>"></td>
-<td><input type="text" name="f_clientid" value="<? echo $auth_info['clientid']; ?>"></td>
+<td><input type="text" name="f_acl" value="<? echo $auth_info['dhcp_acl']; ?>"></td>
 <td><?php print_qa_select('f_dhcp', $auth_info['dhcp']); ?></td>
 <td><?php print_group_select($db_link, 'f_group_id', $auth_info['filter_group_id']); ?> </td>
 <td><?php print_queue_select($db_link, 'f_queue_id', $auth_info['queue_id']); ?> </td>
@@ -207,16 +208,16 @@ print "<b> Адрес доступа пользователя <a href=/admin/use
 </tr>
 <tr>
 <td><?php print $cell_host_model; ?></td>
+<td><?php print $cell_host_firmware; ?></td>
 <td><?php print $cell_nagios_handler; ?></td>
-<td><?php print $cell_acl; ?></td>
 <td><?php print $cell_nagios; ?></td>
 <td><?php print $cell_link; ?></td>
 <td><?php print $cell_traf; ?></td>
 <td></td>
 <tr>
 <td><?php print_device_model_select($db_link,'f_device_model_id',$auth_info['device_model_id']); ?></td>
+<td><input type="text" name="f_firmware" value="<? echo $auth_info['firmware']; ?>"></td>
 <td><input type="text" name="f_handler"	value="<? echo $auth_info['nagios_handler']; ?>"></td>
-<td><input type="text" name="f_acl" value="<? echo $auth_info['dhcp_acl']; ?>"></td>
 <td><?php print_qa_select('f_nagios', $auth_info['nagios']); ?></td>
 <td><?php print_qa_select('f_link', $auth_info['link_check']); ?></td>
 <td><?php print_qa_select('f_save_traf', $auth_info['save_traf']); ?></td>
@@ -225,8 +226,8 @@ print "<b> Адрес доступа пользователя <a href=/admin/use
 <tr>
 <td colspan=2><input type="submit" name="moveauth" value=<?php print $btn_move; ?>><?php print_login_select($db_link, 'new_parent', $auth_info['user_id']); ?></td>
 <td><a href=/admin/logs/authlog.php?auth_id=<?php print $id; ?>>Лог</a></td>
+<td></td>
 <?php
-print "<td>"; print_url("Трафик за день","/admin/reports/authday.php?id=$id"); print "</td>";
 if ($auth_info['deleted']) {
     print "<td colspan=2>Deleted: " . $auth_info['changed_time']."</td>";
     print "<td colspan=1 align=right><input type=\"submit\" name=\"recovery\" value=\"Восстановить\"></td>";
@@ -236,14 +237,24 @@ if ($auth_info['deleted']) {
 }
 ?>
 </tr>
+<tr ><td class="data" colspan=7>Status:</td></tr>
 <tr >
-<td  class="data" colspan=7>
+<td>
+<?php
+print "Created: " . $auth_info['timestamp']."<br>";
+?>
+</td>
+<td colspan=2>
+<?php
+print "Dhcp event: " . $dhcp_str."<br>";
+print "Dhcp hostname: " . $auth_info['dhcp_hostname']."<br>";
+?>
+</td>
+<td><?php print_url("Трафик за день","/admin/reports/authday.php?id=$id"); ?></td>
+<td colspan=3>
 <?php
-print "Created: " . $auth_info['timestamp'];
-print "&nbsp Dhcp: " . $dhcp_str;
-print "&nbsp hostname: " . $auth_info['dhcp_hostname'];
-print "&nbsp Last: " . $auth_info['last_found'];
-print "&nbsp ".get_connection($db_link, $id);
+print "Last found: " . $auth_info['last_found']."<br>";
+print "Connected: ".get_connection($db_link, $id)."<br>";
 ?>
 </td>
 </tr>

+ 2 - 1
html/inc/common.php

@@ -533,6 +533,7 @@ print "</div>\n";
 function print_device_submenu ($current_page) {
 print "<div id='submenu'>\n";
 print_submenu_url('Активное сетевое оборудование','/admin/devices/index.php',$current_page,0);
+print_submenu_url('Пассивное оборудование','/admin/devices/index-passive.php',$current_page,0);
 print_submenu_url('Расположение','/admin/devices/building.php',$current_page,0);
 print_submenu_url('Удалённые','/admin/devices/deleted.php',$current_page,0);
 print_submenu_url('Модели устройств','/admin/devices/devmodels.php',$current_page,0);
@@ -758,7 +759,7 @@ function print_enabled_select($qa_name, $qa_value)
 
 function print_vendor_select($db, $qa_name, $qa_value)
 {
-    print "<select name=\"$qa_name\" class=\"js-select-single\" style=\"width: 100%\">\n";
+    print "<select name=\"$qa_name\" class=\"js-select-single\">\n";
     $sSQL = "SELECT id,`name` FROM `vendors` order by `name`";
     $vendors = mysqli_query($db, $sSQL);
     print_select_item('Всё',0,$qa_value);

+ 1 - 0
html/inc/languages/russian.php

@@ -36,6 +36,7 @@ $cell_name = "Название";
 $cell_ip = "IP";
 $cell_mac = "MAC";
 $cell_clientid = "Client-id";
+$cell_host_firmware = "Firmware";
 $cell_comment = "Комментарий";
 $cell_wikiname = "Wiki Name";
 $cell_filter = "Фильтр";

+ 5 - 5
updates/20210330/db-patch-mysql-ou.sql

@@ -1,5 +1,5 @@
-ALTER TABLE `devices` ADD `device_model_id` INT NULL DEFAULT NULL AFTER `device_type`;
-ALTER TABLE `User_auth` ADD `device_model_id` INT NULL DEFAULT NULL AFTER `month_quota`;
+ALTER TABLE `devices` ADD `device_model_id` INT NULL DEFAULT '89' AFTER `device_type`;
+ALTER TABLE `User_auth` ADD `device_model_id` INT NULL DEFAULT '87' AFTER `month_quota`;
 ALTER TABLE `OU` ADD `nagios_host_use` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
 ALTER TABLE `OU` ADD `nagios_ping` BOOLEAN NOT NULL DEFAULT TRUE AFTER `nagios_host_use`;
 ALTER TABLE `OU` ADD `nagios_default_service` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `nagios_ping`;
@@ -15,8 +15,8 @@ UPDATE `OU` SET `nagios_template` = 'ups' WHERE `OU`.`id` = 8;
 UPDATE `OU` SET `nagios_template` = 'security' WHERE `OU`.`id` = 9;
 UPDATE `OU` SET `nagios_template` = 'routers' WHERE `OU`.`id` = 10;
 UPDATE `OU` SET `nagios_template` = 'ap' WHERE `OU`.`id` = 12;
-INSERT INTO `vendors` (`id`, `name`) VALUES (33, 'QSC');
-ALTER TABLE `devices` CHANGE `device_model_id` `device_model_id` INT NULL DEFAULT '89';
-ALTER TABLE `User_auth` CHANGE `device_model_id` `device_model_id` INT(11) NULL DEFAULT '87';
+INSERT INTO `vendors` (`id`, `name`) VALUES ('33', 'QSC');
 INSERT INTO `vendors` (`id`, `name`) VALUES ('34', 'Projectiondesign');
 INSERT INTO `vendors` (`id`, `name`) VALUES ('35', 'Lenovo');
+ALTER TABLE `User_auth` ADD `firmware` VARCHAR(100) NULL DEFAULT NULL AFTER `device_model_id`;
+ALTER TABLE `devices` ADD `firmware` VARCHAR(100) NULL DEFAULT NULL AFTER `device_model_id`;