<?
/*
=============================================
 Движок:  SHCMS Engine
=============================================
 Название файла: Форум
=============================================
 Official website: http://shcms.ru
=============================================
 Данный код защищен авторскими правами
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
$shcmsengine['title'] = 'Форум - Моя статистика';
include_once'../template/head.php';
if(!$user_id)
{
errors("Статистика доступна только для пользователей");
include_once'../template/foot.php';
exit;
}
switch($act):

case '':

$them = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_them` WHERE `user_id` = '$user_id'"),0);
$message = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_mess` WHERE `id_user` = '$user_id'"),0);


echo '<div class="posts">Мои темы: <a href="?act=them"><strong>'.$them.'</strong></a></div>';
echo '<div class="posts">Мои посты: <a href="?act=message"><strong>'.$message.'</strong></a></div>';

break;



case'them':

$thems = mysql_query("SELECT * FROM `forum_them` WHERE `user_id` = '$user_id'");
if(mysql_num_rows($thems) == 0)
{
errors("У вас нет тем на форуме");
include_once'../template/foot.php';
exit;
}
while($them = mysql_fetch_array($thems))
{
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_mess` WHERE `id_them` = '$them[id]'"),0);
echo '<div class="posts"><img src="icon/icon_them/them.gif"> <a href="message.php?id='.$them['id'].'">'.$them['name'].'</a><span class="count">'.$count.'</span></div>';

}


break;


case'message':

$mess = mysql_query("SELECT DISTINCT (`id_them`) FROM `forum_mess` WHERE `id_user` = '$user_id'");
if(mysql_num_rows($mess) == 0)
{
errors("У вас нет постов на форуме");
include_once'../template/foot.php';
exit;
}
while($messag = mysql_fetch_array($mess))
{
$thems = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id` = '$messag[id_them]'"));

$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_mess` WHERE `id_them` = '$thems[id]' AND`id_user` = '$user_id'"),0);

echo '<div class="posts"><img src="icon/icon_them/them.gif"> <a href="message.php?id='.$thems['id'].'">'.$thems['name'].'</a><span class="count">'.$count.'</span></div>';

}
break;

endswitch;


include_once'../template/foot.php';
?>