目前我修改和开发了两个页面。各位可以自己对应自己的情况进行修改。
以下是两个文件的开发
function.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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
function themeConfig($form) {
?>
<link rel="stylesheet" href="<?php Helper::options()->themeUrl('css/themedash.css?v1.5.3'); ?>">
<div class='set_toc' >
<div class='mtoc'>
<a href='#themeBackup'>主题备份与还原</a>
<a href='#cids'>文章置顶及公共部分</a>
<a href='#pjax'>pjax设置</a>
<a href='#friends'>友情链接设置</a>
<a href='#reward'>打赏功能</a>
<a href='#aside'>侧边栏显示设置</a>
<a href='#beautifyBlock'>美化选项</a>
<a href='#ShowLive2D'>Live2D设置</a>
<a href='#otherCustom'>其他自定义内容</a>
<a href='#CustomColor'>自定义颜色</a>
<a href='#baidustatistics'>百度统计与谷歌广告</a>
<a href='#gxbeian'>备案填写</a>
<a href='#NULL' id='point'>返回上次保存设置时的锚点</a>
</div></div>
<form class="protected" action="?butterflybf" method="post" id="themeBackup">
<input type="submit" name="type" class="btn btn-s" value="备份主题数据" />&nbsp;&nbsp;<input type="submit" name="type" class="btn btn-s" value="还原主题数据" />&nbsp;&nbsp;<input type="submit" name="type" class="btn btn-s" value="删除备份数据" /></form>
<script src='https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js'></script>
<script src="<?php Helper::options()->themeUrl('js/themecustom.js?v1.5.3'); ?>"></script>
<script src='https://gcore.jsdelivr.net/gh/wehaox/CDN@main/postdomai.js'></script>
<?php
$sticky_cids = new Typecho_Widget_Helper_Form_Element_Text('sticky_cids', NULL, NULL,'置顶文章的 cid', '<div style="font-family:arial; background:#E8EFD1; padding:8px">按照排序输入, 请以半角逗号或空格分隔 cid</div>');
$sticky_cids->setAttribute('id', 'cids');
$form->addInput($sticky_cids);

$slide_cids = new Typecho_Widget_Helper_Form_Element_Text('slide_cids', NULL, NULL,'主页轮播图文章的 cid', '填入自动开启,填入方式同上,<b style="color:red">注意:填入错误cid会导致页面出错</b>');
$form->addInput($slide_cids);

$StaticFile = new Typecho_Widget_Helper_Form_Element_Select('StaticFile',
array(
'CDN' => 'CDN加载(默认)',
'local' => '本地加载',
),
'CDN',
'博客静态资源加载方式',
'介绍:无网络服务器或者CDN炸了可开启此项<br>
将博客静态资源,如jscss、图片从服务器加载(会稍微增加服务器流量消耗)<br>
注意:你需要额外<a href="https://github.com/wehaox/Typecho-Butterfly/releases">下载</a>对应版本的静态资源放进主题根目录直接解压即可<br>
此文件与下方的自定义CDN文件通用'
);
$form->addInput($StaticFile->multiMode());


$CDNURL = new Typecho_Widget_Helper_Form_Element_Text('CDNURL',NULL,NULL,
'自定义CDNURL(由@origami-tech提供)',
'需要选择博客静态资源加载方式为CDN加载 此项才会生效 且<b>本地加载>自定义CDNURL>jsdelivr源</b><br>
注意:你需要额外<a href="https://github.com/wehaox/Typecho-Butterfly/releases">下载</a>静态资源放CDN解压<br>
链接填写规则:填写static文件夹的父文件夹 无需最后的/ 例如 https://pub-gcdn.starsdust.cn/libs/butterfly '
);
$form->addInput($CDNURL);

$jsdelivrLink = new Typecho_Widget_Helper_Form_Element_Select('jsdelivrLink',
array(
'cdn.jsdelivr.net' => '官方默认源',
'gcore.jsdelivr.net' => 'gcore源',
'fastly.jsdelivr.net' => 'fastly源',
'raw.fastgit.org' => 'fastgit源',
),
'gcore.jsdelivr.net',
'jsdelivr提供的cdn源切换(默认采用gcore源)',
'需要开启上方的CDN加载'
);
$form->addInput($jsdelivrLink->multiMode());

$NewTabLink = new Typecho_Widget_Helper_Form_Element_Select('NewTabLink',
array(
'on' => '开启(默认)',
'off' => '关闭',
),
'on',
'是否开启新标签打开外部链接',
'介绍:非站内链接在新标签打开'
);
$form->addInput($NewTabLink->multiMode());

$showFramework = new Typecho_Widget_Helper_Form_Element_Select('showFramework',
array(
'on' => '开启(默认)',
'off' => '关闭',
),
'on',
'是否显示底部博客框架和主题',
'介绍:如果你是小白自行修改主题名会导致侵权提示,你可以在这里关闭同时希望你可以<b>尊重本主题</b>'
);
$form->addInput($showFramework->multiMode());

$Defend = new Typecho_Widget_Helper_Form_Element_Select(
'Defend',
array('off' => '关闭(默认)', 'on' => '开启'),
'off',
'是否开启网站维护或密码访问',
'介绍: 下方密码留空则显示网站维护否则显示输入密码访问,登录用户不受限制'
);
$form->addInput($Defend->multiMode());

$ThemePassword = new Typecho_Widget_Helper_Form_Element_Text('ThemePassword', NULL,NULL, _t('全站密码访问(非必填)'), _t('输入访问网站的密码,<b>需要在上方开启网站维护或密码访问</b>'));
$form->addInput($ThemePassword);

$NoQQ = new Typecho_Widget_Helper_Form_Element_Select(
'NoQQ',
array('off' => '关闭(默认)', 'on' => '开启'),
'off',
'是否开启网站禁止手机QQ访问',
'介绍:烦人的QQ'
);
$form->addInput($NoQQ->multiMode());

$SiteLogo = new Typecho_Widget_Helper_Form_Element_Text('SiteLogo', NULL, NULL, _t('站点名称设置为图片logo(非必填)'), _t('当设置此项时站点名称将不会在导航栏左上角显示,使用png格式'));
$form->addInput($SiteLogo);

$Sitefavicon = new Typecho_Widget_Helper_Form_Element_Text('Sitefavicon', NULL, NULL, _t('网站图标'), _t('网站图标,使用png格式,大小建议不超过64x64'));
$form->addInput($Sitefavicon);

$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL,_t('#null'), _t('作者头像'), _t('在这里填入图片地址,它会显示在右侧栏的作者头像'));
$form->addInput($logoUrl);

$author_description = new Typecho_Widget_Helper_Form_Element_Text('author_description', NULL, _t('作者描述'), _t('作者描述'), _t('在这里填入站点描述,它会显示在右侧栏的作者信息'));
$form->addInput($author_description);

$author_site_description = new Typecho_Widget_Helper_Form_Element_Text('author_site_description', NULL,_t('个人网站'), _t('作者链接描述'), _t('作者链接描述'));
$form->addInput($author_site_description);

$author_site = new Typecho_Widget_Helper_Form_Element_Text('author_site', NULL, _t('#null'), _t('作者链接'), _t('在这里填入作者链接,它会显示在右侧栏的作者信息的个人网站上'));
$form->addInput($author_site);

$author_bottom = new Typecho_Widget_Helper_Form_Element_Textarea('author_bottom', NULL, _t(''), _t('侧栏作者信息最底部内容(非必填)'), _t('这里填入html代码,不会勿填'));
$form->addInput($author_bottom);

$announcement = new Typecho_Widget_Helper_Form_Element_Textarea('announcement', NULL, _t('这里是公告<br>'), _t('公告'), _t('在这里填入公告,它会显示在右侧栏的公告上,采用html写法'));
$form->addInput($announcement);

$AD = new Typecho_Widget_Helper_Form_Element_Textarea('AD', NULL, NULL, _t('广告(由@yzl3014提供)'), _t('在这里填入广告,填入后自动显示在侧栏中公告栏的下方,支持html'));
$form->addInput($AD);

$headerimg = new Typecho_Widget_Helper_Form_Element_Text('headerimg', NULL,_t('https://s2.loli.net/2023/01/18/bIJTVaR3MLPzcZ7.jpg'), _t('主页顶图(banner image)'), _t('填入主页头图链接'));
$form->addInput($headerimg);

$buildtime = new Typecho_Widget_Helper_Form_Element_Text('buildtime', NULL,_t('2021/04/05'), _t('建站时间'), _t('按照输入框内格式填写'));
$form->addInput($buildtime);

$outoftime = new Typecho_Widget_Helper_Form_Element_Text('outoftime', NULL,_t('15'), _t('文章过时提醒'), _t('设置文章过时提醒最大天数,默认15天,可在文章管理单独设置是否显示过期提醒'));
$form->addInput($outoftime);

$archivelink = new Typecho_Widget_Helper_Form_Element_Text('archivelink', NULL,_t('#null'), _t('侧栏文章(归档)链接'), _t('需在独立页面创建并手动填入链接'));
$form->addInput($archivelink);

$tagslink = new Typecho_Widget_Helper_Form_Element_Text('tagslink', NULL,_t('#null'), _t('侧栏标签链接'), _t('需在独立页面创建并手动填入链接'));
$form->addInput($tagslink);

$categorylink = new Typecho_Widget_Helper_Form_Element_Text('categorylink', NULL,_t('#null'), _t('侧栏分类链接'), _t('需在独立页面创建并手动填入链接'));
$form->addInput($categorylink);


$CloseComments = new Typecho_Widget_Helper_Form_Element_Select('CloseComments',
array(
'off' => '关闭(默认)',
"on" => '开启'
),
'off',
'全站关闭评论',
'介绍:开启后所有文章不能评论'
);
$form->addInput($CloseComments->multiMode());

$EnableCommentsLogin = new Typecho_Widget_Helper_Form_Element_Select('EnableCommentsLogin',
array(
'off' => '关闭(默认)',
"on" => '开启'
),
'off',
'开启用户评论区登录',
'介绍:开启后在评论区会显示登录按钮
'
);
$form->addInput($EnableCommentsLogin->multiMode());

$ShowRelatedPosts = new Typecho_Widget_Helper_Form_Element_Select('ShowRelatedPosts',
array(
'off' => '关闭(默认)',
'on' => '开启',
),
'off',
'是否显示文章内相关推荐',
'介绍:开启后文章结束后会显示相关的推荐文章(根据文章标签推荐,不一定每篇文章都会显示)'
);
$form->addInput($ShowRelatedPosts->multiMode());

$RelatedPostsNum = new Typecho_Widget_Helper_Form_Element_Select('RelatedPostsNum',
array(
'3' => '3篇(默认)',
'6' => '6篇',
),
'3',
'相关推荐显示数量',
'介绍:最多显示3篇或者6篇相关推荐文章'
);
$form->addInput($RelatedPostsNum->multiMode());

$DefaultEncoding = new Typecho_Widget_Helper_Form_Element_Select('DefaultEncoding',
array(
'2' => '简体(默认)',
'1' => '繁体',
),
'2',
'博客默认字体',
'介绍:如果你使用繁体写文章请选择繁体'
);
$form->addInput($DefaultEncoding->multiMode());

