-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
68 lines (59 loc) · 2.83 KB
/
delete.php
File metadata and controls
68 lines (59 loc) · 2.83 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
session_start();
if(!(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true && $_SESSION["delete_perm"] === true)){// make sure user is logged in
header("location: login.php");
exit;
}
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(isset($_POST["files"]) && !empty(trim($_POST["files"]))){
foreach(explode(",http",trim($_POST["files"])) as $file_){
$file = preg_replace("/.*\/images\//",'',urldecode($file_));
unlink('images/'.$file);
unlink('images/'.str_replace('/','_thumbs/',$file));
unlink('images/'.str_replace('/','_thumbs_square/',$file));
}
}
$year = '2020';//default to 2020
if(isset($_POST["year"]) && !empty(trim($_POST["year"]))){
$year = trim($_POST["year"]);
}
$html = file_get_contents('start_del.html');//this is the html "code" that will be written to the file. start.html contains some one time stuff like <head> and css
$cycle = ["gallery_thin","gallery_wide","gallery_thin","gallery_wide","gallery_thin","gallery_wide","gallery_wide","gallery_wide","gallery_wide"];// css cycle
$cycle2 = ["_thumbs_square","_thumbs","_thumbs_square","_thumbs","_thumbs_square","_thumbs","_thumbs","_thumbs","_thumbs"];// filename cycle. these cycles give the page the square/8:5 structure
$c = 0;//cycle index
if ($handle = opendir('imgAliases/'.$year)) {
while (false !== ($entry = readdir($handle))) {
if (!is_dir('imgAliases/'.$entry) && $entry != '.DS_Store') {//ds store because i have a mac and that file always gets generated and cant be removed
$c = 0;
$html .= "\n<div class = \"gallery_label\">".file_get_contents('imgAliases/'.$year.'/'.$entry)."</div>\n";
if ($handle2 = opendir('images/'.$entry)) {
while (false !== ($entry2 = readdir($handle2))) {
if (!is_dir('images/'.$entry2) && $entry2 != '.DS_Store') {
$html .= "<div onclick=\"select_(this)\" class=\"".$cycle[$c]."\"><img class=\"unselected\" src=\"images/".$entry.$cycle2[$c]."/".$entry2."\"></div>\n";
$c = ($c+1)%count($cycle);
if($c==0||$c==5){
$html .= "\n<div class = \"gallery_label\"></div>";
}
}
}
closedir($handle2);
}
}
}
closedir($handle);
}
$html .= file_get_contents('end_del.html');
echo $html;} else {echo "
<form action=\"\" method=\"post\">
<div>
<label>Year</label>
<input type=\"text\" name=\"year\" value=\"2020\">
</div>
<div class=\"form-group\">
<input type=\"submit\" class=\"btn\" value=\"Confirm\">
</div>
</form>
<br />
<br />
<a href=\"admin.php\">Admin Portal</a>
<br />";}; ?>