<?
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();

if (isset($_POST['msg']) && isset($user))
{
$msg=output_text($_POST['msg']);
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
if (strlen2($msg)>1024){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `clubgo` WHERE `id_user` = '$user[id]' AND `msg` = '".output_text($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}
else{
$msg=mysql_escape_string($msg);
$msg=mysql_real_escape_string($_POST['msg']);


mysql_query("INSERT INTO `clubgo` (id_user, time, msg) values('$user[id]', '$time', '$msg')");
//mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
msg('Сообщение успешно добавлено');
}
}

err();
aut(); // форма авторизации

if (isset($user))
{
echo "<form method=\"post\" action=\"?\">\n";
echo "Сообщение:<a>  <a href='/smiles.php'>[Смайлы]</a><br />\n<input name=\"msg\" type=\"text\" maxlength='200' value='' />\n";
echo "<input value=\"Сказать\" type=\"submit\" />\n";
echo "</form>\n";




$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `clubgo`"),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 "Нет сообщений\n";
echo "  </td>\n";
echo "   </tr>\n";

}

$q=mysql_query("SELECT * FROM `clubgo` ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q))
{

$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));


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>\n";
}

if($num==1){ 
echo "<div class='rowdown'>"; 
$num=0;
}else{ 
echo "<div class='rowup'>"; 
$num=1;}


echo "".online($ank['id'])."<a href='/info.php?id=$ank[id]'><span style=\"color:$ank[color]\">$ank[nick]</span></a> (".vremja($post['time']).")\n";
echo "  </br>\n";

if ($set['set_show_icon']==1)


echo "<span style=\"color:$ank[scolor]\">\n";

echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />\n";

if (user_access('guest_delete'))
echo "<a href='del.php?id=$post[id]'>x</a><br />\n";
echo "</span>\n";

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

echo "</div>\n";



if ($k_page>1)str('?',$k_page,$page); // Вывод страниц


echo '<a href="/gorod/">В город</a></div>';
}
include_once '../sys/inc/tfoot.php';
?>