$GravatarSelect = new Typecho_Widget_Helper_Form_Element_Select('GravatarSelect',
array(
"https://gravatar.loli.net/avatar/" => 'loli(默认)',
'https://gravatar.helingqi.com/wavatar/' => '禾令奇',
"https://sdn.geekzu.org/avatar/" => '极客族',
"https://cdn.sep.cc/avatar/" => '九月的风',
"https://gravatar.com/avatar/" => '官方源(被墙)',
"https://cravatar.cn/avatar/" => '中国官方源(推荐)',
),
'loli',
'gravatar源选择',
'介绍:评论区头像gravatar源'
);
$GravatarSelect->setAttribute('id', 'gravatarlist');
$form->addInput($GravatarSelect->multiMode());

$baidustatistics = new Typecho_Widget_Helper_Form_Element_Text('baidustatistics', NULL,_t(''), _t('百度统计'), _t('仅需要https://hm.baidu.com/hm.js?xxxxxxxxxxxxxxxxxx部分即可'));
$baidustatistics->setAttribute('id', 'baidustatistics');
$form->addInput($baidustatistics);

$googleadsense = new Typecho_Widget_Helper_Form_Element_Text('googleadsense', NULL,_t(''), _t('谷歌广告'), _t('仅需要https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?xxxxxxxxx部分即可'));
$form->addInput($googleadsense);

$gxbeian = new Typecho_Widget_Helper_Form_Element_Text('gxbeian', NULL,_t(''), _t('工信部备案'), _t('仅填写备案号即可,除广东省地区其他地区必须带-(数字),如果还不懂请点击<a href="https://help.aliyun.com/document_detail/137270.htm">这里</a>'));
$gxbeian->setAttribute('id', 'gxbeian');
$form->addInput($gxbeian);

$gabeian = new Typecho_Widget_Helper_Form_Element_Text('gabeian', NULL,_t(''), _t('公安备案'), _t('仅填写备案号即可不懂请点击<a href="http://wap.qianfanyun.com/help/1397">这里</a>'));
$form->addInput($gabeian);

$moebeian = new Typecho_Widget_Helper_Form_Element_Text('moebeian', NULL,_t(''), _t('萌国备案'), _t('娱乐使用,申请点击<a href="https://icp.gov.moe/">这里</a>'));
$form->addInput($moebeian);

$EnablePjax = new Typecho_Widget_Helper_Form_Element_Select('EnablePjax',
array(
'off' => '关闭(默认)',
"on" => '开启'
),
'off',
'开启PJAX',
'介绍:页面无刷新加载,有效提高页面加载速度<br>
请先查看<a href="https://blog.wehaox.com/archives/typecho-butterfly.html#cl-13">使用文档</a>'
);
$EnablePjax->setAttribute('id', 'pjax');
$form->addInput($EnablePjax->multiMode());

$PjaxCallBack = new Typecho_Widget_Helper_Form_Element_Textarea('PjaxCallBack',NULL,NULL,
'Pjax回调函数(非必填)',
'用于解决开启pjax导致js丢失问题'
);
$form->addInput($PjaxCallBack);

/* 友链设置 */
$friendset = new Typecho_Widget_Helper_Form_Element_Select('friendset',
array(
'1' => '插件模式',
'2' => '主题模式',
),
'2',
'是否使用Link插件进行友链(需点击<a href="https://github.com/JoyNop/Typecho-Links">这里</a>下载)',
'介绍:新手和手残党极其友好,默认从主题读取防止报错'
);
$friendset->setAttribute('id', 'friendset');
$form->addInput($friendset);

$Friends = new Typecho_Widget_Helper_Form_Element_Textarea('Friends',NULL,NULL,
'友情链接(非必填)',
'介绍:用于填写友情链接 <br />
注意:需在独立页面创建友链,该项才会生效 <br />
格式:博客名称 || 博客地址 || 博客头像 || 博客简介 <br />
其他:一行一个,一行代表一个友链'
);
$Friends->setAttribute('id', 'friends');
$form->addInput($Friends);

$LazyLoad = new Typecho_Widget_Helper_Form_Element_Text('LazyLoad',
NULL,
NULL,
'全局懒加载图(非必填)',
'介绍:用于修改懒加载图片 格式:base64 或者 图片url'
);
$form->addInput($LazyLoad);


$ShowGlobalReward = new Typecho_Widget_Helper_Form_Element_Select('ShowGlobalReward',
array(
'off' => '关闭(默认)',
'show' => '开启打赏',
),
'off',
'是否开启全局文章打赏',
'介绍:开启此功能所有文章将显示打赏'
);
$ShowGlobalReward->setAttribute('id', 'reward');
$form->addInput($ShowGlobalReward->multiMode());

/* 打赏设置 */
$RewardInfo = new Typecho_Widget_Helper_Form_Element_Textarea('RewardInfo',NULL,_t('微信 || https://cdn.jsdelivr.net/gh/wehaox/CDN@main/reward/wechat.jpg
支付宝 || https://cdn.jsdelivr.net/gh/wehaox/CDN@main/reward/alipay.jpg'),
'打赏信息(非必填)',
'注意:需在开启打赏功能,该项才会显示 <br />
格式:打赏名称 || 图片地址 <br />一行一个'
);
$form->addInput($RewardInfo);

$sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock',
array(
'ShowAuthorInfo' => _t('显示作者信息'),
'ShowAnnounce' => _t('显示公告'),
'ShowRecentPosts' => _t('显示最新文章'),
'ShowRecentComments' => _t('显示最近回复'),
'ShowCategory' => _t('显示分类'),
'ShowTag' => _t('显示标签'),
'ShowArchive' => _t('显示归档'),
'ShowWebinfo' => _t('显示网站资讯'),
'ShowOther' => _t('显示其它杂项'),
'ShowMobileSide' => _t('手机端显示侧栏'),
'ShowWeiboHot' => _t('显示微博热搜')
),
array('ShowAuthorInfo','ShowAnnounce','ShowRecentPosts', 'ShowRecentComments', 'ShowCategory','ShowTag', 'ShowArchive', 'ShowWebinfo', 'ShowOther','ShowMobileSide'), _t('侧边栏显示'));
$sidebarBlock->setAttribute('id', 'aside');
$form->addInput($sidebarBlock->multiMode());
// 在线人数显示
$ShowOnlinePeople = new Typecho_Widget_Helper_Form_Element_Select('ShowOnlinePeople',
array(
'on' => '开启',
'off' => '关闭(默认)',
),
'off',
'是否显示在线人数',
'介绍:侧栏网站咨询模块在线人数统计,防止某些虚拟主机无法开启导致500错误'
);
$form->addInput($ShowOnlinePeople->multiMode());

$sidderArchiveNum = new Typecho_Widget_Helper_Form_Element_Text('sidderArchiveNum', NULL, _t('5'), _t('侧栏归档显示行数'),_t('默认为5'));
$form->addInput($sidderArchiveNum);

// 文章侧边栏设置
$PostSidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('PostSidebarBlock',
array(
'ShowAuthorInfo' => _t('显示作者信息'),
'ShowAnnounce' => _t('显示公告'),
'ShowRecentPosts' => _t('显示最新文章'),
'ShowWebinfo' => _t('显示网站咨询'),
'ShowOther' => _t('显示其它杂项'),
'ShowWeiboHot' => _t('显示微博热搜')
),
array('ShowAuthorInfo','ShowAnnounce','ShowRecentPosts', 'ShowWebinfo', 'ShowOther'), _t('文章侧边栏显示'),_t('说明:单独设置文章内侧栏'));
$form->addInput($PostSidebarBlock->multiMode());

// 美化选项
$beautifyBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('beautifyBlock',
array(
'ShowBeautifyChange' => _t('是否开启美化(基于butterfly小康的魔改)'),
'ShowColorTags' => _t('是否开启彩色标签云'),
'ShowTopimg' => _t('是否显示主页顶图'),
'PostShowTopimg' => _t('是否显示文章示顶图'),
'PageShowTopimg' => _t('是否显示独立页面顶图'),
'showLineNumber' => _t('是否显示代码块行号'),
'showSnackbar' => _t('是否显示主题以及简繁切换弹窗'),
'showLazyloadBlur' => _t('是否开启懒加载模糊效果'),
'showButterflyClock' => _t('是否开启侧栏显示时钟(需要在下方填写和风和高德key)'),
),
array('ShowTopimg','PostShowTopimg','PageShowTopimg','showLineNumber','showSnackbar','showLazyloadBlur'), _t('美化选项'));
$beautifyBlock->setAttribute('id', 'beautifyBlock');
$form->addInput($beautifyBlock->multiMode());

// 封面位置
$coverPosition = new Typecho_Widget_Helper_Form_Element_Select('coverPosition',
array(
'left' => '靠左',
'cross' => '交叉(默认)',
'right' => '靠右',
),
'cross',
'主页文章列表封面显示位置',
'个人还是还是觉得交叉好看'
);
$form->addInput($coverPosition->multiMode());

$qweather_key = new Typecho_Widget_Helper_Form_Element_Text('qweather_key', NULL, null, _t('时钟和风天气key'),_t('<a href="https://github.com/anzhiyu-c/hexo-butterfly-clock-anzhiyu/#安装">按照教程获取key</a>'));
$gaud_map_key = new Typecho_Widget_Helper_Form_Element_Text('gaud_map_key', NULL, null, _t('时钟高得地图web服务key'), _t('侧栏显示时钟用到的key,同上'));
$form->addInput($qweather_key);
$form->addInput($gaud_map_key);

$ShowLive2D = new Typecho_Widget_Helper_Form_Element_Select('ShowLive2D',
array(
'off' => '关闭(默认)',
"on" => '开启(GitHub默认)'
),
'off',
'开启Live2D人物模型(仅通过GitHub默认样式且不会在手机显示)',
'介绍:开启后会在右下角显示一个小人,该功能采用远程调用不会消耗性能'
);
$ShowLive2D->setAttribute('id', 'ShowLive2D');
$form->addInput($ShowLive2D->multiMode());

// 弹窗提示
$SnackbarPosition = new Typecho_Widget_Helper_Form_Element_Select('SnackbarPosition',
array(
'top-left' => '左上(默认)',
'top-center' => '上中',
'top-right' => '右上',
'bottom-left' => '左下',
'bottom-center' => '下中',
'bottom-right' => '右下',
),
'top-left',
'主题以及简繁切换弹窗位置',
'选择其中一个,需要开启是否显示主题以及简繁切换弹窗 '
);
$form->addInput($SnackbarPosition->multiMode());

$CursorEffects = new Typecho_Widget_Helper_Form_Element_Select('CursorEffects',
array(
'off' => '关闭(默认)',
'heart' => '鼠标点击效果:爱心',
'fireworks' => '烟火效果',
),
'off',
'选择鼠标点击特效',
'介绍:用于切换鼠标点击特效 '
);
$form->addInput($CursorEffects->multiMode());
// 自定义subtitle
$CustomSubtitle = new Typecho_Widget_Helper_Form_Element_Text(
'CustomSubtitle',
NULL,
NULL,
'自定义主页副标题/subtitle(非必填)',
'介绍:不填则使用默认的一言api。'
);
$form->addInput($CustomSubtitle);

