Sfoglia il codice sorgente

add slect filter for ip list by type of address assignment

Roman Dmitriev 2 anni fa
parent
commit
898a95672a

+ 11 - 1
html/admin/iplist/index.php

@@ -9,6 +9,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/iptypefilter.php");
 
 $sort_table = 'User_auth';
 if ($sort_field == 'login') { $sort_table = 'User_list'; }
@@ -34,13 +35,21 @@ if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page
 if (!isset($f_ip)) { $f_ip=''; }
 $_SESSION[$page_url]['ip']=$f_ip;
 
+$ip_list_type_filter='';
+if ($ip_type>0) {
+    //dhcp
+    if ($ip_type===2) { $ip_list_type_filter = " and (User_auth.dhcp_action NOT IN ('arp', 'netflow')"; }
+    //static
+    if ($ip_type===1) { $ip_list_type_filter = " and (User_auth.dhcp_action IN ('arp', 'netflow')"; }
+    }
+
 $ip_where = '';
 if (!empty($f_ip)) {
     if (checkValidIp($f_ip)) { $ip_where = " and ip_int=inet_aton('" . $f_ip . "') "; }
     if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "'  "; }
     $ip_list_filter = $ip_where;
     } else {
-    $ip_list_filter = $ou_filter.$cidr_filter.$enabled_filter;
+    $ip_list_filter = $ou_filter.$cidr_filter.$enabled_filter.$ip_list_type_filter;
     }
 
 print_ip_submenu($page_url);
@@ -57,6 +66,7 @@ print_ip_submenu($page_url);
         <b><?php print WEB_cell_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
         <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office_splitted($db_link, 'cidr', $rcidr); ?>
         <b><?php echo WEB_ips_show_by_state; ?> - </b><?php print_enabled_select('enabled', $enabled); ?>
+        <b><?php echo WEB_ips_show_by_ip_type; ?> - </b><?php print_ip_type_select('ip_type', $ip_type); ?>
         <?php echo WEB_ips_search_host; ?>:&nbsp<input type="text" name="ip" value="<?php echo $f_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])|([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12})$"/>
         <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
         <input id="btn_filter" name="btn_filter" type="submit" value="<?php echo WEB_btn_show; ?>">

+ 12 - 0
html/inc/common.php

@@ -955,6 +955,18 @@ function print_enabled_select($qa_name, $qa_value)
     print "</select>\n";
 }
 
+function print_ip_type_select($qa_name, $qa_value)
+{
+    print "<select name=\"$qa_name\">\n";
+    if (!isset($qa_value) or strlen($qa_value) == 0) {
+        $qa_value = 0;
+    }
+    print_select_item(WEB_select_item_every, 0, $qa_value);
+    print_select_item(WEB_select_item_static, 1, $qa_value);
+    print_select_item(WEB_select_item_dhcp, 2, $qa_value);
+    print "</select>\n";
+}
+
 function print_vendor_select($db, $qa_name, $qa_value)
 {
     print "<select name=\"$qa_name\" class=\"js-select-single\">\n";

+ 11 - 0
html/inc/iptypefilter.php

@@ -0,0 +1,11 @@
+<?php
+if (! defined("CONFIG")) die("Not defined");
+
+if (isset($_GET['ip-type'])) { $ip_type = $_GET["ip_type"] * 1; }
+if (isset($_POST['ip-type'])) { $ip_type = $_POST["ip_type"] * 1; }
+if (!isset($ip_type)) {
+    if (isset($_SESSION[$page_url]['ip_type'])) { $ip_type = $_SESSION[$page_url]['ip_type']*1; }
+    }
+if (!isset($ip_type)) { $ip_type = 0; }
+$_SESSION[$page_url]['ip_type']=$ip_type;
+?>

+ 3 - 0
html/inc/languages/english.php

@@ -89,6 +89,8 @@ define("WEB_select_item_enabled","Enabled");
 define("WEB_select_item_wan","External");
 define("WEB_select_item_lan","Internal");
 define("WEB_select_item_all_ips","All ip");
+define("WEB_select_item_static","Static IP");
+define("WEB_select_item_dhcp","Dhcp IP");
 define("WEB_select_item_every","All");
 define("WEB_select_item_all","All");
 define("WEB_select_item_events","All events");
@@ -412,6 +414,7 @@ define("WEB_rules_target","User/Group");
 
 /* all ip list */
 define("WEB_ips_show_by_state","By activity");
+define("WEB_ips_show_by_ip_type","By ip type");
 define("WEB_ips_search_host","Search ip or mac");
 define("WEB_selection_title","Apply to Selection");
 define("WEB_ips_search_full","Search by comment/ip/mac/dhcp hostname");

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

@@ -89,6 +89,8 @@ define("WEB_select_item_enabled","Включенные");
 define("WEB_select_item_wan","Внешний");
 define("WEB_select_item_lan","Внутренний");
 define("WEB_select_item_all_ips","Всe ip");
+define("WEB_select_item_static","Static IP");
+define("WEB_select_item_dhcp","Dhcp IP");
 define("WEB_select_item_every","Все");
 define("WEB_select_item_all","Всё");
 define("WEB_select_item_events","Все события");
@@ -412,6 +414,7 @@ define("WEB_rules_target","Юзер/группа");
 
 /* all ip list */
 define("WEB_ips_show_by_state","По активности");
+define("WEB_ips_show_by_ip_type","По типу");
 define("WEB_ips_search_host","Поиск ip or mac");
 define("WEB_selection_title","Применить к выделению");
 define("WEB_ips_search_full","Поиск по комментарию/ip/mac/dhcp hostname");