Przeglądaj źródła

small fixes in display logs

Dmitriev Roman 3 miesięcy temu
rodzic
commit
6289126504

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

@@ -434,7 +434,7 @@ dst_ip    bigint NOT NULL DEFAULT 0,
 src_port  integer NOT NULL DEFAULT 0,
 dst_port  integer NOT NULL DEFAULT 0,
 bytes     bigint NOT NULL DEFAULT 0,
-pkt       bigint NOT NULL DEFAULT 0,
+pkt       bigint NOT NULL DEFAULT 0
 );
 COMMENT ON TABLE traffic_detail IS 'Detailed traffic flow records (NetFlow)';
 COMMENT ON COLUMN traffic_detail.proto IS 'IP protocol number';

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

@@ -435,7 +435,7 @@ dst_ip    bigint NOT NULL DEFAULT 0,
 src_port  integer NOT NULL DEFAULT 0,
 dst_port  integer NOT NULL DEFAULT 0,
 bytes     bigint NOT NULL DEFAULT 0,
-pkt       bigint NOT NULL DEFAULT 0,
+pkt       bigint NOT NULL DEFAULT 0
 );
 COMMENT ON TABLE traffic_detail IS 'Подробные записи потоков трафика (NetFlow)';
 COMMENT ON COLUMN traffic_detail.proto IS 'Номер IP протокола';

+ 10 - 16
html/admin/logs/detaillog.php

@@ -8,12 +8,8 @@ $default_sort='id';
 $sort_table = 'A';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 
-if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
-if (isset($_GET['ip'])) { $f_ip = $_GET['ip']; }
-if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
-if (empty($f_ip)) { $f_ip = '127.0.0.1'; }
-
-$_SESSION[$page_url]['ip']=$f_ip;
+$f_ip = getParam('ip', $page_url, '127.0.0.1');
+$_SESSION[$page_url]['ip'] = $f_ip;
 
 $ip_where = '';
 $params=[];
@@ -26,16 +22,12 @@ if (!empty($f_ip)) {
         }
     }
 
-$rdns = 0;
-if (isset($_POST['dns'])) { $rdns=$_POST['dns']*1; }
-$_SESSION[$page_url]['dns']=$rdns;
-$dns_checked='';
-if ($rdns) { $dns_checked='checked="checked"'; }
-
+$rdns = getPOST('dns', $page_url, 0, FILTER_VALIDATE_INT);
+$_SESSION[$page_url]['dns'] = $rdns;
+$dns_checked = $rdns ? 'checked="checked"' : '';
 $dns_cache=NULL;
 
 print_log_submenu($page_url);
-/* print_trafdetail_submenu($page_url,"id=$id&date_start=$date1&date_stop=$date2","<b>".WEB_log_detail_for."<a href=/admin/users/editauth.php?id=$id>$f_ip</a></b> ::&nbsp"); */
 
 ?>
 
@@ -60,9 +52,11 @@ $sort_url = "<a href='detaillog.php?date_start=\"".$date1.'"&date_stop="'.$date2
 if (!empty($f_ip)) { $sort_url .='&f_ip="'.$f_ip.'"'; }
 
 $gateway_filter='';
-if (!empty($rgateway) and $rgateway>0) { $gateway_filter="(router_id=?) AND"; $params[]=$rgateway; }
+if (!empty($rgateway) and $rgateway>0) { 
+    $gateway_filter="(router_id=?) AND"; $params[]=$rgateway; 
+    }
 
-$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where ts>=? AND ts<?";
+$countSQL="SELECT Count(*) FROM traffic_detail as A WHERE $gateway_filter $ip_where ts>=? AND ts< ? ";
 $params[]=$date1;
 $params[]=$date2;
 
@@ -94,7 +88,7 @@ $gateway_list = get_gateways($db_link);
 </tr>
 <?php
 $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>=? AND ts<?
+        WHERE $gateway_filter $ip_where ts>= ? AND ts< ?
         ORDER BY ts ASC LIMIT ? OFFSET ?) as T ON A.id = T.id ORDER BY $sort_table.$sort_field $order";
 $params[]=$displayed;
 $params[]=$start;

+ 4 - 10
html/admin/logs/dhcp.php

