-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecReplyPage.php
More file actions
184 lines (158 loc) · 7.86 KB
/
SecReplyPage.php
File metadata and controls
184 lines (158 loc) · 7.86 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
session_start();
include "./php/config.php";
if (isset($_SESSION['id']) || isset($_SESSION['admin_id'])) {
} else {
echo "<h1 class='text-center mt-5' align='center' style='margin-top: 50vh; font-family: calibri; text-transform: uppercase'>Cannot reply if not signed in</h1>";
exit();
}
if (isset($_GET['comment_id'])) {
if (isset($_GET['reply_id'])) {
if (isset($_GET['blog_id'])) {
$comID = $_GET['comment_id'];
$blogID = $_GET['blog_id'];
$replyID = $_GET['reply_id'];
$sql_comment = $conn->query("SELECT* FROM replies WHERE replyID = $replyID");
$fetch = mysqli_fetch_assoc($sql_comment);
$userID = $fetch['userID'];
$uniqueID = $fetch['uniqueID'];
if ($uniqueID == 0) {
$sql_replyee = $conn->query("SELECT* FROM register WHERE unique_id = $userID");
$fetch2 = mysqli_fetch_assoc($sql_replyee);
} else {
$sql_replyee = $conn->query("SELECT* FROM admintable WHERE unique_id = $uniqueID");
$fetch2 = mysqli_fetch_assoc($sql_replyee);
}
global $fetch2;
if (isset($_POST['Btn'])) {
$commentID = $conn->real_escape_string($_POST['commentID']);
$blogID = $conn->real_escape_string($_POST['blogID']);
$userID = $conn->real_escape_string($_POST['userID']);
$replyID = $conn->real_escape_string($_POST['replyID']);
$reply = $conn->real_escape_string($_POST['comment']);
$refName = $conn->real_escape_string($_POST['to']);
if ($reply != "") {
if (isset($_SESSION['id'])) {
$sql = mysqli_query($conn, "INSERT INTO replies (commentID, blogID, userID, uniqueID, reply, createdOn, ref_id, ref_name) VALUES($commentID, $blogID, $userID, '0', '$reply', NOW(), $replyID, '$refName')");
} elseif (isset($_SESSION['admin_id'])) {
$sql = mysqli_query($conn, "INSERT INTO replies (commentID, blogID, userID, uniqueID, reply, createdOn, ref_id, ref_name) VALUES($commentID, $blogID, '0', $userID, '$reply', NOW(), $replyID, '$refName')");
}
if ($sql) {
$_SESSION['success'] = "😀 Reply was successful heading back to blog post";
header("Location: view.php?blog_id=$blogID");
} else {
$_SESSION['failed'] = "😥 Reply unsuccessful";
}
} else {
$_SESSION['failed'] = "😥Reply area cannot ne left empty";
}
}
} else {
echo "<h2> No Blog tag found please go back</h2>";
exit();
}
} else {
echo "<h2> No Reply tag found pls go back</h2>";
exit();
}
} else {
echo "<h2> No comment tag found please go back</h2>";
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/all.css">
<link rel="stylesheet" href="./css/owl.carousel.min.css" />
<link rel="stylesheet" href="./css/owl.theme.default.css" />
<link rel="stylesheet" href="./css/boot4.css" />
<link rel="stylesheet" href="./css/index.css" />
<link rel="stylesheet" href="./css/view.css" />
<link rel="stylesheet" href="./css/comment.css">
<title>Document</title>
</head>
<body>
<div class=" mt-5" id="commentEdit" tabindex="-1" aria-labelledby="">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title text-center" id="">Reply to <?php echo $name = $fetch2['FirstName'] . " " . $fetch2['LastName'] ?>'s</h3>
</div>
<form action="" method="POST">
<div class="modal-body">
<p>
<?php echo $fetch['reply']; ?>
</p>
<div class="form-group mr-2 pr-2">
<input type="number" hidden name="replyID" value="<?php echo $_GET['reply_id'] ?>">
<input type="number" hidden name="commentID" value="<?php echo $_GET['comment_id'] ?>">
<input type="number" hidden name="blogID" value="<?php echo $_GET['blog_id'] ?>">
<input type="number" hidden name="userID" value="<?php if (isset($_SESSION['unique_id'])) {
echo $_SESSION['unique_id'];
} elseif (isset($_SESSION['admin_id'])) {
echo $_SESSION['unique_id'];
} ?>">
<input type="text" hidden name="to" value="<?php echo $name ?>">
<textarea class="p-2" style="font-size: 18px; resize: none" name="comment" id="editArea" cols="60" rows="5"></textarea>
</div>
<p id="info1" class="text-danger">
<?php
if (isset($_SESSION['failed']) && $_SESSION['failed'] !== "") {
echo $_SESSION['failed'];
unset($_SESSION['failed']);
}
?>
</p>
<p id="info2" class="text-success">
<?php
if (isset($_SESSION['success']) && $_SESSION['success'] !== "") {
echo $_SESSION['success'];
unset($_SESSION['success']);
}
?>
</p>
</div>
<div class="modal-footer">
<a href="./view.php?blog_id=<?php echo $_GET['blog_id'] ?>" class="btn btn-secondary"> <i class="fa fa-times"></i> Back</a>
<button type="submit" name="Btn" class="btn btn-danger" id="editCom"> <i class="fa fa-check"></i> Post</button>
</div>
</form>
</div>
</div>
</div>
<script src="./js/jquery-3.2.1.min.js"></script>
<script src="./js/owl.carousel.min.js"></script>
<script src="./js/bootstrap4.js"></script>
<script>
$(document).ready(function() {
$('#editArea').focus();
// var editBtn = $('#editCom');
// editBtn.on('click', function(){
// var editArea = $("#editArea").val();
// if(editArea !== ""){
// $.ajax({
// url: 'edit_comment.php',
// method: 'POST',
// dataType: 'text',
// data:{
// Edit: 1,
// comment: editArea
// },
// success: function(response){
// $("#info2").html("Comment update was success");
// window.location = window.location;
// }
// })
// }else{
// alert("Comment area cannot be empty");
// window.location = window.location;
// }
// });
});
</script>
</body>
</html>