$SubtitleLoop = new Typecho_Widget_Helper_Form_Element_Select('SubtitleLoop',
array(
'true' => '开启循环打字(默认)',
"false" => '关闭循环打字'
),
'true',
'副标题循环打字',
'介绍:开启后主页副标题循环打字'
);
$form->addInput($SubtitleLoop->multiMode());


$EnableAutoHeaderLink = new Typecho_Widget_Helper_Form_Element_Select('EnableAutoHeaderLink',
array(
'on' => '开启(默认)',
"off" => '关闭'
),
'on',
'自动生成导航栏独立页面链接',
'介绍:如果你要自定义导航栏链接部分,你可以选择关闭此项'
);
$form->addInput($EnableAutoHeaderLink->multiMode());

// 自定义导航栏链接
$CustomHeaderLink = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomHeaderLink',
NULL,
NULL,
'自定义导航栏链接',
'介绍:目前使用html写法 <b style="color:red">完全自定义链接记得关闭上方选项</b>'
);
$CustomHeaderLink->setAttribute('id', 'otherCustom');
$form->addInput($CustomHeaderLink);

// 自定义认证用户
$CustomAuthenticated = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomAuthenticated',
NULL,
NULL,
'自定义认证用户',
'介绍:评论区认证用户专属头衔<br>
格式:邮箱||认证头衔 如:<br> xxx@xxx.com||xxx认证<br>
(一行一个)'
);
$form->addInput($CustomAuthenticated);

// 自定义cssjs
$CustomCSS = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomCSS',
NULL,
NULL,
'自定义CSS样式(非必填)',
'介绍:请填写自定义CSS内容,填写时无需填写style标签。'
);
$form->addInput($CustomCSS);

$CustomScript = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomScript',
NULL,
NULL,
'自定义JS代码(非必填,请看下方介绍)',
'介绍:请填写自定义JS内容,填写时无需填写script标签。<br />
非专业人士请勿填写!'
);
$form->addInput($CustomScript);

$CustomHead = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomHead',
NULL,
NULL,
'自定义head标签内位置内容',
'介绍:填写如cdn的&lt;link&gt;标签、百度统计代码等等'
);
$form->addInput($CustomHead);

$CustomBodyEnd = new Typecho_Widget_Helper_Form_Element_Textarea(
'CustomBodyEnd',
NULL,
NULL,
'自定义body标签末尾位置内容',
'介绍:填写如cdn的&lt;script&gt;&lt;/script&gt;标签等等'
);
$form->addInput($CustomBodyEnd);

$Customfooter = new Typecho_Widget_Helper_Form_Element_Textarea(
'Customfooter',
NULL,
NULL,
'自定义Footer内容',
'介绍:网页底部的信息,如备案号等等(可使用html)'
);
$form->addInput($Customfooter);

//自定义颜色
$EnableCustomColor = new Typecho_Widget_Helper_Form_Element_Select('EnableCustomColor',
array(
"false" => '关闭(默认)',
'true' => '开启'
),
'false',
'开启主题自定义颜色(实验性功能)',
'介绍:需要开启此选项下面的自定义颜色才能生效,且下面关于颜色的必填'
);
$EnableCustomColor->setAttribute('id', 'CustomColor');
$form->addInput($EnableCustomColor->multiMode());

$CustomColorMain = new Typecho_Widget_Helper_Form_Element_Text(
'CustomColorMain',
NULL,
_t('#49b1f5'),
'自定主题主要颜色',
'介绍:使用hex格式或者颜色英文,如#fffwhite'
);
$form->addInput($CustomColorMain);

$CustomColorButtonBG = new Typecho_Widget_Helper_Form_Element_Text(
'CustomColorButtonBG',
NULL,
_t('#49b1f5'),
'自定按钮颜色',
'介绍:同上'
);
$form->addInput($CustomColorButtonBG);

$CustomColorButtonHover = new Typecho_Widget_Helper_Form_Element_Text(
'CustomColorButtonHover',
NULL,
_t('#ff7242'),
'自定按钮悬停色',
'介绍:同上'
);
$form->addInput($CustomColorButtonHover);

$CustomColorSelection = new Typecho_Widget_Helper_Form_Element_Text(
'CustomColorSelection',
NULL,
_t('#00c4b6'),
'自定文本选择色',
'介绍:同上'
);
$form->addInput($CustomColorSelection);
//自定义颜色end

$siteKey = new Typecho_Widget_Helper_Form_Element_Text('siteKey',
NULL,
null,
'评论区谷歌验证码 <br> Site Key for reCAPTCHAv2:',
'<a href="https://www.google.com/recaptcha/admin/create">点击获取密钥</a>'
);

$secretKey = new Typecho_Widget_Helper_Form_Element_Text('secretKey', NULL, null, _t('Serect Key for reCAPTCHAv2:'), _t('填写两处密钥评论区自动开启谷歌验证码'));
$form->addInput($siteKey);
$form->addInput($secretKey);


$hcaptchaSecretKey = new Typecho_Widget_Helper_Form_Element_Text('hcaptchaSecretKey',
NULL,
null,
'<hr> 评论区hcaptch人机验证 <br> 密钥(sietkey)- 使用它作为 secret 来检查用户令牌:',
'<a href="https://dashboard.hcaptcha.com/welcome">点击获取密钥</a>'
);

$hcaptchaAPIKey = new Typecho_Widget_Helper_Form_Element_Text('hcaptchaAPIKey', NULL, null, _t('API 密钥:'), _t('填写两处密钥评论区自动开启hcaptch人机验证'));

$form->addInput($hcaptchaSecretKey);
$form->addInput($hcaptchaAPIKey);




$db = Typecho_Db::get();
$sjdq=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:butterfly'));
$ysj = $sjdq['value'];
if(isset($_POST['type']))
{
if($_POST["type"]=="备份主题数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:butterflybf'))){
$update = $db->update('table.options')->rows(array('value'=>$ysj))->where('name = ?', 'theme:butterflybf');
$updateRows= $db->query($update);
echo '<div class="tongzhi">备份已更新,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}else{
if($ysj){
$insert = $db->insert('table.options')->rows(array('name' => 'theme:butterflybf','user' => '0','value' => $ysj));
$insertId = $db->query($insert);
echo '<div class="tongzhi">备份完成,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}
}
}
if($_POST["type"]=="还原主题数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:butterflybf'))){
$sjdub=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:butterflybf'));
$bsj = $sjdub['value'];
$update = $db->update('table.options')->rows(array('value'=>$bsj))->where('name = ?', 'theme:butterfly');
$updateRows= $db->query($update);
echo '<div class="tongzhi">检测到主题备份数据,恢复完成,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2000);</script>
<?php
}else{
echo '<div class="tongzhi">没有主题备份数据,恢复不了哦!</div>';
}
}
if($_POST["type"]=="删除备份数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:butterflybf'))){
$delete = $db->delete('table.options')->where ('name = ?', 'theme:butterflybf');
$deletedRows = $db->query($delete);
echo '<div class="tongzhi">删除成功,请等待自动刷新,如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}else{
echo '<div class="tongzhi">不用删了!备份不存在!!!</div>';
}
}
}
// 结束
}

function themeFields($layout)
{
$thumb = new Typecho_Widget_Helper_Form_Element_Text(
'thumb',
NULL,
NULL,
'自定义文章缩略图',
'填写时:将会显示填写的文章缩略图 <br>不填写时采用默认图片'
);
$layout->addItem($thumb);

$desc = new Typecho_Widget_Helper_Form_Element_Text(
'desc',
NULL,
NULL,
'SEO描述',
'用于填写文章或独立页面的SEO描述,如果不填写则没有'
);
$layout->addItem($desc);

$keywords = new Typecho_Widget_Helper_Form_Element_Text(
'keywords',
NULL,
NULL,
'SEO关键词',
'用于填写文章或独立页面的SEO关键词,如果不填写则没有'
);
$layout->addItem($keywords);


$showTimeWarning = new Typecho_Widget_Helper_Form_Element_Select(
'showTimeWarning',
array(
'on' => '开启(默认)',
'off' => '关闭'
),
'on',
'是否开启当前页面的文章过期警告',
'用于单独设置当前文章的过期警告 <br /> <b>仅在文章内作用,独立页面无需改动</b> <br />'
);
$layout->addItem($showTimeWarning);

$ShowReward = new Typecho_Widget_Helper_Form_Element_Select('ShowReward',
array(
'off' => '关闭(默认)',
'show' => '开启打赏',
),
'off',
'是否开启文章打赏',
'介绍:开启此功能需要在主题设置中添加二维码图片'
);
$layout->addItem($ShowReward);
$ShowToc = new Typecho_Widget_Helper_Form_Element_Select('ShowToc',
array(
'show' => '开启(默认)',
'off' => '关闭',
),
'show',
'是否显示文章目录',
'介绍:或许有的文章不需要目录功能,默认是开启的,一般不需要设置'
);
$layout->addItem($ShowToc);

$CopyRight = new Typecho_Widget_Helper_Form_Element_Select('CopyRight',
array(
'on' => ' CC BY-NC-SA 4.0(默认)',
'off' => '禁止转载',
),
'on',
'文章版权说明',
'介绍:默认为CC BY-NC-SA 4.0'
);
$layout->addItem($CopyRight);

}
// 新文章缩略图
function get_ArticleThumbnail($widget){
// 当文章无图片时的随机缩略图
// $rand = mt_rand(1, 26); // 随机 1-9 张缩略图
// // 缩略图加速
// $rand_url;
// if(!empty(Helper::options()->articleImgSpeed)){
// $rand_url = Helper::options()->articleImgSpeed;
// }else {
// $rand_url = $widget->widget('Widget_Options')->themeUrl . '/images/articles/';
// }
// $random = $rand_url . $rand . '.jpg'; // 随机缩略图路径
// $random = 'https://static01.imgkr.com/temp/517e5d14c312427dbf93304563869279.png';
// $attach = $widget->attachments(1)->attachment;
$random = '/usr/themes/butterfly/img/DefualtThumbnail.jpg';
$pattern = '/\<img.*?src\=\"(.*?)\"[^>]*>/i';

//如果有自定义缩略图
if($widget->fields->thumb) {
return $widget->fields->thumb;
}else if (preg_match_all($pattern, $widget->content, $thumbUrl) && strlen($thumbUrl[1][0]) > 7) {
return $thumbUrl[1][0];
}else {
return $random;
}
};




// 主页文章缩略图
function GetRandomThumbnail($widget)
{
// $random = 'https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg';
$random = '/usr/themes/butterfly/img/DefualtThumbnail.jpg';
if (Helper::options()->futureRandom) {
$moszu = explode("\r\n", Helper::options()->futureRandom);
$random = $moszu[array_rand($moszu, 1)] . "?futureRandom=" . mt_rand(0, 1000000);
}
$pattern = '/\<img.*?src\=\"(.*?)\"[^>]*>/i';
$patternMD = '/\!\[.*?\]\((http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
$patternMDfoot = '/\[.*?\]:\s*(http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
$t = preg_match_all($pattern, $widget->content, $thumbUrl);
$img = $random;
if ($widget->fields->thumb) {
$img = $widget->fields->thumb;
} elseif ($t) {
$img = $thumbUrl[1][0];
} elseif (preg_match_all($patternMD, $widget->content, $thumbUrl)) {
$img = $thumbUrl[1][0];
} elseif (preg_match_all($patternMDfoot, $widget->content, $thumbUrl)) {
$img = $thumbUrl[1][0];
}
echo $img;
}
// 文章封面缩略图
function GetRandomThumbnailPost($widget)
{
if ($widget->fields->thumb&&$widget->fields->thumb!=" ") {
$img = $widget->fields->thumb;
}else{
$img = "https://api.nuoyis.com/yu-api/acg?yasuo=1";
}
echo $img;
}

