-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathprune-tims.php
More file actions
33 lines (25 loc) · 791 Bytes
/
prune-tims.php
File metadata and controls
33 lines (25 loc) · 791 Bytes
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
<?php
include('config.php');
function globRecursiveWithBrace($directory, $pattern) {
$files = glob($directory . DIRECTORY_SEPARATOR . $pattern, GLOB_BRACE);
foreach (glob($directory . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $subDirectory) {
$files = array_merge($files, globRecursiveWithBrace($subDirectory, $pattern));
}
return $files;
}
$files = globRecursiveWithBrace($ROOT_PHOTO_DIR, "*.{" . $IMG_FORMATS . "}");
$tims = glob($TIMS_DIR . '*');
$array1 = [];
$array2 = [];
foreach ($tims as $tim_path) {
$tim = basename($tim_path);
$array1[] = $tim;
}
foreach ($files as $file_path) {
$file = basename($file_path);
$array2[] = $file;
}
$result = array_diff($array1, $array2);
foreach ($result as $tim) {
unlink($TIMS_DIR . $tim);
}