-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremoveEarlier.php
More file actions
executable file
·48 lines (39 loc) · 1.2 KB
/
removeEarlier.php
File metadata and controls
executable file
·48 lines (39 loc) · 1.2 KB
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
<?php
$photoFolder="/home/technik7/public_html/house";
$photoFolderHistory="/home/technik7/public_html/house_history";
$photoExtension=".jpg";
function endsWith($haystack, $needle) {
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
}
?>
<?php
$parameterName="file";
// $globalPath="/var/www/html/security/";
$globalPath="";
$folderSource=$photoFolder."/";
if(isset($_GET[$parameterName]) && !empty($_GET[$parameterName])){
$fileName=$_GET[$parameterName];
$fileSource=$globalPath.$folderSource.$fileName;
if(!file_exists($fileSource)){
header("HTTP/1.0 404 file was not found");
return;
}
$dir = opendir($photoFolder);
$files = array();
while ($files[] = readdir($dir));
sort($files);
closedir($dir);
foreach ($files as $file){
if(endsWith($file, $photoExtension)){
if($file==$fileName){
break;
}
unlink($folderSource.$file);
}
}
} else {
// need to specify request parameter
header("HTTP/1.0 400 Bad request");
}
?>