Skip to content

Commit

Permalink
🍕 更新 随机文章图源以及功能描述
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaoo committed Mar 5, 2025
1 parent 8e7d6de commit 6468bed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ function randPic(){
$setting = Helper::options()->randimg;
$setting_cdn = Helper::options()->randimgCdn;
$rand = mt_rand(0,999);
if ($setting == 'api.ohmyga.cn') {
$output = 'https://api.ohmyga.cn/wallpaper/?rand='.$rand;
}elseif ($setting == 'local') {
if ($setting == 'local') {
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
$dirPath = getcwd() . "/usr/themes/Cuckoo/random/";
$files = scandir($dirPath);
Expand All @@ -238,10 +236,10 @@ function randPic(){
} else {
$output = "Error, please check /random.";
}
}elseif ($setting == 'cdn'){
}elseif ($setting == 'custom'){
$output = preg_replace('/{rand}/', $rand, $setting_cdn);
}elseif ($setting == '9jojo'){
$output = 'https://api.baka.fun/acgpic/?rand='.$rand;
}else if ($setting == 'dmoe.cc'){
$output = 'https://www.dmoe.cc/random.php?rand='.$rand;
}
print_r($output);
}
Expand Down
12 changes: 6 additions & 6 deletions includes/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ function themeConfig($form) {
], '静态文件源', '推荐选择 “JsDelivr源”', 'local').
$config->input('staticCdn', '自定义静态文件CDN', '在这里填写你自己的CDN(如 api.xxx.xxx),以获取静态文件(需在上方选择自定义CDN)').
$config->select('randimg',
['api.ohmyga.cn' => 'OMGのAPI',
'local' => '本地',
'cdn' => '自定义 CDN',
'9jojo' => '9JOJO'
], '随机文章图源', '在这里可以设置随机文章图源,仅当文章没有设置图片时引用。”', '9jojo').
$config->input('randimgCdn', '自定义随机文章图CDN', '在这里填写你自己的CDN(如 api.xxx.xxx),以获取随机图片(需在上方选择自定义CDN)').
[
'local' => '本地',
'custom' => '自定义',
'dmoe.cc' => 'dmoe.cc'
], '随机文章图源', '在这里可以设置随机文章图源,仅当文章没有设置图片时引用。”', 'dmoe.cc').
$config->input('randimgCdn', '自定义随机文章图源', '在这里填写你自己的图源(如 api.xxx.xxx),以获取随机图片(需在上方选择自定义),若出现完全重复可以在结尾加上 ?rand={rand}').
$config->select('gravatar',
['cravatar' => 'Cravatar',
'geekzu' => '极客族',
Expand Down

1 comment on commit 6468bed

@bhaoo
Copy link
Owner Author

@bhaoo bhaoo commented on 6468bed Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix #129

Please sign in to comment.