From 3d6ffe0d3cc35d30467592d55a69132703a234e4 Mon Sep 17 00:00:00 2001 From: IoTcat Date: Fri, 22 Mar 2019 12:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=8C=BA?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/handsome/component/comments.php | 4 + .../usr/themes/handsome/functions.php | 97 +++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/server/cn/home/www/IoTgod-www/usr/themes/handsome/component/comments.php b/server/cn/home/www/IoTgod-www/usr/themes/handsome/component/comments.php index 0965bbb..c73bbc7 100644 --- a/server/cn/home/www/IoTgod-www/usr/themes/handsome/component/comments.php +++ b/server/cn/home/www/IoTgod-www/usr/themes/handsome/component/comments.php @@ -64,6 +64,10 @@ + + + agent); ?> + agent); ?>
diff --git a/server/cn/home/www/IoTgod-www/usr/themes/handsome/functions.php b/server/cn/home/www/IoTgod-www/usr/themes/handsome/functions.php index 1733320..777816c 100644 --- a/server/cn/home/www/IoTgod-www/usr/themes/handsome/functions.php +++ b/server/cn/home/www/IoTgod-www/usr/themes/handsome/functions.php @@ -1012,3 +1012,100 @@ function themeFields(Typecho_Widget_Helper_Layout $layout){ ),'default', _t('文章头图样式选择'), '该选项可以单独为该篇文章配置头图样式,以便达到首页多种头图样式交叉的效果'); $layout->addItem($thumbSyle); } + + + +/***评论区浏览器标识***/ +// 获取浏览器信息 +function getBrowser($agent) +{ + if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) { + $outputer = '  Internet Explore'; + } else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) { + $str1 = explode('Firefox/', $regs[0]); +$FireFox_vern = explode('.', $str1[1]); + $outputer = '  FireFox'; + } else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) { + $str1 = explode('Maxthon/', $agent); +$Maxthon_vern = explode('.', $str1[1]); + $outputer = '  MicroSoft Edge'; + } else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) { +$outputer = '  360极速浏览器'; + } else if (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) { + $str1 = explode('Edge/', $regs[0]); +$Edge_vern = explode('.', $str1[1]); + $outputer = '  MicroSoft Edge'; + } else if (preg_match('/UC/i', $agent)) { + $str1 = explode('rowser/', $agent); +$UCBrowser_vern = explode('.', $str1[1]); + $outputer = '  UC浏览器'; + } else if (preg_match('/QQ/i', $agent, $regs)||preg_match('/QQBrowser\/([^\s]+)/i', $agent, $regs)) { + $str1 = explode('rowser/', $agent); +$QQ_vern = explode('.', $str1[1]); + $outputer = '  QQ浏览器'; + } else if (preg_match('/UBrowser/i', $agent, $regs)) { + $str1 = explode('rowser/', $agent); +$UCBrowser_vern = explode('.', $str1[1]); + $outputer = '  UC浏览器'; + } else if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) { + $outputer = '  Opera'; + } else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) { +$str1 = explode('Chrome/', $agent); +$chrome_vern = explode('.', $str1[1]); + $outputer = '  Google Chrome'; + } else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) { + $str1 = explode('Version/', $agent); +$safari_vern = explode('.', $str1[1]); + $outputer = '  Safari'; + } else{ + $outputer = '  Google Chrome'; + } + echo $outputer; +} +// 获取操作系统信息 +function getOs($agent) +{ + $os = false; + + if (preg_match('/win/i', $agent)) { + if (preg_match('/nt 6.0/i', $agent)) { + $os = '    Windows Vista / '; + } else if (preg_match('/nt 6.1/i', $agent)) { + $os = '    Windows 7 / '; + } else if (preg_match('/nt 6.2/i', $agent)) { + $os = '    Windows 8 / '; + } else if(preg_match('/nt 6.3/i', $agent)) { + $os = '    Windows 8.1 / '; + } else if(preg_match('/nt 5.1/i', $agent)) { + $os = '    Windows XP / '; + } else if (preg_match('/nt 10.0/i', $agent)) { + $os = '    Windows 10 / '; + } else{ + $os = '    Windows X64 / '; + } + } else if (preg_match('/android/i', $agent)) { + if (preg_match('/android 9/i', $agent)) { + $os = '    Android Pie / '; + } + else if (preg_match('/android 8/i', $agent)) { + $os = '    Android Oreo / '; + } + else{ + $os = '    Android / '; + } + } + else if (preg_match('/ubuntu/i', $agent)) { + $os = '    Ubuntu / '; + } else if (preg_match('/linux/i', $agent)) { + $os = '    Linux / '; + } else if (preg_match('/iPhone/i', $agent)) { + $os = '    iPhone / '; + } else if (preg_match('/mac/i', $agent)) { + $os = '    MacOS / '; + }else if (preg_match('/fusion/i', $agent)) { + $os = '    Android / '; + } else { + $os = '    Linux / '; + } + echo $os; +} \ No newline at end of file