Browse Source

keep case sensitive

master
filesite 2 weeks ago
parent
commit
c0dd1de6b1
  1. 30
      lib/DirScanner.php
  2. 30
      themes/beauty/controller/ListController.php
  3. 12
      themes/beauty/controller/SiteController.php
  4. 10
      themes/beauty/views/list/bydate.php
  5. 18
      themes/beauty/views/site/index.php

30
lib/DirScanner.php

@ -145,8 +145,7 @@ Class DirScanner { @@ -145,8 +145,7 @@ Class DirScanner {
fclose($fp);
$img_filename = $this->getFilenameWithoutExtension($img_realpath);
$img_pathinfo = pathinfo($img_realpath);
$extension = strtolower($img_pathinfo['extension']);
$content = $this->getFilePath( $id, $this->getRelativeDirname($img_pathinfo['dirname']), $img_filename, $extension, $fstat['mtime'] );
$content = $this->getFilePath( $id, $this->getRelativeDirname($img_pathinfo['dirname']), $img_filename, $img_pathinfo['extension'], $fstat['mtime'] );
}
}
@ -302,12 +301,14 @@ Class DirScanner { @@ -302,12 +301,14 @@ Class DirScanner {
$fstat = fstat($fp);
fclose($fp);
$pathinfo = pathinfo($realpath);
$extension = strtolower($pathinfo['extension']);
$extension = $pathinfo['extension'];
$extname = strtolower($pathinfo['extension']);
$filename = $this->getFilenameWithoutExtension($realpath);
$data = array(
'id' => $id,
'filename' => $filename,
'extension' => $extension,
'extname' => $extname, //把后缀转小写,程序内部使用
'extension' => $extension, //保持原文件后缀大小写
'fstat' => array(
'size' => $fstat['size'],
'atime' => $fstat['atime'],
@ -315,12 +316,12 @@ Class DirScanner { @@ -315,12 +316,12 @@ Class DirScanner {
'ctime' => $fstat['ctime'],
),
'realpath' => $this->isApi ? $this->getRelativeDirname($realpath) : $realpath,
'path' => $this->getFilePath( $id, $this->getRelativeDirname($pathinfo['dirname']), $filename, $extension, $fstat['mtime'] ),
'path' => $this->getFilePath( $id, $this->getRelativeDirname($pathinfo['dirname']), $filename, $pathinfo['extension'], $fstat['mtime'] ),
);
if ($extension == 'url') {
if ($extname == 'url') {
$data['shortcut'] = $this->parseShortCuts($realpath, $filename);
}else if (in_array($extension, $this->exifSupportFileExtensions) || in_array($extension, $this->iptcSupportFileExtensions)) {
}else if (in_array($extname, $this->exifSupportFileExtensions) || in_array($extname, $this->iptcSupportFileExtensions)) {
$photo_create_time = $this->getCreateDateFromExifMeta($realpath);
if ($photo_create_time == 0) {
$photo_create_time = $this->getCreateDateFromIPTCMeta($realpath);
@ -329,7 +330,7 @@ Class DirScanner { @@ -329,7 +330,7 @@ Class DirScanner {
if ($photo_create_time > 0) {
$data['original_ctime'] = $photo_create_time;
}
}else if ($this->exiftoolSupported && in_array($extension, $this->exiftoolSupportFileExtensions)) {
}else if ($this->exiftoolSupported && in_array($extname, $this->exiftoolSupportFileExtensions)) {
//try to exec command to get original create time of videos
try {
$output = shell_exec( sprintf("exiftool -createdate %s", escapeshellarg($realpath)) );
@ -502,10 +503,11 @@ Class DirScanner { @@ -502,10 +503,11 @@ Class DirScanner {
'ts' => "{$webRoot}{$directory}{$filename}.{$extension}",
);
$path = isset($extensionPathMap[$extension]) ? $extensionPathMap[$extension] : '';
$extname = strtolower($extension);
$path = isset($extensionPathMap[$extname]) ? $extensionPathMap[$extname] : '';
if (!empty($path) && in_array($extension, ['md', 'url', 'm3u8'])) {
if ($this->nginxSecureOn && $extension == 'm3u8') {
if (!empty($path) && in_array($extname, ['md', 'url', 'm3u8'])) {
if ($this->nginxSecureOn && $extname == 'm3u8') {
$path = $this->getSecureLink($path);
$path = "{$path}&id={$id}";
}else {
@ -516,7 +518,7 @@ Class DirScanner { @@ -516,7 +518,7 @@ Class DirScanner {
}
//增加版本号ver参数
if (!in_array($extension, ['md', 'url', 'txt'])) {
if (!in_array($extname, ['md', 'url', 'txt'])) {
$path .= strpos($path, '?') !== false ? "&ver={$mtime}" : "?ver={$mtime}";
}
@ -850,9 +852,7 @@ Class DirScanner { @@ -850,9 +852,7 @@ Class DirScanner {
fclose($fp);
$src_filename = $this->getFilenameWithoutExtension($src_realpath);
$src_pathinfo = pathinfo($src_realpath);
$extension = strtolower($src_pathinfo['extension']);
$src_path = $this->getFilePath( $id, $this->getRelativeDirname($src_pathinfo['dirname']), $src_filename, $extension, $fstat['mtime'] );
$src_path = $this->getFilePath( $id, $this->getRelativeDirname($src_pathinfo['dirname']), $src_filename, $src_pathinfo['extension'], $fstat['mtime'] );
$html = str_replace("\"{$url}\"", "\"{$src_path}\"", $html);
}

30
themes/beauty/controller/ListController.php

@ -149,17 +149,17 @@ Class ListController extends Controller { @@ -149,17 +149,17 @@ Class ListController extends Controller {
if ($showType == 'image' && !empty($scanResults[$cateId]['files'])) {
$scanResults[$cateId]['files'] = array_filter($scanResults[$cateId]['files'], function($item) {
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
return !empty($item['extension']) && in_array($item['extension'], $imgExts);
return !empty($item['extname']) && in_array($item['extname'], $imgExts);
});
}else if ($showType == 'video' && !empty($scanResults[$cateId]['files'])) {
$scanResults[$cateId]['files'] = array_filter($scanResults[$cateId]['files'], function($item) {
$videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8');
return !empty($item['extension']) && in_array($item['extension'], $videoExts);
return !empty($item['extname']) && in_array($item['extname'], $videoExts);
});
}else if ($showType == 'audio' && !empty($scanResults[$cateId]['files'])) {
$scanResults[$cateId]['files'] = array_filter($scanResults[$cateId]['files'], function($item) {
$audioExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3');
return !empty($item['extension']) && in_array($item['extension'], $audioExts);
return !empty($item['extname']) && in_array($item['extname'], $audioExts);
});
}
@ -235,7 +235,7 @@ Class ListController extends Controller { @@ -235,7 +235,7 @@ Class ListController extends Controller {
}
$item['caption'] = "{$title} - {$item['filename']}";
if (!empty($item['extension']) && in_array($item['extension'], $imgExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $imgExts)) {
array_push($imgs, $item);
$index ++;
}
@ -255,12 +255,12 @@ Class ListController extends Controller { @@ -255,12 +255,12 @@ Class ListController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $videoExts)) {
if ($item['extension'] == 'm3u8') {
if (!empty($item['extname']) && in_array($item['extname'], $videoExts)) {
if ($item['extname'] == 'm3u8') {
$item['path'] .= "&cid={$cacheParentDataId}";
}
$item['videoType'] = Html::getMediaSourceType($item['extension']);
$item['videoType'] = Html::getMediaSourceType($item['extname']);
array_push($videos, $item);
$index ++;
@ -281,7 +281,7 @@ Class ListController extends Controller { @@ -281,7 +281,7 @@ Class ListController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $audioExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $audioExts)) {
//为音乐文件获取封面图
if (empty($item['snapshot'])) {
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
@ -486,7 +486,7 @@ Class ListController extends Controller { @@ -486,7 +486,7 @@ Class ListController extends Controller {
foreach($cacheData as $month => $arr) {
$cacheData[$month] = array_filter($arr, function($item) {
$filtExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
return !empty($item['extname']) && in_array($item['extname'], $filtExts);
});
}
}else if ($showType == 'video') {
@ -494,7 +494,7 @@ Class ListController extends Controller { @@ -494,7 +494,7 @@ Class ListController extends Controller {
foreach($cacheData as $month => $arr) {
$cacheData[$month] = array_filter($arr, function($item) {
$filtExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
return !empty($item['extname']) && in_array($item['extname'], $filtExts);
});
}
}else if ($showType == 'audio') {
@ -502,7 +502,7 @@ Class ListController extends Controller { @@ -502,7 +502,7 @@ Class ListController extends Controller {
foreach($cacheData as $month => $arr) {
$cacheData[$month] = array_filter($arr, function($item) {
$filtExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
return !empty($item['extname']) && in_array($item['extname'], $filtExts);
});
}
}
@ -559,7 +559,7 @@ Class ListController extends Controller { @@ -559,7 +559,7 @@ Class ListController extends Controller {
}
$item['caption'] = "{$title} - {$item['filename']}";
if (!empty($item['extension']) && in_array($item['extension'], $imgExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $imgExts)) {
array_push($imgs, $item);
$index ++;
}
@ -579,8 +579,8 @@ Class ListController extends Controller { @@ -579,8 +579,8 @@ Class ListController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $videoExts)) {
$item['videoType'] = Html::getMediaSourceType($item['extension']);
if (!empty($item['extname']) && in_array($item['extname'], $videoExts)) {
$item['videoType'] = Html::getMediaSourceType($item['extname']);
array_push($videos, $item);
$index ++;
@ -601,7 +601,7 @@ Class ListController extends Controller { @@ -601,7 +601,7 @@ Class ListController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $audioExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $audioExts)) {
//为音乐文件获取封面图
if (empty($item['snapshot'])) {
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');

12
themes/beauty/controller/SiteController.php

@ -164,17 +164,17 @@ Class SiteController extends Controller { @@ -164,17 +164,17 @@ Class SiteController extends Controller {
if ($showType == 'image') {
$scanResults = array_filter($scanResults, function($item) {
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
return !empty($item['extension']) && in_array($item['extension'], $imgExts);
return !empty($item['extname']) && in_array($item['extname'], $imgExts);
});
}else if ($showType == 'video') {
$scanResults = array_filter($scanResults, function($item) {
$videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8');
return !empty($item['extension']) && in_array($item['extension'], $videoExts);
return !empty($item['extname']) && in_array($item['extname'], $videoExts);
});
}else if ($showType == 'audio') {
$scanResults = array_filter($scanResults, function($item) {
$audioExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3');
return !empty($item['extension']) && in_array($item['extension'], $audioExts);
return !empty($item['extname']) && in_array($item['extname'], $audioExts);
});
}
@ -201,7 +201,7 @@ Class SiteController extends Controller { @@ -201,7 +201,7 @@ Class SiteController extends Controller {
}
$item['caption'] = "{$title} - {$item['filename']}";
if (!empty($item['extension']) && in_array($item['extension'], $imgExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $imgExts)) {
array_push($imgs, $item);
$index ++;
}
@ -220,7 +220,7 @@ Class SiteController extends Controller { @@ -220,7 +220,7 @@ Class SiteController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $videoExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $videoExts)) {
array_push($videos, $item);
$index ++;
}
@ -239,7 +239,7 @@ Class SiteController extends Controller { @@ -239,7 +239,7 @@ Class SiteController extends Controller {
break;
}
if (!empty($item['extension']) && in_array($item['extension'], $audioExts)) {
if (!empty($item['extname']) && in_array($item['extname'], $audioExts)) {
//为音乐文件获取封面图
if (empty($item['snapshot'])) {
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');

10
themes/beauty/views/list/bydate.php

@ -261,7 +261,7 @@ eof; @@ -261,7 +261,7 @@ eof;
$index = 0;
foreach ($allFiles as $file) {
if (empty($file['extension']) || !in_array($file['extension'], $supportedExts)) {
if (empty($file['extname']) || !in_array($file['extname'], $supportedExts)) {
continue;
}
@ -283,7 +283,7 @@ eof; @@ -283,7 +283,7 @@ eof;
}
}
if (in_array($file['extension'], $imgExts)) {
if (in_array($file['extname'], $imgExts)) {
//缩略图
$imgUrl = urlencode($file['path']);
$smallUrl = "/site/smallimg/?id={$file['id']}&url={$imgUrl}";
@ -328,7 +328,7 @@ eof; @@ -328,7 +328,7 @@ eof;
</a>
</div>
eof;
}else if (in_array($file['extension'], $videoExts)) { //输出视频
}else if (in_array($file['extname'], $videoExts)) { //输出视频
$videoUrl = urlencode($file['path']);
$linkUrl = "/site/player?id={$file['id']}&pid={$file['pid']}&url={$videoUrl}";
if ($viewData['showType'] == 'video') {
@ -337,7 +337,7 @@ eof; @@ -337,7 +337,7 @@ eof;
$linkUrl .= "&year={$viewData['para_year']}&month={$viewData['para_month']}";
}
if ($file['extension'] == 'm3u8') {
if ($file['extname'] == 'm3u8') {
$linkUrl .= "&name=" . urlencode($file['filename']);
}
@ -372,7 +372,7 @@ eof; @@ -372,7 +372,7 @@ eof;
</a>
</div>
eof;
}else if (in_array($file['extension'], $audioExts)) { //输出音乐
}else if (in_array($file['extname'], $audioExts)) { //输出音乐
$title = !empty($file['title']) ? $file['title'] : $file['filename'];
$videoUrl = urlencode($file['path']);
$linkUrl = "/site/audioplayer?id={$file['id']}&pid={$file['pid']}&url={$videoUrl}";

18
themes/beauty/views/site/index.php

@ -269,16 +269,16 @@ eof; @@ -269,16 +269,16 @@ eof;
}
} else if (!empty($dir['files'])) {
$first_img = array_shift($dir['files']);
if (!in_array($first_img['extension'], $imgExts)) {
if (!in_array($first_img['extname'], $imgExts)) {
foreach ($dir['files'] as $file) {
if (in_array($file['extension'], $imgExts)) {
if (in_array($file['extname'], $imgExts)) {
$first_img = $file;
break;
}
}
}
if (in_array($first_img['extension'], $imgExts)) {
if (in_array($first_img['extname'], $imgExts)) {
$imgUrl = urlencode($first_img['path']);
$smallUrl = "/site/smallimg/?id={$first_img['id']}&url={$imgUrl}";
if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') {
@ -413,7 +413,7 @@ eof; @@ -413,7 +413,7 @@ eof;
$index = 0;
foreach ($category['files'] as $file) {
if (empty($file['extension']) || !in_array($file['extension'], $supportedExts)) {
if (empty($file['extname']) || !in_array($file['extname'], $supportedExts)) {
continue;
}
@ -435,7 +435,7 @@ eof; @@ -435,7 +435,7 @@ eof;
}
}
if (in_array($file['extension'], $imgExts)) {
if (in_array($file['extname'], $imgExts)) {
//缩略图
$imgUrl = urlencode($file['path']);
$smallUrl = "/site/smallimg/?id={$file['id']}&url={$imgUrl}";
@ -472,9 +472,9 @@ eof; @@ -472,9 +472,9 @@ eof;
</a>
</div>
eof;
}else if (in_array($file['extension'], $videoExts)) { //输出视频
}else if (in_array($file['extname'], $videoExts)) { //输出视频
//m3u8支持
if ($file['extension'] == 'm3u8') {
if ($file['extname'] == 'm3u8') {
$videoUrl = urlencode("{$file['path']}&cid={$viewData['cacheDataId']}");
}else {
$videoUrl = urlencode($file['path']);
@ -485,7 +485,7 @@ eof; @@ -485,7 +485,7 @@ eof;
$linkUrl .= "&page={$viewData['page']}&limit={$viewData['pageSize']}";
}
if ($file['extension'] == 'm3u8') {
if ($file['extname'] == 'm3u8') {
$linkUrl .= "&name=" . urlencode($file['filename']);
}
@ -506,7 +506,7 @@ eof; @@ -506,7 +506,7 @@ eof;
</a>
</div>
eof;
}else if (in_array($file['extension'], $audioExts)) { //输出音乐
}else if (in_array($file['extname'], $audioExts)) { //输出音乐
$title = !empty($file['title']) ? $file['title'] : $file['filename'];
$videoUrl = urlencode($file['path']);
$linkUrl = "/site/audioplayer?id={$file['id']}&pid={$file['pid']}&cid={$viewData['cacheDataId']}&url={$videoUrl}";

Loading…
Cancel
Save