Dmitriev Roman 3 mesi fa
parent
commit
a8809cc05b
40 ha cambiato i file con 253 aggiunte e 147 eliminazioni
  1. 0 3
      docs/databases/mysql/en/create_db.sql
  2. 1 1
      docs/databases/mysql/en/data.sql
  3. 0 3
      docs/databases/mysql/ru/create_db.sql
  4. 1 1
      docs/databases/mysql/ru/data.sql
  5. 1 1
      docs/databases/postgres/en/data.sql
  6. 1 1
      docs/databases/postgres/ru/data.sql
  7. 1 1
      html/admin/customers/control-options.php
  8. 1 1
      html/admin/customers/ipcam.php
  9. 3 3
      html/admin/devices/portmactable.php
  10. 1 1
      html/admin/devices/switchport.php
  11. 1 1
      html/admin/devices/switchstatus.php
  12. 1 1
      html/admin/filters/editfilter.php
  13. 6 6
      html/admin/filters/editgroup.php
  14. 2 2
      html/admin/filters/index.php
  15. 4 4
      html/admin/iplist/deleted.php
  16. 6 6
      html/admin/iplist/doubles.php
  17. 9 6
      html/admin/iplist/index.php
  18. 3 3
      html/admin/logs/authlog.php
  19. 6 6
      html/admin/logs/detaillog.php
  20. 3 3
      html/admin/logs/dhcp.php
  21. 3 3
      html/admin/logs/index.php
  22. 3 3
      html/admin/logs/ip.php
  23. 3 3
      html/admin/logs/mac.php
  24. 3 3
      html/admin/logs/syslog.php
  25. 3 3
      html/admin/logs/unknown.php
  26. 4 4
      html/admin/reports/authday.php
  27. 2 2
      html/admin/reports/index-full.php
  28. 2 2
      html/admin/reports/index.php
  29. 6 6
      html/admin/reports/userday.php
  30. 2 2
      html/admin/reports/userdaydetail.php
  31. 6 6
      html/admin/reports/userdaydetaillog.php
  32. 3 3
      html/admin/users/edit_rules.php
  33. 7 7
      html/admin/users/editauth.php
  34. 12 6
      html/admin/users/edituser.php
  35. 1 1
      html/css/white.css
  36. 19 19
      html/inc/common.php
  37. 1 0
      html/inc/languages/english.php
  38. 1 0
      html/inc/languages/russian.php
  39. 117 16
      html/inc/sql.php
  40. 4 4
      html/public/blocked.php

+ 0 - 3
docs/databases/mysql/en/create_db.sql

@@ -6,9 +6,6 @@ SET time_zone = "+00:00";
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET NAMES utf8mb4 */;
 
