From 37a5c36e37fbccb67423abeb4e8111c85bb258af Mon Sep 17 00:00:00 2001 From: haoouba <2323333339@qq.com> Date: Sun, 7 Mar 2021 19:49:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/function.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/core/function.php b/core/function.php index 080915b..b00fe28 100644 --- a/core/function.php +++ b/core/function.php @@ -3,7 +3,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "5.6.2"; + return "5.6.3"; }; /* 判断是否是手机 */ @@ -248,26 +248,19 @@ function _getParentReply($parent) /* 获取侧边栏作者随机文章 */ function _getAsideAuthorNav() { - if (Helper::options()->JAside_Author_Nav !== "off") { + if (Helper::options()->JAside_Author_Nav && Helper::options()->JAside_Author_Nav !== "off") { $db = Typecho_Db::get(); - $adapterName = $db->getAdapterName(); - if ($adapterName == 'pgsql' || $adapterName == 'Pdo_Pgsql' || $adapterName == 'Pdo_SQLite' || $adapterName == 'SQLite') { - $order_by = 'RANDOM()'; - } else { - $order_by = 'RAND()'; - } $result = $db->fetchAll( $db->select() ->from('table.contents') ->where('table.contents.status = ?', 'publish') ->where('table.contents.type = ?', 'post') ->where("table.contents.password IS NULL OR table.contents.password = ''") + ->where('table.contents.cid >= ?', '((SELECT MAX(cid) FROM table.contents)-(SELECT MIN(cid) FROM table.contents)) * RAND() + (SELECT MIN(cid) FROM table.contents)') ->limit(Helper::options()->JAside_Author_Nav) - ->order($order_by) ); foreach ($result as $item) { - $obj = Typecho_Widget::widget('Widget_Abstract_Contents'); - $item = $obj->push($item); + $item = Typecho_Widget::widget('Widget_Abstract_Contents')->push($item); $title = htmlspecialchars($item['title']); $permalink = $item['permalink']; echo " @@ -289,6 +282,7 @@ function _curl($url) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $result = curl_exec($ch); curl_close($ch);