-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
56 lines (41 loc) · 1.61 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once 'app/bootstrap.php';
require_once(PROJECT_PATH . '/lib/helper/index.php');
$actualCollectionDirPath = fixDirSeparatorsToTheLeft(PROJECT_PATH . '/test/data/input/');
$outputCollectionDirPath = fixDirSeparatorsToTheLeft(PROJECT_PATH . '/test/data/output/');
$resultCollectionDirPath = fixDirSeparatorsToTheLeft('H:\Alisa\photoalbum/');
foreach (getDirFilesList($actualCollectionDirPath) as $fileName) {
$actualFilePath = $actualCollectionDirPath . $fileName;
$fileData = exif_read_data($actualFilePath);
if ($fileData === false) {
$fileData = strval(filemtime($actualFilePath));
if ($fileData === false) {
throw new Exception('EXCEPTION_A');
}
$date = new DateTime();
$date->setTimestamp($fileData);
$allowedExt = ['mp4'];
} else {
$date = new DateTime($fileData['DateTimeOriginal']);
$allowedExt = ['jpg'];
}
$d = $date->format('Y-m-d');
$extension = strtolower(pathinfo($actualFilePath, PATHINFO_EXTENSION));
if (!in_array($extension, $allowedExt)) {
throw new Exception('EXCEPTION_B');
}
for ($i = 1, $done = false; $done !== true && $i < 88; $i++) {
$format = sprintf('%s.%02d.%s', $d, $i, $extension);
$resultFilePath = $resultCollectionDirPath . $format;
if (file_exists($resultFilePath)) {
continue;
}
$outputFilePath = $outputCollectionDirPath . $format;
if (file_exists($outputFilePath)) {
continue;
}
$done = copy($actualFilePath, $outputFilePath);
}
// echo ".";
};
echo "\nfinished.";