function deleteComment($id) { global $connection; // We have to store the post_id in order to decrement the comment count of this post $comment = findCommentById($id); $query = "DELETE FROM comments WHERE id = {$id}"; $delete_result = mysqli_query($connection, $query); if (!$delete_result) { die("QUERY FAILED: " . mysqli_error($connection)); } else { decrementPostCommentCount($comment['post_id']); } }
function printComment($comment, $comments, $type) { ?> <li id="comment-<?php echo $comment->getId(); ?> " class="comment"> <article class="comment-body"> <div class="comment-meta"> <div class="comment-author vcard"> <img alt="<?php echo htmlentities($comment->getAuthorName(), ENT_QUOTES, "utf-8"); ?> " src="//0.gravatar.com/avatar/<?php echo md5($comment->getAuthorEmail()); ?> ?s=25&d=identicon" class="avatar" height="25" width="25" /> <b class="fn"><?php if ($comment->getAuthorUrl() != null) { ?> <a href="<?php echo htmlentities($comment->getAuthorUrl(), ENT_QUOTES, "utf-8"); ?> " rel="external nofollow" class="url"><?php } echo htmlentities($comment->getAuthorName(), ENT_QUOTES, "utf-8"); if ($comment->getAuthorUrl() != null) { ?> </a><?php } ?> </b> <?php $date = new DateTime($comment->getCreatedOn()); ?> <time datetime="<?php echo $date->format(DateTime::ATOM); ?> "><?php echo $date->format(DateTime::COOKIE); ?> </time> <?php if ($type == Thread::TYPE_NORMAL && $comment->getParentId() != null) { ?> <small>(reply to <b><?php echo htmlentities(findCommentById($comment->getParentId(), $comments)->getAuthorName(), ENT_QUOTES, "utf-8"); ?> </b>)</small> <?php } ?> </div><!-- .comment-author --> </div><!-- .comment-meta --> <div class="comment-content"> <p><?php echo htmlentities($comment->getContents(), ENT_QUOTES, "utf-8"); ?> </p> </div><!-- .comment-content --> </article><!-- .comment-body --> <?php if ($type == Thread::TYPE_THREADED && commentHasChildren($comment, $comments)) { ?> <ol class="comment-list thread"> <?php $childs = getChildComments($comment, $comments); foreach ($childs as $comment2) { printComment($comment2, $comments, $type); } ?> </ol><!-- .comment-list --> <?php } ?> </li> <?php }