Browse Source

export only displayed records

Roman Dmitriev 2 years ago
parent
commit
b84fd8db56
3 changed files with 22 additions and 3 deletions
  1. 2 0
      html/admin/iplist/index.php
  2. 13 0
      html/inc/common.php
  3. 7 3
      html/utils/auth_export.php

+ 2 - 0
html/admin/iplist/index.php

@@ -49,6 +49,8 @@ print_ip_submenu($page_url);
 <div id="cont">
 
 <form name="filter" action="index.php" method="post">
+<input type="hidden" name="ip-filter" value="<?php print $ip_list_filter; ?>">
+<input type="hidden" name="ip-sort" value="<?php print $sort_table.".".$sort_field." ".$order; ?>">
 <table class="data">
 	<tr>
         <td>

+ 13 - 0
html/inc/common.php

@@ -1360,6 +1360,19 @@ function get_connection($db, $auth_id)
     return $result;
 }
 
+function get_connection_string($db, $auth_id)
+{
+    $d_sql = "SELECT D.device_name, DP.port FROM devices AS D, device_ports AS DP, connections AS C WHERE D.deleted=0 and D.id = DP.device_id AND DP.id = C.port_id AND C.auth_id=$auth_id";
+    $t_device = mysqli_query($db, $d_sql);
+    list($f_name, $f_port) = mysqli_fetch_array($t_device);
+    if (isset($f_name)) {
+        $result = $f_name . "[" . $f_port . "]";
+    } else {
+        $result = '';
+    }
+    return $result;
+}
+
 function get_port($db, $port_id)
 {
     $d_sql = "SELECT D.device_name, DP.port FROM devices AS D, device_ports AS DP WHERE D.deleted=0 and D.id = DP.device_id AND DP.id = $port_id";

+ 7 - 3
html/utils/auth_export.php

@@ -13,15 +13,19 @@ if (isset($_POST["ExportAuth"])) {
             if ($val) {
                 $sSQL = "SELECT User_list.login, User_auth.ip, User_auth.mac, User_auth.comments, User_auth.dns_name, User_auth.last_found FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.id = " . $val;
                 $record = get_record_sql($db_link, $sSQL);
-                print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] . ';' . get_connection($db_link, $val)."\n";
+                print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] . ';' . get_connection_string($db_link, $val)."\n";
             }
         }
     } else {
         //export all
-        $sSQL = "SELECT User_list.login, User_auth.id, User_User_auth.ip, User_auth.mac, User_auth.comments, User_auth.dns_name, User_auth.last_found FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted = 0 ORDER BY User_auth.ip_int";
+        $ip_filter = '';
+        $sort = 'User_auth.ip_int';
+        if (!empty($_POST["ip-filter"])) { $ip_filter = $_POST['ip-filter']; }
+        if (!empty($_POST["ip-sort"])) { $sort = $_POST['ip-sort']; }
+        $sSQL = "SELECT User_auth.*, User_list.login, User_list.enabled as UEnabled, User_list.blocked as UBlocked FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted = 0 $ip_filter ORDER BY $sort";
         $auth_table = mysqli_query($db_link, $sSQL);
         while ($record = mysqli_fetch_array($auth_table)) {
-            print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] .';' . get_connection($db_link, $record['id']). "\n";
+            print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] .';' . get_connection_string($db_link, $record['id']). "\n";
         }
     }
 }