소스 검색

small changes

Dmitriev Roman 3 달 전
부모
커밋
ddb7dbee63

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

@@ -356,4 +356,4 @@ document.getElementById('f_snmp_version').addEventListener('change', function(ev
 
 </script>
 
-<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php"); ?>
+<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

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

@@ -133,5 +133,5 @@ document.getElementById('building_id').addEventListener('change', function(event
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -66,5 +66,5 @@ if ($snmp_ok) {
 	}
 
 unset_lock_discovery($db_link,$id);
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

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

@@ -134,5 +134,5 @@ if (!empty($maclist)) {
 
 print "</table>\n";
 
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

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

@@ -63,5 +63,5 @@ print "</table>\n";
 </form>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -147,5 +147,5 @@ print "</table>\n";
 </div>
 </form>
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -448,5 +448,5 @@ print "<tr><td class=\"speed10M\">" . WEB_port_speed_10 . "</td><td class=\"spee
 print "</table>\n";
 print "</form>";
 unset_lock_discovery($db_link, $id);
-require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
 ?>

+ 1 - 1
html/admin/groups/edit_group.php

@@ -238,5 +238,5 @@ document.getElementById('f_dynamic').addEventListener('change', function(event)
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 1 - 1
html/admin/iplist/auto_rules.php

@@ -136,5 +136,5 @@ document.getElementById('rows').addEventListener('change', function(event) {
 
 <?php
 print_navigation($page_url,$page,$displayed,$count_records,$total);
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php"); 
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); 
 ?>

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

@@ -353,5 +353,5 @@ document.getElementById('dynamic_enabled').addEventListener('change', function(e
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 1 - 1
html/admin/iplist/nagios.php

@@ -193,5 +193,5 @@ document.getElementById('rows').addEventListener('change', function(event) {
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -157,5 +157,5 @@ document.getElementById('gateway').addEventListener('change', function(event) {
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

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

@@ -536,4 +536,4 @@ document.getElementById('f_dynamic').addEventListener('change', function(event)
 });
 </script>
 
-<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.simple.php"); ?>
+<?php require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php"); ?>

+ 1 - 1
html/admin/users/index.php

@@ -257,5 +257,5 @@ document.getElementById('rows').addEventListener('change', function(event) {
 </script>
 
 <?php
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 0 - 23
html/inc/footer.simple.php

@@ -1,28 +1,5 @@
 <br style="clear: both">
-
 <div id="copyright">Copyright &copy; 2008-2025 Eye v<?php print $config["version"]; ?> &nbsp<a href="https://github.com/rajven/Eye">rnd@rajven.ru</a></div>
-<hr>
-<div>
-<?php
-$end_time = microtime();
-$end_array = explode(" ",$end_time);
-$end_time = $end_array[1] + $end_array[0];
-$time = $end_time - $start_time;
-$end_memory = memory_get_usage();
-$peak_memory = memory_get_peak_usage();
-ob_end_flush();
-?>
 </div>
-
-<div class="performance-info">
-    ⚡ Страница сгенерирована за <strong><?php printf("%.4f сек", $time); ?></strong>
-    &nbsp;|&nbsp;
-    🧠 Память: <?php echo fbytes($peak_memory); ?> (пик)
-    &nbsp;|&nbsp;
-    💾 Использовано: <?php echo fbytes($end_memory - $start_memory); ?>
-</div>
-
-</div>
-
 </body>
 </html>

+ 64 - 30
html/public/blocked.php

@@ -10,7 +10,10 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header_public.php");
 // === 1. Безопасное получение IP ===
 $auth_ip = get_user_ip();
 if (!$auth_ip || !filter_var($auth_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
-    die("<font color=red><b>Invalid IP detected!</b></font>");
+    print "<div id=\"cont\">";
+    print "<font color=red><b>".WEB_auth_unknown."</b></font>";
+    require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+    exit;
 }
 
 // === 2. Преобразуем IP в BIGINT (беззнаковый) ===
@@ -19,7 +22,22 @@ $ip_long = sprintf('%u', ip2long($auth_ip));
 // === 3. Находим авторизацию и пользователя за один JOIN ===
 $sql = "
     SELECT 
-        ua.*, ul.*
+        ul.id AS user_id,
+        ul.login,
+        ul.fio,
+        ul.enabled AS user_enabled,
+        ul.blocked AS user_blocked,
+        ul.month_quota,
+        ul.day_quota,
+        ul.filter_group_id,
+        ul.queue_id,
+
+        ua.id AS auth_id,
+        ua.ip_int,
+        ua.enabled AS auth_enabled,
+        ua.blocked AS auth_blocked,
+        ua.month_quota AS auth_month_quota,
+        ua.day_quota AS auth_day_quota
     FROM user_auth ua
     JOIN user_list ul ON ua.user_id = ul.id
     WHERE ua.ip_int = ? AND ua.deleted = 0 AND ul.deleted = 0
@@ -27,11 +45,14 @@ $sql = "
 $record = get_record_sql($db_link, $sql, [$ip_long]);
 
 if (!$record) {
-    die("<font color=red><b>" . WEB_cell_ip . "&nbsp;" . htmlspecialchars($auth_ip, ENT_QUOTES) . "&nbsp; - " . WEB_unknown . "!</b></font>");
+    print "<div id=\"cont\">";
+    print "<font color=red><b>".WEB_cell_ip . "&nbsp;" . htmlspecialchars($auth_ip, ENT_QUOTES) . "&nbsp; - " . WEB_unknown . "!</b></font>";
+    require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
+    exit;
 }
 
 // === 4. Подготавливаем данные ===
-$id = $record['id'];
+$auth_id = $record['auth_id'];
 $user_id = $record['user_id'];
 
 $KB = get_const('KB') ? 1024 : 1000;
@@ -44,11 +65,15 @@ $user_day_quota   = ($record['day_quota']   ?? 0) * $KB * $KB;
 $auth_month_quota = ($record['auth_month_quota'] ?? $record['month_quota'] ?? 0) * $KB * $KB;
 $auth_day_quota   = ($record['auth_day_quota']   ?? $record['day_quota']   ?? 0) * $KB * $KB;
 
-// === 5. Получаем трафик за день и месяц за 2 запроса (без циклов!) ===
-$params_day = [$date1, $date2, $user_id];
-$params_month = [$date1m, $date2m, $user_id];
+// === 5. Вычисляем временные границы ===
+$now = new DateTime();
+$date1 = $now->format('Y-m-d 00:00:00');
+$date2 = $now->format('Y-m-d 23:59:59');
 
-// Трафик по всем auth этого пользователя
+$date1m = $now->format('Y-m-01 00:00:00');
+$date2m = (clone $now)->modify('last day of this month')->format('Y-m-d 23:59:59');
+
+// === 6. Получаем трафик за день и месяц ===
 $day_traffic = get_record_sql($db_link, "
     SELECT 
         SUM(CASE WHEN ua.id = ? THEN us.byte_in ELSE 0 END) AS auth_in,
@@ -58,7 +83,7 @@ $day_traffic = get_record_sql($db_link, "
     FROM user_stats us
     JOIN user_auth ua ON us.auth_id = ua.id
     WHERE us.ts >= ? AND us.ts < ? AND ua.user_id = ? AND ua.deleted = 0
-", [$id, $id, $date1, $date2, $user_id]);
+", [$auth_id, $auth_id, $date1, $date2, $user_id]);
 
 $month_traffic = get_record_sql($db_link, "
     SELECT 
@@ -69,7 +94,7 @@ $month_traffic = get_record_sql($db_link, "
     FROM user_stats us
     JOIN user_auth ua ON us.auth_id = ua.id
     WHERE us.ts >= ? AND us.ts < ? AND ua.user_id = ? AND ua.deleted = 0
-", [$id, $id, $date1m, $date2m, $user_id]);
+", [$auth_id, $auth_id, $date1m, $date2m, $user_id]);
 
 $day_auth_sum_in   = $day_traffic['auth_in']   ?? 0;
 $day_auth_sum_out  = $day_traffic['auth_out']  ?? 0;
@@ -100,32 +125,41 @@ $month_user_sum_out = $month_traffic['user_out'] ?? 0;
 <tr>
     <td><?php echo WEB_msg_access_login; ?></td>
     <td><b>
-    <?php if ($record['enabled'] && !$record['blocked']): ?>
-        <?php echo WEB_msg_enabled; ?>
-    <?php else: ?>
-        <?php if (!$record['enabled']): ?>
-            <font color="red"><?php echo WEB_msg_disabled; ?></font>&nbsp;
-        <?php endif; ?>
-        <?php if ($record['blocked']): ?>
-            <font color="red"><?php echo WEB_msg_traffic_blocked; ?></font>
-        <?php endif; ?>
-    <?php endif; ?>
+<?php
+if ($record['user_enabled'] && !$record['user_blocked']) {
+    echo WEB_msg_enabled;
+} else {
+    if (!$record['user_enabled']) {
+        echo '<font color="red">' . WEB_msg_disabled . '</font>&nbsp;';
+    }
+    if ($record['user_blocked']) {
+        echo '<font color="red">' . WEB_msg_traffic_blocked . '</font>';
+    }
+}
+?>
     </b></td>
 </tr>
 <!-- Аналогично для IP-статуса -->
 <tr>
     <td><?php echo WEB_msg_access_ip; ?></td>
     <td><b>
-    <?php if ($record['enabled'] && !$record['blocked'] && $record['auth_enabled'] /*?*/): ?>
-        <?php echo WEB_msg_enabled; ?>
-    <?php else: ?>
-        <?php if (!$record['enabled'] /* или auth_enabled */): ?>
-            <font color="red"><?php echo WEB_msg_disabled; ?></font>&nbsp;
-        <?php endif; ?>
-        <?php if ($record['auth_blocked'] /*?*/): ?>
-            <font color="red"><?php echo WEB_msg_traffic_blocked; ?></font>
-        <?php endif; ?>
-    <?php endif; ?>
+<?php
+$user_active = $record['user_enabled'] && !$record['user_blocked'];
+$auth_active = $user_active && $record['auth_enabled'] && !$record['auth_blocked'];
+if ($auth_active) {
+    echo WEB_msg_enabled;
+} else {
+    // Если пользователь неактивен — IP выключен из-за пользователя
+    if (!$user_active) {
+        echo '<font color="red">' . WEB_msg_disabled . '</font>&nbsp;';
+    } elseif (!$record['auth_enabled']) {
+        echo '<font color="red">' . WEB_msg_disabled . '</font>&nbsp;';
+    }
+    if ($record['auth_blocked']) {
+        echo '<font color="red">' . WEB_msg_traffic_blocked . '</font>';
+    }
+}
+?>
     </b></td>
 </tr>
 <tr><td><?php echo WEB_cell_filter; ?></td><td><?php print get_group($db_link, $record["filter_group_id"]); ?> </td></tr>

+ 1 - 4
scripts/updates/3-0-1/migration.msql

@@ -17,14 +17,10 @@ RENAME TABLE Queue_list TO queue_list;
 
 ALTER TABLE wan_stats CHANGE COLUMN `in` bytes_in BIGINT NOT NULL DEFAULT 0;
 ALTER TABLE wan_stats CHANGE COLUMN `out` bytes_out BIGINT NOT NULL DEFAULT 0;
-
 ALTER TABLE group_filters CHANGE COLUMN `order` rule_order INTEGER NOT NULL DEFAULT 0;
-
 ALTER TABLE user_auth CHANGE COLUMN `client-id` client_id VARCHAR(250);
-
 ALTER TABLE customers CHANGE COLUMN `Login` login VARCHAR(20) DEFAULT 'NULL';
 
-
 -- Переименовываем eof → end_life в user_auth
 ALTER TABLE user_auth CHANGE COLUMN `eof` end_life TIMESTAMP NULL DEFAULT NULL;
 
@@ -84,6 +80,7 @@ ALTER TABLE ou              CHANGE COLUMN `comment` description VARCHAR(250);
 ALTER TABLE subnets         CHANGE COLUMN `comment` description VARCHAR(250);
 ALTER TABLE user_list       CHANGE COLUMN `comment` description VARCHAR(255);
 ALTER TABLE vendors         CHANGE COLUMN `comment` description VARCHAR(255);
+ALTER TABLE customers       CHANGE COLUMN `comment` description VARCHAR(255);
 
 -- ⚠️ user_auth.comments → description
 ALTER TABLE user_auth       CHANGE COLUMN `comments` description VARCHAR(250);