-CREATE DATABASE IF NOT EXISTS `stat` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-USE `stat`;
-
 CREATE TABLE `acl` (
   `id` int(11) NOT NULL,
   `name` varchar(30) NOT NULL,

+ 1 - 1
docs/databases/mysql/en/data.sql

@@ -351,7 +351,7 @@ INSERT INTO `config` VALUES (144,37,'/opt/Eye/scripts/sync_mikrotik.pl');
 INSERT INTO `config` VALUES (145,23,'1');
 INSERT INTO `config` VALUES (148,22,'1');
 
-INSERT INTO `version` (`id`, `version`) VALUES(1, '2.9.1');
+INSERT INTO `version` (`id`, `version`) VALUES(1, '3.0.0');
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

+ 0 - 3
docs/databases/mysql/ru/create_db.sql

@@ -6,9 +6,6 @@ SET time_zone = "+00:00";
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
 /*!40101 SET NAMES utf8mb4 */;
 
-CREATE DATABASE IF NOT EXISTS `stat` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-USE `stat`;
-
 CREATE TABLE `acl` (
   `id` int(11) NOT NULL,
   `name` varchar(30) NOT NULL,

+ 1 - 1
docs/databases/mysql/ru/data.sql

@@ -351,7 +351,7 @@ INSERT INTO `config` VALUES (144,37,'/opt/Eye/scripts/sync_mikrotik.pl');
 INSERT INTO `config` VALUES (145,23,'1');
 INSERT INTO `config` VALUES (148,22,'1');
 
-INSERT INTO `version` (`id`, `version`) VALUES(1, '2.9.1');
+INSERT INTO `version` (`id`, `version`) VALUES(1, '3.0.0');
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

+ 1 - 1
docs/databases/postgres/en/data.sql

@@ -491,7 +491,7 @@ ON CONFLICT (id) DO UPDATE SET
 
 -- System version
 INSERT INTO version (id, version)
-VALUES (1, '2.9.1')
+VALUES (1, '3.0.0')
 ON CONFLICT (id) DO UPDATE SET
     version = EXCLUDED.version;
 

+ 1 - 1
docs/databases/postgres/ru/data.sql

@@ -484,7 +484,7 @@ ON CONFLICT (id) DO UPDATE SET
 
 -- System version
 INSERT INTO version (id, version)
-VALUES (1, '3.0.1')
+VALUES (1, '3.0.0')
 ON CONFLICT (id) DO UPDATE SET
     version = EXCLUDED.version;
 

+ 1 - 1
html/admin/customers/control-options.php

@@ -89,7 +89,7 @@ print_control_submenu($page_url);
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[" . $row["option_id"] . "] value='" . $row['id'] . "'></td>\n";
                 print "<td class=\"data\"><input type=\"text\" value='" . $row['option_name'] . "' disabled=true readonly=true></td>\n";
-                $type = $row['type'];
+                $type = $row['option_type'];
                 print "<td class=\"data\">";
                 $option_value = $row['value'];
                 if ($row['option_id'] == 29) {

+ 1 - 1
html/admin/customers/ipcam.php

@@ -41,7 +41,7 @@ print_ou_select($db_link, 'f_ou_id', $f_ou_id);
 print "</td>\n";
 print "</tr>\n";
 print "<tr><td colspan=3><br></td></tr>\n";
-$t_config = get_records_sql($db_link, "select id,name from building order by name");
+$t_config = get_records_sql($db_link, "select id,name from building ORDER BY name");
 foreach ($t_config as $row) {
     print "<tr align=center>\n";
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";

+ 3 - 3
html/admin/devices/portmactable.php

@@ -107,7 +107,7 @@ unset_lock_discovery($db_link,$device_id);
 </tr>
 <?php
 print "<b>".WEB_device_port_mac_table_history."</b><br>\n";
-$d_sql = "select A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.last_found from user_auth as A, connections as C where C.port_id=$port_id and A.id=C.auth_id order by A.ip_int";
+$d_sql = "select A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.last_found from user_auth as A, connections as C where C.port_id=$port_id and A.id=C.auth_id ORDER BY A.ip_int";
 $t_device = get_records_sql($db_link, $d_sql);
 if (!empty($t_device)) {
     foreach ($t_device as $row) {
@@ -121,13 +121,13 @@ if (!empty($t_device)) {
     }
 }
 
-$maclist = get_records_sql($db_link, "SELECT mac,timestamp from unknown_mac where port_id=$port_id order by timestamp desc");
+$maclist = get_records_sql($db_link, "SELECT mac,ts from unknown_mac where port_id=$port_id ORDER BY ts desc");
 if (!empty($maclist)) {
     foreach ($maclist as $row) {
         print "<tr>";
         print "<td class=\"data\">" . expand_mac($db_link,$row['mac']) . "</td>\n";
         print "<td class=\"data\">Unknown</td>\n";
-        print "<td class=\"data\">".$row['timestamp']."</td>\n";
+        print "<td class=\"data\">".$row['ts']."</td>\n";
         print "</tr>";
     }
 }

+ 1 - 1
html/admin/devices/switchport.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
 if (isset($_POST["regensnmp"])) {
     $snmp_index = $_POST["f_snmp_start"] * 1;
-    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id order by id";
+    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id ORDER BY id";
     $flist = get_records_sql($db_link, $sSQL);
     LOG_DEBUG($db_link, "Recalc snmp_index for device id: $id with start $snmp_index");
     foreach ($flist as $row) {

+ 1 - 1
html/admin/devices/switchstatus.php

@@ -9,7 +9,7 @@ $device_model = get_record($db_link, 'device_models', "id=" . $device['device_mo
 
 if (isset($_POST["regensnmp"])) {
     $snmp_index = $_POST["f_snmp_start"] * 1;
-    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id order by id";
+    $sSQL = "SELECT id,port from device_ports WHERE device_ports.device_id=$id ORDER BY id";
     $flist = get_records_sql($db_link, $sSQL);
     LOG_DEBUG($db_link, "Recalc snmp_index for device id: $id with start $snmp_index");
     foreach ($flist as $row) {

+ 1 - 1
html/admin/filters/editfilter.php

@@ -31,7 +31,7 @@ print "<br> <b>".WEB_title_filter."</b> <br>";
 print "<form name=def action='editfilter.php?id=".$id."' method=post>";
 print "<input type=hidden name=id value=$id>";
 
-if (isset($filter['type']) and $filter['type'] == 0) {
+if (isset($filter['filter_type']) and $filter['filter_type'] == 0) {
     print "<table class=\"data\" cellspacing=\"0\" cellpadding=\"4\">";
     print "<tr><td><b>".WEB_cell_forename."</b></td>";
     print "<td colspan=2><b>".WEB_cell_description."</b></td>";

+ 6 - 6
html/admin/filters/editgroup.php

@@ -14,7 +14,7 @@ if (isset($_POST["editgroup"])) {
 
 if (isset($_POST["addfilter"])) {
     $filter_id = $_POST["newfilter"] * 1;
-    $max_record = get_record_sql($db_link, "SELECT MAX(G.order) as morder FROM group_filters as G where G.group_id='$id'");
+    $max_record = get_record_sql($db_link, "SELECT MAX(G.rule_order) as morder FROM group_filters as G where G.group_id='$id'");
     if (empty($max_record)) {
         $forder = 1;
     } else {
@@ -22,7 +22,7 @@ if (isset($_POST["addfilter"])) {
     }
     $new['group_id'] = $id;
     $new['filter_id'] = $filter_id;
-    $new['order'] = $forder;
+    $new['rule_order'] = $forder;
     $new['action'] = 1;
     insert_record($db_link, "group_filters", $new);
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -47,9 +47,9 @@ if (isset($_POST["updateFilters"])) {
         for ($i = 0; $i < count($f_group_filter); ++$i) {
             $group_filter_id = $f_group_filter[$i];
             if (empty($_POST["f_ord"][$group_filter_id])) {
-                $new['order'] = $i;
+                $new['rule_order'] = $i;
             } else {
-                $new['order'] = $_POST["f_ord"][$group_filter_id] * 1;
+                $new['rule_order'] = $_POST["f_ord"][$group_filter_id] * 1;
             }
             if (empty($_POST["f_action"][$group_filter_id])) {
                 $new['action'] = 0;
@@ -107,12 +107,12 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
             </tr>
 
             <?php
-            $sSQL = "SELECT G.id, G.filter_id, F.name, G.order, G.action, F.description FROM group_filters G, filter_list F WHERE F.id=G.filter_id and group_id=$id Order by G.order";
+            $sSQL = "SELECT G.id, G.filter_id, F.name, G.rule_order, G.action, F.description FROM group_filters G, filter_list F WHERE F.id=G.filter_id and group_id=$id ORDER BY G.rule_order";
             $flist = get_records_sql($db_link, $sSQL);
             foreach ($flist as $row) {
                 print "<tr align=center>\n";
                 print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_group_filter[] value=" . $row['id'] . "></td>\n";
-                print "<td class=\"data\" align=left><input type=text name=f_ord[" . $row['id'] . "] value=" . $row['order'] . " size=4 ></td>\n";
+                print "<td class=\"data\" align=left><input type=text name=f_ord[" . $row['id'] . "] value=" . $row['rule_order'] . " size=4 ></td>\n";
                 print "<td class=\"data\" align=left><a href=editfilter.php?id=" . $row['filter_id'] . ">" . $row['name'] . "</a></td>\n";
                 $cl = "data";
                 if ($row['action']) {

+ 2 - 2
html/admin/filters/index.php

@@ -10,7 +10,7 @@ if (isset($_POST["create"])) {
     }
     if (isset($fname)) {
         $new['name'] = $fname;
-        $new['type'] = $ftype;
+        $new['filter_type'] = $ftype;
         $new_id = insert_record($db_link, "filter_list", $new);
         header("Location: editfilter.php?id=$new_id");
         exit;
@@ -69,7 +69,7 @@ print_filters_submenu($page_url);
                 if (empty($row['srcport'])) {
                     $row['srcport'] = '';
                 }
-                if ($row['type'] == 0) {
+                if ($row['filter_type'] == 0) {
                     print "<td class=\"data\">IP фильтр</td>\n";
                     print "<td class=\"data\">" . $row['proto'] . "</td>\n";
                     print "<td class=\"data\">" . $row['dst'] . "</td>\n";

+ 4 - 4
html/admin/iplist/deleted.php

@@ -66,7 +66,7 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 		<td align=Center><?php print $sort_url . "sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
 		<td align=Center><?php print WEB_cell_description; ?></td>
 		<td align=Center><?php print WEB_cell_dns_name; ?></td>
-		<td align=Center><?php print $sort_url . "sort=timestamp&order=$new_order>".WEB_cell_created."</a>"; ?></td>
+		<td align=Center><?php print $sort_url . "sort=ts&order=$new_order>".WEB_cell_created."</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "sort=changed_time&order=$new_order>".WEB_cell_deleted."</a>"; ?></td>
 		<td align=Center><?php print $sort_url . "sort=last_found&order=$new_order>".WEB_cell_last_found."</a>"; ?></td>
 	</tr>
@@ -74,13 +74,13 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 $sSQL = "SELECT 
 user_auth.id, user_auth.ip, user_auth.mac, user_auth.description, user_auth.dns_name, user_auth.dhcp_hostname, 
-user_auth.dhcp_time, user_auth.last_found, user_auth.timestamp, user_auth.changed_time
+user_auth.dhcp_time, user_auth.last_found, user_auth.ts, user_auth.changed_time
 FROM user_auth WHERE user_auth.deleted = 1 $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 (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
-    if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
+    if (empty($user['ts']) or $user['ts'] === '0000-00-00 00:00:00') { $user['ts'] = ''; }
     if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
     print "<tr align=center>\n";
     $cl = "data";
@@ -92,7 +92,7 @@ foreach ($users as $user) {
         print "<td class=\"$cl\" >".$user['description']."</td>\n";
     }
     print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-    print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
+    print "<td class=\"$cl\" >".$user['ts']."</td>\n";
     print "<td class=\"$cl\" >".$user['changed_time']."</td>\n";
     print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
     print "</tr>\n";

+ 6 - 6
html/admin/iplist/doubles.php

@@ -70,7 +70,7 @@ foreach ($users as $row) {
             $f_index++;
             $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=".$f_id);
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
-            if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
+            if (empty($user['ts']) or $user['ts'] === '0000-00-00 00:00:00') { $user['ts'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
             print "<tr align=center>\n";
             $cl = "data";
@@ -86,8 +86,8 @@ foreach ($users as $row) {
                 print "<td class=\"$cl\" >".$user['description']."</td>\n";
                 }
             print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-            print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
-            print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
+            print "<td class=\"$cl\" >".$user['ts']."</td>\n";
+            print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
             print "</tr>\n";
             $printed[$f_id] = 1;
             }
@@ -96,7 +96,7 @@ foreach ($users as $row) {
             $f_index++;
             $user = get_record_sql($db_link,"SELECT * FROM user_auth WHERE id=".$row['id']);
             if (empty($user['arp_found']) or $user['arp_found'] === '0000-00-00 00:00:00') { $user['arp_found'] = ''; }
-            if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
+            if (empty($user['ts']) or $user['ts'] === '0000-00-00 00:00:00') { $user['ts'] = ''; }
             if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
             print "<tr align=center>\n";
             $cl = "data";
@@ -112,8 +112,8 @@ foreach ($users as $row) {
                 print "<td class=\"$cl\" >".$user['description']."</td>\n";
                 }
             print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
-            print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
-            print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
+            print "<td class=\"$cl\" >".$user['ts']."</td>\n";
+            print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
             print "</tr>\n";
             $printed[$row['id']] = 1;
             }

+ 9 - 6
html/admin/iplist/index.php

@@ -256,12 +256,15 @@ foreach ($users as $user) {
     print_td_qa($user['save_traf'],FALSE,$cl);
     print_td_qa($user['dhcp'],FALSE,$cl);
     print "<td class=\"$cl\" >".$user['dhcp_acl']."</td>\n";
-    if (empty($user['arp_found'])) {
-//        print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
-        print "<td class=\"$cl\" >-</td>\n";
-        } else {
-        print "<td class=\"$cl\" >".$user['arp_found']."</td>\n";
-        }
+    print "<td class=\"$cl\" >";
+    if (!empty($user['arp_found'])) {
+        print $user['arp_found'];
+        } else { print "-"; }
+    print "&nbsp/&nbsp";
+    if (!empty($user['mac_found'])) {
+        print $user['mac_found'];
+        } else { print "-"; }
+    print "</td>\n";
     print "<td class=\"$cl\" >" . get_connection($db_link, $user['id']) . "</td>\n";
     print "</tr>\n";
 }

+ 3 - 3
html/admin/logs/authlog.php

@@ -33,7 +33,7 @@ if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; }
 if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
 if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
 
-$countSQL="SELECT Count(*) FROM worklog WHERE timestamp>='$date1' AND timestamp<'$date2' $log_filter";
+$countSQL="SELECT Count(*) FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -51,11 +51,11 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 	</tr>
 <?php
 #speedup paging
-$sSQL = "SELECT timestamp,customer,message,level FROM worklog as S JOIN (SELECT id FROM worklog WHERE timestamp>='$date1' AND timestamp<'$date2' $log_filter ORDER BY id DESC LIMIT $start,$displayed) AS I ON S.id = I.id";
+$sSQL = "SELECT ts,customer,message,level FROM worklog as S JOIN (SELECT id FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter ORDER BY id DESC LIMIT $start,$displayed) AS I ON S.id = I.id";
 $userlog = get_records_sql($db_link, $sSQL);
 foreach ($userlog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $row['customer'] . "</td>\n";
     $msg_level = 'INFO';
     if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }

+ 6 - 6
html/admin/logs/detaillog.php

@@ -59,7 +59,7 @@ if (!empty($f_ip)) { $sort_url .='&f_ip="'.$f_ip.'"'; }
 $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 
-$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where timestamp>='$date1' AND timestamp<'$date2'";
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where ts>='$date1' AND ts<'$date2'";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -74,7 +74,7 @@ $gateway_list = get_gateways($db_link);
 <tr align="center">
 <td class="data" width=20><b><?php $url = $sort_url.'&sort=id&order='.$new_order."'>id</a>"; print $url; ?></b></td>
 <td class="data" width=20><b><?php echo WEB_cell_login; ?></b></td>
-<td class="data" width=150><b><?php $url = $sort_url.'&sort=timestamp&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
+<td class="data" width=150><b><?php $url = $sort_url.'&sort=ts&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_cell_gateway; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_traffic_proto; ?></b></td>
 <td class="data" width=150><b><?php $url = $sort_url.'&sort=src_ip&order='.$new_order."'>".WEB_traffic_source_address."</a>"; print $url; ?></b></td>
@@ -87,15 +87,15 @@ $gateway_list = get_gateways($db_link);
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>Pkt</a>"; print $url; ?></b></td>
 </tr>
 <?php
-$fsql = "SELECT A.id, A.auth_id, A.timestamp, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
-        WHERE $gateway_filter $ip_where timestamp>='$date1' AND timestamp<'$date2'
-        ORDER BY timestamp ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
+$fsql = "SELECT A.id, A.auth_id, A.ts, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
+        WHERE $gateway_filter $ip_where ts>='$date1' AND ts<'$date2'
+        ORDER BY ts ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
 $userdata = get_records_sql($db_link, $fsql);
 foreach ($userdata as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<td class=\"data\">" . $row['id'] . "</td>\n";
     print "<td class=\"data\">"; print_auth_simple($db_link, $row['auth_id']); print "</td>\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $gateway_list[$row['router_id']] . "</td>\n";
     $proto_name = getprotobynumber($row['proto']);
     if (!$proto_name) { $proto_name = $row['proto']; }

+ 3 - 3
html/admin/logs/dhcp.php

@@ -56,7 +56,7 @@ print_log_submenu($page_url);
 </form>
 
 <?php
-$countSQL="SELECT Count(*) FROM dhcp_log WHERE timestamp>='$date1' AND timestamp<'$date2' $dhcp_where";
+$countSQL="SELECT Count(*) FROM dhcp_log WHERE ts>='$date1' AND ts<'$date2' $dhcp_where";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -77,7 +77,7 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 <?php
 
 #speedup dhcp log paging
-$sSQL = "SELECT * FROM dhcp_log as D JOIN (SELECT id FROM dhcp_log WHERE timestamp>='$date1' and timestamp<'$date2' $dhcp_where ORDER BY id DESC LIMIT $start,$displayed) AS I ON D.id = I.id";
+$sSQL = "SELECT * FROM dhcp_log as D JOIN (SELECT id FROM dhcp_log WHERE ts>='$date1' and ts<'$date2' $dhcp_where ORDER BY id DESC LIMIT $start,$displayed) AS I ON D.id = I.id";
 $userlog = get_records_sql($db_link, $sSQL);
 
 foreach ($userlog as $row) {
@@ -86,7 +86,7 @@ foreach ($userlog as $row) {
     if ($row['action'] == "del") { $row['action'] = WEB_log_dhcp_del.": "; }
     $l_msg = $row['action'] . " " . $row['mac'] . " " . $row['ip'];
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $row['action'] . "</td>\n";
     print "<td class=\"data\">" . $row['mac'] . "</td>\n";
     if (isset($row['auth_id']) and $row['auth_id'] > 0) {

+ 3 - 3
html/admin/logs/index.php

@@ -39,7 +39,7 @@ if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '".$fcus
 if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '".$fmessage."'"; }
 if (!empty($fuser_ip)) { $log_filter = $log_filter." and ip LIKE '".$fuser_ip."'"; }
 
-$countSQL="SELECT Count(*) FROM worklog WHERE timestamp>='$date1' AND timestamp<'$date2' $log_filter";
+$countSQL="SELECT Count(*) FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -48,7 +48,7 @@ $start = ($page * $displayed) - $displayed;
 print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 #speedup paging
-$sSQL = "SELECT * FROM (SELECT * FROM worklog WHERE timestamp>='$date1' AND timestamp<'$date2' $log_filter ) AS W ORDER BY timestamp DESC LIMIT $start,$displayed";
+$sSQL = "SELECT * FROM (SELECT * FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter ) AS W ORDER BY ts DESC LIMIT $start,$displayed";
 
 ?>
 <br>
@@ -66,7 +66,7 @@ $sSQL = "SELECT * FROM (SELECT * FROM worklog WHERE timestamp>='$date1' AND time
 $userlog = get_records_sql($db_link, $sSQL);
 foreach ($userlog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $row['customer'] . "</td>\n";
     $msg_level = 'INFO';
     if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }

+ 3 - 3
html/admin/logs/ip.php

@@ -31,7 +31,7 @@ if (!empty($f_ip)) {
 </form>
 
 <?php
-$countSQL="SELECT Count(*) FROM user_auth WHERE timestamp>='$date1' AND timestamp<'$date2' $ip_where";
+$countSQL="SELECT Count(*) FROM user_auth WHERE ts>='$date1' AND ts<'$date2' $ip_where";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -53,13 +53,13 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 <?php
 
-$sSQL = "SELECT * FROM user_auth WHERE timestamp>='$date1' AND timestamp<'$date2' $ip_where ORDER BY id DESC LIMIT $start,$displayed";
+$sSQL = "SELECT * FROM user_auth WHERE ts>='$date1' AND ts<'$date2' $ip_where ORDER BY id DESC LIMIT $start,$displayed";
 
 $iplog = get_records_sql($db_link, $sSQL);
 foreach ($iplog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<td class=\"data\">" . $row['id'] . "</td>\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $row['last_found'] . "</td>\n";
     if (isset($row['id']) and $row['id'] > 0) {
         print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['id'].">" . $row['ip'] . "</a></td>\n";

+ 3 - 3
html/admin/logs/mac.php

@@ -27,7 +27,7 @@ print_log_submenu($page_url);
 </form>
 
 <?php
-$countSQL="SELECT Count(*) FROM mac_history WHERE timestamp>='$date1' AND timestamp<'$date2' $mac_where ORDER BY id DESC";
+$countSQL="SELECT Count(*) FROM mac_history WHERE ts>='$date1' AND ts<'$date2' $mac_where ORDER BY id DESC";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -46,12 +46,12 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 
 <?php
 
-$sSQL = "SELECT * FROM mac_history WHERE timestamp>='$date1' AND timestamp<'$date2' $mac_where ORDER BY timestamp DESC LIMIT $start,$displayed";
+$sSQL = "SELECT * FROM mac_history WHERE ts>='$date1' AND ts<'$date2' $mac_where ORDER BY ts DESC LIMIT $start,$displayed";
 $maclog = get_records_sql($db_link, $sSQL);
 
 foreach ($maclog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . expand_mac($db_link,mac_dotted($row['mac'])) . "</td>\n";
     print "<td class=\"data\">" . get_port($db_link, $row['port_id']) . "</td>\n";
     if (isset($row['auth_id']) and $row['auth_id'] > 0) {

+ 3 - 3
html/admin/logs/syslog.php

@@ -42,7 +42,7 @@ if ($f_id>0) {
 
 if (!empty($fmessage)) { $log_filter .= " AND message LIKE '%" . addslashes($fmessage) . "%'"; }
 
-$countSQL="SELECT Count(*) FROM remote_syslog WHERE date>='$date1' AND date<'$date2' $log_filter";
+$countSQL="SELECT Count(*) FROM remote_syslog WHERE ts>='$date1' AND ts<'$date2' $log_filter";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -50,7 +50,7 @@ if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed; 
 print_navigation($page_url,$page,$displayed,$count_records,$total);
 #speedup pageing
-$sSQL = "SELECT * FROM (SELECT * FROM remote_syslog WHERE date>='$date1' AND date<'$date2' $log_filter) as R ORDER BY date DESC LIMIT $start,$displayed";
+$sSQL = "SELECT * FROM (SELECT * FROM remote_syslog WHERE ts>='$date1' AND ts<'$date2' $log_filter) as R ORDER BY ts DESC LIMIT $start,$displayed";
 ?>
 
 <br>
@@ -68,7 +68,7 @@ $syslog = get_records_sql($db_link, $sSQL);
 if (!empty($syslog)) {
     foreach ($syslog as $row) {
         print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-        print "<td class=\"data\">" . $row['date'] . "</td>\n";
+        print "<td class=\"data\">" . $row['ts'] . "</td>\n";
         print "<td class=\"data\">" . $row['ip'] . "</td>\n";
         print "<td class=\"data\">" . $row['message'] . "</td>\n";
         print "</tr>\n";

+ 3 - 3
html/admin/logs/unknown.php

@@ -25,7 +25,7 @@ if ($f_id > 0) { $where_dev = " and D.id=$f_id "; }
 </form>
 
 <?php
-$countSQL="SELECT Count(*) FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev";
+$countSQL="SELECT Count(*) FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.ts>='$date1' AND U.ts<'$date2' $where_dev";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -43,14 +43,14 @@ print_navigation($page_url,$page,$displayed,$count_records,$total);
 </tr>
 <?php
 
-$sSQL = "SELECT U.mac, U.timestamp, DP.port, D.device_name FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.timestamp>='$date1' AND U.timestamp<'$date2' $where_dev ORDER BY U.mac LIMIT $start,$displayed";
+$sSQL = "SELECT U.mac, U.ts, DP.port, D.device_name FROM unknown_mac AS U, devices AS D, device_ports AS DP  WHERE D.device_type<=2 and U.device_id = D.id  AND U.port_id = DP.id AND U.ts>='$date1' AND U.ts<'$date2' $where_dev ORDER BY U.mac LIMIT $start,$displayed";
 $maclog = get_records_sql($db_link, $sSQL);
 foreach ($maclog as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
     print "<td class=\"data\">" . $row['device_name'] . "</td>\n";
     print "<td class=\"data\">" . $row['port'] . "</td>\n";
     print "<td class=\"data\"><a href=/admin/logs/mac.php?mac=" . mac_simplify($row['mac']) . ">" . mac_dotted($row['mac']) . "</a></td>\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "</tr>\n";
 }
 print "</table>\n";

+ 4 - 4
html/admin/reports/authday.php

@@ -53,14 +53,14 @@ if ($days_shift >1 and $days_shift <=30) { $display_date_format='%Y-%m-%d'; }
 if ($days_shift >30 and $days_shift <=730) { $display_date_format='%Y-%m'; }
 if ($days_shift >730) { $display_date_format='%Y'; }
 
-$sSQL = "SELECT router_id, DATE_FORMAT(timestamp,'$display_date_format') as tHour, 
+$sSQL = "SELECT router_id, DATE_FORMAT(ts,'$display_date_format') as tHour, 
          SUM(byte_in) as byte_in_sum, SUM(byte_out) as byte_out_sum,
          MAX(ROUND(pkt_in/step)) as pkt_in_max, MAX(ROUND(pkt_out/step)) as pkt_out_max
-         FROM user_stats_full WHERE timestamp>='$date1' AND timestamp<'$date2' AND auth_id=$id";
+         FROM user_stats_full WHERE ts>='$date1' AND ts<'$date2' AND auth_id=$id";
 if ($rgateway == 0) {
-    $sSQL = $sSQL . " GROUP BY DATE_FORMAT(timestamp,'$display_date_format'),router_id ORDER BY tHour,router_id";
+    $sSQL = $sSQL . " GROUP BY DATE_FORMAT(ts,'$display_date_format'),router_id ORDER BY tHour,router_id";
 } else {
-    $sSQL = $sSQL . " AND router_id=$rgateway GROUP BY DATE_FORMAT(timestamp,'$display_date_format'),router_id ORDER BY tHour";
+    $sSQL = $sSQL . " AND router_id=$rgateway GROUP BY DATE_FORMAT(ts,'$display_date_format'),router_id ORDER BY tHour";
 }
 
 $userdata = get_records_sql($db_link, $sSQL);

+ 2 - 2
html/admin/reports/index-full.php

@@ -35,8 +35,8 @@ user_list.login,user_list.ou_id,user_auth.user_id, user_auth.ip, user_stats_full
 user_stats_full.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout, MAX(ROUND(pkt_in/step)) as pin, MAX(ROUND(pkt_out/step)) as pout 
 FROM user_stats_full,user_auth,user_list WHERE user_list.id=user_auth.user_id 
 AND user_stats_full.auth_id = user_auth.id 
-AND user_stats_full.timestamp>='$date1' 
-AND user_stats_full.timestamp<'$date2' 
+AND user_stats_full.ts>='$date1' 
+AND user_stats_full.ts<'$date2' 
 ";
 
 if ($rou !== 0) {

+ 2 - 2
html/admin/reports/index.php

@@ -43,8 +43,8 @@ user_list.login,user_list.ou_id,user_auth.user_id, user_stats.auth_id,
 user_stats.router_id, SUM( byte_in ) AS tin, SUM( byte_out ) AS tout 
 FROM user_stats,user_auth,user_list WHERE user_list.id=user_auth.user_id 
 AND user_stats.auth_id = user_auth.id 
-AND user_stats.timestamp>='$date1' 
-AND user_stats.timestamp<'$date2' 
+AND user_stats.ts>='$date1' 
+AND user_stats.ts<'$date2' 
 ";
 
 if ($rou !== 0) { $trafSQL = $trafSQL . " AND user_list.ou_id=$rou"; }

+ 6 - 6
html/admin/reports/userday.php

@@ -37,7 +37,7 @@ $gateway_list = get_gateways($db_link);
 $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(user_stats.router_id=$rgateway) AND"; }
 
-$sSQL = "SELECT id,ip,description FROM user_auth WHERE (user_auth.user_id=$id) Order by IP";
+$sSQL = "SELECT id,ip,description FROM user_auth WHERE (user_auth.user_id=$id) ORDER BY IP";
 $usersip = get_records_sql($db_link, $sSQL);
 
 $ipcount = 0;
@@ -50,7 +50,7 @@ foreach ($usersip as $row) {
     $fcomm = $row["description"];
 
     $sSQL = "SELECT SUM(byte_in)+SUM(byte_out) as t_sum FROM user_stats 
-    WHERE $gateway_filter user_stats.timestamp>='$date1' AND user_stats.timestamp<'$date2'AND auth_id=$fid";
+    WHERE $gateway_filter user_stats.ts>='$date1' AND user_stats.ts<'$date2'AND auth_id=$fid";
 
     $day_summary = get_record_sql($db_link, $sSQL);
     if (!empty($day_summary)) { $summ = $day_summary['t_sum']; } else { $summ = 0; }
@@ -70,16 +70,16 @@ foreach ($usersip as $row) {
         if ($days_shift >30 and $days_shift <=730) { $display_date_format='%Y-%m'; }
         if ($days_shift >730) { $display_date_format='%Y'; }
 
-        $sSQL = "SELECT user_stats.router_id, DATE_FORMAT(user_stats.timestamp,'$display_date_format') as tHour,
+        $sSQL = "SELECT user_stats.router_id, DATE_FORMAT(user_stats.ts,'$display_date_format') as tHour,
                 SUM(byte_in) as byte_in_sum, SUM(byte_out) as byte_out_sum 
                 FROM user_stats 
-                WHERE user_stats.timestamp>='$date1' AND user_stats.timestamp<'$date2' and auth_id=$fid";
+                WHERE user_stats.ts>='$date1' AND user_stats.ts<'$date2' and auth_id=$fid";
         if ($rgateway == 0) {
-            $sSQL = $sSQL . " GROUP BY DATE_FORMAT(user_stats.timestamp,'$display_date_format'),user_stats.router_id 
+            $sSQL = $sSQL . " GROUP BY DATE_FORMAT(user_stats.ts,'$display_date_format'),user_stats.router_id 
             ORDER BY tHour,user_stats.router_id";
         } else {
             $sSQL = $sSQL . " and user_stats.router_id=$rgateway 
-            GROUP BY DATE_FORMAT(user_stats.timestamp,'$display_date_format'),user_stats.router_id 
+            GROUP BY DATE_FORMAT(user_stats.ts,'$display_date_format'),user_stats.router_id 
             ORDER BY tHour";
         }
 

+ 2 - 2
html/admin/reports/userdaydetail.php

@@ -52,7 +52,7 @@ $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 
 $fsql = "SELECT A.proto, A.src_ip, A.src_port, SUM(A.bytes) as tin FROM traffic_detail A
-            WHERE $gateway_filter (auth_id='$id') and  timestamp>='$date1' and timestamp<'$date2' and (A.dst_ip='$ip_aton')
+            WHERE $gateway_filter (auth_id='$id') and  ts>='$date1' and ts<'$date2' and (A.dst_ip='$ip_aton')
             GROUP BY A.src_ip, A.src_port, A.proto ORDER BY tin DESC LIMIT 0,10";
 $userdata = get_records_sql($db_link, $fsql);
 foreach ($userdata as $row) {
@@ -82,7 +82,7 @@ foreach ($userdata as $row) {
 </tr>
 <?php
 $fsql = "SELECT A.proto, A.dst_ip, A.dst_port, SUM(A.bytes) as tout FROM traffic_detail A
-        WHERE $gateway_filter (auth_id='$id') and  timestamp>='$date1' and timestamp<'$date2' and (A.src_ip='$ip_aton')
+        WHERE $gateway_filter (auth_id='$id') and  ts>='$date1' and ts<'$date2' and (A.src_ip='$ip_aton')
         GROUP BY A.dst_ip, A.dst_port, A.proto ORDER BY tout DESC LIMIT 0,10";
 $userdata = get_records_sql($db_link, $fsql);
 foreach ($userdata as $row) {

+ 6 - 6
html/admin/reports/userdaydetaillog.php

@@ -51,7 +51,7 @@ $gateway_filter='';
 if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=$rgateway) AND"; }
 if (!empty($search)) { $gateway_filter.=' (src_ip='.ip2long($search).' OR dst_ip='.ip2long($search).') AND'; }
 
-$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter (auth_id='$id') and timestamp>='$date1' and timestamp<'$date2'";
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter (auth_id='$id') and ts>='$date1' and ts<'$date2'";
 $count_records = get_single_field($db_link,$countSQL);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
@@ -64,7 +64,7 @@ $gateway_list = get_gateways($db_link);
 <br>
 <table class="data">
 <tr align="center">
-<td class="data" width=150><b><?php $url = $sort_url.'&sort=timestamp&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
+<td class="data" width=150><b><?php $url = $sort_url.'&sort=ts&order='.$new_order."'>".WEB_date."</a>"; print $url; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_cell_gateway; ?></b></td>
 <td class="data" width=30><b><?php echo WEB_traffic_proto; ?></b></td>
 <td class="data" width=150><b><?php $url = $sort_url.'&sort=src_ip&order='.$new_order."'>".WEB_traffic_source_address."</a>"; print $url; ?></b></td>
@@ -77,13 +77,13 @@ $gateway_list = get_gateways($db_link);
 <td class="data" width=80><b><?php $url = $sort_url.'&sort=pkt&order='.$new_order."'>".WEB_pkts."</a>"; print $url; ?></b></td>
 </tr>
 <?php
-$fsql = "SELECT A.id, A.timestamp, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
-        WHERE $gateway_filter (auth_id='$id') and  timestamp>='$date1' and timestamp<'$date2'
-        ORDER BY timestamp ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
+$fsql = "SELECT A.id, A.ts, A.router_id, A.proto, A.src_ip, A.src_port, A.dst_ip, A.dst_port, A.bytes, A.pkt FROM traffic_detail as A JOIN (SELECT id FROM traffic_detail 
+        WHERE $gateway_filter (auth_id='$id') and  ts>='$date1' and ts<'$date2'
+        ORDER BY ts ASC LIMIT $start,$displayed) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
 $userdata = get_records_sql($db_link, $fsql);
 foreach ($userdata as $row) {
     print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
-    print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
+    print "<td class=\"data\">" . $row['ts'] . "</td>\n";
     print "<td class=\"data\">" . $gateway_list[$row['router_id']] . "</td>\n";
     $proto_name = getprotobynumber($row['proto']);
     if (!$proto_name) { $proto_name = $row['proto']; }

+ 3 - 3
html/admin/users/edit_rules.php

@@ -28,10 +28,10 @@ if (isset($_POST['s_save'])) {
         $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
         for ($j = 0; $j < $len_all; $j ++) {
             if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
-            $new['type'] = $_POST['s_type'][$j]*1;
+            $new['rule_type'] = $_POST['s_type'][$j]*1;
             $new['rule'] = trim($_POST['s_rule'][$j]);
             $new['description'] = trim($_POST['s_description'][$j]);
-            if ($new['type'] ==2) {
+            if ($new['rule_type'] ==2) {
                 $new['rule'] = mac_dotted($new['rule']);
                 }
 	    update_auth_rule($db_link,$new,$save_id);
@@ -79,7 +79,7 @@ foreach ( $t_auth_rules as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
     print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
-    print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['type']}"); print "</td>\n";
+    print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['rule_type']}"); print "</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='s_rule[]' value='{$row['rule']}'></td>\n";
     print "<td class=\"data\"><input type=\"text\" name='s_description[]' value='{$row['description']}'></td>\n";
     print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";

+ 7 - 7
html/admin/users/editauth.php

@@ -184,8 +184,8 @@ if (isset($_POST["moveauth"]) and !$old_auth_info['deleted']) {
     $changes = apply_auth_rule($db_link, $moved_auth, $new_parent_id);
     update_record($db_link, "user_auth", "id='$id'", $changes);
     LOG_WARNING($db_link, "IP-address moved to another user! Applyed: " . get_rec_str($changes), $id);
-    run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["mac"]."' AND type=2");
-    run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["ip"]."' AND type=1");
+    run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["mac"]."' AND rule_type=2");
+    run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$old_auth_info["user_id"]." AND rule='".$old_auth_info["ip"]."' AND rule_type=1");
     LOG_INFO($db_link,"Autorules removed for user_id: ".$old_auth_info["user_id"]." login: ".$user_info["login"]." by mac and ip");
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
@@ -294,11 +294,11 @@ if ($auth_info['dhcp_time'] == '0000-00-00 00:00:00') {
     $dhcp_str = $auth_info['dhcp_time'] . " (" . $auth_info['dhcp_action'] . ")";
 }
 if ($auth_info['last_found'] == '0000-00-00 00:00:00') { $auth_info['last_found'] = ''; }
-
+if ($auth_info['mac_found'] == '0000-00-00 00:00:00') { $auth_info['mac_found'] = ''; }
 if ($auth_info['arp_found'] == '0000-00-00 00:00:00') { $auth_info['arp_found'] = ''; }
 
 $now = DateTime::createFromFormat("Y-m-d H:i:s",date('Y-m-d H:i:s'));
-$created = DateTime::createFromFormat("Y-m-d H:i:s",$auth_info['timestamp']);
+$created = DateTime::createFromFormat("Y-m-d H:i:s",$auth_info['ts']);
 
 if (empty($auth_info['end_life']) or $auth_info['end_life'] == '0000-00-00 00:00:00') { 
     $now->modify('+1 day');
@@ -456,7 +456,7 @@ if (empty($auth_info['end_life']) or $auth_info['end_life'] == '0000-00-00 00:00
             </tr>
             <tr>
                 <td><?php print WEB_cell_created; ?></td>
-                <td class="data" align=right><?php print $auth_info['timestamp']; ?></td>
+                <td class="data" align=right><?php print $auth_info['ts']; ?></td>
                 <td><?php print WEB_cell_connection . ": "; ?></td>
                 <td class="data" align=right><?php print get_connection($db_link, $id) ; ?></td>
             </tr>
@@ -469,8 +469,8 @@ if (empty($auth_info['end_life']) or $auth_info['end_life'] == '0000-00-00 00:00
             <tr>
                 <td ><?php print WEB_cell_arp_found . ": "; ?></td>
                 <td class="data" align=right><?php print $auth_info['arp_found'] ; ?></td>
-                <td ><?php print WEB_cell_last_found . ": "; ?></td>
-                <td class="data" align=right><?php print $auth_info['last_found'] ; ?></td>
+                <td ><?php print WEB_cell_mac_found . ": "; ?></td>
+                <td class="data" align=right><?php print $auth_info['mac_found'] ; ?></td>
             </tr>
             <tr>
             </tr>

+ 12 - 6
html/admin/users/edituser.php

@@ -325,7 +325,7 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
                 }
                 ?>
                 <td colspan=3 align=right><?php print WEB_cell_created . ":&nbsp";
-                                            print $user_info["timestamp"]; ?></td>
+                                            print $user_info["ts"]; ?></td>
             </tr>
             <tr>
                 <?php print "<td colspan=2>";
@@ -383,15 +383,21 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
                     if ($row["last_found"] == '0000-00-00 00:00:00') {
                         $row["last_found"] = '';
                     }
+                    if ($row["mac_found"] == '0000-00-00 00:00:00') {
+                        $row["mac_found"] = '';
+                    }
+                    if ($row["arp_found"] == '0000-00-00 00:00:00') {
+                        $row["arp_found"] = '';
+                    }
                     print "<tr align=center>";
                     print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=" . $row["id"] . " ></td>";
 
                     print "<td class=\"data\" align=left><a href=editauth.php?id=" . $row["id"] . ">" . $row["ip"] . "</a>";
-                    if (!empty($row["arp_found"])) { print "<p class='timestamp'>".FormatDateStr('Y.m.d H:i', $row["arp_found"])."</p>"; }
+                    if (!empty($row["arp_found"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["arp_found"])."</p>"; }
                     print "</td>";
 
                     print "<td class=\"data\" >" . expand_mac($db_link, $row["mac"]);
-                    if (!empty($row["last_found"])) { print "<p class='timestamp'>".FormatDateStr('Y.m.d H:i', $row["last_found"])."</p>"; }
+                    if (!empty($row["mac_found"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["mac_found"])."</p>"; }
                     print "</td>";
 
                     if (isset($row["dhcp_hostname"]) and strlen($row["dhcp_hostname"]) > 0) {
@@ -415,13 +421,13 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
                     if (!$row["dhcp"]) { $cl = "data_red"; }
                     print "<td class=\"$cl\" >" . get_qa($row["dhcp"]);
                     if (!empty($row["dhcp_acl"]) or !empty($row["dhcp_option_set"])) {
-                            print "<p class='timestamp'>";
+                            print "<p class='ts'>";
                             if (!empty($row["dhcp_acl"])) { print $row["dhcp_acl"]; }
                             if (!empty($row["dhcp_acl"]) and !empty($row["dhcp_option_set"])) { print "&nbsp/&nbsp"; }
                             if (!empty($row["dhcp_option_set"])) { print $row["dhcp_option_set"]; }
                             print "</p>";
                             }
-                    if (!empty($dhcp_str)) { print "<p class='timestamp'>".$dhcp_str. "</p>"; }
+                    if (!empty($dhcp_str)) { print "<p class='ts'>".$dhcp_str. "</p>"; }
                     print "</td>";
 
                     print "<td class=\"data\" >" . get_group($db_link, $row["filter_group_id"]) . "</td>";
@@ -430,7 +436,7 @@ require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php");
 
                     if ($row['dynamic']) { $cl = "data_red"; } else { $cl = "data_green"; }
                     print "<td class=\"$cl\" >". get_qa($row['dynamic']);
-                    if ($row['dynamic'] and !empty($row["end_life"])) { print "<p class='timestamp'>".FormatDateStr('Y.m.d H:i', $row["end_life"])."</p>"; } else { print "&nbsp"; }
+                    if ($row['dynamic'] and !empty($row["end_life"])) { print "<p class='ts'>".FormatDateStr('Y.m.d H:i', $row["end_life"])."</p>"; } else { print "&nbsp"; }
                     print "</td>";
 
                     print "<td class=\"data\" >";

+ 1 - 1
html/css/white.css

@@ -5,7 +5,7 @@ img                             { border: 0; }
 label                           { float:left; padding-right:10px; }
 .main                           { float:left }
 
-.timestamp                      { font-size: 10pt; color: #4169E1; padding: 1px; }
+.ts                             { font-size: 10pt; color: #4169E1; padding: 1px; }
 hr                              { border: none; border-top: 1px solid #000; margin: 0 0; }
 
 table                           { font-family: tahoma; font-size: 12pt; border-spacing: 1px; }

+ 19 - 19
html/inc/common.php

@@ -1172,7 +1172,7 @@ function print_device_model_select($db, $device_model_name, $device_model_value)
 function print_filter_group_select($db, $group_name, $group_value)
 {
     print "<select id=\"$group_name\" name=\"$group_name\">\n";
-    $t_group = get_records_sql($db, "SELECT id,group_name FROM group_list Order by group_name");
+    $t_group = get_records_sql($db, "SELECT id,group_name FROM group_list ORDER BY group_name");
     foreach ($t_group as $row) {
         print_select_item($row['group_name'], $row['id'], $group_value);
     }
@@ -1183,7 +1183,7 @@ function print_building_select($db, $building_name, $building_value)
 {
     print "<select id=\"$building_name\" name=\"$building_name\">\n";
     print_select_item(WEB_select_item_all, 0, $building_value);
-    $t_building = get_records_sql($db, "SELECT id,name FROM building Order by name");
+    $t_building = get_records_sql($db, "SELECT id,name FROM building ORDER BY name");
     foreach ($t_building as $row) {
         print_select_item($row['name'], $row['id'], $building_value);
     }
@@ -1326,7 +1326,7 @@ function get_gw_subnets($db, $device_id)
 function print_queue_select($db, $queue_name, $queue_value)
 {
     print "<select id=\"$queue_name\" name=\"$queue_name\">\n";
-    $t_queue = get_records_sql($db, "SELECT id,queue_name FROM queue_list Order by queue_name");
+    $t_queue = get_records_sql($db, "SELECT id,queue_name FROM queue_list ORDER BY queue_name");
     foreach ($t_queue as $row) {
         print_select_item($row['queue_name'], $row['id'], $queue_value);
     }
@@ -1624,7 +1624,7 @@ function print_ip_type_select($qa_name, $qa_value)
 function print_vendor_select($db, $qa_name, $qa_value)
 {
     print "<select id=\"$qa_name\" name=\"$qa_name\"  style=\"width: 100%\">\n";
-    $sSQL = "SELECT id,name FROM vendors order by name";
+    $sSQL = "SELECT id,name FROM vendors ORDER BY name";
     $vendors = get_records_sql($db, $sSQL);
     print_select_item(WEB_select_item_all, 0, $qa_value);
     foreach ($vendors as $row) {
@@ -1636,7 +1636,7 @@ function print_vendor_select($db, $qa_name, $qa_value)
 function print_vendor_set($db, $qa_name, $qa_value)
 {
     print "<select id=\"$qa_name\" name=\"$qa_name\" style=\"width: 100%\">\n";
-    $sSQL = "SELECT id,name FROM vendors order by name";
+    $sSQL = "SELECT id,name FROM vendors ORDER BY name";
     $vendors = get_records_sql($db, $sSQL);
     foreach ($vendors as $row) {
         print_select_item($row['name'], $row['id'], $qa_value);
@@ -1711,7 +1711,7 @@ function print_filter_select($db, $filter_name, $group_id)
     if (isset($group_id)) {
         $sSQL = "SELECT id,name FROM filter_list WHERE filter_list.id not in (Select filter_id FROM group_filters WHERE group_id=$group_id)";
     } else {
-        $sSQL = "SELECT id,name FROM filter_list Order by name";
+        $sSQL = "SELECT id,name FROM filter_list ORDER BY name";
     }
 
     $t_filters = get_records_sql($db, $sSQL);
@@ -1745,7 +1745,7 @@ function get_auth_count($db, $user_id)
 function print_login_select($db, $login_name, $current_login)
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT id,login FROM user_list Order by Login");
+    $t_login = get_records_sql($db, "SELECT id,login FROM user_list ORDER BY Login");
     print_select_item('None', 0, $current_login);
     foreach ($t_login as $row) {
         print_select_item($row['login'], $row['id'], $current_login);
@@ -1756,7 +1756,7 @@ function print_login_select($db, $login_name, $current_login)
 function print_auth_select($db, $login_name, $current_auth)
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
+    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) ORDER BY U.login,U.fio,A.ip");
     print_select_item('Empty', 0, $current_auth);
     foreach ($t_login as $row) {
         print_select_item($row['login'] . "[" . $row['fio'] . "] - " . $row['ip'], $row['id'], $current_auth);
@@ -1767,7 +1767,7 @@ function print_auth_select($db, $login_name, $current_auth)
 function print_auth_select_mac($db, $login_name, $current_auth)
 {
     print "<select id=\"$login_name\" name=\"$login_name\" class=\"js-select-single\">\n";
-    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.mac,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) order by U.login,U.fio,A.ip");
+    $t_login = get_records_sql($db, "SELECT U.login,U.fio,A.ip,A.mac,A.id FROM user_list as U, user_auth as A WHERE A.user_id=U.id and A.deleted=0 and (A.id not in (select device_ports.auth_id FROM device_ports) or A.id=$current_auth) ORDER BY U.login,U.fio,A.ip");
 
     print_select_item('Empty', 0, $current_auth);
     foreach ($t_login as $row) {
@@ -1809,7 +1809,7 @@ function print_device_port_select($db, $field_name, $device_id, $target_id)
 function print_device_select($db, $field_name, $device_id)
 {
     print "<select id=\"$field_name\" name=\"$field_name\" class=\"js-select-single\" >\n";
-    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 order by D.device_name ASC";
+    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 ORDER BY D.device_name ASC";
     $t_device = get_records_sql($db, $d_sql);
     print_select_item(WEB_select_item_every, 0, $device_id);
     foreach ($t_device as $row) {
@@ -1821,7 +1821,7 @@ function print_device_select($db, $field_name, $device_id)
 function print_netdevice_select($db, $field_name, $device_id)
 {
     print "<select id=\"$field_name\" name=\"$field_name\" class=\"js-select-single\" >\n";
-    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type<=2 order by D.device_name ASC";
+    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type<=2 ORDER BY D.device_name ASC";
     $t_device = get_records_sql($db, $d_sql);
     print_select_item(WEB_select_item_every, 0, $device_id);
     foreach ($t_device as $row) {
@@ -1851,7 +1851,7 @@ function print_vlan_select($db, $field_name, $vlan)
 function print_device_select_ip($db, $field_name, $device_ip)
 {
     print "<select id=\"$field_name\" name=\"$field_name\" class=\"js-select-single\" >\n";
-    $d_sql = "SELECT D.device_name, D.ip FROM devices AS D Where D.deleted=0 order by D.device_name ASC";
+    $d_sql = "SELECT D.device_name, D.ip FROM devices AS D Where D.deleted=0 ORDER BY D.device_name ASC";
     $t_device = get_records_sql($db, $d_sql);
     print_select_item(WEB_select_item_every, '', $device_ip);
     foreach ($t_device as $row) {
@@ -1878,7 +1878,7 @@ function print_syslog_device_select($db, $field_name, $syslog_filter, $device_ip
 function print_gateway_select($db, $field_name, $device_id)
 {
     print "<select id=\"$field_name\" name=\"$field_name\" >\n";
-    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type=2 order by D.device_name ASC";
+    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type=2 ORDER BY D.device_name ASC";
     $t_device = get_records_sql($db, $d_sql);
     print_select_item(WEB_select_item_every, 0, $device_id);
     foreach ($t_device as $row) {
@@ -1889,7 +1889,7 @@ function print_gateway_select($db, $field_name, $device_id)
 
 function get_gateways($db)
 {
-    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type=2 order by D.device_name ASC";
+    $d_sql = "SELECT D.device_name, D.id FROM devices AS D Where D.deleted=0 and D.device_type=2 ORDER BY D.device_name ASC";
     $t_device = get_records_sql($db, $d_sql);
     unset($result);
     foreach ($t_device as $row) {
@@ -1980,7 +1980,7 @@ function get_device_by_auth($db, $id)
 
 function print_auth_port($db, $port_id, $new_window = FALSE)
 {
-    $d_sql = "SELECT A.ip, A.ip_int, A.mac, A.id, A.dns_name, A.user_id FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $d_sql = "SELECT A.ip, A.ip_int, A.mac, A.id, A.dns_name, A.user_id FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 ORDER BY A.ip_int";
     $t_auth = get_records_sql($db, $d_sql);
     foreach ($t_auth as $row) {
         $name = $row['ip'];
@@ -2001,7 +2001,7 @@ function print_auth_port($db, $port_id, $new_window = FALSE)
 
 function get_port_description($db, $port_id, $port_description = '')
 {
-    $d_sql = "SELECT A.ip_int, A.description FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $d_sql = "SELECT A.ip_int, A.description FROM user_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 ORDER BY A.ip_int";
     $t_auth = get_records_sql($db, $d_sql);
     $description_found = 0;
     $result = '';
@@ -2114,13 +2114,13 @@ function get_port($db, $port_id)
 function print_option_select($db, $option_name)
 {
     print "<select id=\"$option_name\" name=\"$option_name\">\n";
-    $t_option = get_records_sql($db, "SELECT id,option_name FROM config_options WHERE uniq=0 AND draft=0 order by option_name");
+    $t_option = get_records_sql($db, "SELECT id,option_name FROM config_options WHERE uniq=0 AND draft=0 ORDER BY option_name");
     if (!empty($t_option)) {
         foreach ($t_option as $row) {
             print "<option value=".$row['id'].">".$row['option_name']."</option>";
         }
     }
-    $t_option = get_records_sql($db, "SELECT id,option_name FROM config_options WHERE draft=0 AND uniq=1 AND id NOT IN (select option_id FROM config where draft=0) order by option_name");
+    $t_option = get_records_sql($db, "SELECT id,option_name FROM config_options WHERE draft=0 AND uniq=1 AND id NOT IN (select option_id FROM config where draft=0) ORDER BY option_name");
     if (!empty($t_option)) {
         foreach ($t_option as $row) {
             print "<option value=".$row['id'].">".$row['option_name']."</option>";
@@ -2154,7 +2154,7 @@ function clean_dns_cache($db)
     $date = $date - 86400;
     $date_clean = DateTimeImmutable::createFromFormat('U', $date);
     $clean_date = $date_clean->format('Y-m-d H:i:s');
-    run_sql($db, "DELETE FROM dns_cache WHERE timestamp<='" . $clean_date . "'");
+    run_sql($db, "DELETE FROM dns_cache WHERE ts<='" . $clean_date . "'");
 }
 
 function clean_unreferensed_rules($db)

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

@@ -200,6 +200,7 @@ define("WEB_cell_shaper","Shaper");
 define("WEB_cell_connection","Connected");
 define("WEB_cell_last_found","Last MAC/ARP activity");
 define("WEB_cell_arp_found","Last ARP activity");
+define("WEB_cell_mac_found","Last MAC activity");
 define("WEB_cell_dns_name","Dns Name");
 define("WEB_cell_aliases","Aliases");
 define("WEB_cell_host_model","Device Model");

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

@@ -200,6 +200,7 @@ define("WEB_cell_shaper","Шейпер");
 define("WEB_cell_connection","Подключен");
 define("WEB_cell_last_found","Был mac/arp");
 define("WEB_cell_arp_found","Был arp");
+define("WEB_cell_mac_found","Был mac");
 define("WEB_cell_dns_name","Имя в dns");
 define("WEB_cell_aliases","Альясы");
 define("WEB_cell_host_model","Модель устройства");

+ 117 - 16
html/inc/sql.php

@@ -2,6 +2,110 @@
 if (! defined("CONFIG")) die("Not defined");
 if (! defined("SQL")) { die("Not defined"); }
 
+$numericFields = [
+    'id',
+    'option_id',
+    'min_value',
+    'max_value',
+    'draft',
+    'uniq',
+    'device_id',
+    'port_id',
+    'auth_id',
+    'rights',
+    'device_type',
+    'device_model_id',
+    'vendor_id',
+    'building_id',
+    'ip_int',
+    'control_port',
+    'port_count',
+    'snmp_version',
+    'fdb_snmp_index',
+    'discovery',
+    'netflow_save',
+    'user_acl',
+    'dhcp',
+    'nagios',
+    'active',
+    'queue_enabled',
+    'connected_user_only',
+    'user_id',
+    'deleted',
+    'discovery_locked',
+    'instance_id',
+    'snmpin',
+    'interface_type',
+    'poe_in',
+    'poe_out',
+    'snmp_index',
+    'port',
+    'target_port_id',
+    'last_mac_count',
+    'uplink',
+    'skip',
+    'vlan',
+    'ip_int_start',
+    'ip_int_stop',
+    'dhcp_start',
+    'dhcp_stop',
+    'dhcp_lease_time',
+    'gateway',
+    'office',
+    'hotspot',
+    'vpn',
+    'free',
+    'static',
+    'dhcp_update_hostname',
+    'notify',
+    'router_id',
+    'proto',
+    'src_ip',
+    'dst_ip',
+    'src_port',
+    'dst_port',
+    'bytes',
+    'pkt',
+    'filter_type',
+    'subnet_id',
+    'group_id',
+    'filter_id',
+    'order',
+    'action',
+    'default_users',
+    'default_hotspot',
+    'nagios_ping',
+    'enabled',
+    'filter_group_id',
+    'queue_id',
+    'dynamic',
+    'life_duration',
+    'parent_id',
+    'Download',
+    'Upload',
+    'byte_in',
+    'byte_out',
+    'pkt_in',
+    'pkt_out',
+    'step',
+    'bytes_in',
+    'bytes_out',
+    'forward_in',
+    'forward_out',
+    'level',
+    'last_activity',
+    'is_active',
+    'day_quota',
+    'month_quota',
+    'permanent',
+    'blocked',
+    'changed',
+    'dhcp_changed',
+    'link_check'
+];
+
+$numericFieldsSet = array_flip($numericFields);
+
 function db_escape($connection, $value) {
     // Обработка специальных значений
     if ($value === null) {
@@ -271,15 +375,12 @@ function is_assoc($array) {
  */
 function normalize_field_value($key, $value) {
     if ($value === null or $value === 'NULL') {
-        // Регулярное выражение для определения числовых полей
-        $numeric_field_pattern = '/\b(?:id|_id|count|_count|num|port|size|level|status|type|bytes|byte|_time|_timestamp|_at|time|timestamp|_in|_out|_int|forward|gateway|ip_int|quota|step|vlan|index|snmp|protocol|router|subnet|target|vendor|action|active|blocked|changed|connected|default|deleted|dhcp|discovery|draft|dynamic|enabled|free|hotspot|link|nagios|netflow|notify|office|permanent|poe|queue|rights|save|skip|static|uniq|uplink|vpn)\b/i';
-        if (preg_match($numeric_field_pattern, $key)) {
+	if (isset($numericFieldsSet[$key])) {
             return 0;
         } else {
             return '';
         }
     }
-    
     return $value;
 }
 
@@ -679,7 +780,7 @@ function update_record($db, $table, $filter, $newvalue)
             $del_dns['name_type'] = 'A';
             $del_dns['name'] = $old['dns_name'];
             $del_dns['value'] = $old['ip'];
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($rec_id)) {
                 $del_dns['auth_id'] = $rec_id;
             }
@@ -689,7 +790,7 @@ function update_record($db, $table, $filter, $newvalue)
             $del_dns['name_type'] = 'PTR';
             $del_dns['name'] = $old['dns_name'];
             $del_dns['value'] = $old['ip'];
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($rec_id)) {
                 $del_dns['auth_id'] = $rec_id;
             }
@@ -700,7 +801,7 @@ function update_record($db, $table, $filter, $newvalue)
             $new_dns['name_type'] = 'A';
             $new_dns['name'] = $newvalue['dns_name'];
             $new_dns['value'] = $newvalue['ip'];
-            $new_dns['type'] = 'add';
+            $new_dns['operation_type'] = 'add';
             if (!empty($rec_id)) {
                 $new_dns['auth_id'] = $rec_id;
             }
@@ -710,7 +811,7 @@ function update_record($db, $table, $filter, $newvalue)
             $new_dns['name_type'] = 'PTR';
             $new_dns['name'] = $newvalue['dns_name'];
             $new_dns['value'] = $newvalue['ip'];
-            $new_dns['type'] = 'add';
+            $new_dns['operation_type'] = 'add';
             if (!empty($rec_id)) {
                 $new_dns['auth_id'] = $rec_id;
             }
@@ -726,7 +827,7 @@ function update_record($db, $table, $filter, $newvalue)
         if (!empty($old['alias']) and !preg_match('/\.$/', $old['alias'])) {
             $del_dns['name_type'] = 'CNAME';
             $del_dns['name'] = $old['alias'];
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($auth_id)) {
                 $del_dns['auth_id'] = $auth_id;
                 $del_dns['value'] = get_dns_name($db, $auth_id);
@@ -736,7 +837,7 @@ function update_record($db, $table, $filter, $newvalue)
         if (!empty($newvalue['alias'])  and !preg_match('/\.$/', $newvalue['alias'])) {
             $new_dns['name_type'] = 'CNAME';
             $new_dns['name'] = $newvalue['alias'];
-            $new_dns['type'] = 'add';
+            $new_dns['operation_type'] = 'add';
             if (!empty($auth_id)) {
                 $new_dns['auth_id'] = $auth_id;
                 $new_dns['value'] = get_dns_name($db, $auth_id);
@@ -868,7 +969,7 @@ function delete_record($db, $table, $filter)
             $del_dns['name_type'] = 'A';
             $del_dns['name'] = $old['dns_name'];
             $del_dns['value'] = $old['ip'];
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($rec_id)) {
                 $del_dns['auth_id'] = $rec_id;
                 }
@@ -879,7 +980,7 @@ function delete_record($db, $table, $filter)
             $del_dns['name_type'] = 'PTR';
             $del_dns['name'] = $old['dns_name'];
             $del_dns['value'] = $old['ip'];
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($rec_id)) {
                 $del_dns['auth_id'] = $rec_id;
                 }
@@ -899,7 +1000,7 @@ function delete_record($db, $table, $filter)
             $del_dns['name_type'] = 'CNAME';
             $del_dns['name'] = $old['alias'];
             $del_dns['value'] = '';
-            $del_dns['type'] = 'del';
+            $del_dns['operation_type'] = 'del';
             if (!empty($old['auth_id'])) {
                 $del_dns['auth_id'] = $old['auth_id'];
                 $del_dns['value'] = get_dns_name($db, $old['auth_id']);
@@ -1013,7 +1114,7 @@ function insert_record($db, $table, $newvalue)
                 $add_dns['name_type'] = 'CNAME';
                 $add_dns['name'] = $newvalue['alias'];
                 $add_dns['value'] = get_dns_name($db, $newvalue['auth_id']);
-                $add_dns['type'] = 'add';
+                $add_dns['operation_type'] = 'add';
                 $add_dns['auth_id'] = $newvalue['auth_id'];
                 insert_record($db, 'dns_queue', $add_dns);
             }
@@ -1025,7 +1126,7 @@ function insert_record($db, $table, $newvalue)
                 $add_dns['name_type'] = 'A';
                 $add_dns['name'] = $newvalue['dns_name'];
                 $add_dns['value'] = $newvalue['ip'];
-                $add_dns['type'] = 'add';
+                $add_dns['operation_type'] = 'add';
                 $add_dns['auth_id'] = $last_id;
                 insert_record($db, 'dns_queue', $add_dns);
             }
@@ -1034,7 +1135,7 @@ function insert_record($db, $table, $newvalue)
                 $add_dns['name_type'] = 'PTR';
                 $add_dns['name'] = $newvalue['dns_name'];
                 $add_dns['value'] = $newvalue['ip'];
-                $add_dns['type'] = 'add';
+                $add_dns['operation_type'] = 'add';
                 $add_dns['auth_id'] = $last_id;
                 insert_record($db, 'dns_queue', $add_dns);
             }

+ 4 - 4
html/public/blocked.php

@@ -88,7 +88,7 @@ if ($auth['blocked']) { print "<font color=red>".WEB_msg_traffic_blocked."</font
 <?php
 
 ####### day
-$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE timestamp>='".$date1."' AND timestamp<'".$date2."' AND auth_id='".$id."'";
+$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE ts>='".$date1."' AND ts<'".$date2."' AND auth_id='".$id."'";
 $day_auth_itog = get_record_sql($db_link,$sSQL);
 
 $day_auth_sum_in=0;
@@ -108,7 +108,7 @@ $auth_list = get_records_sql($db_link,"SELECT id FROM user_auth WHERE user_id='"
 
 if (!empty($auth_list)) {
     foreach ($auth_list as $row) {
-        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE timestamp>='".$date1."' AND timestamp<'".$date2."' AND auth_id='".$row['id']."'");
+        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE ts>='".$date1."' AND ts<'".$date2."' AND auth_id='".$row['id']."'");
         if (!empty($auth_itog2)) { 
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }
@@ -119,7 +119,7 @@ if (!empty($auth_list)) {
     }
 
 #### month
-$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE timestamp>='".$date1m."' AND timestamp<'".$date2m."' AND auth_id='".$id."'";
+$sSQL = "SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE ts>='".$date1m."' AND ts<'".$date2m."' AND auth_id='".$id."'";
 $month_auth_itog = get_record_sql($db_link,$sSQL);
 
 $month_auth_sum_in=0;
@@ -137,7 +137,7 @@ $month_user_sum_out=0;
 
 if (!empty($auth_list)) {
     foreach ($auth_list as $row) {
-        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE timestamp>='".$date1m."' AND timestamp<'".$date2m."' AND auth_id='".$row['id']."'");
+        $auth_itog2 = get_record_sql($db_link,"SELECT SUM(byte_in) as tin, SUM(byte_out) as tout FROM user_stats WHERE ts>='".$date1m."' AND ts<'".$date2m."' AND auth_id='".$row['id']."'");
         if (!empty($auth_itog2)) {
                 if (empty($auth_itog2['tin'])) { $auth_itog2['tin']=0; }
                 if (empty($auth_itog2['tout'])) { $auth_itog2['tout']=0; }