-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete-file.php
58 lines (52 loc) · 1.71 KB
/
delete-file.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
56
57
58
<?php
session_start(); // start up your PHP session!
$deletedir = './images/prods/';
//$file = $deletedir . basename($_FILES['data']);
$image = $_POST["name"];
$image_id = $_POST["id"];
$file = $deletedir . $image;
$deletedir_thumbs = './images/prods/thumbs/';
$deletedir_medium = './images/prods/medium/';
$file_delete = $deletedir_thumbs . $image;
$file_delete2 = $deletedir_medium . $image;
if (unlink($file) && unlink($file_delete)&& unlink($file_delete2)) {
echo "true";
$_SESSION['image_counter']=$_SESSION['image_counter']-1;
$c = $_SESSION['next_image']-1;
if($image == $_SESSION['image1'])
{ // the first image is deleted so we sift all the other fotos
if($c == 1) { unset($_SESSION['image1']); $_SESSION['next_image'] = 1; }
if($c == 2) { if(isset($_SESSION['image2']))
{ $_SESSION['image1'] = $_SESSION['image2'];
unset($_SESSION['image2']);
$_SESSION['next_image'] = 2; }
if(isset($_SESSION['image3']))
{ $_SESSION['image1'] = $_SESSION['image3'];
unset($_SESSION['image3']);
$_SESSION['next_image'] = 2; }
}
if($c == 3) {
if(isset($_SESSION['image2'])) $_SESSION['image1'] = $_SESSION['image2'];
if(isset($_SESSION['image3'])) $_SESSION['image2'] = $_SESSION['image3'];
unset($_SESSION['image3']);
$_SESSION['next_image'] = 3; }
} //end of delete first image
if($image == $_SESSION['image2'])
{
if($c == 3) {
if(isset($_SESSION['image3'])) $_SESSION['image2'] = $_SESSION['image3'];
unset($_SESSION['image3']);
$_SESSION['next_image'] = 3; }
else
{
unset($_SESSION['image2']);
$_SESSION['next_image'] = 2;
}
}
if($image == $_SESSION['image3'])
{unset($_SESSION['image3']); $_SESSION['next_image'] = 3; echo "del=3";}
}
else {
echo "error";
}
?>