1
|
|
|
<?php |
2
|
|
|
$createNewComment = $di->url->create("comment/newComment"); |
3
|
|
|
$login = $di->url->create("user/login"); |
4
|
|
|
$currentUser = $di->get("session")->has("email") ? $di->get("session")->get("email") : ""; |
5
|
|
|
$deleteComment = $di->url->create("comment/deleteComment"); |
6
|
|
|
$editComment = $di->url->create("comment/editComment"); |
7
|
|
|
$gravatar = $this->di->get("gravatar"); |
8
|
|
|
|
9
|
|
|
$showAll = $this->di->get("url")->create("user/all/"); |
10
|
|
|
|
11
|
|
|
$createNewCommentComment = $di->url->create("comment/newCommentComment"); |
12
|
|
|
$deleteCommentComment = $di->url->create("comment/deleteCommentComment"); |
13
|
|
|
// $editCommentComment = $di->url->create("comment/editCommentComment"); |
|
|
|
|
14
|
|
|
|
15
|
|
|
$userController = $this->di->get("userController"); |
16
|
|
|
$commentController = $this->di->get("commentController"); |
17
|
|
|
|
18
|
|
|
$tag = $di->url->create("tag/tag/"); |
19
|
|
|
|
20
|
|
|
$tags = explode(",", $tags[0]->Category); |
21
|
|
|
$p = "<p> Tags: "; |
22
|
|
|
foreach ($tags as $t) { |
23
|
|
|
//$id = $commentController->returnCatId($t); |
|
|
|
|
24
|
|
|
$p .= '<a class="tag" href=' . $tag . "/" . $t .'>' . $t . '</a> '; |
25
|
|
|
} |
26
|
|
|
$p .= "</p>"; |
27
|
|
|
?> |
28
|
|
|
|
29
|
|
|
<main class="postsAndComments"> |
30
|
|
|
<div class="posts"> |
31
|
|
|
<h1><?= $post[0]->posttitle ?></h5> |
32
|
|
|
<div class="postContent"><?= $post[0]->posttext ?></div> |
33
|
|
|
<p><a class="poster" href="<?= $showAll . "/" . $userController->returnId($post[0]->postname) ?>"><?= $post[0]->postname ?></a></p> |
34
|
|
|
<?= $p ?> |
35
|
|
|
<img src="<?php echo $gravatar->getGravatar($post[0]->postname, 40); ?>" alt=""/> |
36
|
|
|
<hr> |
37
|
|
|
</div> |
38
|
|
|
<div> |
39
|
|
|
<?php if ($this->di->get("session")->has("email")) : ?> |
40
|
|
|
<h4 class="createComment"> <a href="<?= $createNewComment . "/" . $post[0]->postid ?>">Create new comment</a> |
41
|
|
|
</h4> |
42
|
|
|
<?php else : ?> |
43
|
|
|
<h4 class="createComment">Login to create new comment. <a href="<?= $login ?>">Click here</a></h4> |
44
|
|
|
<?php endif ?> |
45
|
|
|
</div> |
46
|
|
|
<div class="comments"> |
47
|
|
|
<?php foreach ($comments as $con => $value) : ?> |
48
|
|
|
<div class="test"> |
49
|
|
|
<div class="commenttext"><?= wordwrap($value[0]->commenttext, 200, "<br />\n"); ?></div> |
50
|
|
|
|
51
|
|
|
<p class="commentPoster"><a href="<?= $showAll . "/" . $userController->returnId($value[0]->Author) ?>"><?= $value[0]->Author ?></a></p> |
52
|
|
|
<img src="<?php echo $gravatar->getGravatar($value[0]->Author, 40); ?>" alt=""/> |
53
|
|
|
<?php if ($currentUser === $value[0]->Author || $permissions === "admin") : ?> |
54
|
|
|
<a class="adminLinks" href="<?= $deleteComment . "/" . $value[0]->idcomment ?>">Delete Comment</a> |
55
|
|
|
<!-- <a class="adminLinks" href="<?= $editComment . "/" . $value[0]->idcomment ?>">Edit Comment</a> --> |
56
|
|
|
<?php endif ?> |
57
|
|
|
<a class="newCommentLink" href="<?= $createNewCommentComment . "/" . $value[0]->idcomment . "/" . $post[0]->postid ?>">Add new Comment</a> |
58
|
|
|
|
59
|
|
|
<?php foreach ($value[1] as $v) : ?> |
60
|
|
|
<div class="commentcomments"> |
61
|
|
|
<div class="commenttext"><?= wordwrap($v->textcomment, 200, "<br />\n"); ?></div> |
62
|
|
|
<p class="commentcommentPoster"><a href="<?= $showAll . "/" . $userController->returnId($v->postuser) ?>"><?= $v->postuser ?></a></p> |
63
|
|
|
<img src="<?php echo $gravatar->getGravatar($v->postuser, 40); ?>" alt=""/> |
64
|
|
|
<?php if ($currentUser === $v->postuser || $permissions === "admin") : ?> |
65
|
|
|
<a class="adminLinks" href="<?= $deleteCommentComment . "/" . $v->idcommentc ?>">Delete Comment</a> |
66
|
|
|
<!-- <a class="adminLinks" href="<?= $editCommentComment . "/" . $v->idcommentc ?>">Edit Comment</a> --> |
67
|
|
|
<?php endif ?> |
68
|
|
|
</div> |
69
|
|
|
<?php endforeach; ?> |
70
|
|
|
</div> |
71
|
|
|
<?php endforeach; ?> |
72
|
|
|
</div> |
73
|
|
|
</main> |
74
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.