This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
74 lines (60 loc) · 1.79 KB
/
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
<?php
require 'include/header.php';
require_once 'classes/comment.php';
require_once 'classes/comment-manager.php';
require_once 'classes/user.php';
require_once 'classes/user-manager.php';
try {
CommentManager::setDB($GLOBALS['db']);
$comments = CommentManager::getComments();
$users = UserManager::getUsers();
} catch (PDOExeption $e) {
error_log($e);
http_response_code(500);
die("An error occurred");
}
?>
<div class="row">
<div class="col-xs-12 col-sm-9">
<h2>Comments</h2>
<ul class="list-group">
<?php
foreach ($comments as $comment) {
$extraClass = '';
if ($comment->getUsername() != '') {
$extraClass = ' active';
}
?>
<li class="list-group-item<?= $extraClass ?>">
<?php // A3 Cross-Site Scripting (XSS) ?>
<?php // UNSAFE ?>
<?= $comment->getComment() ?>
<?php // SAFE ?>
<?php //= htmlspecialchars($comment->getComment()) ?>
<?php if ($_SESSION['username'] != '') { ?>
<a href="remove-comment-action.php?id=<?= htmlspecialchars($comment->getId()) ?>" class="close">×</a>
<?php } ?>
<?php if ($comment->getUsername() != '') { ?>
<span class="label"><?= htmlspecialchars($comment->getUsername()) ?></span>
<?php } ?>
</li>
<?php } ?>
</ul>
<form id="form" action="add-comment-action.php" method="POST" class="">
<div class="form-group">
<textarea name="comment" class="form-control" placeholder="Your comment..."></textarea>
</div>
<button type="submit" class="btn btn-default">Post</button>
</form>
</div>
<div class="col-xs-12 col-sm-3">
<h4>Moderators</h4>
<ul class="list-group">
<?php foreach ($users as $user) { ?>
<li class="list-group-item"><?= htmlspecialchars($user->getName()) ?></li>
<?php } ?>
</ul>
<span class="hit-counter label label-info"></span>
</div>
</div>
<?php require 'include/footer.php' ?>