瀏覽代碼

added search form for auto rules page

root 1 年之前
父節點
當前提交
cae0ec6
共有 5 個文件被更改,包括 117 次插入5 次删除
  1. 44 5
      html/admin/iplist/auto_rules.php
  2. 25 0
      html/inc/common.php
  3. 6 0
      html/inc/languages/english.php
  4. 6 0
      html/inc/languages/russian.php
  5. 36 0
      html/inc/rulesfilter.php

+ 44 - 5
html/admin/iplist/auto_rules.php

@@ -3,6 +3,7 @@ $default_displayed=50;
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/rulesfilter.php");
 
 if (isset($_POST["removeRule"])) {
     $r_id = $_POST["f_id"];
@@ -18,13 +19,49 @@ print_ip_submenu($page_url);
 <div id="cont">
 <br>
 <form name="def" action="auto_rules.php" method="post">
-<div>
-<?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?> <input type="submit" value="<?php echo WEB_btn_show; ?>">
-</div>
+
+<table>
+<tr>
+        <td>
+        <b><?php echo WEB_rules_search_target; ?> - </b><?php print_rule_target_select('rule_target', $rule_target); ?>
+        </td>
+        <td>
+        <b><?php echo WEB_rules_search_type; ?> - </b><?php print_rule_type_select('rule_type', $rule_type); ?>
+        </td>
+        <td></td>
+</tr>
+<tr>
+        <td colspan=2>
+        <?php echo WEB_ips_search; ?>:&nbsp<input type="text" name="f_rule" value="<?php echo $f_rule; ?>"/>
+        </td>
+        <td>
+        <?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; ?>">
+        </td>
+</tr>
+</table>
 
 <?php
+
+$target_filter='';
+if ($rule_target>0) {
+    if ($rule_target==1) { $target_filter = ' AND user_id>0'; }
+    if ($rule_target==2) { $target_filter = ' AND ou_id>0'; }
+    }
+
+$type_filter='';
+if ($rule_type>0) { $type_filter = ' AND `type`='.$rule_type; }
+
+$rule_filter='';
+if (!empty($f_rule)) { $rule_filter = ' AND `rule` LIKE "'.$f_rule.'%"'; }
+
+$rule_filters = '';
+if (!empty($target_filter) or !empty($type_filter) or !empty($rule_filter)) {
+    $rule_filters='WHERE 1'.$target_filter.$type_filter.$rule_filter;
+    }
+
 fix_auth_rules($db_link);
-$countSQL="SELECT Count(*) FROM auth_rules";
+$countSQL="SELECT Count(*) FROM auth_rules $rule_filters";
 $res = mysqli_query($db_link, $countSQL);
 $count_records = mysqli_fetch_array($res);
 $total=ceil($count_records[0]/$displayed);
@@ -33,6 +70,8 @@ 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>
@@ -42,7 +81,7 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeRule" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 <?php
-$t_auth_rules = get_records_sql($db_link,"SELECT * FROM auth_rules ORDER BY id LIMIT $start,$displayed");
+$t_auth_rules = get_records_sql($db_link,"SELECT * FROM auth_rules $rule_filters ORDER BY id LIMIT $start,$displayed");
 foreach ( $t_auth_rules 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";

+ 25 - 0
html/inc/common.php

@@ -1182,6 +1182,31 @@ function print_enabled_select($qa_name, $qa_value)
     print "</select>\n";
 }
 
+function print_rule_target_select($qa_name, $qa_value)
+{
+    print "<select id=\"$qa_name\" name=\"$qa_name\">\n";
+    if (!isset($qa_value) or strlen($qa_value) == 0) {
+        $qa_value = 0;
+    }
+    print_select_item('-', 0, $qa_value);
+    print_select_item(WEB_msg_IP, 1, $qa_value);
+    print_select_item(WEB_cell_ou, 2, $qa_value);
+    print "</select>\n";
+}
+
+function print_rule_type_select($qa_name, $qa_value)
+{
+    print "<select id=\"$qa_name\" name=\"$qa_name\">\n";
+    if (!isset($qa_value) or strlen($qa_value) == 0) {
+        $qa_value = 0;
+    }
+    print_select_item('-', 0, $qa_value);
+    print_select_item(WEB_rules_type_subnet, 1, $qa_value);
+    print_select_item(WEB_rules_type_mac, 2, $qa_value);
+    print_select_item(WEB_rules_type_hostname, 3, $qa_value);
+    print "</select>\n";
+}
+
 function print_yn_select($qa_name, $qa_value)
 {
     print "<select id=\"$qa_name\" name=\"$qa_name\">\n";

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

@@ -433,11 +433,17 @@ define("WEB_ou_new_rule","New rule");
 
 /* auto rules */
 define("WEB_rules_target","User/Group");
+define("WEB_rules_search_target","Rule target");
+define("WEB_rules_search_type","Rule type");
+define("WEB_rules_type_subnet","Subnet");
+define("WEB_rules_type_mac","Mac");
+define("WEB_rules_type_hostname","Hostname");
 
 /* 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,mac or comment");
+define("WEB_ips_search","Search");
 define("WEB_selection_title","Apply to Selection");
 define("WEB_ips_search_full","Search by comment/ip/mac/dhcp hostname");
 

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

@@ -433,11 +433,17 @@ define("WEB_ou_new_rule","Новое правило");
 
 /* auto rules */
 define("WEB_rules_target","Юзер/группа");
+define("WEB_rules_search_target","Назначение правила");
+define("WEB_rules_search_type","Тип правила");
+define("WEB_rules_type_subnet","Подсеть");
+define("WEB_rules_type_mac","Мак-адрес");
+define("WEB_rules_type_hostname","Имя хоста");
 
 /* all ip list */
 define("WEB_ips_show_by_state","По активности");
 define("WEB_ips_show_by_ip_type","По типу");
 define("WEB_ips_search_host","Поиск ip,mac,комментарий");
+define("WEB_ips_search","Поиск");
 define("WEB_selection_title","Применить к выделению");
 define("WEB_ips_search_full","Поиск по комментарию/ip/mac/dhcp hostname");
 

+ 36 - 0
html/inc/rulesfilter.php

@@ -0,0 +1,36 @@
+<?php
+if (! defined("CONFIG")) die("Not defined");
+
+//rule type
+if (isset($_GET['rule_type'])) { $rule_type = $_GET["rule_type"] * 1; }
+if (isset($_POST['rule_type'])) { $rule_type = $_POST["rule_type"] * 1; }
+if (!isset($rule_type)) {
+    if (isset($_SESSION[$page_url]['rule_type'])) { $rule_type = $_SESSION[$page_url]['rule_type']*1; }
+    }
+if (!isset($rule_type)) { $rule_type = 0; }
+$_SESSION[$page_url]['rule_type']=$rule_type;
+
+//rule target
+if (isset($_GET['rule_target'])) { $rule_target = $_GET["rule_target"] * 1; }
+if (isset($_POST['rule_target'])) { $rule_target = $_POST["rule_target"] * 1; }
+if (!isset($rule_target)) {
+    if (isset($_SESSION[$page_url]['rule_target'])) { $rule_target = $_SESSION[$page_url]['rule_target']*1; }
+    }
+if (!isset($rule_target)) { $rule_target = 0; }
+$_SESSION[$page_url]['rule_target']=$rule_target;
+
+//search string
+if (isset($_GET['f_rule'])) { $f_rule = htmlspecialchars(trim($_GET["f_rule"]), ENT_QUOTES, 'UTF-8'); }
+if (isset($_POST['f_rule'])) { $f_rule = htmlspecialchars(trim($_POST["f_rule"]), ENT_QUOTES, 'UTF-8'); }
+
+if (!isset($f_rule)) {
+    if (isset($_SESSION[$page_url]['f_rule'])) { $f_rule = $_SESSION[$page_url]['f_rule']; }
+    }
+
+if (!isset($f_rule)) { $f_rule = ''; }
+
+$f_rule = str_replace('%', '', $f_rule);
+
+$_SESSION[$page_url]['f_rule']=$f_rule;
+
+?>