My personal blog. https://blog.airikr.me
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

98 lines
2.6 KiB

<?php
require_once 'site-header.php';
$c_comments = sql("SELECT COUNT(id)
FROM comments
", Array(), 'count');
if($c_comments != 0) {
$get_comments = sql("SELECT *,
c.id AS id_c,
c.id_post AS id_p,
c.timestamp_published AS c_published
FROM comments AS c
JOIN posts AS p
ON c.id_post = p.id
WHERE is_inenglish ".($viewing_in_english == true ? "IS NOT" : "IS")." NULL
ORDER BY c.timestamp_published DESC
", Array());
}
echo '<section id="comments">';
echo '<h1>'.($viewing_in_english == false ? 'Kommentarer' : 'Comments').'</h1>';
if($c_comments == 0) {
echo '<div class="message no-select">';
echo ($viewing_in_english == false ? 'Kunde inte hitta några kommentarer' : 'Couldn\'t find any comments');
echo '</div>';
} else {
echo '<div class="head">';
echo '<div class="datetime">'.($viewing_in_english == false ? 'Publicerades' : 'Published').'</div>';
echo '<div class="name">'.($viewing_in_english == false ? 'Avsändare' : 'Sender').'</div>';
echo '<div class="post">'.($viewing_in_english == false ? 'Inlägg' : 'Post').'</div>';
echo '</div>';
foreach($get_comments AS $comment) {
$post = sql("SELECT id_unique, subject
FROM posts
WHERE id = :_idpost
", Array(
'_idpost' => (int)$comment['id_p']
), 'fetch');
if($comment['visitor_email'] != null) {
$comment_identity = MD5($comment['visitor_name'] . $comment['visitor_email'] . (empty($comment['visitor_url']) ? '' : $comment['visitor_url']));
} else {
$comment_identity = strtolower(str_replace(' ', '-', trim($comment['visitor_name'])));
}
echo '<div class="comment">';
echo '<div class="datetime">';
echo '<a href="'.url('read:'.$post['id_unique'].'#'.$comment['id_c']).'" title="'.($viewing_in_english == false ? 'Gå till kommentaren' : 'Go to the comment').'">';
echo date_($comment['c_published'], 'short');
echo '</a>';
echo '</div>';
echo '<div class="name">';
echo '<a href="'.url('comment-author:'.$comment_identity).'" title="'.($viewing_in_english == false ? 'Se alla kommentarer från' : 'See all comments from').' '.trim($comment['visitor_name']).'">';
echo $comment['visitor_name'];
echo '</a>';
echo '</div>';
echo '<div class="post">';
echo '<a href="'.url('read:'.$post['id_unique']).'" title="'.($viewing_in_english == false ? 'Gå till inlägget' : 'Go to the post').'">';
echo $post['subject'];
echo '</a>';
echo '</div>';
echo '</div>';
}
}
echo '</section>';
require_once 'site-footer.php';
?>