|
|
@ -155,6 +155,7 @@ Class SiteController extends Controller { |
|
|
|
//mp3支持 |
|
|
|
//mp3支持 |
|
|
|
$audioExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3'); |
|
|
|
$audioExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$allFiles = $scanResults; |
|
|
|
$showType = $this->get('show', 'all'); |
|
|
|
$showType = $this->get('show', 'all'); |
|
|
|
if ($showType == 'image') { |
|
|
|
if ($showType == 'image') { |
|
|
|
$scanResults = array_filter($scanResults, function($item) { |
|
|
|
$scanResults = array_filter($scanResults, function($item) { |
|
|
@ -174,7 +175,7 @@ Class SiteController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//dataType支持:[image, video] |
|
|
|
//dataType支持:[image, video, audio] |
|
|
|
$dataType = $this->get('dataType', 'html'); |
|
|
|
$dataType = $this->get('dataType', 'html'); |
|
|
|
if ($dataType == 'image') { |
|
|
|
if ($dataType == 'image') { |
|
|
|
$imgs = array(); |
|
|
|
$imgs = array(); |
|
|
@ -235,6 +236,17 @@ Class SiteController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($item['extension']) && in_array($item['extension'], $audioExts)) { |
|
|
|
if (!empty($item['extension']) && in_array($item['extension'], $audioExts)) { |
|
|
|
|
|
|
|
//为音乐文件获取封面图 |
|
|
|
|
|
|
|
if (empty($item['snapshot'])) { |
|
|
|
|
|
|
|
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); |
|
|
|
|
|
|
|
$matchedImage = Html::searchImageByFilename($item['filename'], $allFiles, $imgExts); |
|
|
|
|
|
|
|
if (!empty($matchedImage)) { |
|
|
|
|
|
|
|
$item['snapshot'] = $matchedImage['path']; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
$item['snapshot'] = '/img/beauty/audio_icon.jpeg?v1'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
array_push($audios, $item); |
|
|
|
array_push($audios, $item); |
|
|
|
$index ++; |
|
|
|
$index ++; |
|
|
|
} |
|
|
|
} |
|
|
@ -249,7 +261,7 @@ Class SiteController extends Controller { |
|
|
|
$params = compact( |
|
|
|
$params = compact( |
|
|
|
'page', 'pageSize', 'cacheDataId', 'showType', |
|
|
|
'page', 'pageSize', 'cacheDataId', 'showType', |
|
|
|
'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme', 'mp3File', 'copyright', |
|
|
|
'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme', 'mp3File', 'copyright', |
|
|
|
'alertWarning', 'isAdminIp' |
|
|
|
'alertWarning', 'isAdminIp', 'allFiles' |
|
|
|
); |
|
|
|
); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
} |
|
|
|
} |
|
|
@ -286,7 +298,7 @@ Class SiteController extends Controller { |
|
|
|
* original - 原图 |
|
|
|
* original - 原图 |
|
|
|
* small - 缩略图 |
|
|
|
* small - 缩略图 |
|
|
|
* vm - 视频封面图(vmeta) |
|
|
|
* vm - 视频封面图(vmeta) |
|
|
|
* am - 音乐封面图(ameta) |
|
|
|
* am - 音乐封面图 |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
public function actionDirsnap() { |
|
|
|
public function actionDirsnap() { |
|
|
|
$code = 1; |
|
|
|
$code = 1; |
|
|
@ -307,8 +319,8 @@ Class SiteController extends Controller { |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$withCreateTime = true; //返回数据的缓存时间 |
|
|
|
$withCreateTime = true; //返回数据的缓存时间 |
|
|
|
$cache = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir, $withCreateTime); |
|
|
|
$cache = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir, $withCreateTime); |
|
|
|
$cachedData = $cache['data']; |
|
|
|
$cachedData = !empty($cache) ? $cache['data'] : null; |
|
|
|
$cachedCtime = $cache['ctime']; |
|
|
|
$cachedCtime = !empty($cache) ? $cache['ctime'] : 0; |
|
|
|
$now = time(); |
|
|
|
$now = time(); |
|
|
|
|
|
|
|
|
|
|
|
//如果关闭缩略图 |
|
|
|
//如果关闭缩略图 |
|
|
@ -318,7 +330,7 @@ Class SiteController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
}else if ( !empty($cachedData) && !empty($cachedData['size']) && in_array($cachedData['size'], array('vm', 'am')) ) { |
|
|
|
}else if ( !empty($cachedData) && !empty($cachedData['size']) && in_array($cachedData['size'], array('vm', 'am')) ) { |
|
|
|
//如果是视频、音乐封面图,则缓存 10 分钟 |
|
|
|
//如果是视频、音乐封面图,则缓存 10 分钟 |
|
|
|
if ($now - $cachedCtime > 600) { |
|
|
|
if ($cachedCtime > 0 && $now - $cachedCtime > 600) { |
|
|
|
$cachedData = null; |
|
|
|
$cachedData = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -635,6 +647,23 @@ Class SiteController extends Controller { |
|
|
|
$videoExtension = pathinfo($arr['path'], PATHINFO_EXTENSION); |
|
|
|
$videoExtension = pathinfo($arr['path'], PATHINFO_EXTENSION); |
|
|
|
$videoSourceType = Html::getMediaSourceType($videoExtension); |
|
|
|
$videoSourceType = Html::getMediaSourceType($videoExtension); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从缓存数据获取封面图 |
|
|
|
|
|
|
|
$poster = '/img/beauty/audio_bg.jpg'; |
|
|
|
|
|
|
|
$cacheSeconds = 86400; |
|
|
|
|
|
|
|
$cachedParentData = Common::getCacheFromFile($cacheParentDataId, $cacheSeconds); |
|
|
|
|
|
|
|
if (!empty($cachedParentData)) { |
|
|
|
|
|
|
|
$mp3 = $cachedParentData[$videoId]; |
|
|
|
|
|
|
|
if (!empty($mp3['snapshot'])) { |
|
|
|
|
|
|
|
$poster = $mp3['snapshot']; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); |
|
|
|
|
|
|
|
$matchedImage = Html::searchImageByFilename($mp3['filename'], $cachedParentData, $imgExts); |
|
|
|
|
|
|
|
if (!empty($matchedImage)) { |
|
|
|
|
|
|
|
$poster = $matchedImage['path']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取联系方式 |
|
|
|
//获取联系方式 |
|
|
|
$maxScanDeep = 0; //最大扫描目录级数 |
|
|
|
$maxScanDeep = 0; //最大扫描目录级数 |
|
|
@ -656,7 +685,7 @@ Class SiteController extends Controller { |
|
|
|
$params = compact( |
|
|
|
$params = compact( |
|
|
|
'videoUrl', 'videoId', 'videoFilename', |
|
|
|
'videoUrl', 'videoId', 'videoFilename', |
|
|
|
'cateId', 'cacheParentDataId', 'page', 'pageSize', |
|
|
|
'cateId', 'cacheParentDataId', 'page', 'pageSize', |
|
|
|
'copyright', 'isAdminIp', 'videoExtension', 'videoSourceType' |
|
|
|
'copyright', 'isAdminIp', 'videoExtension', 'videoSourceType', 'poster' |
|
|
|
); |
|
|
|
); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
} |
|
|
|
} |
|
|
|