// 文章字数统计
function art_count ($cid){
$db=Typecho_Db::get ();
$rs=$db->fetchRow ($db->select ('table.contents.text')->from ('table.contents')->where ('table.contents.cid=?',$cid)->order ('table.contents.cid',Typecho_Db::SORT_ASC)->limit (1));
echo mb_strlen($rs['text'], 'UTF-8');
}
// 文章字数统计2
function charactersNum($archive) {
return mb_strlen($archive->text,'UTF-8');
}

// 全站字数统计
function allOfCharacters() {
$showPrivate = 0;
$chars = 0;
$db = Typecho_Db::get();
if($showPrivate == 0){
$select = $db ->select('text')->from('table.contents')->where('table.contents.status = ?','publish');
}else {
$select = $db ->select('text')->from('table.contents');
}
$rows = $db->fetchAll($select);
foreach ($rows as $row){
$chars += mb_strlen($row['text'], 'UTF-8');
}
$unit = '';
if($chars >= 10000) {
$chars /= 10000;
$unit = 'W';
}else if($chars >= 1000) {
$chars /= 1000;
$unit = 'K';
}
$out = sprintf('%.2lf %s',$chars, $unit);
echo $out;
}

function thumb($cid) {
if (empty($imgurl)) {
$rand_num = 10; //随机图片数量,根据图片目录中图片实际数量设置
if ($rand_num == 0) {
$imgurl = "img/0.jpg";
//如果$rand_num = 0,则显示默认图片,须命名为"0.jpg",注意是绝对地址
}else{
$imgurl = "img/".rand(1,$rand_num).".jpg";
//随机图片,须按"1.jpg","2.jpg","3.jpg"...的顺序命名,注意是绝对地址
}
}
$db = Typecho_Db::get();
$rs = $db->fetchRow($db->select('table.contents.text')
->from('table.contents')
->where('table.contents.type = ?', 'attachment')
->where('table.contents.parent= ?', $cid)
->order('table.contents.cid', Typecho_Db::SORT_ASC)
->limit(1));
$img = unserialize($rs['text']);
if (empty($img)){
echo $imgurl;
}
else{
echo '你的博客地址'.$img['path'];
}
}


// 评论时间
function timesince($older_date,$comment_date = false) {
$chunks = array(
array(86400 , '天'),
array(3600 , '小时'),
array(60 , '分'),
array(1 , '秒'),
);
$newer_date = time();
$since = abs($newer_date - $older_date);
if($since < 2592000){
for ($i = 0, $j = count($chunks); $i < $j; $i++){
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
if (($count = floor($since / $seconds)) != 0) break;
}
$output = $count.$name.'前';
}else{
$output = !$comment_date ? (date('Y-m-j G:i', $older_date)) : (date('Y-m-j', $older_date));
}
return $output;
}



// 文章内获取第一张图做封面
function getPostImg($archive) {
$img = array();
// 匹配 img 的 src 的正则表达式
preg_match_all("/<img.*?src=\"(.*?)\".*?\/?>/i", $archive->content, $img);
// 判断是否匹配到图片
if (count($img) > 0 && count($img[0]) > 0) {
// 返回图片
return $img[1][0];
} else {
// 如果没有匹配到就返回 none
return 'none';
}
}

function createCatalog($obj) { //为文章标题添加锚点
global $catalog;
global $catalog_count;
$catalog = array();
$catalog_count = 0;
$obj = preg_replace_callback('/<h([1-6])(.*?)>(.*?)<\/h\1>/i', function($obj) {
global $catalog;
global $catalog_count;
$catalog_count ++;
$catalog[] = array('text' => trim(strip_tags($obj[3])), 'depth' => $obj[1], 'count' => $catalog_count);
return '<h'.$obj[1].$obj[2].' id="cl-'.$catalog_count.'"><a class="markdownIt-Anchor" href="#cl-'.$catalog_count.'"></a>'.$obj[3].'</h'.$obj[1].'>';
}, $obj);
return $obj;
}


// 目录树
function getCatalog() { //输出文章目录容器
global $catalog;
$index = '';
if ($catalog) {
$prev_depth = '';
$to_depth = 0;
foreach($catalog as $catalog_item) {
$catalog_depth = $catalog_item['depth'];
if ($prev_depth) {
if ($catalog_depth == $prev_depth) {
$index .= '</li >'."\n";
} elseif ($catalog_depth > $prev_depth) {
$to_depth++;
$index .= '<ol class="toc-child">'."\n";
} else {
$to_depth2 = ($to_depth > ($prev_depth - $catalog_depth)) ? ($prev_depth - $catalog_depth) : $to_depth;
if ($to_depth2) {
for ($i=0; $i<$to_depth2; $i++) {
$index .= '</li>'."\n".'</ol>'."\n";
$to_depth--;
}
}
$index .= '</li>';
}
}
$index .= '<li class="toc-item">
<a class="toc-link" href="#cl-'.$catalog_item['count'].'">
<span class="toc-number"></span>
<span class="toc-text">'.$catalog_item['text'].'</span>
</a>';
$prev_depth = $catalog_item['depth'];
}
for ($i=0; $i<=$to_depth; $i++) {
$index .= '</li>'."\n";
}
// $index = '<div >'."\n".'<div >'."\n"."\n".$index.'</div>'."\n".'</div>'."\n";
}
echo $index;
}

/* 获取懒加载图片 */
function GetLazyLoad()
{
if (Helper::options()->LazyLoad) {
return Helper::options()->LazyLoad;
} else {
return "data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=";
}
}

/* 格式化标签 */
function ParseCode($text)
{
$text = Short_Tabs($text);
$text = Note_Fsm($text);
$text = Note_Ico($text);
$text = Hide_Lnline($text);
$text = Hide_Block($text);
$text = Hide_Toggle($text);
$text = Button($text);
$text = Cheak_Box($text);
$text = inline_Tag($text);
$text = Bf_Radio($text);
$text = Bf_Mark($text);
$text = Font($text);
$text = ArtPlayer($text);
$text = PostImage($text);
return $text;
}
// 标签外挂-Tabs
function Short_Tabs($text)
{
$text = preg_replace_callback('/<p>\[tabs\](.*?)\[\/tabs\]<\/p>/ism', function ($text) {
return '[tabs]' . $text[1] . '[/tabs]';
}, $text);
$text = preg_replace_callback('/\[tabs\](.*?)\[\/tabs\]/ism', function ($text) {
return preg_replace('~<br.*?>~', '', $text[0]);
}, $text);
$text = preg_replace_callback('/\[tabs\](.*?)\[\/tabs\]/ism', function ($text) {
$tabname = '';
preg_match_all('/label=\"(.*?)\"\]/i', $text[1], $tabnamearr);
for ($i = 0; $i < count($tabnamearr[1]); $i++) {
if ($i === 0) {
$tabname .= '<li class="tab active"><button type="button" data-href="' . $i . '">' . $tabnamearr[1][$i] . '</button></li>';
} else {
$tabname .= '<li class="tab" data-href="' . $i . '"><button type="button" data-href="' . $i . '">' . $tabnamearr[1][$i] . '</button></li>';
}
}
$tabcon = '';
preg_match_all('/"\](.*?)\[\//i', $text[1], $tabconarr);
for ($i = 0; $i < count($tabconarr[1]); $i++) {
if ($i === 0) {
$tabcon .= '<div class="tab-item-content active" id="' . $i . '">' . $tabconarr[1][$i] . ' <button type="button" class="tab-to-top" aria-label="scroll to top"><i class="fas fa-arrow-up"></i></button></div>';
} else {
$tabcon .= '<div class="tab-item-content" id="' . $i . '">' . $tabconarr[1][$i] . '<button type="button" class="tab-to-top" aria-label="scroll to top"><i class="fas fa-arrow-up"></i></button></div>';
}
}
return '
<div class="tabs" id="tags"><ul class="nav-tabs">' . $tabname . '</ul><div class="tab-contents">' . $tabcon . '</div></div>';
}, $text);
return $text;
}
// 标签外挂-btn
function Button($text)
{
$text = preg_replace_callback('/\[btn href=\"(.*?)\" type=\"(.*?)\".*?\ ico=\"(.*?)\"](.*?)\[\/btn\]/ism', function ($text) {
return '<a href="' . $text[1] . '" class="btn-beautify button--animated ' . $text[2] . '">
<i class=" ' . $text[3] . '"></i><span>' . $text[4] . '</span></a>';
}, $text);
return $text;
}

// 标签外挂-note
function Note_Fsm($text)
{
$text = preg_replace_callback('/\[note type=\"(.*?)\".*?\](.*?)\[\/note\]/ism', function ($text) {
return '<div class="note ' . $text[1] . '"> <p>' . $text[2] . '</p></div>';
}, $text);
return $text;
}
// 标签外挂-note_ico
function Note_Ico($text)
{
$text = preg_replace_callback('/\[note-ico type=\"(.*?)\".*?\ ico=\"(.*?)\"](.*?)\[\/note-ico\]/ism', function ($text) {
return '<div class="note ' . $text[1] . '"><i class="' . $text[2] . '"></i><p>' . $text[3] . '</p></div>';
}, $text);
return $text;
}
// hide-inline
function Hide_Lnline($text)
{
$text = preg_replace_callback('/\[hide-inline name=\"(.*?)\".*?\](.*?)\[\/hide-inline\]/ism', function ($text) {
return '<span class="hide-inline"><button type="button" class="hide-button button--animated">' . $text[1] . '</button><span class="hide-content">' . $text[2] . '</span></span>';
}, $text);
return $text;
}
// hide-block
function Hide_Block($text)
{
$text = preg_replace_callback('/\[hide-block name=\"(.*?)\".*?\](.*?)\[\/hide-block\]/ism', function ($text) {
return '<div class="hide-block"><button type="button" class="hide-button button--animated">' . $text[1] . '</button><div class="hide-content">' . $text[2] . '</div></div>';
}, $text);
return $text;
}

// hide-toggle
function Hide_Toggle($text)
{
$text = preg_replace_callback('/\[hide-toggle name=\"(.*?)\".*?\](.*?)\[\/hide-toggle\]/ism', function ($text) {
return '<details class="toggle"><summary class="toggle-button">' . $text[1] . '</summary><div class="toggle-content">' . $text[2] . '</div></details>';
}, $text);
return $text;
}
// 复选框
function Cheak_Box($text)
{
$text = preg_replace_callback('/\[cb type=\"(.*?)\".*?\ checked=\"(.*?)"\](.*?)\[\/cb\]/ism', function ($text) {
return '<div class="checkbox '. $text[1] .' checked"><input type="checkbox" '. $text[2] .'>'. $text[3] .'</div>';
}, $text);
return $text;
}
// 行内标签
function inline_Tag($text)
{
$text = preg_replace_callback('/\[in-tag color=\"(.*?)\"](.*?)\[\/in-tag\]/ism', function ($text) {
return '<span class="inline-tag '. $text[1] .'">'. $text[2] .'</span>';
}, $text);
return $text;
}
// 单选框-radio
function Bf_Radio($text)
{
$text = preg_replace_callback('/\[radio color=\"(.*?)\".*?\ checked=\"(.*?)"\](.*?)\[\/radio\]/ism', function ($text) {
return '<div class="checkbox '. $text[1] .' checked"><input type="radio" '. $text[2] .'>'. $text[3] .'</div>';
}, $text);
return $text;
}

