$lng[section_blog]\n");
$offset = (int) $_GET['o'];
$q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE visible = 1 ORDER BY dtime DESC LIMIT 5 OFFSET $offset;");
while($r = mysqli_fetch_array($q)){
echo "
\n";
?>
\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "$r[title]\n";
$q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx LIMIT 1;");
if (mysqli_num_rows($q_image) > 0){
$r_image = mysqli_fetch_array($q_image);
echo "
\n";
echo "
\n";
}
#Pager
$q_count = mysqli_query($con, "SELECT COUNT(id) AS count FROM post WHERE visible = 1;");
$r_count = mysqli_fetch_array($q_count);
$cur_page = (int) ($offset / 5) + 1;
$max_page = (int) ($r_count['count'] / 5);
if ($r_count['count'] % 5 != 0)
$max_page ++;
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "
\n";
echo "$r[title]\n";
$q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx LIMIT 1;");
if (mysqli_num_rows($q_image) > 0){
$r_image = mysqli_fetch_array($q_image);
echo "\n";
echo "\n";
echo "\n";
echo "
\n";
echo "\n";
echo "\n";
}
echo "
" . cutText($r['text'], 800, $lng['blog_read_more'], "$proto$http_host/blog/$r[permalink]/") . "
\n"; # Tags (if any), date, and comment counter echo "| " . formatDate($r['dtime'], $lang, false) . " $tag_string | \n"; } else echo "" . formatDate($r['dtime'], $lang, false) . " | \n"; #Comment counter if ($r['comments'] == 1){ $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r[id] AND visible = 1;"); $r_comment = mysqli_fetch_array($q_comment); echo "\n"; if ($r_comment['count'] == 1) echo "1 $lng[blog_comments_1]\n"; else if ($r_comment['count'] == 0) echo " | $lng[blog_comments_0]\n"; else echo " | $r_comment[count] $lng[blog_comments_multiple]\n"; } echo " | \n"; echo "
... | \n";
for ($i = $cur_page - 2; $i < $cur_page; $i ++)
echo "\n"; } else for ($i = 1; $i < $cur_page; $i ++) echo " | \n"; echo " | $cur_page | \n";
if ($cur_page + 4 < $max_page){
for ($i = $cur_page + 1; $i < $cur_page + 3; $i ++)
echo ""; echo " | ... | "; } else for ($i = $cur_page + 1; $i <= $max_page; $i ++) echo " | "; echo " |