-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
functions.php
630 lines (605 loc) · 26.9 KB
/
functions.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
<?php
/**
* .______ __ __ ___ ______
* | _ \ | | | | / \ / __ \
* | |_) | | |__| | / ^ \ | | | |
* | _ < | __ | / /_\ \ | | | |
* | |_) | | | | | / _____ \ | `--' |
* |______/ |__| |__| /__/ \__\ \______/
*
* Functions
*
* @author Bhao
* @link https://dwd.moe/
* @date 2024-01-02
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
define("THEME_NAME", "Cuckoo");
define("THEME_VERSION", "2.1.0");
require_once("includes/setting.php");
require_once("includes/owo.php");
// 文章自定义设置
function themeFields($layout) {
$articleType = new Typecho_Widget_Helper_Form_Element_Select('articleType',array('article' => '文章', 'daily' => '日常', 'normal' => '无封面'), 'article', _t('文章类型'));
$layout->addItem($articleType);
$wzimg = new Typecho_Widget_Helper_Form_Element_Text('wzimg', NULL, NULL, _t('文章/独立页面封面图'), _t('如果不填将显示随机封面图'));
$layout->addItem($wzimg);
$catalog = new Typecho_Widget_Helper_Form_Element_Select('catalog',array('false' => '关闭', 'true' => '启用'), 'false', _t('文章目录'), _t('默认关闭,启用则显示“文章目录”'));
$layout->addItem($catalog);
$remark = new Typecho_Widget_Helper_Form_Element_Text('remark', NULL, NULL, _t('吐槽'), _t('仅文章类型为 无封面 时有效'));
$layout->addItem($remark);
}
// Typecho 设置
function themeInit($archive){
Helper ::options() -> pageSize = 5;
Helper ::options() -> commentsOrder = 'DESC';
Helper ::options() -> commentsMaxNestingLevels = 9999;
Helper ::options() -> commentsAntiSpam = false;
Helper ::options() -> commentsMarkdown = true;
Helper ::options() -> commentsHTMLTagAllowed = '<a href=""> <img src=""> <img src="" class=""> <code> <del>';
}
/* 联系方式 */
function contact(){
$setting = Helper::options()->drawerContact;
$output = json_decode($setting, true);
if(is_array($output)){
foreach($output as $key => $value){
if($key == "qq"){
$website = "//wpa.qq.com/msgrd?v=3&site=qq&menu=yes&uin=";
}elseif($key == "weibo"){
$website = "//weibo.com/";
}elseif($key == "bilibili"){
$website = "//space.bilibili.com/";
}elseif($key == "github"){
$website = "//github.com/";
}elseif($key == "twitter"){
$website = "//twitter.com/";
}elseif($key == "telegram"){
$website = "//t.me/";
}elseif($key == "email"){
$website = "mailto:";
}elseif($key == "netease-music"){
$website = "//music.163.com/#/user/home?id=";
}elseif($key == "zhihu") {
$website = "//www.zhihu.com/people/";
}elseif($key == "tencent-kg") {
$website = "//static-play.kg.qq.com/node/personal_v2?uid=";
}elseif($key == "douyin") {
$website = "//v.douyin.com/";
}
print_r('<a target ="_blank" href="'.$website.$value.'"><button class="mdui-btn mdui-btn-icon mdui-ripple"><i class="iconfont icon-'.$key.'"></i></button></a>');
}
}
}
function drawerBottom(){
$setting = Helper::options()->drawerBottom;
$output = json_decode($setting, true);
if(is_array($output)){
echo '<div class="drawer-bottom">';
foreach($output as $key => $value){
print_r('<a target ="_blank" href="'.$value.'"><button class="mdui-textfield-close mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">'.$key.'</i></button></a>');
}
echo '</div>';
}
}
// 文章短代码
function parseContent($content) {
$patt_table = '/<table>(.*?)<\/table>/s';
$text_table = '<div class="mdui-table-fluid"><table class="mdui-table mdui-table-hoverable">${1}</table></div>';
$content = preg_replace($patt_table, $text_table, $content);
$patt_panel = '/\[pl.*?title="(.*?)".*?summary="(.*?)".*?class="(.*?)".*?\](.*?)\[\/pl\]/s';
$text_panel = '<div class="mdui-panel" mdui-panel>
<div class="mdui-panel-item ${3}">
<div class="mdui-panel-item-header">
<div class="mdui-panel-item-title">${1}</div>
<div class="mdui-panel-item-summary">${2}</div>
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
</div>
<div class="mdui-panel-item-body">${4}</div>
</div>
</div>';
$content = preg_replace($patt_panel, $text_panel, $content);
$patt_hr = '/<hr(.*?)>/s';
$text_hr = '<div class="mdui-divider"></div>';
$content = preg_replace($patt_hr, $text_hr, $content);
$patt_bili = '/\[bili.*?av="(.*?)".*?bv="(.*?)".*?\]/s';
$text_bili = '<div class="post-bili"><iframe src="//player.bilibili.com/player.html?aid=${1}&bvid=${2}&high_quality=1" class="bili-player" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe></div>';
$content = preg_replace($patt_bili, $text_bili, $content);
$patt_timeline = '/\[timeline\](.*?)\[\/timeline\]/s';
$text_timeline = '<div class="post-timeline">${1}</div>';
$content = preg_replace($patt_timeline, $text_timeline, $content);
$patt_timeline_item = '/\[item.*?time="(.*?)"\](.*?)\[\/item\]/s';
$text_timeline_item = '<div class="post-timeline-item">
<div class="post-timeline-time">${1}</div>
<div class="post-timeline-content">${2}</div>
</div>';
$content = preg_replace($patt_timeline_item, $text_timeline_item, $content);
echo $content;
}
/* 表情包解析 感谢ohmyga */
function parseBiaoQing($content) {
$owoList = (Smile::getOwOList()) ? Smile::getOwOList() : NULL;
//如果没有表情包则不解析
if (!$owoList) {
return $content;
}
for ($owoNum = 0; $owoNum < count($owoList); $owoNum++) {
//如果是 Text 或者 emoji //没必要返回
if ($owoList[$owoNum]['type'] == 'text' || $owoList[$owoNum]['type'] == 'emoji') {
$content = $content;
}
//如果是图片
if ($owoList[$owoNum]['type'] == 'picture') {
//判断有无图片
if ($owoList[$owoNum]['content']) {
for ($i = 0; $i < count($owoList[$owoNum]['content']); $i++) {
$new = '<img src="' . $owoList[$owoNum]['dir'] . $owoList[$owoNum]['content'][$i]['file'] . '" class="emoji-img-'.$owoList[$owoNum]['css'].'" />';
$content = str_replace($owoList[$owoNum]['content'][$i]['data'], $new, $content);
}
}
}
}
return $content;
}
// 判断是否为好丽友
function get_comment_prefix($mail){
$db = Typecho_Db::get();
$type = explode('_', $db->getAdapterName());
$type = array_pop($type);
$prefix = $db->getPrefix();
if(array_key_exists('Links', Typecho_Plugin::export()['activated'])){
if ($type == 'Pgsql')
$number = $db->fetchAll($db->query("SELECT \"user\" FROM ".$prefix."links WHERE \"user\" = '$mail'"));
else
$number = $db->fetchAll($db->query("SELECT user FROM ".$prefix."links WHERE user = '$mail'"));
if($number){
?><img src="<?php staticFiles('images/friend.png'); ?>" class="comment-prefix" mdui-tooltip="{content: '好朋友'}"/><?php
}
}
}
// 静态文件源
function staticFiles($content, $type = 0, $isExternal = 0) {
$setting = Helper::options()->staticFiles;
if($isExternal){
if($setting == 'local' || $setting == 'cdn'){
$setting = Helper::options()->staticFiles;
}else{
$setting = 'jsdelivr';
}
}
switch($setting){
case 'jsdelivr':
$output = 'https://gcore.jsdelivr.net/gh/Bhaoo/Cuckoo@'.THEME_VERSION.'/assets/'.$content;
break;
case 'cdn':
$output = Helper::options()->staticCdn.'/'.$content;
break;
case 'cdnjs':
$output = 'https://cdnjs.cloudflare.com/ajax/libs/Cuckoo/'.THEME_VERSION.'/'.$content;
break;
case 'staticfile':
$output = 'https://cdn.staticfile.org/Cuckoo/'.THEME_VERSION.'/'.$content;
break;
case 'bootcdn':
$output = 'https://cdn.bootcdn.net/ajax/libs/Cuckoo/'.THEME_VERSION.'/'.$content;
break;
case 'baomitu':
$output = 'https://lib.baomitu.com/Cuckoo/'.THEME_VERSION.'/'.$content;
break;
case 'local':
default:
$output = Helper::options()->themeUrl.'/assets/'.$content;
break;
}
if($type == 0){
print_r($output);
}elseif($type == 1){
return($output);
}
}
// 随机文章封面
function randPic(){
$setting = Helper::options()->randimg;
$setting_cdn = Helper::options()->randimgCdn;
$rand = mt_rand(0,999);
if ($setting == 'api.ohmyga.cn') {
$output = 'https://api.ohmyga.cn/wallpaper/?rand='.$rand;
}elseif ($setting == 'local') {
$openfile = glob(Helper::options()->themeFile("Cuckoo", "random/*"), GLOB_BRACE);
$img = array_rand($openfile);
preg_match('/\/random\/\S*\.(jpg|png|gif|webp)/', $openfile[$img], $out);
$output = Helper::options()->siteUrl.'usr/themes/Cuckoo'.$out[0];
}elseif ($setting == 'cdn'){
$output = preg_replace('/{rand}/', $rand, $setting_cdn);
}elseif ($setting == '9jojo'){
$output = 'https://api.baka.fun/acgpic/?rand='.$rand;
}
print_r($output);
}
// 阅读时间
function readingTime($cid){
$db=Typecho_Db::get ();
$arr=$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", "", $arr['text']);
$text_word = mb_strlen($text,'utf-8');
echo '约 '.ceil($text_word / 400).' 分钟';
}
// 阅读数量
function get_post_view($archive){
$cid = $archive->cid;
$db = Typecho_Db::get();
$type = explode('_', $db->getAdapterName());
$type = array_pop($type);
$prefix = $db->getPrefix();
if(!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))){
if ($type == 'Pgsql')
$db->query('ALTER TABLE "' . $prefix . 'contents" ADD "views" bigint DEFAULT 0;');
else
$db->query('ALTER TABLE `' . $prefix . 'contents` ADD `views` INT(10) DEFAULT 0;');
echo 0;
return;
}
$row = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid));
if($archive->is('single')){
$views = Typecho_Cookie::get('extend_contents_views');
if(empty($views)){
$views = array();
}else{
$views = explode(',', $views);
}
if(!in_array($cid,$views)){
$db->query($db->update('table.contents')->rows(array('views' => (int) $row['views'] + 1))->where('cid = ?', $cid));
array_push($views, $cid);
$views = implode(',', $views);
Typecho_Cookie::set('extend_contents_views', $views);
}
}
echo $row['views'];
}
// 获取评论者头像
function get_comment_avatar($moe = NULL){
$gravatar = Helper::options()->gravatar;
if($gravatar == 'geekzu'){
$host = 'https://sdn.geekzu.org/avatar/';
}elseif($gravatar == 'qiniu'){
$host = 'https://dn-qiniu-avatar.qbox.me/avatar';
}elseif($gravatar == 'cravatar'){
$host = 'https://cravatar.cn/avatar';
}elseif($gravatar == 'cdn'){
$host = Helper::options()->gravatarCdn;
}
$hash = md5(strtolower($moe));
$avatar = $host.'/'.$hash.'?s=100';
echo $avatar;
}
// 更多CSS
function otherCss(){
echo (Helper::options()->otherCss) ? '<style>'.Helper::options()->otherCss.'</style>' : '';
echo (Helper::options()->otherHeader) ?? '';
}
// 更多JS、百度统计、跨设备阅读、Katex
function otherJs(){
if(Helper::options()->brightTime || Helper::options()->statisticsBaidu || (Helper::options()->qrcode && in_array('open', Helper::options()->qrcode)) || Helper::options()->otherJs || !Helper::options()->describe){
$brightTime_arr = (Helper::options()->brightTime) ? explode(',', Helper::options()->brightTime) : '';
$string = '<script>';
$string .= (Helper::options()->statisticsBaidu) ? "var _hmt = _hmt || [];(function() {var hm = document.createElement('script');hm.src = 'https://hm.baidu.com/hm.js?". Helper::options()->statisticsBaidu ."';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(hm, s);})();" : '';
$string .= (Helper::options()->qrcode && in_array('open', Helper::options()->qrcode)) ? "qrcode(true);" : '';
$string .= ($brightTime_arr) ? "var nowHour=new Date().getHours();if(nowHour>".$brightTime_arr[0]." && nowHour<".$brightTime_arr[1]."){darkContent('".$brightTime_arr[2]."')};" : '';
$string .= (Helper::options()->katexOption) ? 'renderMath=function(className){renderMathInElement(className,'. Helper::options()->katexOption .')};if($(".post-content").length){renderMath($(".post-content")[0])}' : '';
$string .= (Helper::options()->otherJs) ? Helper::options()->otherJs : '';
$string .= '</script>';
$string .= (!Helper::options()->describe) ? "<script>Hitokoto();</script>" : '';
$string .= (Helper::options()->otherFooter) ?? '';
echo $string;
}
}
// 更多PJAX、百度统计、跨设备阅读
function otherPjax(){
if(Helper::options()->statisticsBaidu || (Helper::options()->qrcode && in_array('open', Helper::options()->qrcode)) || Helper::options()->otherPjax){
$string = "<script>$(document).on('pjax:complete',function(){";
$string .= (Helper::options()->statisticsBaidu) ? "if(typeof _hmt !== 'undefined'){ _hmt.push(['_trackPageview', location.pathname + location.search])};" : '';
$string .= (Helper::options()->qrcode && in_array('open', Helper::options()->qrcode)) ? "if(!$('.post-content').length){ $('.qrcode').css('display', 'none')}else{ $('.qrcode').css('display', 'block')};" : '';
$string .= (!Helper::options()->describe) ? "Hitokoto();" : '';
$string .= (Helper::options()->katexOption) ? 'if($(".post-content").length){renderMath($(".post-content")[0])}' : '';
$string .= (Helper::options()->otherPjax) ? Helper::options()->otherPjax : '';
$string .= "});</script>";
echo $string;
}
}
// 背景图片
function bgUrl(){
$setting = Helper::options()->bgUrl;
$setting_phone = Helper::options()->bgphoneUrl;
$setting_bgf = Helper::options()->bgFilter;
$textareaBG = (Helper::options()->textareaBG) ? Helper::options()->textareaBG : staticFiles('images/textarea.png',1);
$loadingUrl = (Helper::options()->loadingUrl) ? Helper::options()->loadingUrl : staticFiles('images/loading.gif', 1);
if($setting_bgf > 0){
echo "<style>.index-filter{backdrop-filter: blur(".$setting_bgf."px);}</style>";
}else{
echo "<style>.index-filter{display: none}</style>";
}
?><style>.comment-textarea{background-image: url("<?php echo $textareaBG ?>");}.index-img{background-image: url("<?php echo $loadingUrl ?>")}</style><?php
if(empty($setting) && empty($setting_phone)){
?><style>.background{background-image: url("<?php staticFiles('images/bg.jpg'); ?>");}</style><?php
}else{
if(empty($setting_phone)){
echo "<style>.background{background-image: url('$setting');}@media(max-width: 900px){.background{background-image: url('$setting');}}</style>";
}elseif(empty($setting)){
echo "<style>.background{background-image: url('$setting_phone');}@media(max-width: 900px){.background{background-image: url('$setting_phone');}}</style>";
}else{
echo "<style>.background{background-image: url('$setting');}@media(max-width: 900px){.background{background-image: url('$setting_phone');}}</style>";
}
}
}
// 自定义字体
function fontFamily(){
static $output;
$output .= (Helper::options()->fontUrl) ? '<link rel="stylesheet" href="'.Helper::options()->fontUrl.'">' : '';
$output .= (Helper::options()->globalFont) ? '<style>body{font-family:'.Helper::options()->globalFont.'}</style>' : '';
$output .= (Helper::options()->globalFontWeight) ? '<style>body{font-weight:'.Helper::options()->globalFontWeight.'}</style>' : '';
$output .= (Helper::options()->logoFont) ? '<style>.mdui-appbar .mdui-typo-title{font-family:'.Helper::options()->logoFont.'}</style>' : '';
echo $output;
}
// 自定义抽屉
function otherMenu(){
$data = Helper::options()->otherMenu;
if (!empty($data)) {
$json = json_decode($data, true);
foreach($json as $i) {
if ($i['type'] == '0') {
echo '<a href="'.$i['link'].'" class="mdui-list-item mdui-ripple" mdui-drawer-close>
<i class="mdui-icon material-icons mdui-list-item-icon">'.$i['icon'].'</i>
<div class="mdui-list-item-content">'.$i['name'].'</div>
</a>';
}elseif ($i['type'] == '1') {
echo '<li class="mdui-collapse-item">
<div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
<i class="mdui-icon material-icons mdui-list-item-icon">'.$i['icon'].'</i>
<div class="mdui-list-item-content">'.$i['name'].'</div>
<i class="mdui-icon material-icons mdui-list-item-icon mdui-collapse-item-arrow">keyboard_arrow_down</i>
</div>
<ul class="mdui-collapse-item-body mdui-list mdui-list-dense">';
Typecho_Widget::widget('Widget_Contents_Post_Date', 'type=month&format=Y 年 m 月')->parse('<a href="{permalink}" class="mdui-list-item mdui-ripple" mdui-drawer-close><div class="mdui-list-item-content">{date}</div><div class="drawer-item">{count}</div></a>');
echo '</ul></li>';
}elseif ($i['type'] == '2') {
echo '<li class="mdui-collapse-item">
<div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
<i class="mdui-icon material-icons mdui-list-item-icon">'.$i['icon'].'</i>
<div class="mdui-list-item-content">'.$i['name'].'</div>
<i class="mdui-icon material-icons mdui-list-item-icon mdui-collapse-item-arrow">keyboard_arrow_down</i>
</div>
<ul class="mdui-collapse-item-body mdui-list mdui-list-dense">';
Typecho_Widget::widget('Widget_Metas_Category_List')->parse('<a href="{permalink}" class="mdui-list-item mdui-ripple" mdui-drawer-close><div class="mdui-list-item-content">{name}</div><div class="drawer-item">{count}</div></a>');
echo '</ul>
</li>';
}elseif ($i['type'] == '3') {
Typecho_Widget::widget('Widget_Contents_Page_List')->to($pages);
echo '<li class="mdui-collapse-item">
<div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
<i class="mdui-icon material-icons mdui-list-item-icon">'.$i['icon'].'</i>
<div class="mdui-list-item-content">'.$i['name'].'</div>
<i class="mdui-icon material-icons mdui-list-item-icon mdui-collapse-item-arrow">keyboard_arrow_down</i>
</div>
<ul class="mdui-collapse-item-body mdui-list mdui-list-dense">';
while($pages->next()){
echo '<a class="mdui-list-item mdui-ripple" href="'.$pages->permalink.'" mdui-drawer-close>'.$pages->title.'</a>';
}
echo '</ul></li>';
}elseif($i['type'] == '4'){
echo ' <div class="mdui-collapse" mdui-collapse>
<li class="mdui-collapse-item">
<div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
<i class="mdui-list-item-icon mdui-icon material-icons">'.$i['icon'].'</i>
<div class="mdui-list-item-content">'.$i['name'].'</div>
<i class="mdui-collapse-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
</div>
<ul class="mdui-collapse-item-body mdui-list mdui-list-dense">';
foreach($i['list'] as $ii){ echo '<a class="mdui-list-item mdui-ripple" href="'.$ii['link'].'" mdui-drawer-close>'.$ii['name'].'</a>';}
echo '</ul></li></div>';
}elseif ($i['type'] == '5') {
echo '<div class="mdui-divider"></div>';
}elseif ($i['type'] == '6') {
echo '<a href="'.Helper::options()->feedUrl.'" target="_blank" class="mdui-list-item mdui-ripple" mdui-drawer-close>
<i class="mdui-icon material-icons mdui-list-item-icon">rss_feed</i>
<div class="mdui-list-item-content">RSS订阅</div>
</a>';
}
}
}
}
/* 拒绝【删除】或【修改】版权,若删除或修改将不会提供主题相关服务。*/
function Footer(){
$content = '';
$footer = Helper::options()->Footer;
$gabeian = Helper::options()->gabeian;
$moebei = Helper::options()->moebei;
$beian = Helper::options()->beian;
$copy = Helper::options()->copy;
$copy = preg_replace('/{site}/', Helper::options()->siteUrl, $copy);
$copy = preg_replace('/{name}/', Helper::options()->title, $copy);
$copy = preg_replace('/{year}/', date('Y'), $copy);
if($gabeian){
preg_match_all("/\d+/", $gabeian,$num);
$num = $num[0][0];
}
if($moebei){
preg_match_all("/\d+/", $moebei,$num2);
$num2 = $num2[0][0];
}
if(($beian && $gabeian) || ($beian && $moebei) || ($gabeian && $moebei) || ($beian && $gabeian && $moebei)){
$content .= '<br><br>';
} elseif ($beian || $gabeian || $moebei) {
$content .= '|';
}
$content .= ($moebei) ? '<span><a href="https://icp.gov.moe" target="_blank">萌ICP备</a><a href="https://icp.gov.moe/?keyword='.$num2.'" target="_blank">'.$num2.'</a>号</span>' : '';
$content .= ($beian) ? '<span><a href="//beian.miit.gov.cn">'.Helper::options()->beian.'</a></span>' : '';
$content .= ($gabeian) ? '<span><img style="vertical-align:middle" src="'.staticFiles('images/beian.png', 1).'" height="20" width="20" alt="公安备案"> <a href="//www.beian.gov.cn/portal/registerSystemInfo?recordcode='.$num.'">'.Helper::options()->gabeian.'</a></span>' : '';
echo $footer.'<p>'.$copy.$content.'<br><br><span id="cuckoo-copy">Theme <a href="https://github.com/bhaoo/cuckoo" target="_blank">Cuckoo</a> by <a href="https://dwd.moe/" target="_blank">Bhao</a>|Powered By <a href="http://www.typecho.org" target="_blank">Typecho</a></span></p>';
}
// 友链插件
function Links($type = 0) {
if(array_key_exists("Links", Typecho_Plugin::export()['activated'])){
$shuffle = Helper::options()->linksshuffle;
$link_limit = Helper::options()->linksIndexNum;
if($type == 0) {
$Links = Links_Plugin::output("
<a target='_blank' class='links-url' href='{url}'>
<div class='mdui-col-sm-6'>
<div class='links-card mdui-shadow-10'>
<div class='links-img'><img class='mdui-img-circle' src='{image}' loading='lazy'/></div>
<div class='links-name links-text'>{name}</div>
<div class='links-describe links-text'>{description}</div>
</div>
</div>
</a>");
}elseif($type == 1) {
$Links = Links_Plugin::output("
<div class='mdui-col'>
<a target='_blank' href='{url}'>
<li class='mdui-list-item mdui-ripple sidebar-module-list'>
<div class='sidebar-reply-text'>{name}</div>
</li>
</a>
</div>");
}
if($shuffle && in_array('open', $shuffle)){
shuffle($Links);
}
$link_limit = (!$type || $link_limit > count($Links)) ? count($Links) : $link_limit;
for($i = 0; $i < $link_limit; $i++){
echo $Links[$i];
}
}
}
function getBrowser($agent) {
if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
$name = 'IE';
$icon = 'icon-IE';
}elseif (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
$name = 'Firefox';
$icon = 'icon-firefox';
}elseif (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$name = 'Aoyou';
$icon = 'icon-Aoyou_Browser';
}elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $agent, $regs)) {
$name = 'Sougou';
$icon = 'icon-Sougou_Browser';
}elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) {
$name = '360';
$icon = 'icon-360_Browser';
}elseif (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$name = 'Edge';
$icon = 'icon-edge';
}elseif (preg_match('/QQ/i', $agent, $regs)||preg_match('/QQBrowser\/([^\s]+)/i', $agent, $regs)) {
$name = 'QQ';
$icon = 'icon-QQBrowser';
}elseif (preg_match('/UC/i', $agent)) {
$name = 'UC';
$icon = 'icon-UC_Browser';
}elseif (preg_match('/UBrowser/i', $agent, $regs)) {
$name = 'UC';
$icon = 'icon-UC_Browser';
}elseif (preg_match('/MicroMesseng/i', $agent, $regs)) {
$name = 'WeChat';
$icon = 'icon-wechat';
}elseif (preg_match('/WeiBo/i', $agent, $regs)) {
$name = 'Weibo';
$icon = 'icon-weibo';
}elseif (preg_match('/BIDU/i', $agent, $regs)) {
$name = 'Baidu';
$icon = 'icon-Baidu_Browser';
}elseif (preg_match('/LBBROWSER/i', $agent, $regs)) {
$name = 'LB';
$icon = 'icon-LBBROWSER';
}elseif (preg_match('/TheWorld/i', $agent, $regs)) {
$name = 'TheWorld';
$icon = 'icon-TheWorld_Browser';
}elseif (preg_match('/XiaoMi/i', $agent, $regs)) {
$name = 'Xiaomi';
$icon = 'icon-xiaomi';
}elseif (preg_match('/2345Explorer/i', $agent, $regs)) {
$name = '2345';
$icon = 'icon-2345_Browser';
}elseif (preg_match('/YaBrowser/i', $agent, $regs)) {
$name = 'Yandex';
$icon = 'icon-Yandex_Browser';
}elseif (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) {
$name = 'Opera';
$icon = 'icon-Opera_Browser';
}elseif (preg_match('/Thunder/i', $agent, $regs)) {
$name = 'Xunlei';
$icon = 'icon-xunlei';
}elseif (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$name = 'Chrome';
$icon = 'icon-chrome';
}elseif (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
$name = 'Safari';
$icon = 'icon-safari';
}else{
$name = 'Other';
$icon = 'icon-Browser';
}
echo '<i class="iconfont '.$icon.' comment-ua" mdui-tooltip="{content: \''.$name.'\'}"></i>';
}
function getOs($agent) {
if (preg_match('/win/i', $agent)) {
if (preg_match('/nt 5.1/i', $agent)) {
$name = 'Windows XP';
$icon = 'icon-windows_old';
}elseif (preg_match('/nt 6.0/i', $agent)) {
$name = 'Windows Vista';
$icon = 'icon-windows_old';
}elseif (preg_match('/nt 6.1/i', $agent)) {
$name = 'Windows 7';
$icon = 'icon-windows_old';
}elseif (preg_match('/nt 6.2/i', $agent)) {
$name = 'Windows 8';
$icon = 'icon-windows';
}elseif (preg_match('/nt 6.3/i', $agent)) {
$name = 'Windows 8.1';
$icon = 'icon-windows';
}elseif (preg_match('/nt 10.0/i', $agent)) {
$name = 'Windows 10';
$icon = 'icon-windows';
}else{
$name = 'Windows XP';
$icon = 'icon-windows';
}
}elseif (preg_match('/android/i', $agent)) {
if (preg_match('/android 5/i', $agent)) {
$name = 'Android';
$icon = 'icon-android';
}elseif (preg_match('/android 6/i', $agent)) {
$name = 'Android';
$icon = 'icon-android';
}elseif (preg_match('/android 7/i', $agent)) {
$name = 'Android';
$icon = 'icon-android';
}elseif (preg_match('/android 8/i', $agent)) {
$name = 'Android';
$icon = 'icon-android';
}elseif (preg_match('/android 9/i', $agent)) {
$name = 'Android';
$icon = 'icon-android';
}else{
$name = 'Android';
$icon = 'icon-android';
}
}elseif (preg_match('/linux/i', $agent)) {
$name = 'Linux';
$icon = 'icon-linux';
}elseif (preg_match('/iPhone/i', $agent)) {
$name = 'IPhone';
$icon = 'icon-ios';
}elseif (preg_match('/iPad/i', $agent)) {
$name = 'IPad';
$icon = 'icon-ios';
}elseif (preg_match('/mac/i', $agent)) {
$name = 'Mac';
$icon = 'icon-ios';
}else{
$name = 'other';
$icon = 'icon-os';
}
echo '<i class="iconfont '.$icon.' comment-ua" mdui-tooltip="{content: \''.$name.'\'}"></i>';
}