File size: 4.3Kb
<?
if (!isset($_GET['id']))
{
echo "<div class=\"h\">Входящие</div><hr />\n";
$k_mess=0;
$q = mysql_query("SELECT * FROM `$mysql[pref]mail` WHERE `id_in_user` = '$user[id]';");
while ($messagess = mysql_fetch_array($q))
{
$mess[$k_mess]=$messagess;
$k_mess++;
}
$k_p_str=$user['forum_k_p_s'];
if (isset ($mess) && count($mess)!="0")
{
$v_pages_okr=count($mess)/$k_p_str%100;
$v_pages_tochn=count($mess)/$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 ($mess, "stime");
$mess=array_reverse($mess);
for ($i=$k_p_str*$page-$k_p_str;$i<$k_mess && $i<$k_p_str*$page;$i++)
{
$timep=vremja($mess[$i]['time']+$timesdvig);
echo "<div class=\"mess\">\n";
$mess_id=$mess[$i]['id'];
if ($mess[$i]['read']==0)
{
echo "<img src=\"SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> ";
}
else
{
echo "<img src=\"SYSTEM/themes/$them/img/mail1.gif\" alt=\"\" /> ";
}
echo " <a href=\"mail.php?act=in&id=$mess_id\"><span style=\"color:$color[mess_nick]\"><b>".$mess[$i]['nick']."</b></span></a> ";
echo "<span style=\"color:$color[post_time]\">[$timep]</span>";
echo "</div>\n";
}
echo "<hr />\n<div class=\"str\">";
echo "Стр: [";
if ($page!=1)
{
echo "<a href=\"mail.php?act=in&page=1\">1</a>";
}
else
{
echo "<b>1</b>";
}
$in=-3;
$out=3;
for ($ot=$in; $ot<=$out; $ot++)
{
$t_str=$page+$ot;
if ($t_str>1 && $t_str<$k_page)
{
if ($in==$ot && $t_str>2)
{
echo " ..";
}
if ($ot!=0)
{
echo " <a href=\"mail.php?act=in&page=$t_str\">$t_str</a>";
}
else
{
echo " <b>$t_str</b>";
}
if ($ot==$out && $t_str<$k_page-1)
{
echo " ..";
}
}
}
if ($page!=$k_page)
{
echo " <a href=\"mail.php?act=in&page=end\">$k_page</a>";
}
elseif ($k_page>1)
{
echo " <b>$k_page</b>";
}
echo "]";
echo "</div>\n";
}
else
{
echo "Нет сообщений<br />\n";
}
echo "<hr />";
if ($k_mess>0)
{
echo "<a href=\"mail.php?act=del_in\">Очистить ящик</a><br />\n";
}
echo "<a href=\"mail.php\"><< Почта</a><br />\n";
echo "<a href=\"index.php\"><< На главную</a>\n";
foot();
}
$id_mess=intval($_GET['id']);
echo "<div class=\"h\">Входящее сообщение</div><hr />\n";
$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]mail` WHERE `id_in_user` = '$user[id]' AND `id` = '$id_mess';");
if(mysql_result($q, 0)==0){header ("Location: mail.php?".SID."&act=in");exit;}
$q = mysql_query("SELECT * FROM `$mysql[pref]mail` WHERE `id_in_user` = '$user[id]' AND `id` = '$id_mess' LIMIT 1;");
$mess = mysql_fetch_array($q);
echo "<div class=\"mess\">\n";
echo "<img src=\"SYSTEM/themes/$them/img/mail1.gif\" alt=\"\" /> ";
echo " <a href=\"info.php?id=$mess[id_out_user]\"><span style=\"color:$color[mess_nick]\"><b>$mess[nick]</b></span></a>";
$timep=vremja($mess['time']+$timesdvig);
echo "<br />\n";
echo "<span style=\"color:$color[post_time]\">[$timep]</span>";
echo "<br />\n";
echo "<span style=\"color:$color[post]\">".smiles(links(mess($mess['text'])))."</span><br />";
echo "<a href=\"mail.php?act=crt&id=$mess[id_out_user]\">Ответить</a> | ";
echo "<a href=\"mail.php?act=del_in&mess=$mess[id]\">Удалить</a><br />\n";
echo "<a href=\"mail.php?act=crt&id=$mess[id_out_user]&id_mess=$id_mess\">Ответ + цитата</a>";
echo "</div><hr />\n";
mysql_query("UPDATE `$mysql[pref]mail` SET `read` = '1' WHERE `id` = '$id_mess';");
$q = mysql_query("SELECT COUNT(id) FROM `$mysql[pref]kont` WHERE `id_user` = '$user[id]' AND `id_kont` = '$mess[id_out_user]';");
if (mysql_result($q, 0)==0)
{
echo "<a href=\"mail.php?act=kont&id=$mess[id_out_user]\">В контакты</a><br />\n";
}
echo "<a href=\"mail.php?act=in\"><< Входящие</a><br />\n";
echo "<a href=\"mail.php\"><< Почта</a><br />\n";
echo "<a href=\"index.php\"><< На главную</a>\n";
foot();
?>