-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_delete_noti.php
63 lines (50 loc) · 2.42 KB
/
admin_delete_noti.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
59
60
61
62
<?php
include 'bbdd_db_conn.php';
// $id = $_POST['username'];
$q = intval($_GET['id']);
$query0 = "SELECT * FROM notice 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 notice WHERE id= $q";
$username = $rows['username'];
$editor = "editor";
$admin = "admin";
session_start();
$URL = "./admin_notiList.php";
if(!isset($_SESSION['username'])) {
?> <script>
alert("권한이 없습니다. 로그인하세요.");
location.replace("<?php echo $URL?>");
</script>
<?php }
else if($_SESSION['cast']==$admin || $_SESSION['cast']==$editor || $_SESSION['username']==$username) {
$result = $conn->query($query1);
//이미지 삭제
// unlink($rows['img_dir']);
$notiNo = intval($rows['no']);
$imgFiles = glob("se2/upload/n$notiNo*.{jpg,jpeg,gif,png,bmp}", GLOB_BRACE);
if(isset($imgFiles)) {
for ($imgNo = 0; $imgNo <= count($imgFiles); $imgNo++ ) {
unlink($imgFiles[$imgNo]);
}
}
echo $c_arr;
echo $q;
echo $notiNo;
echo $imgFiles;
echo "삭제되었습니다"
?> <script>
location.replace("<?php echo $URL?>");
</script>
<?php
} else {
?>
<script>
alert("권한이 없습니다.");
// location.replace("<?php echo $URL?>");
history.back();
</script>
<?php
}
?>