@@ -5,17 +5,11 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 
-if (isset($_POST['dhcp_show'])) { $f_dhcp = $_POST['dhcp_show']; }
-    else {
-    if (isset($_SESSION[$page_url]['f_dhcp'])) { $f_dhcp=$_SESSION[$page_url]['f_dhcp']; } else { $f_dhcp = 'all'; }
-    }
-
-if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
-if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
-if (!isset($f_ip)) { $f_ip=''; }
+$f_dhcp = getPOST('dhcp_show', $page_url, 'all');
+$f_ip   = getPOST('ip',        $page_url, '');
 
-$_SESSION[$page_url]['f_dhcp']=$f_dhcp;
-$_SESSION[$page_url]['ip']=$f_ip;
+$_SESSION[$page_url]['f_dhcp'] = $f_dhcp;
+$_SESSION[$page_url]['ip']     = $f_ip;
 
 $dhcp_where = '';
 $params=[ $date1, $date2 ];

+ 2 - 5
html/admin/logs/index.php

@@ -6,11 +6,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/loglevelfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/logfilter.php");
 
-if (isset($_POST['user_ip'])) { $fuser_ip = $_POST['user_ip']; }
-if (isset($_GET['user_ip'])) { $fuser_ip = $_GET['user_ip']; }
-if (!isset($fuser_ip) and isset($_SESSION[$page_url]['user_ip'])) { $fuser_ip=$_SESSION[$page_url]['user_ip']; }
-if (!isset($fuser_ip)) { $fuser_ip=''; }
-$_SESSION[$page_url]['user_ip']=$fuser_ip;
+$fuser_ip = getParam('user_ip', $page_url, '');
+$_SESSION[$page_url]['user_ip'] = $fuser_ip;
 
 print_log_submenu($page_url);
 ?>

+ 2 - 6
html/admin/logs/ip.php

@@ -4,12 +4,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 
-if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
-if (isset($_GET['ip'])) { $f_ip = $_GET['ip']; }
-if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
-if (!isset($f_ip)) { $f_ip=''; }
-
-$_SESSION[$page_url]['ip']=$f_ip;
+$f_ip = getParam('ip', $page_url, '');
+$_SESSION[$page_url]['ip'] = $f_ip;
 
 print_log_submenu($page_url);
 

+ 2 - 7
html/admin/logs/mac.php

@@ -5,13 +5,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 
-if (isset($_POST['mac'])) { $f_mac = mac_simplify($_POST['mac']); }
-if (isset($_GET['mac'])) { $f_mac = mac_simplify($_GET['mac']); }
-if (!isset($f_mac) and isset($_SESSION[$page_url]['mac'])) { $f_mac=$_SESSION[$page_url]['mac']; }
-if (!isset($f_mac)) { $f_mac=''; }
-
-$_SESSION[$page_url]['mac']=$f_mac;
-
+$f_mac = mac_simplify(getParam('mac', $page_url, ''));
+$_SESSION[$page_url]['mac'] = $f_mac;
 
 print_log_submenu($page_url);
 ?>

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

@@ -5,18 +5,12 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/logfilter.php");
 
-if (isset($_POST['device_show'])) { $f_id = $_POST['device_show']*1; }
-if (isset($_GET['device_show'])) { $f_id = $_GET['device_show']*1; }
-
-if (!isset($f_id) and isset($_SESSION[$page_url]['device_show'])) { $f_id=$_SESSION[$page_url]['device_show']*1; }
-if (!isset($f_id)) { $f_id=0; }
-
-$_SESSION[$page_url]['device_show']=$f_id;
-
-print_log_submenu($page_url);
+$f_id = getParam('device_show', $page_url, 0, FILTER_VALIDATE_INT);
+$_SESSION[$page_url]['device_show'] = $f_id;
 
 $params = [$date1, $date2];
 $conditions = [];
