From f44fd965444fa600b9111ee1f8168b55808bab79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Fri, 7 Jun 2024 14:28:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=AF=84=E8=AE=BA=E8=AF=B4?= =?UTF-8?q?=E8=AF=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comments.php | 49 ++++----- page-times.php | 18 ++++ times/Content.php | 56 ++++++++++ times/UA.php | 256 ++++++++++++++++++++++++++++++++++++++++++++ times/dycomment.php | 107 ++++++++++++++++++ 5 files changed, 460 insertions(+), 26 deletions(-) create mode 100644 page-times.php create mode 100644 times/Content.php create mode 100644 times/UA.php create mode 100644 times/dycomment.php diff --git a/comments.php b/comments.php index c19890e..ba4c05d 100644 --- a/comments.php +++ b/comments.php @@ -54,31 +54,6 @@ commentsNum(_t('0'), _t('1'), _t('%d')); ?> -
    - have()): ?> - listComments(); ?> - pageNav( - '', - '', - 1, - '...', - array( - 'wrapTag' => 'div', - 'wrapClass' => 'pagination_page', - 'itemTag' => '', - 'textTag' => 'a', - 'currentClass' => 'active', - 'prevClass' => 'prev', - 'nextClass' => 'next' - ) - ); - ?> - - -

    - -
    @@ -112,6 +87,29 @@ +
      + have()): ?> + listComments(); ?> + pageNav( + '', + '', + 1, + '...', + array( + 'wrapTag' => 'div', + 'wrapClass' => 'pagination_page', + 'itemTag' => '', + 'textTag' => 'a', + 'currentClass' => 'active', + 'prevClass' => 'prev', + 'nextClass' => 'next' + ) + ); + ?> + +

      + options->twikoo(); ?>
      gravatar('40', ''); ?> -
      author; ?> diff --git a/page-times.php b/page-times.php new file mode 100644 index 0000000..6b37dc5 --- /dev/null +++ b/page-times.php @@ -0,0 +1,18 @@ + +need('header.php'); ?> +
      +
      +

      title() ?>

      +

      content(); ?>

      +
      +
      + need('times/dycomment.php'); ?> +
      +
      +need('footer.php'); ?> \ No newline at end of file diff --git a/times/Content.php b/times/Content.php new file mode 100644 index 0000000..b06dc92 --- /dev/null +++ b/times/Content.php @@ -0,0 +1,56 @@ +此条为私密说说,仅发布者可见
      '; + } else { + return '
      该评论仅登录用户及评论双方可见
      '; + } + } + } + /** + * 解析时光机页面的评论内容 + * @param $content + * @return string + */ + public static function timeMachineCommentContent($content) + { + return Content::parseContentPublic($content); + } + /** + * 一些公用的解析,文章、评论、时光机公用的,与用户状态无关 + * @param $content + * @return null|string|string[] + */ + public static function parseContentPublic($content) + { + $options = Helper::options(); + //倒计时 + if (strpos($content, '[countdown') !== false) { + $pattern = self::get_shortcode_regex(array('countdown')); + $content = preg_replace_callback("/$pattern/", array('Content', 'countdownParseCallback'), + $content); + } + return $content; + } + + +} \ No newline at end of file diff --git a/times/UA.php b/times/UA.php new file mode 100644 index 0000000..e5f8094 --- /dev/null +++ b/times/UA.php @@ -0,0 +1,256 @@ +ua = $ua; + } + public function returnBrowser(){ + $ua = $this->ua; + if(preg_match('/rv:(11.0)/i', $ua, $matches)){ + $title = 'Internet Explorer '. $matches[1]; + $icon = 'fa fa-internet-explorer';//ie11 + }elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Internet Explorer '. $matches[1]; + + if ( strpos($matches[1], '7') !== false || strpos($matches[1], '8') !== false) + $icon = 'fa fa-internet-explorer';//ie8 + elseif ( strpos($matches[1], '9') !== false) + $icon = 'fa fa-internet-explorer';//ie9 + elseif ( strpos($matches[1], '10') !== false) + $icon = 'fa fa-internet-explorer';//ie10 + }elseif (preg_match('#Edge/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Edge '. $matches[1]; + $icon = 'fa fa-edge'; + }elseif (preg_match('#TheWorld ([a-zA-Z0-9.]+)#i', $ua, $matches)){ + $title = 'TheWorld(世界之窗) '. $matches[1]; + $icon = 'iconfont icon-theworld'; + }elseif (preg_match('#JuziBrowser#i', $ua, $matches)){ + $title = 'Juzi(桔子) '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#KBrowser#i', $ua, $matches)){ + $title = 'KBrowser(超快) '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#MyIE#i', $ua, $matches)){ + $title = 'MyIE(蚂蚁) '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)){ + $title = 'Firefox '. $matches[1]; + $icon = 'fa fa-firefox'; + }elseif (preg_match('#CriOS/([a-zA-Z0-9.]+)#i', $ua, $matches)){ + $title = 'Chrome for iOS '. $matches[1]; + $icon = 'fa fa-chrome'; + } elseif (preg_match('#LBBROWSER#i', $ua, $matches)) { + $title = '猎豹'; + $icon = 'iconfont icon-liebaoliulanqi'; + }elseif (preg_match('#Opera.(.*)Version[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Opera '. $matches[2]; + $icon = 'fa fa-opera'; + if (preg_match('#opera mini#i', $ua)) + $title = 'Opera Mini '. $matches[2]; + }elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua,$matches)) { + $title = 'Maxthon(遨游) '. $matches[2]; + $icon = 'iconfont icon-liulanqi-aoyou'; + }elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = '360 Browser '. $matches[1]; + $icon = 'iconfont icon-liulanqi-jisu'; + }elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'SouGou Browser 2 '.$matches[1]; + $icon = 'iconfont icon-liulanqi-sougou'; + }elseif (preg_match('#QQBrowser/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'QQBrowser '.$matches[1]; + $icon = 'iconfont icon-QQliulanqi'; + if (preg_match('#Mobile MQQBrowser/([a-zA-Z0-9.]+)#i', $ua,$matches)) { + $title = 'Mobile MQQBrowser '. $matches[1]; + $icon = 'fa fa-qq'; + }elseif (preg_match('#MicroMessenger/([a-zA-Z0-9.]+)#i', $ua,$matches)) { + $title = 'Wechat Browser '. $matches[1]; + $icon = 'weixin'; + } + }elseif (preg_match('#QQ/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'QQ '.$matches[1]; + $icon = 'fa fa-qq'; + }elseif (preg_match('#YYE/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'YYE '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#115Browser/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = '115 '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#37abc/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = '37abc '.$matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#TheWorld ([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = '世界之窗 '.$matches[1]; + $icon = 'iconfont icon-theworld'; + }elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'UCWEB '. $matches[1]; + $icon = 'icon-win8 icon-ucliulanqi'; + }elseif (preg_match('#UBrowser/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'UBrowser '. $matches[1]; + $icon = 'iconfont icon-ucliulanqi'; + }elseif (preg_match('#Quark/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Quark '. $matches[1]; + $icon = 'iconfont icon-ucliulanqi'; // + }elseif (preg_match('#2345Explorer/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = '2345Explorer '. $matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('#XiaoMi/MiuiBrowser/([0-9.]+)#i', $ua, $matches)) { + $title = '小米 '. $matches[1]; + $icon = 'iconfont icon-xiaomi'; + }elseif (preg_match('/WeiBo/i', $ua, $matches)) { + $title = '微博 '. $matches[1]; + $icon = 'iconfont icon-weibo'; + }elseif (preg_match('/BIDU/i', $ua, $matches)) { + $title = '百度 '. $matches[1]; + $icon = 'iconfont icon-setting'; + }elseif (preg_match('/mailapp/i', $ua, $matches)) { + $title = 'EmailApp '. $matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('/Sleipnir/i', $ua, $matches)) { + $title = '神马 '. $matches[1]; + $icon = 'iconfont icon-weibiaoti--'; + }elseif (preg_match('/MZBrowser/i', $ua, $matches)) { + $title = '魅族 '. $matches[1]; + $icon = 'iconfont icon-meizu'; + }elseif (preg_match('/VivoBrowser/i', $ua, $matches)) { + $title = 'Vivo '. $matches[1]; + $icon = 'iconfont icon-VIVO'; + }elseif (preg_match('/mixia/i', $ua, $matches)) { + $title = '米侠 '. $matches[1]; + $icon = 'fa fa-globe'; + }elseif (preg_match('/CoolMarket/i', $ua, $matches)) { + $title = '酷安 '. $matches[1]; + $icon = 'iconfont icon-coolapk'; + }elseif (preg_match('/YaBrowser/i', $ua, $matches)) { + $title = 'Yandex '. $matches[1]; + $icon = 'iconfont icon-yandex'; + }elseif (preg_match('/Kraitnabo\/([^\s|;]+)/i', $ua, $matches)) { + $title = '南博 '. $matches[1]; + $icon = 'anzhuo'; + }elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Google Chrome '. $matches[1]; + $icon = 'fa fa-chrome'; + if (preg_match('#OPR/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Opera '. $matches[1]; + $icon = 'fa fa-opera'; + } + }elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) { + $title = 'Safari '. $matches[1]; + $icon = 'fa fa-safari'; + } + return array("title"=>$title, + "icon"=>$icon); + } + public function returnOS(){ + $ua = $this->ua; + $title = "未知浏览器"; + $icon = ""; + if (preg_match('/win/i', $ua)) { + if (preg_match('/Windows NT 6.1/i', $ua)) { + $title = "Windows 7"; + $icon = "iconfont icon-win"; + }elseif (preg_match('/Windows 98/i', $ua)) { + $title = "Windows 98"; + $icon = "iconfont icon-win2"; + }elseif (preg_match('/Windows NT 5.0/i', $ua)) { + $title = "Windows 2000"; + $icon = "iconfont icon-win2"; + }elseif (preg_match('/Windows NT 5.1/i', $ua)) { + $title = "Windows XP"; + $icon = "iconfont icon-win"; + }elseif (preg_match('/Windows NT 5.2/i', $ua)) { + if (preg_match('/Win64/i', $ua)) { + $title = "Windows XP 64 bit"; + } else { + $title = "Windows Server 2003"; + } + $icon = 'iconfont icon-win'; + }elseif (preg_match('/Windows NT 6.0/i', $ua)) { + $title = "Windows Vista"; + $icon = "fa fa-windows"; + }elseif (preg_match('/Windows NT 6.2/i', $ua)) { + $title = "Windows 8"; + $icon = "iconfont icon-win8"; + }elseif (preg_match('/Windows NT 6.3/i', $ua)) { + $title = "Windows 8.1"; + $icon = "iconfont icon-win8"; + }elseif (preg_match('/Windows NT 10.0/i', $ua)) { + $title = "Windows 10"; + $icon = "iconfont icon-win3"; + }elseif (preg_match('/Windows Phone/i', $ua)) { + $matches = explode(';',$ua); + $title = $matches[2]; + $icon = "iconfont icon-winphone"; + } + } elseif (preg_match('#iPod.*.CPU.([a-zA-Z0-9.( _)]+)#i', $ua, $matches)) { + $title = "iPod ";//.$matches[1] + $icon = "iconfont icon-ipod"; + } elseif (preg_match('/iPhone OS ([_0-9]+)/i', $ua, $matches)) { + $title = "Iphone ";//.$matches[1] + $icon = "iconfont icon-iphone"; + } elseif (preg_match('/iPad; CPU OS ([_0-9]+)/i', $ua, $matches)) { + $title = "iPad ";//.$matches[1] + $icon = "iconfont icon-ipad"; + } elseif (preg_match('/Mac OS X ([0-9_]+)/i', $ua, $matches)) { + if(count(explode(7,$matches[1]))>1) $matches[1] = 'Lion '.$matches[1]; + elseif(count(explode(8,$matches[1]))>1) $matches[1] = 'Mountain Lion '.$matches[1]; + $title = "Mac OSX"; + $icon = "iconfont icon-macosdeicon"; + } elseif (preg_match('/Macintosh/i', $ua)) { + $title = "Mac OS"; + $icon = "iconfont icon-iconmacos"; + } elseif (preg_match('/CrOS/i', $ua)){ + $title = "Google Chrome OS"; + $icon = "iconfont icon-iconchromeos"; + } elseif (preg_match('/Linux/i', $ua)) { + $title = 'Linux'; + $icon = 'fa fa-linux'; + if (preg_match('/Ubuntu/i', $ua)) { + $title = "Ubuntu Linux"; + $icon = "iconfont icon-ubuntu"; + }elseif(preg_match('#Debian#i', $ua)) { + $title = "Debian GNU/Linux"; + $icon = "iconfont icon-debian"; + }elseif (preg_match('#Fedora#i', $ua)) { + $title = "Fedora Linux"; + $icon = "iconfont icon-fedora"; + }elseif (preg_match('/Kraitnabo\/([^\s|;]+)/i', $ua, $matches)) { + $title = '南博app '. $matches[1]; + $icon = 'anzhuo'; + }elseif (preg_match('/Android.([0-9. _]+)/i',$ua, $matches)) { + $title= "Android"; + $icon = "iconfont icon-android"; + } + } elseif (preg_match('/Android.([0-9. _]+)/i',$ua, $matches)) { + $title= "Android"; + $icon = "iconfont icon-android"; + } + return array("title"=>$title, + "icon"=>$icon); + } + /** + * 时光机页面ua,如果是手机设备,只显示设备类型,如果是电脑设备只显示电脑设备类型,如果是扩展发送,显示发送自「扩展」,如果是微信公众号,显示 + */ + public function returnTimeUa(){ + if ($this->ua == "weixin" || $this->ua == "weChat"){ + return array("title"=>("微信公众号"), + "icon"=>"weixin"); + }elseif ($this->ua == "crx"){ + return array("title"=>("Chrome扩展"), + "icon"=>"liulanqi"); + }elseif ($this->ua == "yearcross"){ + return array("title"=>("YearCross"), + "icon"=>"QQ"); + }elseif ($this->ua == "Kraitnabo"){ + return array("title"=>("南博app"), + "icon"=>"anzhuo"); + }elseif ($this->ua == "python"){ + return array("title"=>("python脚本"), + "icon"=>"python"); + }else{ + $ua = $this->returnOS(); + $ua["icon"] = "anzhuo"; + return $ua; + } + } +} \ No newline at end of file diff --git a/times/dycomment.php b/times/dycomment.php new file mode 100644 index 0000000..e65722d --- /dev/null +++ b/times/dycomment.php @@ -0,0 +1,107 @@ +user->hasLogin()){ + $GLOBALS['isLogin'] = true; +}else{ + $GLOBALS['isLogin'] = false; +} +function threadedComments($comments, $options) +{ + $db = Typecho_Db::get(); +?> +
      +
      +
      + agent); ?> +
      gravatar('48', ''); ?>
      + author(); ?> + +

      date('Y年m月d日 H:i'); ?>

      + + returnTimeUa()['title'];?> +
      +
      + text),$GLOBALS['isLogin'] ,"","","",true); ?> +
      +
      +
      + +comments()->to($comments); ?> + + user->hasLogin()) : ?> +
      +
      有什么新鲜事想告诉大家?
      + +

      + + + + + +

      +

      + +

      + +
      + + listComments(['commentUrl'=>$this->commentUrl,'class'=>$this]); ?> + pageNav( + '', + '', + 1, + '...', + array( + 'wrapTag' => 'div', + 'wrapClass' => 'pagination_page', + 'itemTag' => '', + 'textTag' => 'a', + 'currentClass' => 'active', + 'prevClass' => 'prev', + 'nextClass' => 'next' + ) + ); + ?> + \ No newline at end of file