Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7e63831
Merge: 9a7330c f5d2f0b
Author: 染川 瞳 <[email protected]>
Date:   Thu Oct 31 15:38:56 2024 +0900

    Merge pull request #957 from LeaVES-0/patch-1

    fix issue #954

commit f5d2f0b
Author: LeaVES-0 <[email protected]>
Date:   Tue Oct 22 22:42:08 2024 +0800

    fix issue #954

    增强对Alpine Linux的兼容性
  • Loading branch information
mirai-mamori committed Oct 31, 2024
1 parent e18ce6b commit b8f679f
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions inc/classes/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,20 @@ public function SMMS_API($image) {

public static function cover_gallery($size = 'source') {
if (iro_opt('random_graphs_options') == 'local') {
$img_array = glob(STYLESHEETPATH . '/manifest/gallary/*.{gif,jpg,jpeg,png}', GLOB_BRACE);
// $img_array = glob(STYLESHEETPATH . '/manifest/gallary/*.{gif,jpg,jpeg,png}', GLOB_BRACE);
// Alpine不支持GLOB_BRACE常量,出于兼容性考虑,不使用glob函数
$folderPath = STYLESHEETPATH . '/manifest/gallary/';
$allowedExtensions = array('jpg', 'jpeg', 'png', 'gif');
$img_array = array();
$files = scandir($folderPath);
foreach ($files as $file) {
// 检查文件扩展名是否在允许的范围内
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (in_array($extension, $allowedExtensions)) {
$img_array[] = STYLESHEETPATH . '/manifest/gallary/' . $file;
}
}

if (count($img_array) == 0){
return ['status'=>False,'msg'=>'ERROR:请联系管理员查看gallary目录中是否存在图片!'];
}
Expand Down Expand Up @@ -220,7 +233,22 @@ public static function cover_gallery($size = 'source') {

public static function mobile_cover_gallery() {
if (iro_opt('random_graphs_options') == 'local') {
$img_array = glob(STYLESHEETPATH . '/manifest/gallary/*.{gif,jpg,jpeg,png}', GLOB_BRACE);
// $img_array = glob(STYLESHEETPATH . '/manifest/gallary/*.{gif,jpg,jpeg,png}', GLOB_BRACE);

$folderPath = STYLESHEETPATH . '/manifest/gallary/';

$allowedExtensions = array('jpg', 'jpeg', 'png', 'gif', 'webp');
$img_array = array();

$files = scandir($folderPath);
foreach ($files as $file) {
// 检查文件扩展名是否在允许的范围内
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (in_array($extension, $allowedExtensions)) {
$img_array[] = STYLESHEETPATH . '/manifest/gallary/' . $file;
}
}

if (count($img_array) == 0){
return ['status'=>False,'msg'=>'没有找到图片,请联系管理员检查gallary目录下是否存在图片'];
}
Expand Down Expand Up @@ -261,4 +289,4 @@ public static function feature_gallery($size = 'source') {
return $imgurl;
}

}
}

0 comments on commit b8f679f

Please sign in to comment.