From 0615f62964b26f5d2f54da3c9262a1ea17df41ce Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Tue, 14 Jul 2020 16:01:49 +0800 Subject: =?UTF-8?q?:poop:=20Fix:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E5=9B=BE=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 11 ++++++++--- index.php | 2 +- libs/Utils.php | 12 +++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/functions.php b/functions.php index 796a4f2..8e62dce 100644 --- a/functions.php +++ b/functions.php @@ -1,5 +1,8 @@ - -commentsMaxNestingLevels = '9999';//最大嵌套层数 Helper::options()->commentsPageDisplay = 'first';//强制评论第一页 Helper::options()->commentsOrder = 'DESC';//将最新的评论展示在前 - Helper::options()->commentsCheckReferer = false;//关闭检查评论来源URL与文章链接是否一致判断(否则会无法评论) + Helper::options()->commentsCheckReferer = false;//关闭检查评论来源URL与文章链接是否一致判断(否则会无法评论) + //将设置储存到全局变量以便使用 + $GLOBALS['miraclesOptions_randomBanner'] = Helper::options()->randomBanner; } /** diff --git a/index.php b/index.php index ed79ec9..f2de215 100644 --- a/index.php +++ b/index.php @@ -22,7 +22,7 @@ $this->need('includes/header.php');
- +
diff --git a/libs/Utils.php b/libs/Utils.php index b78aa06..3d62f77 100644 --- a/libs/Utils.php +++ b/libs/Utils.php @@ -157,18 +157,18 @@ class Utils /** * 缩略图 */ - public static function postBanner($post, $random){ + public static function postBanner($post){ if($post->fields->banner && $post->fields->banner=!''): $banner = $post->fields->banner; else: - if($random==''){ + if($GLOBALS['miraclesOptions_randomBanner']==''){ $banner = '/usr/themes/Miracles/images/postbg/'; $banner .= srand(mb_strlen($post->title)); - $banner .= rand(1,15).'.jpg'; + $banner .= mt_rand(1,15).'.jpg'; } else{ - $banner_url = explode(',',$random); - $banner = $banner_url[mt_rand(0,count($banner_url)-1)].'\"'; + $banner_url = explode(',', $GLOBALS['miraclesOptions_randomBanner']); + $banner = $banner_url[mt_rand(0,count($banner_url)-1)]; } endif; //使用 TimThumb 剪裁 @@ -192,6 +192,8 @@ class Utils $banner_url = '/usr/themes/Miracles/libs/TimThumb.php'; $banner = $banner_url.'?src='.$banner.$banner_size; } + //不知道为什么会有奇怪的空格,所以这里用暴力的方法去掉 + $banner = trim($banner); echo $banner; } -- cgit v1.2.3