This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
728 lines (547 loc) · 15.6 KB
/
index.php
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
<!--
项目名称:明石留言板
版本:V2.2
时间:2021-9-5
Copyright©2021 | Akashi Tec.
遵循 CC-BY-NC-SA 4.0版权协议
index.php
-->
<?php require_once( 'header.php');?>
<div class="mdui-drawer" id="main-drawer">
<div class="mdui-list" mdui-collapse="{accordion: true}" style="margin-bottom: 68px;">
<div class="mdui-list">
<a href="./index.php" class="yuan mdui-list-item mdui-list-item-active">
<i class="mdui-list-item-icon mdui-icon material-icons">filter_none</i>
 主页
</a>
<?php
if (($selfsettingout[5] != 1)){
echo "<a href=\"./about.php\" class=\"yuan mdui-list-item\">";
echo "<i class=\"mdui-list-item-icon mdui-icon material-icons\">info_outline</i>";
echo " 关于";
echo "</a> ";
}else{
}
?>
<?php
switch($_SESSION['ambadminlogin']){
case '1':
echo' <a href="./admin.php" class="yuan mdui-list-item"><i class="mdui-list-item-icon mdui-icon material-icons">build</i> 后台管理';
break;
}
?>
</a>
</div>
<br>
</div>
</div>
<br/>
<div class="mdui-typo">
<?php //////////////////////////////////////////////////////////////////////////////跳转链接
if (isset($_GET['outlink'])) {
$outlink = $_GET['outlink'];
$replacelink=[
"<"=>"《",
">"=>"》",
"$"=>"¥",
"{"=>"(",
"}"=>")",
";"=>";",
"?"=>"?",
":"=>":",
"\""=>"”",
"'"=>"’",
"("=>"(",
")"=>")",
];
foreach($replacelink as $klink => $vlink){
$outlink=str_replace($klink,$vlink,$outlink);
}
?>
<br>
<div class="mdui-container" style="max-width: 88%; ">
<div class="mdui-typo">
<div style="padding-left: 6%;" class="mdui-card yuan">
<h1>即将离开 <?php echo $selfsettingout[1]; ?></h1>
<h4>将访问以下链接,请注意您的信息和财产安全。</h4>
<h4>http://<?php echo $outlink; ?>/</h4>
<br>
<a class="mdui-btn mdui-color-blue-50 btyuan" href="http://<?php echo $outlink; ?>">继续访问</a>
<a class="mdui-btn mdui-color-blue-100 btyuan" href="./">返回上一页</a>
<br>
<br>
</div>
</div>
</div>
<?php
exit();
}
?>
<?php //////////////////////////////////////////////////////////////////////////////添加留言
if (isset($_POST['add'])) {
//IP黑白名单检测
$ip=$_SERVER["REMOTE_ADDR"];
$addban=file_get_contents("./database/ban/addban.dat");
if(stripos($addban,$ip))
{
exit("<br><center><h1>你的IP地址 [$ip] 已被拉黑,禁止提交留言。</h1><h2>如果你有任何疑问,请联系网站管理者。</h2></center>");
}
$addcaptchafinal = $_POST["addcaptcharesult"];
$addcaptchauser = htmlspecialchars($_POST["addcaptchauser"]);
if(($addcaptchafinal != $addcaptchauser))
{
?>
<script>
mdui.snackbar({
message: '验证码错误,请重新输入!',
position:'top',
timeout:'2500'
});
</script>
<?php
}
elseif(($addcaptchauser == ''))
{
?>
<script>
mdui.snackbar({
message: '验证码不能为空,请重新输入!',
position:'top',
timeout:'2500'
});
</script>
<?php
}
elseif(($addcaptchauser = $addcaptchafinal))
{
$title = htmlspecialchars($_POST['title']); // 获取留言标题
$author = htmlspecialchars($_POST['author']); // 获取留言者
$content = $_POST["content"]; // 留言内容
if($title == null || $author == null){
$urlnullcontent = "./?err=5";
echo "<script language='javascript' type='text/javascript'>window.location.href='$urlnullcontent'</script>";
exit();
}
$replaceadd=[
"<"=>"《",
">"=>"》",
"$"=>"¥",
"{"=>"(",
"}"=>")",
";"=>";",
"?"=>"?",
":"=>":",
"'"=>"’",
"[li]"=>"<a href=\"./index.php?outlink=",
"[nk]"=>"\"target=_blank\">链接<i class=\"mdui-icon material-icons\">link</i></a>",
"[br]"=>"<br>",
"("=>"(",
")"=>")",
];
foreach($replaceadd as $kadd => $vadd){
$content=str_replace($kadd,$vadd,$content);
}
if(( $author == '管理员' || $author == 'admin' || $author == $selfsettingout[7])){
if (isset($_SESSION['ambadminlogin'])) {
} else {
// 若没有登录
$urladminname = "./?err=1";
echo "<script language='javascript' type='text/javascript'>window.location.href='$urladminname'</script>";
exit();
}
}
if((mb_strlen($content) > $selfsettingout[3]*2) || (mb_strlen($author) > 18*2) || (mb_strlen($title) > 26*2)){
exit("<br><h1><center>不要搞小聪明哦这位同学~ 字数超了</h1></center><br><br>");
}else{
}
//限制同IP多次访问
if (!isset($_SESSION['ambadminlogin'])) {
define('TIME_OUT',"$selfsettingout[4]");
$time = time();
if( isset($_SESSION['time']) )
{
if( $time - $_SESSION['time'] <= TIME_OUT ) //判断超时
{
$urltimeout = "./?err=3";
echo "<script language='javascript' type='text/javascript'>window.location.href='$urltimeout'</script>";
exit();
}
}
$_SESSION['time'] = $time;
}
date_default_timezone_set('PRC');
$ip = $_SERVER["REMOTE_ADDR"];
$addtime = date('Y-m-d H:i:s');
$message = "{$title}##{$author}##{$content}##{$ip}##{$addtime}@@@";
switch($_POST['secret']){
case '1':
$dbaction = $db2;
break;
case null:
$dbaction = $db1;
break;
}
$oldinfo = file_get_contents($dbaction);
file_put_contents($dbaction,"$message".$oldinfo);
?>
<script>
mdui.snackbar({
message: '留言发表成功!',
position:'top',
timeout:'2000'
});
</script>
<?php
}
}
?>
<?php //////////////////////////////////////////////////////////////////////////////登录
if (isset($_POST['log_in'])) {
//验证验证码
$logincaptchauser = htmlspecialchars($_POST["logincap"]);
if(($logincaptchauser != $_POST['logincaptcharesult']))
{
?>
<script>
mdui.snackbar({
message: '验证码错误,请重新输入!',
position:'top',
timeout:'3000'
});
</script>
<?php
}
elseif(($logincaptchauser == ''))
{
?>
<script>
mdui.snackbar({
message: '验证码不能为空,请重新输入!',
position:'top',
timeout:'3000'
});
</script>
<?php
}
elseif($logincaptchauser == $_POST['logincaptcharesult']){
//验证密码
$password = htmlspecialchars($_POST['passwd']);
switch($password){
case null:
$urlpasswordnull = "./?err=2";
echo "<script language='javascript' type='text/javascript'>window.location.href='$urlpasswordnull'</script>";
exit();
break;
case $passwd:
$_SESSION['ambadminlogin'] = 1;
$url = "./admin.php?suc=2";
echo "<script language='javascript' type='text/javascript'>window.location.href='$url'</script>";
exit();
break;
}
?>
<script>
mdui.snackbar({
message: '密码错误,请重新输入!',
position:'top',
timeout:'2500'
});
</script>
<?php
}
}
?>
</div>
<div class="mdui-tab" mdui-tab>
<a href="#show" class="mdui-ripple">
<i class="mdui-icon material-icons">assignment</i>
<label>主页</label>
</a>
<a href="#add" class="mdui-ripple">
<i class="mdui-icon material-icons">border_color</i>
<label>添加留言</label>
</a>
<?php
// 首先判断Cookie是否有记住了用户信息
if (isset($_SESSION['ambadminlogin'])) {
} else {
?>
<a href="#login" class="mdui-ripple">
<i class="mdui-icon material-icons">assignment_ind</i>
<label>管理员登录</label>
</a>
<?php
}
?>
<!----------------------------GET传值的错误代码---------------------------->
<?php
if(isset($_GET['suc'])){
$succode = $_GET['suc'];
switch($succode){
case '1':
?>
<script>
mdui.snackbar({
message: '密码修改成功!请重新登录。',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
case '2':
?>
<script>
mdui.snackbar({
message: '已安全退出登录。',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
}
}
?>
<?php
if(isset($_GET['err'])){
$errcode = $_GET['err'];
switch($errcode){
case '1':
?>
<script>
mdui.snackbar({
message: '非管理员不得使用此昵称!请重新输入。',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
case '2':
?>
<script>
mdui.snackbar({
message: '密码不能为空!',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
case '3':
?>
<script>
mdui.snackbar({
message: '<?php echo $selfsettingout[4]; ?>秒内只能提交一次留言,请稍后再试。',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
case '4':
?>
<script>
mdui.snackbar({
message: '您还未登录',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
case '5':
?>
<script>
mdui.snackbar({
message: '内容不为空,请重新填写!',
position:'top',
timeout:'4000'
});
</script>
<?php
break;
}
}
?>
<!----------------------------GET传值的错误代码---------------------------->
</div>
<!-- 显示留言界面开始 -->
<div id="show" class="mdui-p-a-2">
<div id="goTopBtn" style="position:relative;z-index:3">
<button class="mdui-fab mdui-color-theme-accent mdui-ripple mdui-fab-fixed" mdui-tooltip="{content: '返回顶部', position: 'top'}"><i class="mdui-icon material-icons">keyboard_arrow_up</i></button>
</div>
<div style="z-index:2" class="mdui-typo">
<h3>
<?php
$messagelistshow = file_get_contents($db1);
// 获取留言
$info = file_get_contents($db1);
$info = rtrim($info, "@");
if (strlen($info)>=8){
// 拆分留言
$messagelist = explode("@@@", $info);
foreach ($messagelist as $key => $value) {
$message = explode("##", $value);
if (($message[3] != null)){
echo("<div class=\"yuan mdui-card\">");
//卡片的标题和副标题
echo("<div class=\"mdui-card-primary\">");
echo("<div class=\"mdui-card-primary-title\">「" . $message[0] . "」</div>");
echo("<div class=\"mdui-card-primary-subtitle\">来自 [" . $message[1] . "]</div>");
if (isset($_SESSION['ambadminlogin'])) {
echo("<div class=\"mdui-card-primary-subtitle\">IP地址 [" . $message[3] . "]</div>");
} else {
}
echo("<div class=\"mdui-card-primary-subtitle\">" . $message[4] . "</div>");
echo"<div class=\"mdui-card-content\"><h3>".$message[2] ."</h3></div>";
echo("</div>");
// 卡片的内容
if (isset($_SESSION['ambadminlogin'])) {
echo "<div style=\"float:right\" class=\"mdui-typo\"><a href=\"./delete.php?id={$key}&method=1\"><button class=\"mdui-btn mdui-color-blue-50 mdui-ripple btyuan\" type=\"submit\">删除</button></a></form></div>";
} else {
}
echo("</div>");
echo("<br/>");
}
}
}
?>
</h3>
</div>
</div>
<!-- 显示留言界面结束 -->
<div class="mdui-typo">
<?php
// 首先判断Cookie是否有记住了用户信息
if (isset($_SESSION['ambadminlogin'])) {
} else {
?>
<!-- 登录界面开始 -->
<div id="login" class="mdui-p-a-2">
<div style="max-width: 600px; ">
<div class="yuan mdui-card">
<br>
<center>
<div style="max-width: 90%; ">
<form action="" method="post" >
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">密码</label>
<input class="mdui-textfield-input" type="password" name="passwd" maxlength="18" required/>
<div class="mdui-textfield-error">密码不能为空</div>
</div>
<?php
$adCAPTCHAnum1 = mt_rand(1,20);
$adCAPTCHAnum2 = mt_rand(1,20);
$logincap = $adCAPTCHAnum1 + $adCAPTCHAnum2;
?>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">请输入<?php echo "$adCAPTCHAnum1" ;echo'+';echo"$adCAPTCHAnum2" ?>的值</label>
<input class="mdui-textfield-input" type="text" name="logincap" maxlength="3" required/>
<div class="mdui-textfield-error">验证码不能为空</div>
<input type="hidden" name="logincaptcharesult" value="<?php echo "$logincap"; ?>">
</div>
<button class="mdui-btn mdui-color-blue-50 mdui-ripple btyuan" name="log_in" type="submit">登录</button>
</form>
<!--<button class="mdui-btn mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">lock_outline</i>使用 WebAuthn 认证</button>
-->
</div>
</center>
</div>
</div>
</div>
<?php
}
?>
<!-- 登录界面结束 -->
<!-- 提交界面开始 -->
<div id="add" class="mdui-p-a-2">
<div class="mdui-typo">
<div style="max-width: 600px; ">
<div style="padding: 20px; " class="mdui-card yuan">
<h4> 发送特殊符号</h4>
<p> 1.换行: [br] <br>
2.发送链接: [li]网站域名.后缀[nk] <b>(不加请求头)</b><br>
3.发送html标记符号或其它自动转义。
</p></div><br>
<?php
if(($selfsettingout[8] != null)){
?>
<div style="padding: 20px; " class="mdui-card yuan">
<h4>“<?php echo "$selfsettingout[1]"; ?>” 使用协议</h4>
<?php
echo "$selfsettingout[8]";
?>
</div><br>
<?php
}
?>
<div class="yuan mdui-card">
<br>
<center>
<div style="max-width: 90%; ">
<form action="" method="post">
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">您的称呼</label>
<input class="mdui-textfield-input" <?php if (!isset($_SESSION['ambadminlogin'])){ }else{ echo'value="'.$selfsettingout[7].'"'; } ?> {type="text" name="author" maxlength="18"/ required/>
<div class="mdui-textfield-error">您的名称不能为空</div>
</div>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">标题</label>
<input class="mdui-textfield-input" type="text" maxlength="26" name="title">
</div>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">留言内容</label>
<textarea class="mdui-textfield-input" name="content" maxlength="<?php echo "$selfsettingout[3]"; ?>"></textarea>
</div>
<?php
$addCAPTCHAnum1 = mt_rand(1,20);
$addCAPTCHAnum2 = mt_rand(1,20);
$addcaptcharesult = $addCAPTCHAnum1 + $addCAPTCHAnum2;
?>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">请输入<?php echo "$addCAPTCHAnum1" ;echo'+';echo"$addCAPTCHAnum2" ?>的值</label>
<input class="mdui-textfield-input" type="text" name="addcaptchauser" maxlength="3" required/>
<div class="mdui-textfield-error">验证码不能为空</div>
<input type="hidden" name="addcaptcharesult" value="<?php echo "$addcaptcharesult"; ?>">
</div>
<label class="mdui-checkbox">
<input type="checkbox" value="1" name="secret" />
<i class="mdui-checkbox-icon"></i>
发送私信(仅管理员可见)
</label>
<br>
<br>
<button class="mdui-btn mdui-ripple mdui-color-blue-50 btyuan" name="add" type="submit">送信</button>
<button class="mdui-btn mdui-color-theme-accent mdui-ripple btyuan" type="reset">重置</button>
</form>
</div>
</center>
</div>
</div>
</div>
</div>
<!-- 提交界面结束 -->
</div>
<?php include 'footer.php';?>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
/*返回顶部*/
$(window).scroll(function(){
var sc=$(window).scrollTop();
var rwidth=$(window).width()
if(sc>0){
$("#goTopBtn").css("display","block");
$("#goTopBtn").css("left",(rwidth-36)+"px")
}else{
$("#goTopBtn").css("display","none");
}
})
$("#goTopBtn").click(function(){
var sc=$(window).scrollTop();
$('body,html').animate({scrollTop:0},500);
})
</script>
</body>
</html>