File size: 5.95Kb
<?
require_once '../core/system.php';
$header = 'Мои сообщения';
$req = mysql_query("SELECT * from `ban` where `id_us` = '".$user['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$ban = mysql_fetch_array($req);
if($ban['ban'] == 3){
header('Location: /moduls/ban');
}
if($ban['ban'] == 2){
header('Location: /');
$_SESSION['err'] = "Вы находитесь в бане!";
exit;
}
if(!isset($user['id'])) header('Location: /');
require_once '../core/head.php';
mysql_query("DELETE FROM `mail` WHERE timer<='".$tm."' ");
mysql_query("DELETE FROM `users_konts` WHERE timer<='".$tm."' ");
mysql_query("DELETE FROM `mail` WHERE `del_user`>'0' and `del_kont`>'0' ");
mysql_query("UPDATE `user` set `mesto` = 'Почта' where `id` = '".$user['id']."'");
if($user['save'] < 1){
header('Location: /');
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_user` = '".$user['id']."' and `del`!='".$user['id']."'"),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
$q = mysql_query("SELECT * FROM `users_konts` WHERE `id_user` = '".$user['id']."' and `del`!='".$user['id']."' ORDER by `time` DESC LIMIT ".$start.", 10");
echo"<div class='foot'>
<div class='menuList'>
<span class='float-left'>
<a href='/user/friends'>
<img src='/images/icon/friends.png'>
Мои друзья
</a>
</span>
<span class='float-right'>
<a href='/user/ignor'>
<img src='/images/icon/ignor.png'>
Черный список
</a>
</span>
</div>
</br>
<div class='empty'></div>
<div class='empty2'></div>
<div class='empty'></div>
</div>
<hr>
<a class='mli' href='/user/new'>
<center>
<div class='empty2'></div>
Написать сообщение
<div class='empty2'></div>
</a>
</center>";
if($k_post == 0)echo "<hr><div class='player grey'>Нет сообщений</div>";
if($k_post > 0)echo "<hr>";
while ($post = mysql_fetch_array($q)){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = ".$post['id_kont']." LIMIT 1"));
$mess = mysql_query("SELECT * FROM `mail` WHERE `id_user` = '".$user['id']."' AND `id_kont` = '".$ank['id']."' and `del_user`!='".$user['id']."' and `del_kont`!='".$user['id']."' OR `id_user` = '".$ank['id']."' AND `id_kont` = '".$user['id']."' and `del_user`!='".$user['id']."' and `del_kont`!='".$user['id']."' ORDER BY id DESC LIMIT 1");
$msg = mysql_fetch_array($mess);
if($msg['read'] == 1) $color = 'white';
if($msg['read'] == 0) $color = 'grey';
if(isset($_GET['del'])){
$id_chmsg = intval($_GET['id']);
$sms1 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '".$user['id']."' and `id_kont`= '".$id_chmsg."'"));
$sms2 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_kont`= '".$user['id']."' and `id_user` = '".$id_chmsg."'" ));
if($sms1 > 0){
mysql_query("UPDATE `mail` SET `del_user` = '".$user['id']."' WHERE `id_user` = '".$user['id']."' and `id_kont`= '".$id_chmsg."'");
mysql_query("UPDATE `users_konts` SET `del` = '".$user['id']."', `new_msg`='0' where `id_kont` = '".$id_chmsg."' and `id_user` = '".$user['id']."'");
}
if($sms2 > 0){
mysql_query("UPDATE `mail` SET `del_kont` = '".$user['id']."' WHERE `id_kont` = '".$user['id']."' and `id_user` = '".$id_chmsg."'");
mysql_query("UPDATE `users_konts` SET `del` = '".$user['id']."', `new_msg`='0' where `id_user` = '".$user['id']."' and `id_kont` = '".$id_chmsg."'");
}
$_SESSION['message'] = 'Переписка удалена!';
header('Location: /user/newmsg');
}
if(isset($_GET['alldel'])){
$id_chmsg = intval($_GET['id']);
$sms1 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '".$user['id']."'"));
$sms2 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_kont`= '".$user['id']."'" ));
if($sms1 > 0){
mysql_query("UPDATE `mail` SET `del_user` = '".$user['id']."' WHERE `id_user` = '".$user['id']."'");
mysql_query("UPDATE `users_konts` SET `del` = '".$user['id']."', `new_msg`='0' where `id_user` = '".$user['id']."'");
}
if($sms2 > 0){
mysql_query("UPDATE `mail` SET `del_kont` = '".$user['id']."' WHERE `id_kont` = '".$user['id']."'");
mysql_query("UPDATE `users_konts` SET `del` = '".$user['id']."', `new_msg`='0' where `id_user` = '".$user['id']."'");}
$_SESSION['message'] = 'Все сообщения удалены!';
header('Location: /user/newmsg');
}
if($ank['prava'] == 5){
$status = "<font color='ffc22b'>[A]</font>";
$tcolor = 'F7990D';
}
if($ank['prava'] == 4){
$status = "<font color='ffc22b'>[a]</font>";
$tcolor='EBC621';
}
if($ank['prava'] == 3){
$status = "<font color='ffc22b'>[M]</font>";
}
if($ank['prava'] == 2){
$status = "<font color='ffc22b'>[m]</font>";
}
echo"<div class='news'>
<a style='border-left: 1px solid #2C2C2C;' class='news-close' href='?del&id=".$ank['id']."'>
</a>
<div class='player menuList'>
<li>
<a href='mail?id=".$ank['id']."'>";
echo online($ank['id']);
echo"<font color='".$ank['font']."'>".$ank['nick']."</font> ";
if($ank['prava'] >= 2){
echo $status;
}
echo" <span class='grey'>[".vremja($msg['time'])."]</span>";
if($ank['prava'] < 4){
echo"<br>
<span class='".$color."'>".rez_text(antimat($msg['msg']))."
</span>
</a>
</div>
</div>
</li>
<hr>";
}
if($ank['prava'] >= 4){
echo "<br><span class='".$color."'>".rez_text(($msg['msg']))."</span></a></div></div></li><hr>";
}
}
$req = mysql_query("SELECT * FROM `note` WHERE `id_user` = '".$user['id']."'");
$note = mysql_num_rows($req);
if($k_post == 0)echo"<hr>";
echo "<div class='but-list-light center'>
<a href='/moduls/note'>
<img src='/images/icon/st.png' width=12 height=12> Открыть блокнот (".$note."/20)
</div>
</a>
</font>
</div>
<hr>
<div class='foot grey'>
<center>
Сообщения хранятся 15 дней. Далее они автоматически удаляются.
</center>
</div>";
if($k_page > 1)echo"<hr>";
if($k_page > 1)str('?',$k_page,$page);
echo"<hr>
<div class='but-list-light'>
<a href='?alldel'>
<img src='/images/icon/error.png'> Удалить все сообщения
</div>
</a>";
require_once '../core/foot.php';
?>