-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewreport_user.php
180 lines (175 loc) · 9.26 KB
/
viewreport_user.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
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
<?php
session_start();
include "functions/database.php";
@$loggedId = $_SESSION['id'];
@$loggedType = $_SESSION['type'];
if (!isset($_SESSION['user']) && isset($_SESSION['id']) && isset($_SESSION['type'])){
header("location: login.php");
exit;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>DatosAnalyticos| Blog</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<!-- Include external CSS. -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/codemirror.min.css">
<!-- Include Editor style. -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.8.4/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.8.4/css/froala_style.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!--<link rel="stylesheet" href="/resources/demos/style.css">-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="css/viewreport_user.css">
</head>
<body>
<nav class="nav">
<div class="container">
<h2 style="margin: 6px 0 10px 0;float: left">DatosAnalyticos</h2>
<a href="functions/lslfunction.php?logout" type="submit" id="logout" name="logout"><i class="fas fa-sign-out-alt" ></i>Logout</a>
</div>
</nav>
<!--Content-->
<div class="container">
<div class="row">
<div class="colOne">
<ul>
<li><a href="index.php" class="link" ><i class="fas fa-home fa-lg" style="color: #a5a2a2;"></i> Home</a></li>
<li><a href="updates.php" class="link"><i class="fas fa-edit fa-lg" style="color: #a5a2a2;"></i> Updates</a></li>
<?php
if ($loggedType > 0){
echo ' <li><a href="adminpost.php" class="link"><i class="fas fa-pen-alt fa-lg" style="color: #a5a2a2;"></i> Post</a></li>';
echo ' <li class="active"><a href="sent_reports.php" class="link"><i class="fas fa-envelope-open"></i> View reports</a></li>';
} else{
echo '<li class="active"><a href="report.php" class="link"> <i class="fas fa-file fa-lg"></i> Report</a></li>';
}
?>
<li><a href="#" class="link"><i class="fas fa-phone fa-lg" style="color: #a5a2a2;"></i> Contact us</a></li>
</ul>
<a href="sendreport.php" class="createReport" <?php if ($loggedType > 0){echo 'style="display: none"';}?>>Create a report?</a>
</div>
<div id="qpost">
<?php
@$reportId = $_GET['rpid'];
$query = mysqli_query($connect,"SELECT report.*,users.username FROM report,users WHERE report.user_id=users.id AND report.id ='$reportId' ORDER BY `id` DESC");
$posts = array();
while ($row = mysqli_fetch_array($query)){
array_push($posts,$row);
}
foreach ($posts as $v) {
echo '<div class="colTwo">';
echo "<h3>" . $v['title'] . "</h3>";
if($loggedId == $v['user_id']){
echo '<div class="editDeleteBtn">
<a href="editPage.php?rpId='.$reportId.'" id="edit" class="editDelete">Edit |</a>
<a href="#" id="delete" class="editDelete">Delete</a>
</div>';
}
echo "<small>" . $v['username'] . " | " . $v['send_at'] . "</small><hr/>";
echo "<p>" . $v['description'] . "</p>";
echo "<div style='text-align: center; margin-top: 22px;'>";
echo '<a href="comment.php?rpid='.$reportId.'" class="cmtBtn">Comment</a>';
echo '</div>';
echo '</div>';
}
?>
</div>
<?php
//Comment query
$query = mysqli_query($connect,"SELECT comments.*,users.username FROM users,comments WHERE comments.comment_by = users.id AND comments.report_id = '$reportId' ORDER BY id DESC");
$comment = array();
while ($row = mysqli_fetch_array($query)){
array_push($comment,$row);
}
//Reply query
@ $sql = "SELECT reply.*,users.username FROM reply,users WHERE reply.report_id = '$reportId' AND reply.reply_by = users.id ";
@ $query = mysqli_query($connect, $sql);
$reply = array();
while ($row = mysqli_fetch_array($query)){
$reply[$row['comment_id']][] = $row;
}
foreach ($comment as $c){
$commentId = $c['id'];
echo '<div class="commentcard" data-id="'.$commentId.'">
<small>'.$c['username'].' | '.$c['comment_at'].'</small>';
if($loggedId == $c['comment_by']){
echo '<div class="editDeleteBtn">
<a href="editPage.php?replyRepId='.$commentId.'&reportId='.$reportId.'" id="edit" class="editDelete">Edit |</a>
<a href="#" id="delete" class="editDelete">Delete</a>
</div>';
}else{
echo '<a href="javascript:void(0)" class="reply">Reply</a>';
}
echo '<p>'.$c['comment_text'].'</p>';
echo ' <div class="replysec">
<hr>
<form action="functions/postfunction.php?cmId='.$c['id'].'&rpid='.@$reportId.'" method="post">
<textarea name="replyArea" class="replyArea textarea" rows="3" placeholder=" @'.$c['username'].'"></textarea><br>
<div class="replyBtn">
<button class="rbtn">Cancel </button>
<button type="submit" name="reply" class="rbtn">Submit </button>
</div>
</form>
</div>
</div>';
if (isset($reply[$commentId])){
foreach ($reply[$commentId] as $r){
echo '<div class="replycard" >
<small>'.@$r['username'].' | '.@$r['reply_at'].'</small>';
if($loggedId == $r['reply_by']){
echo '<div class="editDeleteBtn">
<a href="editPage.php?replypostid='.$r['id'].'&post_id='.$reportId.'" id="edit" class="editDelete">Edit |</a>
<a href="#" id="delete" class="editDelete">Delete</a>
</div>';
}
echo '<p>'.@$r['reply_text'].'</p>';
echo'<div class="replysection" style="display: none;"><hr>
<form action="functions/postfunction.php?commentId='.$c['id'].'&pid='.@$reportId.'" method="post">
<textarea name="replyArea" class="replyArea textarea" rows="3" placeholder=" @'.$c['username'].'"></textarea><br>
<div class="replyBtn">
<button class="rbtn">Cancel </button>
<button type="submit" name="reply" class="rbtn">Submit </button>
</div>
</form>
</div>
</div>';
}
}
}
?>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/codemirror.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/mode/xml/xml.min.js"></script>
<!-- Include Editor JS files. -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.8.4/js/froala_editor.pkgd.min.js"></script>
<!-- Initialize the editor. -->
<script> $(function() { $('textarea').froalaEditor() }); </script>
<script src="js/smooth-scroll.js"></script>
<script>
$(document).ready(function(){
$(".reply").on('click',function(){
$(this).parents(".commentcard").find(".replysec").slideToggle();
});
});
$(function() {
$('.textarea').froalaEditor({
// Set the file upload URL.
imageUploadURL: 'upload_image.php',
/*imageUploadParams: {
id: 'my_editor'
}*/
})
});
</script>
</body>
</html>