Repository navigation
Expand file tree
/
Copy pathconsole.php
More file actions
1479 lines (1308 loc) · 55.4 KB
/
Copy pathconsole.php
File metadata and controls
1479 lines (1308 loc) · 55.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* 高级IP访问控制插件 - 控制台页面
*
* 显示详细的日志记录和统计信息
*/
if (!defined('__TYPECHO_ADMIN__') && !defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
// 引入适配器确保类别名正确加载
require_once __DIR__ . '/adapter.php';
// 获取必要的对象
$request = Typecho_Request::getInstance();
$action = $request->get('action', '');
$page = max(1, (int)$request->get('page', 1));
$pageSize = 15;
// 获取数据库连接
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
$optionsWidget = Widget_Options::alloc(); // Use a different name to avoid conflict if $options is used later for plugin options specifically
$pluginOptions = $optionsWidget->plugin('AdvancedBlockIP');
// 处理清空日志请求
if ($action === 'clear_logs' && $request->isPost()) {
try {
$db->query($db->delete($prefix . 'blockip_logs'));
$success_message = "日志已清空";
} catch (Exception $e) {
$error_message = "清空失败: " . $e->getMessage();
}
}
// 处理修复数据库结构的请求
if ($action === 'fix_database' && $request->isPost()) {
try {
// 调用Plugin类的修复方法
require_once __DIR__ . '/Plugin.php';
$result = \TypechoPlugin\AdvancedBlockIP\Plugin::fixDatabaseSchema();
$success_message = $result;
} catch (\Exception $e) {
$error_message = "修复数据库失败: " . $e->getMessage();
}
}
// 处理从黑名单删除IP的请求
if ($action === 'delete_from_blacklist' && $request->isPost()) {
$ipToDelete = $request->get('ip_to_delete', '');
if ($ipToDelete) {
try {
// $pluginOptions is already loaded
if ($pluginOptions) {
$blacklistConfigKey = isset($pluginOptions->blacklist) ? 'blacklist' : (isset($pluginOptions->ips) ? 'ips' : null);
$currentBlacklist = $blacklistConfigKey ? $pluginOptions->{$blacklistConfigKey} : '';
$blacklistLines = preg_split('/[\\r\\n]+/', $currentBlacklist);
$newBlacklistLines = [];
$found = false;
foreach ($blacklistLines as $line) {
$trimmedLine = trim($line);
if (empty($trimmedLine)) {
continue; // Skip empty or whitespace-only lines
}
// Check if the line starts with the IP to delete, optionally followed by a space and #
if (preg_match('/^' . preg_quote($ipToDelete, '/') . '(\\s+#.*)?$/', $trimmedLine)) {
$found = true;
continue; // Skip this line
}
$newBlacklistLines[] = $line; // Add the original line back
}
if ($found) {
$updatedBlacklist = implode("\n", $newBlacklistLines);
// 重新获取当前完整的插件配置
$currentConfigResult = $db->fetchObject($db->select('value')
->from('table.options')
->where('name = ? AND user = 0', 'plugin:AdvancedBlockIP'));
if ($currentConfigResult && $currentConfigResult->value) {
$currentPluginConfigArray = unserialize($currentConfigResult->value);
$currentPluginConfigArray[$blacklistConfigKey] = $updatedBlacklist;
$db->query(
$db->update('table.options')
->rows(['value' => serialize($currentPluginConfigArray)])
->where('name = ? AND user = 0', 'plugin:AdvancedBlockIP')
);
// 清除Typecho的配置缓存
try {
$reflectionClass = new \ReflectionClass('Widget_Options');
$configsProperty = $reflectionClass->getProperty('_configs');
$configsProperty->setAccessible(true);
$configsProperty->setValue(null, null);
$pluginsProperty = $reflectionClass->getProperty('_plugins');
$pluginsProperty->setAccessible(true);
$pluginsProperty->setValue(null, null);
} catch (\ReflectionException $e) {
error_log("AdvancedBlockIP Console Cache Clear Error: " . $e->getMessage());
}
$success_message = "IP '" . htmlspecialchars($ipToDelete) . "' 已从黑名单中移除。";
// 重定向到当前页面以刷新数据显示
header('Location: ' . $_SERVER['REQUEST_URI']);
exit;
} else {
$error_message = "无法获取插件配置以删除IP。";
}
} else {
$error_message = "未在黑名单中找到IP '" . htmlspecialchars($ipToDelete) . "'。";
}
} else {
$error_message = "无法加载插件配置以删除IP。";
}
} catch (Exception $e) {
$error_message = "从黑名单移除IP失败: " . $e->getMessage();
}
} else {
$error_message = "未指定要从黑名单移除的IP。";
}
}
// 处理删除本页日志请求
if ($action === 'delete_page_logs' && $request->isPost()) {
try {
// 获取当前页的日志ID
$offset = ($page - 1) * $pageSize;
$currentPageLogs = $db->fetchAll($db->select('id')
->from($prefix . 'blockip_logs')
->order('created', Typecho_Db::SORT_DESC)
->limit($pageSize)
->offset($offset));
if (!empty($currentPageLogs)) {
$deletedCount = 0;
foreach ($currentPageLogs as $log) {
$db->query($db->delete($prefix . 'blockip_logs')->where('id = ?', $log['id']));
$deletedCount++;
}
$success_message = "本页 " . $deletedCount . " 条日志已删除";
} else {
$error_message = "本页没有可删除的日志";
}
} catch (Exception $e) {
$error_message = "删除本页日志失败: " . $e->getMessage();
}
}
// 获取统计数据
function getDetailedStats($db, $prefix)
{
$stats = array();
try {
// 基础统计
$totalResult = $db->fetchObject($db->select('COUNT(*) as count')
->from($prefix . 'blockip_logs'));
$stats['total'] = $totalResult ? (int)$totalResult->count : 0;
// 今日统计
$today = strtotime('today');
$todayResult = $db->fetchObject($db->select('COUNT(*) as count')
->from($prefix . 'blockip_logs')
->where('created >= ?', $today));
$stats['today'] = $todayResult ? (int)$todayResult->count : 0;
// 自动加入黑名单统计
$autoBlacklistResult = $db->fetchObject($db->select('COUNT(*) as count')
->from($prefix . 'blockip_logs')
->where('action = ?', 'auto_blacklisted'));
$stats['auto_blacklisted'] = $autoBlacklistResult ? (int)$autoBlacklistResult->count : 0;
// 按原因分组统计
$reasonStats = $db->fetchAll($db->select('reason, COUNT(*) as count')
->from($prefix . 'blockip_logs')
->group('reason')
->order('count', Typecho_Db::SORT_DESC));
$stats['by_reason'] = $reasonStats ?: array();
// 最活跃IP统计
$topIPs = $db->fetchAll($db->select('ip, COUNT(*) as count')
->from($prefix . 'blockip_logs')
->group('ip')
->order('count', Typecho_Db::SORT_DESC)
->limit(10));
$stats['top_ips'] = $topIPs ?: array();
// 24小时内按小时统计
$hourlyStats = array();
for ($i = 23; $i >= 0; $i--) {
$hourStart = strtotime("-{$i} hours", strtotime(date('Y-m-d H:00:00')));
$hourEnd = $hourStart + 3600;
$hourResult = $db->fetchObject($db->select('COUNT(*) as count')
->from($prefix . 'blockip_logs')
->where('created >= ? AND created < ?', $hourStart, $hourEnd));
$hourlyStats[] = array(
'hour' => date('H:i', $hourStart),
'count' => $hourResult ? (int)$hourResult->count : 0
);
}
$stats['hourly'] = $hourlyStats;
} catch (Exception $e) {
$stats['error'] = $e->getMessage();
}
return $stats;
}
// 获取日志列表
function getLogsList($db, $prefix, $page, $pageSize)
{
$offset = ($page - 1) * $pageSize;
try {
// 获取总数
$totalResult = $db->fetchObject($db->select('COUNT(*) as count')
->from($prefix . 'blockip_logs'));
$total = $totalResult ? (int)$totalResult->count : 0;
// 获取日志列表
$logs = $db->fetchAll($db->select()
->from($prefix . 'blockip_logs')
->order('created', Typecho_Db::SORT_DESC)
->limit($pageSize)
->offset($offset));
return array(
'logs' => $logs ?: array(),
'total' => $total,
'total_pages' => ceil($total / $pageSize)
);
} catch (Exception $e) {
return array(
'logs' => array(),
'total' => 0,
'total_pages' => 0,
'error' => $e->getMessage()
);
}
}
$stats = getDetailedStats($db, $prefix);
$logData = getLogsList($db, $prefix, $page, $pageSize);
// 重新加载插件选项以确保获取最新数据(特别是在删除操作后)
$optionsWidget = Widget_Options::alloc();
$pluginOptions = $optionsWidget->plugin('AdvancedBlockIP');
// 获取黑名单条目
function getBlacklistEntries($pluginOptions)
{
$entries = [];
if (!$pluginOptions) {
return $entries;
}
$blacklistConfigKey = isset($pluginOptions->blacklist) ? 'blacklist' : (isset($pluginOptions->ips) ? 'ips' : null);
$blacklistString = $blacklistConfigKey ? $pluginOptions->{$blacklistConfigKey} : '';
if (empty($blacklistString)) {
return $entries;
}
$lines = preg_split('/[\\r\\n]+/', $blacklistString, -1, PREG_SPLIT_NO_EMPTY);
foreach ($lines as $line) {
$line = trim($line);
if (empty($line)) continue;
$ip = $line;
$reason = '手动添加'; // Default reason
$date_added = date('Y-m-d H:i:s'); // 默认使用当前时间
if (strpos($line, '#') !== false) {
list($ip, $comment) = explode('#', $line, 2);
$ip = trim($ip);
$comment = trim($comment);
// Try to parse reason and date from comment
// Example comment: 智能检测:频率异常, UA异常 @ 2024-07-30 10:00:00
if (preg_match('/^(.*?) @ (\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})$/', $comment, $matches)) {
$reason = trim($matches[1]);
$date_added = trim($matches[2]);
} elseif (!empty($comment)) {
// If comment doesn't match the full pattern but is not empty, use it as reason
$reason = $comment;
}
}
// Ensure IP is valid before adding (basic check)
if (
filter_var($ip, FILTER_VALIDATE_IP) ||
strpos($ip, '*') !== false ||
strpos($ip, '/') !== false ||
(strlen($ip) == 2 && ctype_alpha($ip)) || // Country code
(strpos($ip, '-') !== false && substr_count($ip, '.') >= 1) // Range
) {
$entries[] = [
'ip' => $ip,
'reason' => $reason,
'date_added' => $date_added
];
}
}
return $entries;
}
$blacklistEntries = getBlacklistEntries($pluginOptions);
// 获取原因的中文描述
function getReasonDescription($reason)
{
$descriptions = array(
'blacklisted' => '黑名单拦截',
'not_whitelisted' => '非白名单',
'smart_detection' => '智能检测',
'access_too_frequent' => '访问过频',
'blacklist_rate_limit' => '黑名单频率限制',
'frequency_anomaly' => '频率异常',
'user_agent_anomaly' => 'UA异常',
'referer_anomaly' => '来源异常',
'behavior_pattern' => '行为异常',
'smart_detection_auto_add' => '智能检测自动加入黑名单',
'频率异常' => '频率异常',
'UA异常' => 'UA异常',
'UA为空' => 'UA为空',
'来源异常' => '来源异常',
'行为模式异常' => '行为异常'
);
// 如果原因以特定前缀开头,直接返回完整描述
if (
strpos($reason, '智能检测:') === 0 ||
strpos($reason, '黑名单:') === 0
) {
return $reason;
}
return isset($descriptions[$reason]) ? $descriptions[$reason] : $reason;
}
// 构建当前页面URL(用于分页)
function getCurrentPageUrl($page = null)
{
$baseUrl = $_SERVER['REQUEST_URI'];
$baseUrl = preg_replace('/[?&]page=\d+/', '', $baseUrl);
$separator = strpos($baseUrl, '?') !== false ? '&' : '?';
if ($page !== null) {
return $baseUrl . $separator . 'page=' . $page;
}
return $baseUrl;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>IP防护控制台 - <?php echo $optionsWidget->title; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $optionsWidget->adminStaticUrl('css'); ?>/normalize.css">
<link rel="stylesheet" type="text/css" href="<?php echo $optionsWidget->adminStaticUrl('css'); ?>/grid.css">
<link rel="stylesheet" type="text/css" href="<?php echo $optionsWidget->adminStaticUrl('css'); ?>/style.css">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--color-primary: rgb(18, 123, 203);
/* 更柔和的蓝色 */
--color-primary-light: #e8f4fd;
--color-primary-dark: #4a8bc2;
--color-success: #28a745;
/* 绿色成功 */
--color-success-light: #eaf6ec;
--color-danger: rgb(245, 68, 86);
/* 红色危险 */
--color-danger-light: #fdecea;
--color-warning: #ffc107;
/* 黄色警告 */
--color-text-primary: #212529;
/* 主要文本 */
--color-text-secondary: #6c757d;
/* 次要文本 */
--color-text-muted: #adb5bd;
/* 静默文本 */
--color-background: #f8f9fa;
/* 主背景 */
--color-card-background: #ffffff;
/* 卡片背景 */
--color-border: #dee2e6;
/* 边框颜色 */
--font-family-sans-serif: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
--border-radius: 0.375rem;
/* 6px - Slightly smaller radius for a tighter feel */
--box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.04);
/* Subtler shadow */
}
* {
box-sizing: border-box;
}
body {
font-family: var(--font-family-sans-serif);
background-color: var(--color-background);
color: var(--color-text-primary);
line-height: 1.55;
/* Slightly tighter line height */
margin: 0;
padding: 0;
font-size: 15px;
/* Base font size slightly reduced */
}
.container {
max-width: 1500px;
/* Slightly reduced max-width */
margin: 0 auto;
padding: 1.5rem;
/* Reduced container padding */
}
/* 标签页导航样式 */
.tab-navigation {
display: flex;
background: var(--color-card-background);
border-radius: var(--border-radius) var(--border-radius) 0 0;
box-shadow: var(--box-shadow);
margin-bottom: 0;
overflow: hidden;
}
.tab-button {
flex: 1;
padding: 1rem 1.5rem;
background: transparent;
border: none;
cursor: pointer;
font-size: 0.9375rem;
font-weight: 500;
color: var(--color-text-secondary);
transition: all 0.2s ease;
border-bottom: 3px solid transparent;
position: relative;
}
.tab-button:hover {
background-color: #f8f9fa;
color: var(--color-text-primary);
}
.tab-button.active {
color: var(--color-primary);
border-bottom-color: var(--color-primary);
background-color: var(--color-card-background);
}
.tab-button .tab-icon {
margin-right: 0.5rem;
font-size: 1.1rem;
}
/* 标签页内容样式 */
.tab-content {
display: none;
background: var(--color-card-background);
border-radius: 0 0 var(--border-radius) var(--border-radius);
box-shadow: var(--box-shadow);
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.tab-content.active {
display: block;
}
/* 页面头部 */
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
/* Reduced margin */
padding-bottom: 1rem;
/* Reduced padding */
border-bottom: 1px solid var(--color-border);
}
.page-title-group {
flex-grow: 1;
}
.page-title {
font-size: 1.75rem;
/* Reduced from 1.875rem */
font-weight: 600;
margin: 0;
color: var(--color-text-primary);
}
.page-subtitle {
font-size: 0.875rem;
/* Reduced from 0.9375rem */
font-weight: 400;
color: var(--color-text-secondary);
margin-top: 0.2rem;
}
.action-buttons-header {
display: flex;
gap: 0.625rem;
/* Reduced gap */
}
/* 消息提示 */
.message {
padding: 0.875rem 1rem;
/* Reduced padding */
margin: 1.25rem 0;
/* Reduced margin */
border-radius: var(--border-radius);
font-weight: 500;
font-size: 0.875rem;
/* Reduced font size */
border: 1px solid transparent;
}
.success {
background-color: var(--color-success-light);
color: var(--color-success);
border-color: var(--color-success);
}
.error {
background-color: var(--color-danger-light);
color: var(--color-danger);
border-color: var(--color-danger);
}
/* 卡片基础样式 */
.card {
background-color: var(--color-card-background);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
margin-bottom: 1.25rem;
/* Reduced margin */
padding: 1.25rem;
/* Reduced padding */
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.card:hover {
transform: translateY(-2px);
/* Reduced hover effect */
box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.06);
}
.card-header {
display: flex;
align-items: center;
margin-bottom: 1rem;
/* Reduced margin */
padding-bottom: 0.625rem;
/* Reduced padding */
border-bottom: 1px solid var(--color-border);
}
.card-icon {
font-size: 1.125rem;
/* Reduced icon size */
margin-right: 0.625rem;
color: var(--color-primary);
}
.card-title {
font-size: 1.0625rem;
/* Approx 17px, reduced */
font-weight: 600;
margin: 0;
color: var(--color-text-primary);
}
/* 统计卡片 */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
/* Reduced minmax */
gap: 1rem;
/* Reduced gap */
margin-bottom: 1.5rem;
/* Reduced margin */
}
.stat-card {
padding: 1rem;
/* Reduced padding */
text-align: center;
}
.stat-number {
font-size: 2rem;
/* Reduced from 2.25rem */
font-weight: 700;
margin-bottom: 0.2rem;
color: var(--color-primary);
line-height: 1.1;
}
.stat-label {
font-size: 0.8125rem;
/* Reduced from 0.875rem */
font-weight: 500;
color: var(--color-text-secondary);
margin: 0;
}
/* 趋势图表 */
.hourly-chart-container .card-header {
margin-bottom: 0.625rem;
/* Reduced margin */
}
.hourly-chart {
display: flex;
align-items: flex-end;
height: 170px;
/* Reduced from 200px */
gap: 0.2rem;
/* Reduced gap */
padding: 0.75rem 0 0 0;
/* Reduced padding */
}
.hour-bar {
flex: 1;
background-color: var(--color-primary-light);
border-top: 2px solid var(--color-primary);
position: relative;
cursor: pointer;
border-radius: 0.1875rem 0.1875rem 0 0;
/* 3px */
transition: background-color 0.2s ease, border-color 0.2s ease;
}
.hour-bar:hover {
background-color: var(--color-primary);
border-color: var(--color-primary-dark);
}
.hour-bar:hover::after {
content: attr(data-tooltip);
position: absolute;
bottom: 105%;
left: 50%;
transform: translateX(-50%);
background-color: var(--color-text-primary);
color: white;
padding: 0.4rem 0.6rem;
/* Reduced padding */
border-radius: 0.25rem;
/* 4px */
font-size: 0.75rem;
/* Reduced from 0.8125rem */
font-weight: 500;
white-space: nowrap;
z-index: 10;
box-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.1);
}
.chart-time-labels {
display: flex;
justify-content: space-between;
font-size: 0.75rem;
/* Reduced from 0.8125rem */
color: var(--color-text-muted);
margin-top: 0.4rem;
padding: 0 0.2rem;
}
/* 原因和IP统计 */
.detailed-stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
/* Reduced minmax */
gap: 1rem;
/* Reduced gap */
}
.list-stat-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.625rem 0;
/* Reduced padding */
border-bottom: 1px solid var(--color-border);
font-size: 0.875rem;
/* Reduced from 0.9375rem */
}
.list-stat-item:last-child {
border-bottom: none;
}
.list-stat-item span:first-child {
font-weight: 500;
color: var(--color-text-secondary);
}
.list-stat-item-value {
font-weight: 600;
color: var(--color-text-primary);
background-color: #e9ecef;
padding: 0.2rem 0.5rem;
/* Reduced padding */
border-radius: 0.1875rem;
/* 3px */
font-size: 0.8125rem;
/* Reduced from 0.875rem */
}
.monospace-font {
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}
/* 黑名单表格专用样式 */
.blacklist-table {
width: 100%;
border-collapse: collapse;
margin-top: 0.75rem;
font-size: 0.8125rem;
}
.blacklist-table th,
.blacklist-table td {
padding: 0.625rem 0.75rem;
text-align: left;
border-bottom: 1px solid var(--color-border);
}
.blacklist-table th {
background-color: #f1f3f5;
font-weight: 600;
font-size: 0.75rem;
color: var(--color-text-secondary);
text-transform: uppercase;
letter-spacing: 0.025em;
}
.blacklist-table tr:hover td {
background-color: #f8f9fa;
}
.blacklist-table .btn-delete-ip {
font-size: 0.75rem;
padding: 0.25rem 0.5rem;
}
/* 日志表格 */
.log-table-container .card-header {
justify-content: space-between;
}
.log-summary {
font-size: 0.875rem;
/* Reduced from 0.9375rem */
color: var(--color-text-secondary);
}
.log-table {
width: 100%;
border-collapse: collapse;
margin-top: 0.75rem;
/* Reduced margin */
font-size: 0.8125rem;
/* Reduced from 0.875rem */
}
.log-table th,
.log-table td {
padding: 0.625rem 0.75rem;
/* Reduced padding */
text-align: left;
border-bottom: 1px solid var(--color-border);
}
.log-table th {
background-color: #f1f3f5;
font-weight: 600;
font-size: 0.75rem;
/* Reduced from 0.8125rem */
color: var(--color-text-secondary);
text-transform: uppercase;
letter-spacing: 0.025em;
}
.log-table tr:hover td {
background-color: #f8f9fa;
}
.log-table td .highlight {
background-color: var(--color-danger-light);
color: var(--color-danger);
padding: 0.2rem 0.4rem;
/* Reduced padding */
border-radius: 0.1875rem;
/* 3px */
font-weight: 600;
font-size: 0.6875rem;
/* 11px, reduced */
display: inline-block;
}
.log-table .text-truncate {
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
vertical-align: middle;
}
/* 分页 */
.pagination {
text-align: center;
margin: 1.5rem 0 0.75rem 0;
/* Reduced margin */
}
.pagination a,
.pagination span {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 32px;
/* Reduced size */
height: 32px;
/* Reduced size */
padding: 0 0.625rem;
/* Reduced padding */
margin: 0 0.1875rem;
/* Reduced margin */
border: 1px solid var(--color-border);
text-decoration: none;
border-radius: 0.25rem;
/* 4px */
transition: all 0.2s ease;
font-weight: 500;
font-size: 0.8125rem;
/* Reduced font size */
background-color: var(--color-card-background);
color: var(--color-primary);
}
.pagination a:hover {
background-color: var(--color-primary-light);
border-color: var(--color-primary);
color: var(--color-primary-dark);
}
.pagination .current {
background-color: var(--color-primary);
color: white;
border-color: var(--color-primary);
font-weight: 600;
}
/* 按钮样式 */
.btn {
display: inline-flex !important;
align-items: center;
justify-content: center;
gap: 0.3rem;
/* 减小间距 */
padding: 0.4rem 0.8rem !important;
/* 减小内边距 */
border: 1px solid transparent;
border-radius: 0.25rem;
/* 4px */
text-decoration: none;
font-weight: 500;
/* Standardized weight */
font-size: 0.8125rem;
/* 减小字体 */
cursor: pointer;
transition: all 0.2s ease-in-out;
line-height: 1.4;
/* 减小行高 */
box-sizing: border-box;
height: auto !important;
vertical-align: middle;
}
.btn-primary {
background-color: var(--color-primary) !important;
color: white !important;
border-color: var(--color-primary) !important;
}
.btn-primary:hover {
background-color: var(--color-primary-dark) !important;
border-color: var(--color-primary-dark) !important;
color: white !important;
text-decoration: none !important;
transform: translateY(-1px);
}
.btn-danger {
background-color: var(--color-danger) !important;
color: white !important;
border-color: var(--color-danger) !important;
}
.btn-danger:hover {
background-color: #c82333 !important;
border-color: #c82333 !important;
color: white !important;
text-decoration: none !important;
transform: translateY(-1px);
}
.btn-outline-secondary {
background-color: transparent !important;
color: var(--color-text-secondary) !important;
border-color: var(--color-border) !important;
}
.btn-outline-secondary:hover {
background-color: var(--color-text-secondary) !important;
color: white !important;
border-color: var(--color-text-secondary) !important;
text-decoration: none !important;
}
/* 确保按钮图标和文字对齐 */
.btn-icon {
display: inline-flex;
align-items: center;
font-size: 0.875rem;
/* 减小图标尺寸 */
}
/* 功能说明区域 */
.info-section .card-title {
font-size: 1.0625rem;
/* Consistent with other card titles */
}
.info-section ul {
margin: 0;
padding-left: 0;
list-style: none;
}
.info-section li {
margin-bottom: 0.625rem;
/* Reduced margin */
color: var(--color-text-secondary);
font-size: 0.875rem;
/* Reduced font size */
padding-left: 1.25rem;
/* Reduced padding */
position: relative;
}
.info-section li::before {
content: '💡';
position: absolute;
left: 0;
color: var(--color-warning);
font-size: 0.9rem;
/* Reduced icon size */
}
.info-section .info-highlight {
color: var(--color-primary);
font-weight: 600;
}
/* 空状态 */
.empty-state {
text-align: center;
padding: 1.5rem;
/* Reduced padding */
color: var(--color-text-muted);
}
.empty-state-icon {
font-size: 2.5rem;
/* Reduced icon size */