<?
if ($mp!=1)
{
$mp=0;

include_once "../SYSTEM/include/functions.php";
include_once "../SYSTEM/include/mysql.php";
include_once "../SYSTEM/include/param.php";
include_once "../SYSTEM/include/ban.php";
include_once "../SYSTEM/include/sess.php";
include_once "../SYSTEM/include/ban_2.php";
include_once "../SYSTEM/include/theme.php";

$title='Гостевая';
$mesto='Гостевая книга';
head();
}

if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";
echo "<div class=\"title\">общайся вместе с нами</div><hr />\n";

echo "<a href=\"".BASEDIR."PAGES/smiles.php\">смайлы</a>|<a href=\"".BASEDIR."PAGES/bb-codes.php\">бб-коды</a>|<a href=\"".BASEDIR."guest/reload.php\">обновить</a><br />\n";
if ($mp==1)
{
echo "[+]<a href=\"guest/index.php\">*полная версия*</a>[<b>";
include "guest/count.php";
echo "</b>]<br />";
}
echo "<hr />\n";
if (isset($_GET['err']))
{
$err=$_GET['err'];
echo "<span style=\"color:$color[msg]\"><b>";

echo "</b></span><br/>";
}

$shut=0;
$umnik=0;


if ($shut==1) include BASEDIR."guest/shut.php";
if ($umnik==1) include BASEDIR."guest/umnik.php";


$q = mysql_query("SELECT * FROM `$mysql[pref]chat_main`;");
$k_post=0;
$k_page=1;
while ($posts = mysql_fetch_array($q))
{
$post[$k_post]=$posts;
$k_post++;
}
if (isset($user))
{
$k_p_str=$user['k_page'];
}
else
{
$k_p_str=$set['k_p_s'];
}
if (isset ($post) && count($post)!="0")
{
$v_pages_okr=count($post)/$k_p_str%100;
$v_pages_tochn=count($post)/$k_p_str;
if ($v_pages_okr==$v_pages_tochn)
{
$k_page=$v_pages_okr;
}
else
{
$k_page=$v_pages_okr+1;
}


//echo "Количество страниц: $k_page<br />";
//echo "Количество сообщений: ".count($post)."<br /><br />";
$page=1;
if (isset($_GET['page']) && $_GET['page']!='')
{
if ($_GET['page']=='end')
{
$page=$k_page;
}
else
{
$page=intval($_GET['page']);
}
}
$page=intval($page);
if ($k_page<$page){$page=$k_page;}
if (0>$page){$page=1;}

usort ($post, "stime");
$post=array_reverse($post);


for ($i=$k_p_str*$page-$k_p_str;$i<$k_post && $i<$k_p_str*$page;$i++)
{
$timep=vremja($post[$i]['time']+$timesdvig);


echo "<div class=\"mess\">\n";

if (isset($user) && $user['level']>0 && $user['slinks']==0)
echo "<a href=\"".BASEDIR."guest/set.php?id_post=".$post[$i]['id'].(($mp==1) ? '&amp;mp' : '')."\">\n";

if ($post[$i]['id_user']!=0)user_pic($post[$i]['id_user']);
//else echo "<br /><img src=\"".BASEDIR."SYSTEM/themes/$them/img/user/pol_.gif\" alt=\"\" />";
else echo "<br /><img src=\"".BASEDIR."SYSTEM/images/smiles/novichek.gif\" alt=\"\" />";

if (isset($user) && $user['level']>0 && $user['slinks']==0)echo "</a>\n";


$id_us=$post[$i]['id_user'];
if ($id_us!=0)
echo " ".user_nick($id_us, BASEDIR."guest/user.php?id_user=$id_us".(($mp==1) ? '&amp;mp' : ''));
else
echo " <a href=\"".BASEDIR."guest/user.php?id_user=$id_us".(($mp==1) ? '&amp;mp' : '')."\"><span style=\"color:$color[mess_nick]\"><b>Гость</b></span></a>\n";

echo "<br />\n";
echo "<span style=\"color:$color[post_time]\">[$timep]</span>";
echo "<br />\n";

$post_user_id=$post[$i]['id_user'];
$q = mysql_query("SELECT * FROM `$mysql[pref]users` WHERE `id` = '$post_user_id';");
$post_user = mysql_fetch_array($q);

if ($post_user['level']>0)
echo "<span style=\"color:$color[post]\">".bbcode(admin_smiles(smiles(links($post[$i]['text']))))."</span>";
else
echo "<span style=\"color:$color[post]\">".bbcode(smiles(links($post[$i]['text'])))."</span>";


if ($post[$i]['id_user']==0 && $post[$i]['nick']!=$nick_shut && $post[$i]['nick']!=$nick_umn)
{
echo "<br />".$post[$i]['ua'];
echo " | ".$post[$i]['ip'];

if (isset($user) && $user['level']>1)
{
echo "<a href=\"".BASEDIR."guest/set.php?act=del&amp;id_post=".$post[$i]['id']."\">[X]</a>";
echo "<a href=\"".BASEDIR."admin_dfbdaba8c8508412d239e603506162f8/ban.php?ip=".$post[$i]['ip']."\">[BAN]</a>";
}
}



echo "</div>\n";
echo "<br />\n";
}
}
else
{
echo "Нет постов<br />\n";
}

if($mp==0)
{
echo "<hr />\n<div class=\"str\">";

str("index.php?",$k_page,$page);

echo "</div>\n";

}


echo "<hr />\n";

echo "<form method=\"post\" action=\"".BASEDIR."guest/add.php?act=add".(($mp==1) ? '&amp;mp' : '')."\">\n";

echo "Сообщение:<br />\n<textarea name=\"msg\" class=\"form\" rows=\"3\"></textarea><br />\n";if(!isset($user)){$chislo = rand(100,999);

$_SESSION['chislo']=$chislo;echo "&#x041F;&#x0440;&#x043E;&#x0432;. &#x0447;&#x0438;&#x0441;&#x043B;&#x043E;:<br /><b>".$chislo."</b>: <input name=\"chislo\" size=\"3\" maxlength=\"3\" value=\"\" type=\"text\" /><br />\n";}

//echo "<input type=\"checkbox\" name=\"tr\" value=\"1\" /> Транслит<br />\n";

echo "<input type=\"hidden\" name=\"umnik\" value=\"$umnik\" /><br />\n";

echo "<input value=\"добавить сообщение\" class=\"form\" type=\"submit\" />\n";



echo "</form>";

echo "<hr />\n";



if ($mp==0)

{

if (isset($user) && $user['level']>0 && $user['slinks']==0)echo "<a href=\"clear.php\">Очистка гостевой</a><br />\n";
echo "<a href=\"../index.php\">&lt;&lt; На главную</a>\n";
foot();
}
?>
