-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_delete_thumbs.php
51 lines (39 loc) · 1.89 KB
/
admin_delete_thumbs.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
<?php
include 'bbdd_db_conn.php';
// $id = $_POST['username'];
$q = intval($_GET['id']);
$query0 = "SELECT * FROM thumbs WHERE id= $q";
// $query0 = "SELECT id, username, created, title, img0, img0_dir, addressinfo, contact, img1, img1_dir, autoparking, img2, img2_dir, publictrans, extmaplink FROM visit WHERE id= $q";
$result0 = $conn->query($query0);
$rows = mysqli_fetch_assoc($result0);
$query1 = "DELETE FROM thumbs WHERE id= $q";
$username = $rows['username'];
$editor = "editor";
$admin = "admin";
session_start();
$URL = "./admin_thumbsList.php";
if(!isset($_SESSION['username'])) {
?> <script>
alert("권한이 없습니다. 로그인하세요.");
location.replace("<?php echo $URL?>");
</script>
<?php }
else if($_SESSION['cast']==$admin || $_SESSION['cast']==$editor) {
$result = $conn->query($query1);
//이미지 삭제
unlink($rows['img_dir']);
echo "삭제되었습니다"
?> <script>
location.replace("<?php echo $URL?>");
</script>
<?php
} else {
?>
<script>
alert("권한이 없습니다.");
// location.replace("<?php echo $URL?>");
history.back();
</script>
<?php
}
?>