function Bf_Mark($text)
{
$text = preg_replace_callback('/\[label color=\"(.*?)\".*?\](.*?)\[\/label\]/ism', function ($text) {
return '<mark class="hl-label '. $text[1] .'">'. $text[2] .'</mark>';
}, $text);
return $text;
}

function Font($text)
{
$text = preg_replace_callback('/\[font size=\"(.*?)"\ color=\"(.*?)"\](.*?)\[\/font\]/ism', function ($text) {
return '<font style="font-size: '. $text[1] .'px;color:'. $text[2] .'">'. $text[3] .'</font>';
}, $text);
return $text;
}

function ArtPlayer($text)
{
$text = preg_replace_callback('/\[video title=\"(.*?)"\ url=\"(.*?)"\ container=\"(.*?)"\ subtitle=\"(.*?)"\ poster=\"(.*?)"\](.*?)\[\/video\]/ism', function ($text) {
$t = explode("<br>", $text[6]);
for($i=0;$i<count($t);$i++){
$a[] = explode("|", $t[$i]);
}
for($i=0;$i<count($a);$i++){
$c[$i]['time']=$a[$i][0];
$c[$i]['text']=$a[$i][2];
unset($c[$i][0]);
unset($c[$i][3]);
}
$c[0]['text']==null ? $highlight = '[]' : $highlight = json_encode($c,JSON_NUMERIC_CHECK);
$text[4] == ' '?$tooltip = '无字幕' : $tooltip = '默认字幕';
return '
<div class="iframe_video artplayer artplayer-'.$text[3].'"></div>
<script>
var '.$text[3].' = new Artplayer({
container: ".artplayer-'.$text[3].'",
url: "'.$text[2].'",
title: "'.$text[1].'",
poster: "'.$text[5].'",
subtitle: {
url: "'.$text[4].'",
},
volume: 0.5,
muted: false,
autoplay: false,
pip: true,
autoSize: true,
autoMini: false,
screenshot: true,
setting: true,
loop: true,
flip: true,
playbackRate: true,
aspectRatio: true,
fullscreen: true,
fullscreenWeb: true,
subtitleOffset: true,
miniProgressBar: true,
mutex: true,
backdrop: true,
playsInline: true,
autoPlayback: true,
theme: "#23ade5",
lang: navigator.language.toLowerCase(),
whitelist: ["*"],
moreVideoAttr: {
crossOrigin: "anonymous",
},
settings: [{
width: 200,
html: "字幕",
tooltip: "'.$tooltip.'",
selector: [{
html: "Display",
tooltip: "显示",
switch: true,
onSwitch: function (item) {
item.tooltip = item.switch ? "关闭" : "显示";
'.$text[3].'.subtitle.show = !item.switch;
return !item.switch;
},
}],
onSelect: function(item) {
art.subtitle.switch(item.url, {
name: item.html,
});
return item.html;
},
}, ],
highlight: '.$highlight.'
});
</script>';
}, $text);
return $text;
}

// 重写文章图片加载
function PostImage($text)
{
$text = preg_replace_callback('/<img src=\"(.*?)"\ alt=\"(.*?)"\>/ism', function ($text) {
return '<img title="'.$text[2].'" alt="'.$text[2].'" data-lazy-src="'.$text[1].'" src="'.GetLazyLoad().'" />';
}, $text);
return $text;
}

function themeInit($archive) {
if(Helper::options()->EnablePjax == "on"){
Helper::options()->commentsAntiSpam = false;
}
if ($archive->is('single')) {
$archive->content = createCatalog($archive->content);
$archive->content = ParseCode($archive->content);
}
$loginStatus = $archive->widget('Widget_User')->hasLogin();
if(Helper::options()->siteKey !== "" && Helper::options()->secretKey !=="" && !$loginStatus){
comments_filter($archive);
}
if (Helper::options()->hcaptchaSecretKey !== "" && Helper::options()->hcaptchaAPIKey !== "" && !$loginStatus) {
hcaptcha_filter($archive);
}
if ($archive->is('index')) {
// echo '<script src="'..'"></script>';
}

}

/**
* 判断时间区间
*
* 使用方法 if(timeZone($this->date->timeStamp)) echo 'ok';
*/
function timeZone($from){
$now = new Typecho_Date(Typecho_Date::gmtTime());
return $now->timeStamp - $from < 24*60*60 ? true : false;
}


/**
* 获取标签数目
*
* 语法: <?php echo tagsNum(); ?>
*
* @access protected
* @return integer
*/
function tagsNum($display = true)
{
$db = Typecho_Db::get();
$total_tags = $db->fetchObject($db->select(array('COUNT(mid)' => 'num'))
->from('table.metas')
->where('table.metas.type = ?', 'tag'))->num;
if($display) {
echo $total_tags;
} else {
return $total_tags;
}
}


//获取Gravatar头像 QQ邮箱取用qq头像
function getGravatar($email,$name, $comments_a,$s = 96, $d = 'mp', $r = 'g')
{
preg_match_all('/((\d)*)@qq.com/', $email, $vai);
if (empty($vai['1']['0'])) {
// $hasGravatar = hasGravatar($email);
// if($hasGravatar){
// $url = 'https://gravatar.loli.net/avatar/';
$url = Helper::options()->GravatarSelect;
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
$imga = '<img '.$comments_a.' src="'.GetLazyLoad().'" data-lazy-src="'.$url.'" >';
// }else{
// $imga = '<img avatar="'.$name.'" color '.$comments_a.'>';
// }
}else{
$qquser = $vai['1']['0'];
$db=Typecho_Db::get();
if (!array_key_exists('qqk', $db->fetchRow($db->select()->from('table.comments')))) {
$db->query('ALTER TABLE `'.$db->getPrefix().'comments` ADD `qqk` varchar(64) DEFAULT NULL;');
}
$dbk = $db->fetchRow($db->select('qqk')->from('table.comments')->where('mail=?',$email))['qqk'];
if($dbk == NULL){
$geturl = 'https://ptlogin2.qq.com/getface?&imgtype=1&uin='.$qquser;
$qqurl = file_get_contents($geturl);
$str1 = explode('sdk&k=', $qqurl);
if(isset($str1[1])){
$str2 = explode('&t=',$str1[1]);
$k = $str2[0];
$db->query($db->update('table.comments')->rows(array('qqk' => $k))->where('mail=?',$email));
}
$url = 'https://q1.qlogo.cn/headimg_dl?dst_uin='.$qquser.'&spec=100';
}else{
$url = 'https://q1.qlogo.cn/g?b=qq&k='.$dbk.'&s=100';
}
$imga = '<img '.$comments_a.' src="'.GetLazyLoad().'" data-lazy-src="'.$url.'" >';
}
return $imga;
}

