-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_annotation_index.php
109 lines (102 loc) · 4.92 KB
/
admin_annotation_index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
include('session_admin.php');
$selfIDQuery = mysqli_query($conn, "select accountID from account where email_address = '$user_check'");
$row = mysqli_fetch_array($selfIDQuery);
if (isset($_SESSION['login_user'])){
$selfID = $row['accountID'];
} else {
$selfID = "error";
}
$annotations_query = mysqli_query($conn, "SELECT * FROM annotation LEFT JOIN account ON annotation.accountID = account.accountID");
$comments_query = mysqli_query($conn, "SELECT * FROM comment LEFT JOIN account ON comment.accountID = account.accountID ");
if(count($_POST) > 0 ){
if(isset($_POST['deleteComment']) ) {
$bp_ID = $_POST['photoID'];
$user_accountID = $_POST['accountID'];
$timeOfComment = $_POST['timestamp'];
$deleteQuery = "DELETE FROM Comment WHERE photoID = $bp_ID AND accountID = $user_accountID AND timestamp = '$timeOfComment'";
$result = mysqli_query($conn, $deleteQuery)
or die('Error making delete comments query' . mysql_error());
}
if(isset($_POST['deleteAnnotation']) ){
$bp_ID = $_POST['photoID'];
$user_accountID = $_POST['accountID'];
$timeOfComment = $_POST['timestamp'];
$deleteQuery = "DELETE FROM annotation WHERE photoID = $bp_ID AND accountID = $user_accountID AND timestamp = '$timeOfComment'";
$result = mysqli_query($conn, $deleteQuery)
or die('Error making delete comments query' . mysql_error());
}
header("Refresh:0");
}
?>
<html>
<head>
<title>User Index </title>
<?php require_once('head.php');?>
</head>
<body>
<style type="text/css">
td
{
padding:0 15px 0 15px;
}
</style>
<?php require_once('common_navbar.html');?>
<script>
$("#profile_header").addClass("active");
</script>
<h1>User Index</h1>
<?php echo '<table>';
echo '<tr> <th> Email Address</th>
<th> Name </th>
<th> Action </th>
<th> Content</th>
<th> Photo ID </th>
<th> Time </th>
<th> Delete? </th
</tr>';
while($annotation_row = mysqli_fetch_array($annotations_query)){
echo '<tr>
<td><a href="admin_user_update.php?user_id=' . $annotation_row['accountID'] . '">'. $annotation_row['email_address'] . '</a></td>
<td>' .$annotation_row['name'].'</td>
<td> Annotation </td>
<td>'. $annotation_row['annotation'].'</td>';
echo ' <td><a href="photo.php?photoID=' . $annotation_row["photoID"] . '">' . $annotation_row['photoID'] . '</a></td>';
echo '<td>'. $annotation_row['timestamp'].'</td>
<td>
<form name="deleteAnnotation" action="admin_annotation_index.php" id="delete" method="post">
<input name="deleteAnnotation" type="hidden" id="d}elele" value="1"/>
<input name="accountID" type="hidden" id="d}elele" value="'.$annotation_row['accountID'].'"/>
<input name="photoID" type="hidden" id="delele" value="'.$annotation_row['photoID'].'"/>
<input name="timestamp" type="hidden" id="delele" value="'.$annotation_row['timestamp'].'"/>
<button type=\"submit\" class=\"btn-default btn-xs\" >
<i class=\"fa fa-times\" aria-hidden=\"true\"></i>
</button>
</form>
</td>';
}
while($comment_row = mysqli_fetch_array($comments_query)){
echo '<tr>
<td><a href="admin_user_update.php?user_id=' . $comment_row['accountID'] . '">'. $comment_row['email_address'] . '</a></td>
<td>' .$comment_row['name'].'</td>
<td> Commented </td>
<td>' .substr($comment_row['comment'], 0, 10). '</td>';
echo ' <td><a href="photo.php?photoID=' . $comment_row["photoID"] . '">' . $comment_row['photoID'] . '</a></td>';
echo '<td>'. $comment_row['timestamp'].'</td>
<td>
<form name="deleteAnnotation" action="admin_annotation_index.php" id="delete" method="post">
<input name="deleteComment" type="hidden" id="d}elele" value="1"/>
<input name="accountID" type="hidden" id="delele" value="'.$comment_row['accountID'].'"/>
<input name="photoID" type="hidden" id="delele" value="'.$comment_row['photoID'].'"/>
<input name="timestamp" type="hidden" id="delele" value="'.$comment_row['timestamp'].'"/>
<button type=\"submit\" class=\"btn-default btn-xs\" >
<i class=\"fa fa-times\" aria-hidden=\"true\"></i>
</button>
</form>
</td>';
}
echo '</table>'; ?>
<h2 class = "btn btn-info"><a href = "logout.php">Sign Out</a></h2>
<?php require_once('common_footer.html');?>
</body>
</html>