|
|
|
@ -27,6 +27,12 @@ Class DirScanner {
@@ -27,6 +27,12 @@ Class DirScanner {
|
|
|
|
|
'description' => '描述', |
|
|
|
|
'keywords' => '关键词', |
|
|
|
|
'snapshot' => '快照图片', |
|
|
|
|
|
|
|
|
|
'original_ctime' => '照片拍摄时间', |
|
|
|
|
|
|
|
|
|
//TODO: 待启用 |
|
|
|
|
'exif' => '照片EXIF信息', |
|
|
|
|
'iptc' => '照片IPTC信息', |
|
|
|
|
); |
|
|
|
|
private $rootDir; //当前扫描的根目录 |
|
|
|
|
private $webRoot = '/content/'; //网站静态文件相对路径的根目录 |
|
|
|
@ -53,6 +59,16 @@ Class DirScanner {
@@ -53,6 +59,16 @@ Class DirScanner {
|
|
|
|
|
'm3u8', //视频 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
protected $exifSupportFileExtensions = array( |
|
|
|
|
'jpg', //图片 |
|
|
|
|
'jpeg', //图片 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
protected $iptcSupportFileExtensions = array( |
|
|
|
|
'jpg', //图片 |
|
|
|
|
'jpeg', //图片 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//暂未使用 |
|
|
|
|
/* |
|
|
|
|
protected $maxReadFilesize = array( //默认每种文件读取内容最大大小 |
|
|
|
@ -230,6 +246,49 @@ Class DirScanner {
@@ -230,6 +246,49 @@ Class DirScanner {
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//format: Ymd |
|
|
|
|
//example: 20240322 |
|
|
|
|
//return: timestamp |
|
|
|
|
private function getCreateDateFromIPTCMeta($realpath) { |
|
|
|
|
$createTime = 0; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (function_exists('getimagesize') && function_exists('iptcparse')) { |
|
|
|
|
$size = getimagesize($realpath, $info); |
|
|
|
|
if(!empty($info['APP13'])) { |
|
|
|
|
$iptc = iptcparse($info['APP13']); |
|
|
|
|
if (!empty($iptc['2#055'])) { |
|
|
|
|
$createTime = strtotime($iptc['2#055'][0]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch(Exception $e) { |
|
|
|
|
//do nothing |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $createTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//format: Y:m:d H:i:s |
|
|
|
|
//example: 2024:03:22 00:23:02 |
|
|
|
|
//return: timestamp |
|
|
|
|
private function getCreateDateFromExifMeta($realpath) { |
|
|
|
|
$createTime = 0; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (function_exists('exif_read_data')) { |
|
|
|
|
$exif = exif_read_data($realpath, 0, true); |
|
|
|
|
if(!empty($exif['EXIF']['DateTimeOriginal'])) { |
|
|
|
|
$createTime = strtotime($exif['EXIF']['DateTimeOriginal']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch(Exception $e) { |
|
|
|
|
//do nothing |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $createTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//根据路径生成文件数组,兼容URL文件 |
|
|
|
|
private function getFileData($realpath) { |
|
|
|
|
$id = $this->getId($realpath); |
|
|
|
@ -255,6 +314,15 @@ Class DirScanner {
@@ -255,6 +314,15 @@ Class DirScanner {
|
|
|
|
|
|
|
|
|
|
if ($extension == 'url') { |
|
|
|
|
$data['shortcut'] = $this->parseShortCuts($realpath, $filename); |
|
|
|
|
}else if (in_array($extension, $this->exifSupportFileExtensions) || in_array($extension, $this->iptcSupportFileExtensions)) { |
|
|
|
|
$photo_create_time = $this->getCreateDateFromExifMeta($realpath); |
|
|
|
|
if ($photo_create_time == 0) { |
|
|
|
|
$photo_create_time = $this->getCreateDateFromIPTCMeta($realpath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($photo_create_time > 0) { |
|
|
|
|
$data['original_ctime'] = $photo_create_time; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|