<?
require_once ('../system/func.php');
$id = num($_GET['id']);
$prof = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."'"));
$set['p_str'] = 10;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE (`in` = '$prof[id]' && `out` = '$user[id]') or (`in` = '$user[id]' && `out` = '$prof[id]')"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `mail` WHERE (`in` = '$prof[id]' && `out` = '$user[id]') or (`in` = '$user[id]' && `out` = '$prof[id]') ORDER BY `id` DESC LIMIT $start, $set[p_str]");
if($k_post == 0) echo "<div class='block'>Сообщений не найдено...</div>";
mysql_query("update `mail` set `online` = '0' WHERE `in` = '".$prof['id']."' && `out` = '".$myID."'");
mysql_query("UPDATE `kont` SET `new_msg` = '0' WHERE `id_kont` = '$ank[id]' AND `id_user` = '$myID' LIMIT 1");
while($post = mysql_fetch_assoc($q)) {
echo "<div class='block'>";
if($post['online'] == 1)$color = 'green';
else $color = '#A8A8A8';
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[in] LIMIT 1"));
if($ank['id'] == 0){
$ank['id'] = 0;
$ank['login'] = '<span class="grey">Система</span>';
$ank['access'] = 2;
}
if($ank['id'] != 0)echo icons_user($ank[id])." <a href='/profile/$ank[id]'>$ank[login]</a>, <font color='$color'>".vremja($post['time'])."</font><br>".text_msg($post['text'])."";
else echo "$ank[login], <font color='$color'>".vremja($post['time'])."</font><br>".text_msg($post['text'])."";
echo '</div>';
}
?>