+
 // === Фильтр по IP (через IN с параметрами) ===
 if ($f_id > 0) {
     $dev_ips = get_device_ips($db_link, $f_id);
@@ -40,9 +34,6 @@ $count_records = (int)get_single_field($db_link, $countSQL, $params);
 $total = ceil($count_records / $displayed);
 $page = max(1, min($page, $total));
 $start = ($page - 1) * $displayed;
-
-print_navigation($page_url, $page, $displayed, $count_records, $total);
-
 $limit = (int)$displayed;
 $offset = (int)$start;
 
@@ -56,18 +47,27 @@ $sSQL = "
 ";
 
 $syslog = get_records_sql($db_link, $sSQL, $dataParams);
+
+print_log_submenu($page_url);
+
 ?>
 
 <div id="cont">
 <br>
 <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
-<?php print_date_fields($date1,$date2,$date_shift); ?>
-<?php echo WEB_log_report_by_device; ?>&nbsp <?php print_device_select($db_link, "device_show", $f_id); ?>
-<?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
-<input type="submit" value="<?php echo WEB_btn_show; ?>"><br><br>
-<?php echo WEB_log_filter_event; ?>:<input name="message" value="<?php echo $fmessage; ?>" />
+    <?php
+    print_date_fields($date1, $date2, $date_shift);
+    echo WEB_log_report_by_device, "&nbsp;";
+    print_device_select($db_link, "device_show", $f_id);
+    echo WEB_rows_at_page, "&nbsp;";
+    print_row_at_pages('rows', $displayed);
+    ?>
+    <input type="submit" value="<?=WEB_btn_show?>"><br><br>
+    <?php echo WEB_log_filter_event; ?>:<input name="message" value="<?php echo $fmessage; ?>" />
 </form>
 
+<?php print_navigation($page_url, $page, $displayed, $count_records, $total); ?>
+
 <br>
 <table class="data" width="90%">
 		<tr align="center">

+ 12 - 11
html/admin/logs/unknown.php

@@ -4,13 +4,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
 
-if (isset($_POST['device_show'])) { $f_id = $_POST['device_show'] * 1; }
-if (isset($_GET['device_show'])) { $f_id = $_GET['device_show'] * 1; }
-if (!isset($f_id) and isset($_SESSION[$page_url]['device_show'])) { $f_id=$_SESSION[$page_url]['device_show']; }
-if (!isset($f_id)) { $f_id=0; }
-
-$_SESSION[$page_url]['device_show']=$f_id;
-print_log_submenu($page_url);
+$f_id = getParam('device_show', $page_url, 0, FILTER_VALIDATE_INT);
+$_SESSION[$page_url]['device_show'] = $f_id;
 
 $params = [$date1, $date2];
 $conditions = [];
@@ -39,7 +34,6 @@ $total = ceil($count_records / $displayed);
 $page = max(1, min($page, $total));
 $start = ($page - 1) * $displayed;
 
-print_navigation($page_url, $page, $displayed, $count_records, $total);
 
 $limit = (int)$displayed;
 $offset = (int)$start;
@@ -60,17 +54,24 @@ $sSQL = "
 ";
 
 $maclog = get_records_sql($db_link, $sSQL, $dataParams);
+
+print_log_submenu($page_url);
+
 ?>
 
 <div id="cont">
 <br>
 <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
-<?php echo WEB_log_report_by_device; ?>&nbsp<?php print_netdevice_select($db_link, "device_show", $f_id); ?>
-<?php print_date_fields($date1,$date2,$date_shift); ?>
-<?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
+<?php echo WEB_log_report_by_device; print "&nbsp"; 
+print_netdevice_select($db_link, "device_show", $f_id);
+print_date_fields($date1,$date2,$date_shift);
+print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); 
+?>
 <input type="submit" value="<?php echo WEB_btn_show; ?>">
 </form>
 
+<?php print_navigation($page_url, $page, $displayed, $count_records, $total); ?>
+
 <br>
 <table class="data" width="750">
 <tr align="center">

+ 21 - 0
scripts/updates/3-0-1/after_clean.pl

@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use File::Path qw(remove_tree);
+
+my $dir = '/opt/Eye/html/sessions';
+
+if (-d $dir) {
+    eval {
+        remove_tree($dir, { safe => 0 });
+    };
+    if ($@) {
+        die "Failed to remove '$dir': $@";
+    }
+    print "Directory '$dir' successfully removed.\n";
+} else {
+    print "Directory '$dir' does not exist.\n";
+}
+
+exit 0;