Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
740 lines (657 loc) · 31.4 KB
/
Copy pathindex.php
File metadata and controls
740 lines (657 loc) · 31.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
<?php
require_once __DIR__ . '/config.php';
session_start();
function getClientIP() {
$headers = ['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'REMOTE_ADDR'];
foreach ($headers as $header) {
if (!empty($_SERVER[$header])) {
return strpos($_SERVER[$header], ',') !== false
? trim(explode(',', $_SERVER[$header])[0])
: $_SERVER[$header];
}
}
return '0.0.0.0';
}
function checkRateLimit($ip) {
$rateFile = __DIR__ . '/rate_limits.json';
$limits = file_exists($rateFile) ? json_decode(file_get_contents($rateFile), true) : [];
$now = time();
foreach ($limits as $key => $record) {
if ($record['time'] < ($now - 60)) {
unset($limits[$key]);
}
}
$ipKey = md5($ip);
if (!isset($limits[$ipKey])) {
$limits[$ipKey] = ['time' => $now, 'count' => 0];
}
$limits[$ipKey]['count']++;
file_put_contents($rateFile, json_encode($limits));
return $limits[$ipKey]['count'] <= 10;
}
function loadData() {
$content = file_get_contents(DATA_FILE);
$data = json_decode($content, true);
if (!isset($data['links'])) $data['links'] = [];
if (!isset($data['total_clicks'])) $data['total_clicks'] = 0;
if (!isset($data['recent'])) $data['recent'] = [];
if (!isset($data['blocked_ips'])) $data['blocked_ips'] = [];
if (!isset($data['blocked_domains_log'])) $data['blocked_domains_log'] = [];
return $data;
}
function saveData($data) {
file_put_contents(DATA_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
}
function generateCode($length = 6) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code = '';
for ($i = 0; $i < $length; $i++) {
$code .= $characters[random_int(0, strlen($characters) - 1)];
}
return $code;
}
function checkSensitiveUrl($url) {
$sensitiveWords = SENSITIVE_WORDS;
$foundWords = [];
$urlLower = strtolower($url);
foreach ($sensitiveWords as $word) {
if (stripos($urlLower, strtolower($word)) !== false) {
$foundWords[] = $word;
}
}
return [
'is_risky' => count($foundWords) >= RISK_THRESHOLD,
'found_words' => $foundWords
];
}
/**
* 检查域名是否在黑名单中
*/
function isDomainBlacklisted($url) {
if (!ENABLE_DOMAIN_BLACKLIST) {
return false;
}
$blacklist = BLACKLIST_DOMAINS;
if (empty($blacklist)) {
return false;
}
// 解析域名
$host = parse_url($url, PHP_URL_HOST);
if (empty($host)) {
return false;
}
// 去掉 www. 前缀
$host = preg_replace('/^www\./', '', $host);
$hostLower = strtolower($host);
$mode = DOMAIN_BLACKLIST_MODE;
foreach ($blacklist as $domain) {
$domainLower = strtolower($domain);
switch ($mode) {
case 'exact':
// 精确匹配
if ($hostLower === $domainLower) {
return $domain;
}
break;
case 'contains':
// 包含匹配(检查域名是否包含黑名单字符串)
if (strpos($hostLower, $domainLower) !== false) {
return $domain;
}
break;
case 'suffix':
default:
// 后缀匹配(检查是否以黑名单域名结尾)
// 支持子域名匹配:sub.example.com 匹配 example.com
if ($hostLower === $domainLower ||
strpos($hostLower, '.' . $domainLower) !== false) {
return $domain;
}
// 也检查反向:黑名单域名是否以目标域名结尾(用于通配符效果)
if (strpos($domainLower, '.' . $hostLower) !== false) {
return $domain;
}
break;
}
}
return false;
}
function checkLoopReference($url, $code, $data) {
if (strpos($url, SITE_URL) === 0) {
$target_code = str_replace(SITE_URL . '/', '', rtrim($url, '/'));
if ($target_code === $code) {
return ['error' => '不能创建指向自身的短链,这会导致无限循环!'];
}
if (isset($data['links'][$target_code])) {
return ['error' => '不能创建指向本站其他短链的链接,请使用原始URL!'];
}
}
return ['error' => null];
}
if (!isset($_SESSION['captcha_answer'])) {
$num1 = rand(1, 10);
$num2 = rand(1, 5);
$_SESSION['captcha_answer'] = $num1 + $num2;
$_SESSION['captcha_nums'] = ['num1' => $num1, 'num2' => $num2];
}
$num1 = $_SESSION['captcha_nums']['num1'];
$num2 = $_SESSION['captcha_nums']['num2'];
$result = null;
$error = null;
if (!isset($_SESSION['form_token'])) {
$_SESSION['form_token'] = bin2hex(random_bytes(32));
}
$form_token = $_SESSION['form_token'];
if ($_SERVER['REQUEST_METHOD'] === 'POST' && ALLOW_PUBLIC_CREATE) {
if (!isset($_POST['form_token']) || $_POST['form_token'] !== $_SESSION['form_token']) {
$error = '表单已过期,请重新提交';
$_SESSION['form_token'] = bin2hex(random_bytes(32));
$_SESSION['last_error'] = $error;
header('Location: ' . SITE_URL);
exit;
}
$_SESSION['form_token'] = bin2hex(random_bytes(32));
$long_url = trim($_POST['url'] ?? '');
$custom_code = trim($_POST['custom_code'] ?? '');
$captcha_input = $_POST['captcha'] ?? '';
if (empty($captcha_input)) {
$error = '请填写验证码';
} elseif ((int)$captcha_input !== (int)$_SESSION['captcha_answer']) {
$error = '验证码错误,请重新输入';
} elseif (!checkRateLimit(getClientIP())) {
$error = '操作过于频繁,请一分钟后再试';
} elseif (empty($long_url)) {
$error = '请输入需要缩短的链接地址';
} elseif (!filter_var($long_url, FILTER_VALIDATE_URL)) {
$error = '请输入有效的URL地址(包含 http:// 或 https://)';
} else {
$data = loadData();
// ========== 新增:域名黑名单检查 ==========
if (ENABLE_DOMAIN_BLACKLIST) {
$blockedDomain = isDomainBlacklisted($long_url);
if ($blockedDomain) {
$error = '该域名 (' . htmlspecialchars($blockedDomain) . ') 已被禁止创建短链,请使用其他链接。';
// 记录被拦截的域名
if (LOG_BLOCKED_DOMAINS) {
if (!isset($data['blocked_domains_log'])) {
$data['blocked_domains_log'] = [];
}
$data['blocked_domains_log'][] = [
'domain' => $blockedDomain,
'url' => $long_url,
'ip' => getClientIP(),
'time' => date('Y-m-d H:i:s')
];
// 只保留最近100条记录
if (count($data['blocked_domains_log']) > 100) {
$data['blocked_domains_log'] = array_slice($data['blocked_domains_log'], -100);
}
saveData($data);
}
}
}
if (!isset($error)) {
if (FORBIDDEN_LOOP) {
$loopCheck = checkLoopReference($long_url, $custom_code, $data);
if ($loopCheck['error']) {
$error = $loopCheck['error'];
}
}
}
$checkResult = checkSensitiveUrl($long_url);
$initialStatus = $checkResult['is_risky'] ? 'risk' : 'normal';
$riskReason = $checkResult['is_risky'] ? '该链接包含不安全内容,已被系统标记' : null;
if (!isset($error)) {
if (!empty($custom_code) && ALLOW_CUSTOM_CODE) {
if (isset($data['links'][$custom_code])) {
$error = '短码 "' . $custom_code . '" 已被使用,请换一个';
} elseif (!preg_match('/^[a-zA-Z0-9]+$/', $custom_code)) {
$error = '短码只能包含字母和数字';
} elseif (strlen($custom_code) < 2 || strlen($custom_code) > 20) {
$error = '短码长度应在2-20个字符之间';
} else {
$code = $custom_code;
}
} else {
do {
$code = generateCode(CODE_LENGTH);
} while (isset($data['links'][$code]));
}
}
if (!isset($error)) {
$ip = getClientIP();
$now = date('Y-m-d H:i:s');
$data['links'][$code] = [
'url' => $long_url,
'created_at' => $now,
'clicks' => 0,
'ip' => $ip,
'status' => $initialStatus,
'risk_reason' => $riskReason,
'risk_detected_at' => $riskReason ? $now : null,
'status_history' => [
['from' => 'none', 'to' => $initialStatus, 'by' => 'system', 'time' => $now]
]
];
$recent_item = [
'code' => $code,
'url' => $long_url,
'short_url' => SITE_URL . '/' . $code,
'created_at' => $now,
'ip' => $ip,
'status' => $initialStatus
];
array_unshift($data['recent'], $recent_item);
if (count($data['recent']) > 100) {
$data['recent'] = array_slice($data['recent'], 0, 100);
}
saveData($data);
$short_url = SITE_URL . '/' . $code;
$result = [
'short_url' => $short_url,
'code' => $code,
'original_url' => $long_url,
'status' => $initialStatus
];
if ($initialStatus === 'risk') {
$error = '该链接包含不安全内容,已被系统标记为风险状态。如为误判,请发送邮件至 <a href="mailto:qqzqxq@163.com" style="color:#ec4899;font-weight:bold;">qqzqxq@163.com</a> 说明情况,我们核实后会解除限制。';
$result = null;
}
$_SESSION['last_result'] = $result;
$_SESSION['last_error'] = $error;
unset($_SESSION['captcha_answer'], $_SESSION['captcha_nums']);
header('Location: ' . SITE_URL);
exit;
}
}
if ($error) {
$_SESSION['last_error'] = $error;
unset($_SESSION['captcha_answer'], $_SESSION['captcha_nums']);
header('Location: ' . SITE_URL);
exit;
}
}
if (isset($_SESSION['last_result'])) {
$result = $_SESSION['last_result'];
unset($_SESSION['last_result']);
}
if (isset($_SESSION['last_error'])) {
$error = $_SESSION['last_error'];
unset($_SESSION['last_error']);
}
$data = loadData();
$total_links = count($data['links']);
$total_clicks = $data['total_clicks'];
$recent_records = $data['recent'] ?? [];
$recent_records_display = array_filter($recent_records, function($record) use ($data) {
$code = $record['code'];
if (isset($data['links'][$code])) {
$status = $data['links'][$code]['status'] ?? 'normal';
return $status === 'normal';
}
return false;
});
$recent_records_display = array_values($recent_records_display);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>流欺短链 - 免费短链接生成服务 | 永久有效</title>
<meta name="description" content="流欺短链提供免费、稳定的短链接生成服务。支持自定义短码,永久有效,简单快捷。立即生成你的短链接!">
<meta name="keywords" content="短链接,短网址,短链生成,免费短链,URL缩短,流欺短链,在线短链工具">
<link rel="canonical" href="<?php echo SITE_URL; ?>">
<meta property="og:type" content="website">
<meta property="og:title" content="流欺短链 - 免费短链接生成服务">
<meta property="og:description" content="免费、稳定的短链接生成服务,支持自定义短码,永久有效。">
<meta property="og:url" content="<?php echo SITE_URL; ?>">
<meta property="og:site_name" content="流欺短链">
<meta property="og:locale" content="zh_CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="流欺短链 - 免费短链接生成服务">
<meta name="twitter:description" content="免费、稳定的短链接生成服务,支持自定义短码。">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "流欺短链",
"description": "免费短链接生成服务",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "All",
"url": "<?php echo SITE_URL; ?>",
"browserRequirements": "Requires JavaScript",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "CNY"
}
}
</script>
<link rel="preconnect" href="https://cdn.jsdmirror.com">
<link rel="dns-prefetch" href="https://cdn.jsdmirror.com">
<link href="https://cdn.jsdmirror.com/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--pink-primary: #f472b6;
--pink-light: #f9a8d4;
--pink-dark: #ec4899;
--pink-glow: rgba(244, 114, 182, 0.3);
--glass-bg: rgba(255, 245, 250, 0.75);
--glass-border: rgba(244, 114, 182, 0.2);
--text-dark: #831843;
}
html.darkmode {
--glass-bg: rgba(30, 20, 25, 0.8);
--text-dark: #fbcfe8;
}
.bg-slideshow { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -2; overflow: hidden; }
.bg-slideshow .slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; opacity: 0; transition: opacity 1.2s ease-in-out; filter: brightness(0.7); }
.bg-slideshow .slide.active { opacity: 1; z-index: 1; }
html.darkmode .bg-slideshow .slide { filter: brightness(0.4); }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; min-height: 100vh; background: transparent; }
.container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; position: relative; z-index: 10; }
.card-glass {
background: var(--glass-bg);
backdrop-filter: blur(16px) saturate(180%);
border-radius: 28px;
box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 0 0 1px var(--glass-border);
margin-bottom: 30px;
transition: all 0.3s ease;
}
.card-glass:hover { box-shadow: 0 12px 48px var(--pink-glow), 0 0 0 1px var(--pink-light); transform: translateY(-2px); }
.card-inner { padding: 35px 30px; }
.logo-area { text-align: center; margin-bottom: 35px; }
.logo-area h1 { font-size: 52px; font-weight: 700; background: linear-gradient(135deg, #f472b6 0%, #ec4899 50%, #fbcfe8 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.logo-area p { color: var(--text-dark); margin-top: 8px; font-size: 16px; opacity: 0.8; }
html.darkmode .logo-area p { color: var(--text-light); }
.stats-row { display: flex; justify-content: space-around; padding: 20px 0; margin-bottom: 20px; border-bottom: 1px solid var(--glass-border); }
.stat-item { text-align: center; }
.stat-number { font-size: 32px; font-weight: bold; background: linear-gradient(135deg, #f472b6, #ec4899); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { font-size: 13px; color: var(--text-dark); margin-top: 5px; opacity: 0.7; }
html.darkmode .stat-label { color: var(--text-light); }
.form-group { margin-bottom: 22px; }
label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-dark); }
html.darkmode label { color: var(--text-light); }
input[type="url"], input[type="text"], input[type="number"] { width: 100%; padding: 14px 18px; background: rgba(255,255,255,0.5); border: 1.5px solid var(--glass-border); border-radius: 20px; font-size: 16px; outline: none; color: var(--text-dark); }
input:focus { border-color: var(--pink-primary); box-shadow: 0 0 0 4px var(--pink-glow); background: rgba(255,255,255,0.7); }
html.darkmode input { background: rgba(50,40,45,0.5); color: var(--text-light); }
.input-hint { font-size: 12px; color: var(--text-dark); margin-top: 6px; opacity: 0.6; }
.captcha-group { display: flex; align-items: center; gap: 12px; }
.captcha-question {
background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
color: white;
padding: 14px 20px;
border-radius: 20px;
font-weight: bold;
font-size: 18px;
white-space: nowrap;
min-width: 120px;
text-align: center;
}
.captcha-group input { width: 120px; }
.btn-pink { width: 100%; padding: 14px; background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%); border: none; border-radius: 40px; color: white; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 2px 8px var(--pink-glow); }
.btn-pink:hover { transform: translateY(-2px); box-shadow: 0 8px 25px var(--pink-glow); filter: brightness(1.05); }
.result-card { margin-top: 25px; padding: 20px; background: rgba(255,245,250,0.6); border-radius: 20px; text-align: center; backdrop-filter: blur(8px); }
html.darkmode .result-card { background: rgba(50,40,45,0.5); }
.result-card a { color: var(--pink-dark); font-size: 16px; word-break: break-all; text-decoration: none; font-weight: 500; }
.copy-btn { margin-top: 12px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); font-size: 14px; padding: 8px 24px; width: auto; display: inline-block; border-radius: 40px; border: none; color: white; cursor: pointer; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.error-msg { margin-top: 15px; padding: 12px; background: rgba(244,114,182,0.15); color: #db2777; border-radius: 16px; text-align: center; backdrop-filter: blur(4px); }
.recent-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; color: var(--text-dark); display: flex; align-items: center; gap: 10px; }
.recent-table { width: 100%; border-collapse: collapse; }
.recent-table th, .recent-table td { padding: 14px 10px; text-align: left; border-bottom: 1px solid var(--glass-border); font-size: 14px; }
.recent-table th { font-weight: 600; color: var(--text-dark); opacity: 0.8; }
.recent-table td { color: var(--text-dark); }
html.darkmode .recent-table td { color: var(--text-light); }
.short-link { color: var(--pink-dark); text-decoration: none; font-family: monospace; font-weight: 500; }
.target-url { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-url a { color: #888; text-decoration: none; }
.target-url a:hover { color: var(--pink-primary); }
.time-cell { font-size: 12px; opacity: 0.7; white-space: nowrap; }
.copy-icon { background: none; border: none; color: var(--pink-primary); cursor: pointer; font-size: 16px; padding: 4px 8px; transition: all 0.2s; border-radius: 8px; }
.copy-icon:hover { transform: scale(1.1); color: var(--pink-dark); background: rgba(244,114,182,0.1); }
.footer-text { text-align: center; margin-top: 20px; color: var(--text-dark); font-size: 13px; opacity: 0.7; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; color: var(--text-dark); margin-top: 20px; }
.feature-item { text-align: center; padding: 15px; }
.feature-item h3 { font-size: 16px; color: var(--pink-dark); margin-bottom: 8px; }
.feature-item p { font-size: 14px; opacity: 0.8; }
.breadcrumb { margin-bottom: 20px; font-size: 14px; color: var(--text-dark); opacity: 0.7; }
.breadcrumb a { color: var(--pink-dark); text-decoration: none; }
.breadcrumb span { margin: 0 8px; }
@media (max-width: 768px) {
.container { padding: 20px 15px; }
.card-inner { padding: 25px 20px; }
.logo-area h1 { font-size: 38px; }
.captcha-group { flex-direction: column; align-items: flex-start; }
.captcha-group input { width: 100%; }
.features-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
.features-grid { grid-template-columns: 1fr; }
.stats-row { flex-wrap: wrap; gap: 15px; }
.stat-item { flex: 1; min-width: 80px; }
}
</style>
</head>
<body>
<div id="bgSlideshow" class="bg-slideshow"></div>
<div class="container">
<nav class="breadcrumb" aria-label="面包屑导航">
<a href="<?php echo SITE_URL; ?>">首页</a>
<span>/</span>
<span>短链生成</span>
</nav>
<header class="card-glass">
<div class="card-inner">
<div class="logo-area">
<h1>流欺短链</h1>
<p>简单 · 免费 · 实用的短链接服务</p>
</div>
<div class="stats-row">
<div class="stat-item">
<div class="stat-number"><?php echo $total_links; ?></div>
<div class="stat-label">总链接数</div>
</div>
<div class="stat-item">
<div class="stat-number"><?php echo number_format($total_clicks); ?></div>
<div class="stat-label">总点击量</div>
</div>
</div>
<form method="POST" action="">
<input type="hidden" name="form_token" value="<?php echo $form_token; ?>">
<div class="form-group">
<label for="url_input">长链接地址</label>
<input type="url" id="url_input" name="url" placeholder="https://example.com/very/long/url" required>
</div>
<?php if (ALLOW_CUSTOM_CODE): ?>
<div class="form-group">
<label for="custom_code_input">自定义短码(可选)</label>
<input type="text" id="custom_code_input" name="custom_code" placeholder="例如: mylink">
<div class="input-hint">留空自动生成随机短码,只能包含字母和数字</div>
</div>
<?php endif; ?>
<div class="form-group">
<label>验证码</label>
<div class="captcha-group">
<span class="captcha-question"><?php echo $num1; ?> + <?php echo $num2; ?> = ?</span>
<input type="number" name="captcha" placeholder="输入结果" required>
</div>
<div class="input-hint">请输入左侧算式的结果</div>
</div>
<button type="submit" class="btn-pink">生成短链接</button>
</form>
<?php if ($result): ?>
<div class="result-card">
<div style="margin-bottom: 8px;">生成成功!</div>
<a href="<?php echo $result['short_url']; ?>" target="_blank"><?php echo $result['short_url']; ?></a>
<br>
<button class="copy-btn" onclick="copyToClipboard('<?php echo $result['short_url']; ?>')">复制链接</button>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div class="error-msg"><?php echo $error; ?></div>
<?php endif; ?>
</div>
</header>
<section class="card-glass" aria-label="为什么选择流欺短链">
<div class="card-inner">
<h2 style="font-size: 20px; color: var(--text-dark); margin-bottom: 15px; text-align: center;">为什么选择流欺短链?</h2>
<div class="features-grid">
<div class="feature-item">
<h3>完全免费</h3>
<p>无需注册,不限次数,永久免费使用</p>
</div>
<div class="feature-item">
<h3>快速生成</h3>
<p>智能算法,毫秒级生成短链接</p>
</div>
<div class="feature-item">
<h3>安全可靠</h3>
<p>自动检测风险链接,保护用户安全</p>
</div>
<div class="feature-item">
<h3>数据追踪</h3>
<p>实时统计点击量,了解链接效果</p>
</div>
</div>
</div>
</section>
<section class="card-glass" aria-label="最近生成的短链接">
<div class="card-inner">
<h2 class="recent-title">
<i class="fa fa-history" style="color: #f472b6;"></i> 最近创建的短链
<span style="font-size: 12px; font-weight: normal; opacity: 0.6;">(共 <?php echo count($recent_records_display); ?> 条)</span>
</h2>
<?php if (empty($recent_records_display)): ?>
<div style="text-align: center; padding: 40px; opacity: 0.6;">
<i class="fa fa-inbox" style="font-size: 48px; color: #f472b6;"></i>
<p style="margin-top: 10px;">暂无记录,去创建一个吧~</p>
</div>
<?php else: ?>
<div style="overflow-x: auto;">
<table class="recent-table">
<thead>
<tr>
<th style="width: 60px;">#</th>
<th>短链接</th>
<th style="min-width: 250px;">目标地址</th>
<th style="width: 140px;">创建时间</th>
<th style="width: 60px;">操作</th>
</tr>
</thead>
<tbody>
<?php $index = 1; ?>
<?php foreach ($recent_records_display as $record): ?>
<tr>
<td><?php echo $index++; ?></td>
<td><a href="<?php echo htmlspecialchars($record['short_url']); ?>" target="_blank" class="short-link"><?php echo htmlspecialchars($record['code']); ?></a></td>
<td class="target-url"><a href="<?php echo htmlspecialchars($record['url']); ?>" target="_blank" title="<?php echo htmlspecialchars($record['url']); ?>"><?php echo htmlspecialchars(mb_strimwidth($record['url'], 0, 50, '...')); ?></a></td>
<td class="time-cell"><?php echo $record['created_at']; ?></td>
<td><button class="copy-icon" onclick="copyToClipboard('<?php echo htmlspecialchars($record['short_url']); ?>')" title="复制链接"><i class="fa fa-copy"></i></button></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</section>
<footer class="footer-text">
<p>输入长链接即可免费使用 | 永久有效 | 展示最近100条公开记录</p>
<p style="margin-top: 10px; font-size: 12px;">
<a href="/privacy" style="color: var(--pink-dark); text-decoration: none;">隐私政策</a> |
<a href="/terms" style="color: var(--pink-dark); text-decoration: none;">服务条款</a>
</p>
</footer>
</div>
<script>
function copyToClipboard(text) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(function() {
alert('链接已复制到剪贴板!');
});
} else {
var textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
alert('链接已复制到剪贴板!');
}
}
class BackgroundSlideshow {
constructor(apiUrl, intervalMs) {
this.apiUrl = apiUrl;
this.intervalMs = intervalMs || 5000;
this.container = document.getElementById('bgSlideshow');
this.timer = null;
}
addImage(imageUrl) {
var div = document.createElement('div');
div.className = 'slide';
div.style.backgroundImage = 'url(' + imageUrl + ')';
div.style.backgroundSize = 'cover';
div.style.backgroundPosition = 'center';
div.style.backgroundRepeat = 'no-repeat';
div.style.opacity = '0';
div.style.transform = 'scale(1.02)';
div.style.transition = 'opacity 1.2s cubic-bezier(0.2, 0.9, 0.4, 1.1), transform 1.5s ease-out';
this.container.appendChild(div);
return div;
}
preloadImage(url) {
var img = new Image();
img.src = url;
}
rotateBackground() {
var newUrl = this.apiUrl + '?t=' + Date.now() + '&r=' + Math.random();
this.preloadImage(newUrl);
var newSlide = this.addImage(newUrl);
var img = new Image();
var self = this;
img.onload = function() {
var slides = document.querySelectorAll('.bg-slideshow .slide');
for (var i = 0; i < slides.length; i++) {
if (slides[i] !== newSlide) {
slides[i].style.opacity = '0';
slides[i].classList.remove('active');
}
}
setTimeout(function() {
newSlide.style.opacity = '1';
newSlide.style.transform = 'scale(1)';
newSlide.classList.add('active');
}, 50);
if (document.querySelectorAll('.bg-slideshow .slide').length > 8) {
document.querySelectorAll('.bg-slideshow .slide')[0].remove();
}
};
img.src = newUrl;
}
start() {
var defaultUrl = 'https://cdn.jsdmirror.com/gh/lqay-cn/cdn@main/img/zx/h/%E7%9C%9F%E5%AF%BB170.png';
this.addImage(defaultUrl);
var firstSlide = document.querySelector('.bg-slideshow .slide');
if (firstSlide) {
firstSlide.style.opacity = '1';
firstSlide.style.transform = 'scale(1)';
firstSlide.classList.add('active');
}
var self = this;
for (var i = 0; i < 3; i++) {
setTimeout(function() {
self.rotateBackground();
}, i * 200);
}
this.timer = setInterval(function() {
self.rotateBackground();
}, this.intervalMs);
}
}
var bgSlideshow = new BackgroundSlideshow('https://api.lqay.cn/api/zxsjt/', 5000);
bgSlideshow.start();
</script>
</body>
</html>