|
|
@ -281,6 +281,13 @@ Class SiteController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据目录id,获取第一张图网址作为封面图返回 |
|
|
|
//根据目录id,获取第一张图网址作为封面图返回 |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* size可选值: |
|
|
|
|
|
|
|
* original - 原图 |
|
|
|
|
|
|
|
* small - 缩略图 |
|
|
|
|
|
|
|
* vm - 视频封面图(vmeta) |
|
|
|
|
|
|
|
* am - 音乐封面图(ameta) |
|
|
|
|
|
|
|
**/ |
|
|
|
public function actionDirsnap() { |
|
|
|
public function actionDirsnap() { |
|
|
|
$code = 1; |
|
|
|
$code = 1; |
|
|
|
$msg = 'OK'; |
|
|
|
$msg = 'OK'; |
|
|
@ -298,13 +305,22 @@ Class SiteController extends Controller { |
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'snap'); |
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'snap'); |
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$withCreateTime = true; //返回数据的缓存时间 |
|
|
|
|
|
|
|
$cache = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir, $withCreateTime); |
|
|
|
|
|
|
|
$cachedData = $cache['data']; |
|
|
|
|
|
|
|
$cachedCtime = $cache['ctime']; |
|
|
|
|
|
|
|
$now = time(); |
|
|
|
|
|
|
|
|
|
|
|
//如果关闭缩略图 |
|
|
|
//如果关闭缩略图 |
|
|
|
if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { |
|
|
|
if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { |
|
|
|
if (!empty($cachedData) && !empty($cachedData['size']) && $cachedData['size'] == 'small') { |
|
|
|
if (!empty($cachedData) && !empty($cachedData['size']) && $cachedData['size'] == 'small') { |
|
|
|
$cachedData = null; |
|
|
|
$cachedData = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else if ( !empty($cachedData) && !empty($cachedData['size']) && in_array($cachedData['size'], array('vm', 'am')) ) { |
|
|
|
|
|
|
|
//如果是视频、音乐封面图,则缓存 10 分钟 |
|
|
|
|
|
|
|
if ($now - $cachedCtime > 600) { |
|
|
|
|
|
|
|
$cachedData = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//弃用老版本数据格式,抛弃没有size属性的 |
|
|
|
//弃用老版本数据格式,抛弃没有size属性的 |
|
|
@ -339,7 +355,7 @@ Class SiteController extends Controller { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$url = $cachedData['snapshot']; |
|
|
|
$url = $cachedData['snapshot']; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$size = 'vm'; |
|
|
|
$size = 'vm'; //视频封面图 |
|
|
|
Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); |
|
|
|
Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
@ -347,12 +363,16 @@ Class SiteController extends Controller { |
|
|
|
$firstVideo = $scanner->getSnapshotImage($realpath, $audioExts); |
|
|
|
$firstVideo = $scanner->getSnapshotImage($realpath, $audioExts); |
|
|
|
if (!empty($firstVideo)) { |
|
|
|
if (!empty($firstVideo)) { |
|
|
|
$url = '/img/beauty/audio_icon.jpeg'; |
|
|
|
$url = '/img/beauty/audio_icon.jpeg'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 获取音乐封面图 |
|
|
|
|
|
|
|
//$size = 'am'; //音乐封面图 |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$url = $imgFile['path']; |
|
|
|
$url = $imgFile['path']; |
|
|
|
$img_id = $imgFile['id']; |
|
|
|
$img_id = $imgFile['id']; |
|
|
|
$size = 'orignal'; |
|
|
|
$size = 'orignal'; //原尺寸 |
|
|
|
|
|
|
|
|
|
|
|
//小尺寸图片支持 |
|
|
|
//小尺寸图片支持 |
|
|
|
if (!empty(FSC::$app['config']['enableSmallImage']) && FSC::$app['config']['enableSmallImage'] !== 'false') { |
|
|
|
if (!empty(FSC::$app['config']['enableSmallImage']) && FSC::$app['config']['enableSmallImage'] !== 'false') { |
|
|
@ -362,7 +382,7 @@ Class SiteController extends Controller { |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey_smimg, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey_smimg, $expireSeconds, $cacheSubDir); |
|
|
|
if (!empty($cachedData)) { //已经有缩略图 |
|
|
|
if (!empty($cachedData)) { //已经有缩略图 |
|
|
|
$url = $cachedData; |
|
|
|
$url = $cachedData; |
|
|
|
$size = 'small'; |
|
|
|
$size = 'small'; //缩略图 |
|
|
|
|
|
|
|
|
|
|
|
//当前目录有缩略图的时候才缓存 |
|
|
|
//当前目录有缩略图的时候才缓存 |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
@ -419,7 +439,6 @@ Class SiteController extends Controller { |
|
|
|
$msg = '403 Forbidden,禁止访问'; |
|
|
|
$msg = '403 Forbidden,禁止访问'; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'snap'); |
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'snap'); |
|
|
|
$img_id = ''; //为保持数据格式一致,图片id传空 |
|
|
|
|
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
$cacheSubDir = 'dir'; |
|
|
|
|
|
|
|
|
|
|
|
$size = 'orignal'; |
|
|
|
$size = 'orignal'; |
|
|
@ -427,7 +446,7 @@ Class SiteController extends Controller { |
|
|
|
$size = 'small'; |
|
|
|
$size = 'small'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$saved = Common::saveCacheToFile($cacheKey, compact('url', 'img_id', 'size'), $cacheSubDir); |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); |
|
|
|
|
|
|
|
|
|
|
|
if ($saved !== false) { |
|
|
|
if ($saved !== false) { |
|
|
|
$code = 1; |
|
|
|
$code = 1; |
|
|
|