// 获取浏览器信息
function getBrowser($agent)
{
if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
$outputer = '<i class="fab fa-internet-explorer"></i>&nbsp;&nbsp;Internet Explore';
} else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('Firefox/', $regs[0]);
$outputer = '<i class="fab fa-firefox-browser"></i>&nbsp;&nbsp;FireFox';
} else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('Maxthon/', $agent);
$outputer = '<i class="iconfont icon-maxthon"></i>&nbsp遨游';
} else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) {
$outputer = '<i class="iconfont icon-chrome"></i>&nbsp;360极速浏览器';
} else if (preg_match('/Edg([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('Edge/', $regs[0]);
$outputer = '<i class="fab fa-edge"></i>&nbsp;&nbsp;MicroSoft Edge';
} else if (preg_match('/UC/i', $agent)) {
$str1 = explode('rowser/', $agent);
$outputer = '<i class="iconfont icon-UCliulanqi"></i>&nbsp;UC浏览器';
} else if (preg_match('/QQ/i', $agent, $regs)||preg_match('/QQBrowser\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('rowser/', $agent);
$outputer = '<i class="iconfont icon-QQliulanqi"></i>&nbsp;QQ浏览器';
} else if (preg_match('/UBrowser/i', $agent, $regs)) {
$str1 = explode('rowser/', $agent);
$outputer = '<i class="iconfont icon-UCliulanqi"></i>&nbsp;UC浏览器';
} else if (preg_match('/Opera[\s|\/]([^\s]+)|OPR/i', $agent, $regs)) {
$outputer = '<i class="fab fa-opera"></i>&nbsp;&nbsp;Opera';
} else if (preg_match('/YaBrowser/i', $agent, $regs)) {
$str1 = explode('Version/', $agent);
$outputer = '<i class="fab fa-yandex-international"></i>&nbsp;&nbsp;Yandex';
}else if (preg_match('/Quark/i', $agent, $regs)) {
$str1 = explode('Version/', $agent);
$outputer = '<i class="iconfont icon-quark"></i>&nbsp;Quark';
}else if (preg_match('/XiaoMi/i', $agent, $regs)) {
$outputer = '<i class="iconfont icon-XiaoMi"></i>&nbsp;小米浏览器';}
else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('Chrome/', $agent);
$outputer = '<i class="fab fa-chrome""></i>&nbsp;&nbsp;Google Chrome';
} else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
$str1 = explode('Version/', $agent);
$outputer = '<i class="fab fa-safari"></i>&nbsp;&nbsp;Safari';
}
else{
$outputer = '<i class="fab fa-chrome"></i>&nbsp;&nbsp;Google Chrome';
}
echo $outputer;
}
// 获取操作系统信息
function getOs($agent)
{
$os = false;
if (preg_match('/win/i', $agent)) {
if (preg_match('/nt 6.0/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-windows"></i>&nbsp;Windows Vista&nbsp;/&nbsp;';
} else if (preg_match('/nt 6.1/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-windows"></i>&nbsp;Windows 7&nbsp;/&nbsp;';
} else if (preg_match('/nt 6.2/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-windows"></i>&nbsp;&nbsp;Windows 8&nbsp;/&nbsp;';
} else if(preg_match('/nt 6.3/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-windows"></i>&nbsp;&nbsp;Windows 8.1&nbsp;/&nbsp;';
} else if(preg_match('/nt 5.1/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-windows"></i>&nbsp;Windows XP&nbsp;/&nbsp;';
} else if (preg_match('/nt 10.0/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-windows"></i>&nbsp;&nbsp;Windows 10&nbsp;/&nbsp;';
}else if (preg_match('/nt 11.0/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-windows"></i>&nbsp;&nbsp;Windows 11&nbsp;/&nbsp;';
}else{
$os = '&nbsp;&nbsp;<i class="fab fa-windows"></i>&nbsp;&nbsp;Windows X64&nbsp;/&nbsp;';
}
}
else if (preg_match('/android/i', $agent)) {
if (preg_match('/android 9/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android Pie&nbsp;/&nbsp;';
}else if (preg_match('/android 4/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android ICS&nbsp;/&nbsp;';
}
else if (preg_match('/android 5/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android Lollipop&nbsp;/&nbsp;';
}
else if (preg_match('/android 6/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android M&nbsp;/&nbsp;';
}
else if (preg_match('/android 7/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android Nougat&nbsp;/&nbsp;';
}else if (preg_match('/android 8/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android Oreo&nbsp;/&nbsp;';
}else if (preg_match('/android 10/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android Q&nbsp;/&nbsp;';
}
else if (preg_match('/android 11/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android 11&nbsp;/&nbsp;';
}
else if (preg_match('/android 12/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android 12&nbsp;/&nbsp;';
}
else if (preg_match('/android 13/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android 13&nbsp;/&nbsp;';
}
else{
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android&nbsp;/&nbsp;';
}
}
else if (preg_match('/ubuntu/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-ubuntu"></i>&nbsp;&nbsp;Ubuntu&nbsp;/&nbsp;';
}else if (preg_match('/Arch/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-Arch-Linux"></i>&nbsp;Arch Linux&nbsp;/&nbsp;';
}else if (preg_match('/manjaro/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-manjaro"></i>&nbsp;&nbsp;Manjaro&nbsp;/&nbsp;';
}else if (preg_match('/debian/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="iconfont icon-debianos"></i>&nbsp;Debian&nbsp;/&nbsp;';
}else if (preg_match('/linux/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-linux"></i>&nbsp;&nbsp;Linux&nbsp;/&nbsp;';
}else if (preg_match('/iPad/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-apple"></i>&nbsp;&nbsp;iOS(iPad)&nbsp;/&nbsp;';
}else if (preg_match('/iPhone/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-apple"></i>&nbsp;&nbsp;iOS(iPhone)&nbsp;/&nbsp;';
}else if (preg_match('/mac/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-apple"></i>&nbsp;&nbsp;MacOS&nbsp;/&nbsp;';
}else if (preg_match('/fusion/i', $agent)) {
$os = '&nbsp;&nbsp;<i class="fab fa-android"></i>&nbsp;&nbsp;Android&nbsp;/&nbsp;';
} else {
$os = '&nbsp;&nbsp;<i class="fab fa-linux"></i>&nbsp;&nbsp;Linux&nbsp;/&nbsp;';
}
echo $os;
}

function commentRank($widget, $email = NULL)
{
if (empty($email)) return;
$txt = Helper::options()->CustomAuthenticated;
if($txt == ""){
$txt = 'x||x';
}
$string_arr = explode("\r\n", $txt);
$long = count($string_arr);
for ($i = 0; $i < $long; $i++) {
$mailList[] = explode("||", $string_arr[$i])[0];
$authList[] = explode("||", $string_arr[$i])[1];
}
$all = array_combine($mailList,$authList);

if ($widget->authorId == $widget->ownerId) {
echo '<span class="vtag vmaster">博主</span>';
}
else if (in_array($email, $mailList)) {
echo '<span class="vtag vauth">'.$all[$email].'</span>';

}
else{
echo '<span class="vtag vvisitor">访客</span>';
}
}

//获取评论的锚点链接
function get_comment_at($coid)
{
$db = Typecho_Db::get();
$prow = $db->fetchRow($db->select('parent,status')->from('table.comments')
->where('coid = ?', $coid));//当前评论
$mail = "";
$parent = @$prow['parent'];
if ($parent != "0") {//子评论
$arow = $db->fetchRow($db->select('author,status,mail')->from('table.comments')
->where('coid = ?', $parent));//查询该条评论的父评论的信息
@$author = @$arow['author'];//作者名称
$mail = @$arow['mail'];
if(@$author && $arow['status'] == "approved"){//父评论作者存在且父评论已经审核通过
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(评论审核中))</p>';
}
echo '<a onclick="b(this);return false;" href="#comment-' . $parent . '">@' . $author . '</a>';
}else{//父评论作者不存在或者父评论没有审核通过
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(评论审核中))</p>';
}else{
echo '';
}
}

} else {//母评论,无需输出锚点链接
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(评论审核中))</p>';
}else{
echo '';
}
}
}
/**
* 重写评论显示函数
*/
function threadedComments($comments, $options) {
$commentClass = '';
if ($comments->authorId) {
if ($comments->authorId == $comments->ownerId) {
$commentClass .= ' comment-by-author';
} else {
$commentClass .= ' comment-by-user';
}
}
$commentLevelClass = $comments->levels > 0 ? ' comment-child' : ' comment-parent';
?>
<li id="li-<?php $comments->theId(); ?>" class="comment-body<?php
if ($comments->levels > 0) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
} else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass;
?>">
<div id="<?php $comments->theId(); ?>">
<div class="comment-author">
<?php $email=$comments->mail;$name=$comments->author; $comments_a = 'class="vimg" style="border-radius: 50%;"';echo getGravatar($email,$name,$comments_a);?>
<cite class="vnick"><?php $comments->author(); ?></cite>
<?php commentRank($comments, $comments->mail); ?>

</div>
<div class="vhead">
<b><?php $parentMail = get_comment_at($comments->coid)?><?php echo $parentMail;?></b>
<a class="vtime" href="<?php $comments->permalink(); ?>"><?php $comments->date('Y-m-d H:i'); ?></a>
<?php if(Helper::options()->CloseComments == 'off'): ?>
<span class="comment-reply"><?php $comments->reply(); ?></span>
<?php endif ?>
</div>
<div class="comment-content"><?php $comments->content(); ?></div>
<span class="comment-ua"><?php getOs($comments->agent); ?><?php getBrowser($comments->agent); ?></span>
</div>
<?php if ($comments->children) { ?>
<div class="comment-children">
<?php $comments->threadedComments($options); ?>
</div>
<?php } ?>
</li>
<?php }

// 主页封面
function img_postthemb($thiz,$default_img){
$content = $thiz->content;
$ret = preg_match("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $thumbUrl);
if($ret === 1 && count($thumbUrl) == 2){
return $thumbUrl[1];
}else{
return $default_img="https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg";
}
}

// 输出标签
function printTag($that) { ?>
<?php if (count($that->tags) > 0): ?>
<?php foreach( $that->tags as $tags): ?>
<a href="<?php print($tags['permalink']) ?>" class="post-meta__tags"><span><?php print($tags['name']) ?></span></a>
<?php endforeach;?>
<?php else: ?>
<a class="post-meta__tags"><span>无标签</span></a>
<?php endif;?>
<?php }


//当前人数
function onlinePeople(){
$online_log = "usr/themes/butterfly/online.dat"; //保存人数的文件到根目录,
$timeout = 30;//30秒内没动作者,认为掉线
if(!file_exists($online_log) ){
fopen($online_log, "w");
}
$entries = file($online_log);
$temp = array();
for ($i=0;$i<count($entries);$i++){
$entry = explode(",",trim($entries[$i]));
if(($entry[0] != getenv('REMOTE_ADDR')) && ($entry[1] > time())) {
array_push($temp,$entry[0].",".$entry[1]."\n"); //取出其他浏览者的信息,并去掉超时者,保存进$temp
}
}
array_push($temp,getenv('REMOTE_ADDR').",".(time() + ($timeout))."\n"); //更新浏览者的时间
$slzxrs = count($temp); //计算在线人数
$entries = implode("",$temp);
//写入文件
$fp = fopen($online_log,"w");
flock($fp,LOCK_EX); //flock() 不能在NFS以及其他的一些网络文件系统中正常工作
fputs($fp,$entries);
flock($fp,LOCK_UN);
fclose($fp);
echo $slzxrs;
}

/*
* 无插件阅读数
*/
function get_post_view($archive)
{
$db = Typecho_Db::get();
$cid = $archive->cid;
if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
$db->query('ALTER TABLE `'.$db->getPrefix().'contents` ADD `views` INT(10) DEFAULT 0;');
}
$exist = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid))['views'];
if ($archive->is('single')) {
$cookie = Typecho_Cookie::get('contents_views');
$cookie = $cookie ? explode(',', $cookie) : array();
if (!in_array($cid, $cookie)) {
$db->query($db->update('table.contents')
->rows(array('views' => (int)$exist+1))
->where('cid = ?', $cid));
$exist = (int)$exist+1;
array_push($cookie, $cid);
$cookie = implode(',', $cookie);
Typecho_Cookie::set('contents_views', $cookie);
}
}
echo $exist == 0 ? '0':' '.$exist;
}
//总访问量
function theAllViews(){
$db = Typecho_Db::get();
if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
$db->query('ALTER TABLE `'.$db->getPrefix().'contents` ADD `views` INT(10) DEFAULT 0;');
}
$row = $db->fetchAll($db->select('SUM(views)')->from('table.contents'));
echo array_values($row[0])[0];
}
// 回复可见
Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('myyodux','one');
Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('myyodux','one');
class myyodux {
public static function one($con,$obj,$text)
{
$text = empty($text)?$con:$text;
if(!$obj->is('single')){
$text = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'',$text);
// $text = preg_replace("/\n\s*){3,}/sm",' ',$text);
}
return $text;
}
}

/**
* 显示上一篇
*
* 如果没有下一篇,返回null
*/
function thePrevCid($widget, $default = NULL) {
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')
->where('table.contents.created < ?', $widget->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $widget->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_DESC)
->limit(1);
$content = $db->fetchRow($sql);

if ($content) {
return $content["cid"];
} else {
return $default;
}
};

/**
* 获取下一篇文章mid
*
* 如果没有下一篇,返回null
*/
function theNextCid($widget, $default = NULL) {
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')
->where('table.contents.created > ?', $widget->created)
->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', $widget->type)
->where('table.contents.password IS NULL')
->order('table.contents.created', Typecho_Db::SORT_ASC)
->limit(1);
$content = $db->fetchRow($sql);

if ($content) {
return $content["cid"];
} else {
return $default;
}
};

//调用博主最近文章更新时间
function get_last_update(){
$num = '1';
$type = 'post';
$status = 'publish';
$now = time();
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
$create = $db->fetchRow($db->select('created')->from('table.contents')->where('table.contents.type=? and status=?',$type,$status)->order('created',Typecho_Db::SORT_DESC)->limit($num));
$update = $db->fetchRow($db->select('modified')->from('table.contents')->where('table.contents.type=? and status=?',$type,$status)->order('modified',Typecho_Db::SORT_DESC)->limit($num));
if($create>=$update){
echo Typecho_I18n::dateWord(isset($create['created']), $now);
}else{
$lastday = floor(date($now-$update['modified'])/86400);
if($lastday>365){$lastyear = floor(date($now-$update['modified'])/30758400);echo $lastyear . " 年前" ;
} elseif($lastday > 30){$lastmom = floor(date($now-$update['modified'])/2592000);echo $lastmom ." 个月前" ;
}elseif($lastday < 1){$lasthour = floor(date($now-$update['modified'])/3600);
if($lasthour<1){$lastmin = floor(date($now-$update['modified'])/60);
if($lastmin < 1){$lastsecd = floor(date($now-$update['modified'])); echo $lastsecd ." 秒前" ;}
else{echo $lastmin ." 分钟前" ;}
}else{echo $lasthour ." 小时前" ;}
}else{echo $lastday." 天前";}}
}
//文章阅读时间统计
function art_time ($cid){
$db=Typecho_Db::get ();
$rs=$db->fetchRow ($db->select ('table.contents.text')->from ('table.contents')->where ('table.contents.cid=?',$cid)->order ('table.contents.cid',Typecho_Db::SORT_ASC)->limit (1));
$text = preg_replace("/[^\x{4e00}-\x{9fa5}]/u", "", $rs['text']);
$text_word = mb_strlen($text,'utf-8');
echo ceil($text_word / 400);
}
// 自定义编辑器
Typecho_Plugin::factory('admin/write-post.php')->bottom = array('editor', 'reset');
Typecho_Plugin::factory('admin/write-page.php')->bottom = array('editor', 'reset');
class editor
{
public static function reset()
{
echo "<script src='" . Helper::options()->themeUrl . '/edit/extend.js?v1.6.3' . "'></script>";
echo "<link rel='stylesheet' href='" . Helper::options()->themeUrl . '/edit/edit.css?v1.6.3' . "'>";
}

}
/* 判断是否是移动端 */
function isMobile()
{
if (isset($_SERVER['HTTP_X_WAP_PROFILE']))
return true;
if (isset($_SERVER['HTTP_VIA'])) {
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
return true;
}
if (isset($_SERVER['HTTP_ACCEPT'])) {
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
return true;
}
}
return false;
}
function RunTime(){
$site_create_time = strtotime(Helper::options()->buildtime);
$time = time() - $site_create_time;
if(is_numeric($time)){
if($time >= 86400){
$days = floor($time/86400);
$time = ($time%86400);
echo $days.' 天';
}else{
echo '1 天';
}

}else{
echo '';
}
}
function RecapOutPut($login) {
$siteKey = Helper::options()->siteKey;
$secretKey = Helper::options()->secretKey;
if ($siteKey !== "" && $secretKey !== "" && !$login) {
echo '<script src="https://recaptcha.net/recaptcha/api.js" async defer data-no-instant></script>
<div class="g-recaptcha" data-sitekey=' . $siteKey . '></div>';
}
if (Helper::options()->hcaptchaSecretKey !== "" && Helper::options()->hcaptchaAPIKey !== "" && !$login) {
echo '<script src="https://www.hCaptcha.com/1/api.js" async defer></script><div class="h-captcha" data-sitekey='. Helper::options()->hcaptchaSecretKey .'></div>';
}
}

function comments_filter($comment) {
if (isset($_REQUEST['text']) != null) {
if($_POST['g-recaptcha-response'] == null) {
throw new Typecho_Widget_Exception(_t('人机验证失败,确认你加载了谷歌人机验证并通过验证'));
}else {
$siteKey = Helper::options()->siteKey;
$secretKey = Helper::options()->secretKey;
function getCaptcha($recaptcha_response, $secretKey) {
$response = file_get_contents("https://recaptcha.net/recaptcha/api/siteverify?secret=".$secretKey."&response=".$recaptcha_response);
$response = json_decode($response);
return $response;
}
$resp = getCaptcha($_POST['g-recaptcha-response'], $secretKey);

if ($resp->success == true) {
return $comments;
} else {
switch ($resp->error-codes) {
case '{[0] => "timeout-or-duplicate"}':
throw new Typecho_Widget_Exception(_t('验证时间超过2分钟或连续重复发言!'));
break;
case '{[0] => "invalid-input-secret"}':
throw new Typecho_Widget_Exception(_t('博主填了无效的siteKey或者secretKey...'));
break;
case '{[0] => "bad-request"}':
throw new Typecho_Widget_Exception(_t('请求错误!请检查网络'));
break;
default:
throw new Typecho_Widget_Exception(_t('很遗憾,您被当成了机器人...'));
}
}
}
}
return $comment;
}


function hcaptcha_filter($comment){
if (isset($_REQUEST['text']) != null) {
if($_POST['h-captcha-response'] == null) {
throw new Typecho_Widget_Exception(_t('人机验证失败,确认你加载了hcaptcha人机验证并通过验证'));
}else{
if(isset($_POST['h-captcha-response']) && !empty($_POST['h-captcha-response'])){
$secret = Helper::options()->hcaptchaAPIKey;
$verifyResponse = file_get_contents('https://hcaptcha.com/siteverify?secret='.$secret.'&response='.$_POST['h-captcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR']);
$responseData = json_decode($verifyResponse);
if($responseData->success == true)
{
return $comments;
}else{
throw new Typecho_Widget_Exception(_t($responseData->error-codes));
}
}
}
}
return $comment;
}

// 微博热搜
function weibohot(){
$api = file_get_contents('https://weibo.com/ajax/side/hotSearch');
$data = json_decode($api,true)['data']['realtime'];

$jyzy = array(
'电影' => '影',
'剧集' => '剧',
'综艺' => '综',
'音乐' => '音',
'盛典' => '盛',
);

$hotness = array(
'爆' => 'weibo-boom',
'热' => 'weibo-hot',
'沸' => 'weibo-boil',
'新' => 'weibo-new',
'荐' => 'weibo-recommend',
'音' => 'weibo-jyzy',
'影' => 'weibo-jyzy',
'剧' => 'weibo-jyzy',
'综' => 'weibo-jyzy',
'盛' => 'weibo-jyzy',
);

foreach($data as $item){
$hot = '荐';
if(isset($item['is_ad'])){
continue;
}
if(isset($item['is_boom'])){
$hot = '爆';
}
if(isset($item['is_hot'])){
$hot = '热';
}
if(isset($item['is_fei'])){
$hot = '沸';
}
if(isset($item['is_new'])){
$hot = '新';
}
if(isset($item['flag_desc'])){
$hot = $jyzy[$item['flag_desc']];
}
echo '<div class="weibo-list-item"><div class="weibo-hotness '.$hotness[$hot].'">'.$hot.'</div><span class="weibo-title"><a title="'.$item['note'].'" href="https://s.weibo.com/weibo?q=%23' . $item['word'] . '%23" target="_blank" rel="external nofollow noreferrer" style="color:#a08ed5">'.$item['note'].'</a></span><div class="weibo-num"><span>'.$item['num'].'</span></div></div>';
}
}

footer.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
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php if(!$this->page404()): ?>
<footer id="footer">
<div id="footer-wrap"><div class="copyright">
<div class="copyright">©<?php echo date('Y'); ?> By <?php $this->author(); ?></div>
<div class="framework-info">
<span>由</span>
<a target="_blank" href="http://www.typecho.org">Typecho</a><span> 强力驱动</span>
<span class="footer-separator">|</span>
<span>主题</span>
<a id="btheme" target="_blank" href="https://github.com/wehaox/Typecho-Butterfly">Butterfly</a>
</br><?php if($this->options->gxbeian != ""): ?>
备案号:<a href="//beian.miit.gov.cn"><?php $this->options->gxbeian(); ?></a> |
<?php endif; ?>
<?php if($this->options->gabeian != ""):
if (is_string($this->options->gabeian) || !empty($this->options->gabeian)):
$gabeian1 = $gabeian2 = '';
if (is_string($this->options->gabeian) || !empty($this->options->gabeian)){
for ($i = 0; $i < strlen($this->options->gabeian); $i++) {
$char = substr($this->options->gabeian, $i, 1);
if (ctype_digit($char)) {
$gabeian1=substr($this->options->gabeian, 0, $i);
$gabeian2=substr($this->options->gabeian, $i, strlen($this->options->gabeian)-$i-3);
break;
}
}
}
?>
<img src="https://static.nuoyis.com/lib/blog/typecho/themes/butterfly/images/beian.png"><?=$gabeian1; ?><a href="//www.beian.gov.cn/portal/registerSystemInfo?recordcode=<?=$gabeian2 ?>"><?=$gabeian2 ?></a>号 |
<?php endif; ?>
<?php endif; ?>
<?php if($this->options->moebeian != ""):
if (is_string($this->options->moebeian) || !empty($this->options->moebeian)):
$moebeian1 = $moebeian2 = '';
if (is_string($this->options->moebeian) || !empty($this->options->moebeian)){
for ($i = 0; $i < strlen($this->options->moebeian); $i++) {
$char = substr($this->options->moebeian, $i, 1);
if (ctype_digit($char)) {
$moebeian1=substr($this->options->moebeian, 0, $i);
$moebeian2=substr($this->options->moebeian, $i, strlen($this->options->moebeian)-$i-3);
break;
}
}
}
?>
<?=$moebeian1; ?><a href="https://icp.gov.moe/?keyword=<?=$moebeian2; ?>" target="_blank"><?=$moebeian2; ?></a>号
<?php endif; ?>
<?php endif; ?>
</div>
<div class="footer_custom_text"><?php $this->options->Customfooter() ?></div>
</div>
</div>
</footer>
<?php endif ?>
<?php $this->footer(); ?>
<style type="text/css" data-typed-js-css="true">
.typed-cursor{
opacity: 1;
}
.typed-cursor.typed-cursor--blink{
animation: typedjsBlink 0.7s infinite;
-webkit-animation: typedjsBlink 0.7s infinite;
animation: typedjsBlink 0.7s infinite;
}
@keyframes typedjsBlink{
50% { opacity: 0.0; }
}
@-webkit-keyframes typedjsBlink{
0% { opacity: 1; }
50% { opacity: 0.0; }
100% { opacity: 1; }
}
</style>
<?php if ($this->options->showFramework == 'off'): ?>
<style>.framework-info{display:none}</style>
<?php endif; ?>
<?php if ($this->options->CursorEffects !== 'off' &&$this->options->CursorEffects == 'heart') : ?>
<?php if($this->options->StaticFile == 'CDN' && $this->options->CDNURL == ''): ?>
<script id="click-heart" src="https://<?php $this->options->jsdelivrLink() ?>/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script>
<?php elseif($this->options->StaticFile == 'CDN' && $this->options->CDNURL !== ''): ?>
<script id="click-heart" src="<?php $this->options->CDNURL() ?>/static/js/click-heart.min.js" async="async" mobile="false"></script>
<?php else : ?>
<script id="click-heart" src="<?php $this->options->themeUrl('/static/js/click-heart.min.js'); ?>" async="async" mobile="false"></script>
<?php endif; ?>
<?php elseif ($this->options->CursorEffects !== 'off' &&$this->options->CursorEffects == 'fireworks') : ?>
<canvas class="fireworks"></canvas>

<?php if($this->options->StaticFile == 'CDN' && $this->options->CDNURL == ''): ?>
<script id="fireworks" src="https://<?php $this->options->jsdelivrLink() ?>/npm/butterfly-extsrc@1.1.0/dist/fireworks.min.js" async="async" mobile="false"></script>
<?php elseif($this->options->StaticFile == 'CDN' && $this->options->CDNURL !== ''): ?>
<script id="fireworks" src="<?php $this->options->CDNURL() ?>/static/js/fireworks.min.js" async="async" mobile="false"></script>
<?php else : ?>
<script id="fireworks" src="<?php $this->options->themeUrl('/static/js/fireworks.min.js'); ?>" async="async" mobile="false"></script>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->options->ShowLive2D !== 'off' && !isMobile()) : ?>
<?php if($this->options->StaticFile == 'CDN' && $this->options->CDNURL == ''): ?>
<script src="https://<?php $this->options->jsdelivrLink() ?>/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>
<?php elseif($this->options->StaticFile == 'CDN' && $this->options->CDNURL !== ''): ?>
<script src="<?php $this->options->CDNURL() ?>/static/js/autoload.js"></script>
<?php else : ?>
<script src="<?php $this->options->themeUrl('/static/js/autoload.js'); ?>"></script>
<?php endif; ?>
<?php endif; ?>
<script type="text/javascript" src="<?php $this->options->themeUrl('js/custom.main.js'); ?>"></script>
<script><?php $this->options->CustomScript() ?></script>
<?php $this->options->CustomBodyEnd() ?>
<!--搜索 -->
<div id="local-search">
<div class="search-dialog">
<nav class="search-nav">
<span class="search-dialog-title">本地搜索</span>
<span id="loading-status"></span>
<button class="search-close-button">
<i class="fas fa-times"></i>
</button>
</nav>
<div class="search-wrap" style="display: block;">
<div id="local-search-input">
<form class="local-search-box" method="post" action="<?php $this->options->siteUrl(); ?>" role="search" id="search">
<label for="s" class="sr-only"><?php _e('搜索关键字'); ?></label>
<input type="text" name="s" placeholder="回车查询" required="required"></div>
</form>
<hr>
<div id="local-search-results"></div>
</div>
</div>
<div id="search-mask" style=""></div>
</div>
</div>
<!--搜索end -->
<div class="js-pjax">
<?php if ($this->is('post') || $this->is('page')): ?>
<script src="<?php $this->options->themeUrl('js/comjs.js?v1.4.3'); ?>"></script>
<?php endif ?>
<?php if (!empty($this->options->beautifyBlock) && in_array('showButterflyClock',$this->options->beautifyBlock)): ?>
<script data-pjax>function butterfly_clock_anzhiyu_injector_config() {
var a = document.getElementsByClassName("sticky_layout")[0];
a && a.insertAdjacentHTML("afterbegin", '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src= "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-lazy-src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>')}
for (var elist = "null".split(","), cpage = location.pathname, epage = "all",
qweather_key = "<?php $this->options->qweather_key() ?>",
gaud_map_key = "<?php $this->options->gaud_map_key() ?>",
baidu_ak_key = "undefined", flag = 0,
clock_rectangle = "112.6534116,27.96920845", clock_default_rectangle_enable = "false", i = 0; i < elist.length; i++) cpage.includes(elist[i]) && flag++;
"all" === epage && 0 == flag ? butterfly_clock_anzhiyu_injector_config() : epage === cpage && butterfly_clock_anzhiyu_injector_config()</script>
<script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script>
<script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script>
<link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css">
<?php endif ?>
<?php $this->header('commentReply=1&description=0&keywords=0&generator=0&template=0&pingback=0&xmlrpc=0&wlw=0&rss2=0&rss1=0&antiSpam=0&atom'); ?>
<?php if ($this->options->NewTabLink == 'on'): ?>
<script>$(document).ready(function(){var a=document.getElementsByTagName("a");for(let i=0;i<a.length;i++){let domain=document.domain;let url=a[i].href;if(typeof(url)!="undefined"&&url.length!=0&&url.match(domain)==null&&url!="javascript:void(0);"){a[i].setAttribute("target","_BLANK")}}});</script>
<?php endif; ?>
<?php if($this->is('index')): ?>
<script type="text/javascript" src="<?php $this->options->themeUrl('js/wehao.js?v1.7.0'); ?>"></script>
<style>#page-header:not(.not-top-img):before {background-color: rgba(0,0,0,0);}</style>
<!--打字-->
<?php if (is_array($this->options->beautifyBlock) && in_array('ShowTopimg',$this->options->beautifyBlock)): ?>
<?php if(!empty($this->options->CustomSubtitle)): ?>
<script>
function subtitleType() {
if (true) {
var typed = new Typed("#subtitle", {
strings: "<?php $this->options->CustomSubtitle()?>".split(","),
startDelay: 300,
typeSpeed: 150,
loop: <?php $this->options->SubtitleLoop() ?>,
backSpeed: 50
})
}
}
"function"==typeof Typed?subtitleType():getScript("/usr/themes/butterfly/js/typed.min.js")
.then(subtitleType)
</script>
<?php else: ?>
<script>
function subtitleType(){
fetch("https://v1.hitokoto.cn").then(t=>t.json()).then(t=>{
o=0=="".length?new Array:" ".split(",");
o.unshift(t.hitokoto),
new Typed("#subtitle",{
strings:o,
startDelay:300,
typeSpeed:150,
loop: <?php $this->options->SubtitleLoop() ?>,
backSpeed:50
}
)}
)}
"function"==typeof Typed?subtitleType():getScript("/usr/themes/butterfly/js/typed.min.js")
.then(subtitleType)
</script>
<?php endif ?>
<?php endif?>
<!--打字end-->
<!--判断主页end-->
<?php endif?>
<?php if(!empty($this->options->slide_cids) && $this->is('index')):?>
<script data-pjax>
function butterfly_swiper_injector_config() {
var parent_div_git = document.getElementById('recent-posts');
var item_html = `<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;">
<?php
$slide_cids=$this->options->slide_cids;
$cid = explode(',', strtr($slide_cids, ' ', ','));
$num=count($cid);
$html="";
for($i=0;$i<$num;$i++){
$this->widget('Widget_Archive@post'.$i, 'pageSize=1&type=post', 'cid='.$cid[$i])->to($ji);
$html=$html.'<div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" href="'.$ji->permalink.'" alt=""><img width="48" height="48" src="'.get_ArticleThumbnail($ji).'" alt="" /></a><div class="blog-slider__content"><span class="blog-slider__code">'.date('Y-m-d', $ji->modified).'</span><a class="blog-slider__title" href="'.$ji->permalink.'" alt="'.$ji->title.'">'.$ji->title.'</a><div class="blog-slider__text">'.$ji->title.'</div><a class="blog-slider__button" href="'.$ji->permalink.'" alt="">详情</a></div></div>';}echo $html;
?>
</div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>`;
parent_div_git.innerHTML=item_html+parent_div_git.innerHTML // 无报错,但不影响使用(支持pjax跳转)
// parent_div_git.insertAdjacentHTML("afterbegin", item_html) // 有报错,但不影响使用(支持pjax跳转)
}
if (document.getElementById('recent-posts') && (location.pathname === 'all' || 'all' === 'all')) {
butterfly_swiper_injector_config()}
</script>
<script src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script>
<script data-pjax src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper_init.js"></script>
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css">
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css">
<?php endif?>
</div>
<!--js-pjax end-->
<div id="rightside" style="">
<div id="rightside-config-hide" class="">
<button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button>
<button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button>
<?php if ($this->is('post')): ?>
<button id="readmode" type="button" title="阅读模式">
<i class="fas fa-book-open"></i>
</button>
<?php endif ?>
<button id="translateLink" type="button" title="简繁转换">

</button>
<button id="darkmode" type="button" title="浅色和深色模式转换">
<i class="fas fa-adjust">
</i>
</button>
<button id="hide-aside-btn" type="button" title="单栏和双栏切换">
<i class="fas fa-arrows-alt-h">
</i>
</button>
</div>
<div id="rightside-config-show">
<button id="rightside_config" type="button" title="设置">
<i class="fas fa-cog fa-spin">
</i>
</button>
<?php if ($this->is('post')): ?>
<button class="close" id="mobile-toc-button" type="button" title="目录">
<i class="fas fa-list-ul">
</i>
</button>
<?php endif ?>
<?php if($this->is('post') && $this->allow('comment') || $this->is('page') && $this->allow('comment')): ?>
<a id="to_comment" href="#comments" title="直达评论">
<i class="fas fa-comments">
</i>
</a>
<?php endif ?>
<button id="go-up" type="button" title="回到頂部" class="show-percent">
<span class="scroll-percent"></span>
<i class="fas fa-arrow-up">
</i>
</button>
</div>
</div>
<!--pjax-->
<?php if($this->options->EnablePjax === 'on') : ?>
<?php if($this->options->StaticFile == 'CDN' && $this->options->CDNURL == ''): ?>
<link rel="stylesheet" href="https://<?php $this->options->jsdelivrLink() ?>/gh/rstacruz/nprogress@master/nprogress.css">
<script src="https://<?php $this->options->jsdelivrLink() ?>/gh/rstacruz/nprogress@master/nprogress.js"></script>
<script src="https://<?php $this->options->jsdelivrLink() ?>/npm/pjax/pjax.min.js"></script>
<?php elseif($this->options->StaticFile == 'CDN' && $this->options->CDNURL !== ''): ?>
<link rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.css">
<script src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.js"></script>
<script src="<?php $this->options->CDNURL() ?>/static/js/pjax.min.js"></script>
<?php else: ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('static/css/nprogress.css'); ?>">
<script src="<?php $this->options->themeUrl('static/js/nprogress.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('static/js/pjax.min.js'); ?>"></script>
<?php endif; ?>
<script>
let pjaxSelectors = ["title", "#body-wrap", "#rightside-config-hide", "#rightside-config-show", ".js-pjax"];
var pjax = new Pjax({
elements: 'a:not([target="_blank"])',
selectors: pjaxSelectors,
cacheBust: !1,
analytics: !1,
scrollRestoration: !1});
document.addEventListener("pjax:send", (function() {
if (window.removeEventListener("scroll", window.tocScrollFn), window.removeEventListener("scroll", scrollCollect), "object" == typeof preloader && preloader.initLoading(), window.aplayers)
for (let e = 0; e < window.aplayers.length; e++) window.aplayers[e].options.fixed || window.aplayers[e].destroy();"object" == typeof typed && typed.destroy();
const e = document.body.classList;
e.contains("read-mode") && e.remove("read-mode")
NProgress.start();
})),
document.addEventListener("pjax:complete", (function() {
<?php $this->options->PjaxCallBack() ?>
NProgress.done();
window.refreshFn(),
document.querySelectorAll("script[data-pjax]").forEach(e => {
const t = document.createElement("script"),
o = e.text || e.textContent || e.innerHTML || "";
Array.from(e.attributes).forEach(e => t.setAttribute(e.name, e.value)), t.appendChild(document.createTextNode(o)), e.parentNode.replaceChild(t, e)}),
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update(), "function" == typeof chatBtnFn && chatBtnFn(), "function" == typeof panguInit && panguInit(), "function" == typeof gtag && gtag("config", "",
{page_path: window.location.pathname}),
"object" == typeof _hmt && _hmt.push(["_trackPageview", window.location.pathname]),
"function" == typeof loadMeting && document.getElementsByClassName("aplayer").length && loadMeting(),
"object" == typeof Prism && Prism.highlightAll(), "object" == typeof preloader && preloader.endLoading()
})),
document.addEventListener("pjax:error", e => {
// 404 === e.request.status && pjax.loadUrl("/404");
if(e.request.status === 404){
window.location="/404";
}
if(e.request.status === 403){
window.location=e.request.responseURL
}
})
</script>
<?php endif?>
<!--pjax end-->
</body>
</html>

前台截图:
前台截图
后台截图:
后台截图