forked from stanikeva/SciPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
377 lines (309 loc) · 16.4 KB
/
account.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<?php
session_start();
if (!isset($_SESSION['id']))
header('Location: index.php');
?>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>SciPortal - My Account</title>
<link rel="icon" type="image/x-icon" href="images/logo.png" />
<!-- Bootstrap icons-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet" type="text/css" />
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css" />
<!-- Core theme CSS (includes Bootstrap)-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="js/scripts.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="css/styles.css" rel="stylesheet" />
<?php
include('modals.php');
$id = $_SESSION['id'];
$sql = "SELECT title, uploadDate FROM Pending_articles WHERE Users_id='$id' ORDER BY uploadDate";
$result = mysqli_query($conn, $sql);
$sql2 = "SELECT * FROM Articles WHERE Users_id='$id' ";
$result2 = mysqli_query($conn, $sql2);
$sql3="SELECT * FROM Pending_articles";
$result3 = mysqli_query($conn, $sql3);
$sql4="SELECT * FROM users WHERE id!='0'";
$result4= mysqli_query($conn, $sql4);
$sql5 = "SELECT * FROM Articles ";
$result5 = mysqli_query($conn, $sql5);
?>
</head>
<body>
<?php
include('navbarsimple.php');
$url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
$_SESSION['url']=$url;
?>
<div class="px-5 pt-0 pb-4 bg-image" style="background: url('images/account_bg.jpg'); background-size: 100%">
<div class="media align-items-end profile-header">
<center>
<div class="profile position-relative mr-3"><img src="images/img_avatar.png" alt="..." width="130" height="130" class="rounded mb-2 img-thumbnail">
<div class="media-body mb-5 text-white">
<h4 class="mt-0 mb-0"><?php echo $_SESSION['name']?></h4>
<p class="small mb-4"> <i class="fa fa-map-marker mr-2"></i>Location</p>
</div>
</div>
</center>
</div>
</div>
<?php if ($_SESSION['id']!=0) {?>
<div class="container">
<div class="row">
<div class="col-2 border-end border-5 border-dark">
<main>
<div class="space50"></div>
<h1 class="text-break">Personal Stats</h1>
<div class="space50"></div>
<h4 class="text-break">Posted:</h4>
<p class="text-break"><?php $posted= mysqli_num_rows($result2); echo $posted?></p>
<h4 class="text-break">Pending:</h4>
<p class="text-break"><?php $pending = mysqli_num_rows($result); echo $pending?></p>
</main>
</div>
<div class="col-10">
<div class="space50"></div>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container pt-0 pb-0">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#btnacc" aria-controls="navbarResponsive"
aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="btnacc">
<ul>
<li class="nav-item"><button type="button" onclick="showContent('MyArticles','newArticle','pendingArticles')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >My articles</button></li>
<li class="nav-item"><button type="button" onclick="showContent('newArticle','pendingArticles','MyArticles')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >New article</button></li>
<li class="nav-item"><button type="button" onclick="showContent('pendingArticles','newArticle','MyArticles')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >Pending approval</button></li>
</ul>
</div>
</div>
</nav>
<div class="space50"></div>
<div class="valign-wrapper" id="MyArticles" style="display: none">
<?php
while($rows = mysqli_fetch_assoc($result2))
{
?>
<div class="container">
<div class="row">
<div class="col s12 m3">
<center>
<div class="card3">
<div class="card-image ">
<img src="images/card2.png" width="100" height="100" class="responsive-img">
</div>
<br>
<div class="card-content">
<a href="article.php?art_id=<?php echo $rows['id']?>" class="alert-secondary">
<p><?php echo $rows['title']; ?></p>
</a>
<a class="badge bg-dark a2" href="deleteArticle.php?id=<?php echo $rows['id']?>">Delete article</a>
</div>
</div>
</center>
</div>
</div>
</div>
<div class="space50"> </div>
<?php
}
?>
</div>
<form id="newArticle" style="display: none" action="submitArticle.php" method="post">
<?php if (isset($_GET['error3'])) { ?>
<p class="error alert-danger"><?php echo $_GET['error3']; ?></p>
<script>showContent('newArticle','pendingArticles','MyArticles')</script>
<?php } ?>
<div class="form-group">
<label for="exampleFormControlInput1">Title</label>
<input class="form-control" id="title" name="title" required="" placeholder="Title goes here..." >
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Subject</label>
<select class="form-control" id="subject" name="subject">
<option>Economics</option>
<option>Cognitive Science</option>
<option>Biology</option>
<option>Chemistry</option>
<option>Physics</option>
<option>Computer Science</option>
<option>Mathematics</option>
<option>Engineering</option>
<option>Architecture</option>
<option>Law</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Article goes here</label>
<textarea class="form-control" name="content" required="" rows="3"></textarea>
<p class="small-text text-warning">*You may alter the content of a previously submitted article by entering its existing title and subject and inserting the revised content in the 'Article goes here' text area.</p>
<div class="space50"></div>
<center>
<button type="submit" class="btn btn-dark mb-2">Submit Article</button>
</center>
</div>
</form>
<table class="table" id="pendingArticles" style="display: none; margin-left: 45px">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col">Date of submission</th>
</tr>
</thead>
<tbody>
<?php // LOOP TILL END OF DATA
$counter = 1;
while($row = mysqli_fetch_assoc($result))
{?>
<tr>
<td><?php echo $counter?></td>
<td><?php echo $row['title'];?></td>
<td><?php echo $row['uploadDate'];?></td>
</tr>
<?php
$counter++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php } else if ($_SESSION['id']==0){?>
<div class="container">
<div class="row">
<div class="col-2 border-end border-5 border-dark">
<main>
<div class="space50"></div>
<h4 class="text-break">Posted:</h4>
<p class="text-break"><?php echo $_SESSION['Articles']?> </p>
<h4 class="text-break">Pending:</h4>
<p class="text-break"><?php $pending = mysqli_num_rows($result3); echo $pending?></p>
</main>
</div>
<div class="col-10">
<div class="space50"></div>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container pt-0 pb-0">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#btnacc" aria-controls="navbarResponsive"
aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="btnacc">
<ul>
<li class="nav-item"><button type="button" onclick="showContent('ApproveArticles','DeleteArticles','ManageUsers')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >Approve Articles</button></li>
<li class="nav-item"><button type="button" onclick="showContent('DeleteArticles','ApproveArticles','ManageUsers')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >Delete Articles</button></li>
<li class="nav-item"><button type="button" onclick="showContent('ManageUsers','ApproveArticles','DeleteArticles')" class="btn btn-light2 btn-acc" data-bs-toggle="modal" >Manage Users</button></li>
</ul>
</div>
</div>
</nav>
<div class="space50"></div>
<div class="valign-wrapper" id="ApproveArticles" style="display: none">
<?php
while($rows3 = mysqli_fetch_assoc($result3))
{
?>
<div class="container">
<div class="row">
<div class="col s12 m3">
<center>
<div class="card3">
<div class="card-image ">
<img src="images/card2.png" width="100" height="100" class="responsive-img">
</div>
<br>
<div class="card-content">
<a href="previewArticle.php?art_id=<?php echo $rows3['id']?> " target="_blank" class="alert-secondary">
<p><?php echo $rows3['title']; ?></p>
</a>
<a class="badge bg-dark a2" href="approveArticles.php?id=<?php echo $rows3['id']?>">Approve</a>
</div>
</div>
</center>
</div>
</div>
</div>
<div class="space50"> </div>
<?php
}
?>
</div>
<div class="valign-wrapper" id="DeleteArticles" style="display: none">
<?php
while($rows = mysqli_fetch_assoc($result5))
{
?>
<div class="container">
<div class="row">
<div class="col s12 m3">
<center>
<div class="card3">
<div class="card-image ">
<img src="images/card2.png" width="100" height="100" class="responsive-img">
</div>
<br>
<div class="card-content">
<a href="article.php?art_id=<?php echo $rows['id']?>" class="alert-secondary">
<p><?php echo $rows['title']; ?></p>
</a>
<a class="badge bg-dark a2" href="deleteArticle.php?id=<?php echo $rows['id']?>">Delete</a>
</div>
</div>
</center>
</div>
</div>
</div>
<div class="space50"> </div>
<?php
}
?>
</div>
<table class="table" id="ManageUsers" style="display: none; margin-left: 45px">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Manage User</th>
</tr>
</thead>
<tbody>
<?php // LOOP TILL END OF DATA
$counter = 1;
while($row = mysqli_fetch_assoc($result4))
{?>
<tr>
<td><?php echo $counter?></td>
<td><?php echo $row['first_name'];?></td>
<td><?php echo $row['last_name'];?></td>
<td><a class="badge bg-dark a2" href="deleteUser.php?id=<?php echo $row['id']?>" >Delete User</a></td>
</tr>
<?php
$counter++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php } ?>
<div class="space100"></div>
<?php include('footer.php') ?>
</body>
</html>
<!--if (isset($_SESSION['id']) && isset($_SESSION['user_name'])) }else{
header("Location: index.php");
exit();
}{-->