<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';


$set['title']='Блоги';
include_once '../sys/inc/thead.php';
title();
err();
aut();


if (isset($_GET['sort']) && $_GET['sort'] =='t')$order='order by `time` desc';
elseif (isset($_GET['sort']) && $_GET['sort'] =='c') $order='order by `count` desc';
else $order='order by `time` desc';

echo'<div class="str">';
echo"<a href='?sort=t'>Последние</a><br /><a href='?sort=c'>Популярные</a><br />\n";
echo '</div>';

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_list` WHERE `privat` = 0"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";


if($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Блоггеров пока нет<br />";
echo "  </td>\n";
echo "   </tr>\n";
}

$res = mysql_query("select * from `blog_list` WHERE `privat` = 0 $order LIMIT $start, $set[p_str];"); 
while ($blog = mysql_fetch_array($res)){


$ank=get_user($blog['id_user']);
echo "   <tr>\n";
if ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";
avatar($ank['id']);
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "  <td class='icon14'>\n";
echo "<img src='/style/themes/$set[set_them]/user/$ank[pol].png' alt='' />";
echo "  </td>\n";
}
echo "  <td class='p_t'>\n";
echo "<a href='user.php?id=$ank[id]'>$ank[nick]</a>".online($ank['id'])." (".vremja($blog['time']).")\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";

if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";
echo "<a href='list.php?id=".$blog['id']."'>".output_text($blog['name'])."</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_blog` = '$blog[id]'"),0)."/".mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_files` WHERE `id_blog` = '$blog[id]'"),0).")<br />\n";
echo"Просмотров: ".$blog['count']."<br />\n";




echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";

if (isset($_GET['sort'])) $dop="sort=$_GET[sort]&amp;";
else $dop='';
if ($k_page>1)str('?'.$dop.'',$k_page,$page); // Вывод страниц


if(isset($user))
{
echo'<div class="foot">';

echo "<a href=\"user.php\">Мой блог</a><br />";
echo "<a href=\"add.php\">Добавить запись в блог</a><br />";
echo '</div>';
}




include_once '../sys/inc/tfoot.php';

?>