View file sdark.mobi/adm_root/amail2.php

File size: 3.87Kb
<?
require_once '../core/system.php';
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['id'])."'"));
}
$header = 'Сообщения';
echo admin();
require_once '../core/head.php';

if(intval($_GET['id'])==1 && $user['id'] != 11 && $user['prava']<5){header("Location: /"); exit;}
if(intval($_GET['id'])==500  && $user['prava']<5){header("Location: /"); exit;}


if(isset($_GET['alldel'])){
$sms1 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$ank[id]'"));
$sms2 = mysql_num_rows(mysql_query("SELECT * FROM `mail` WHERE `id_kont`= '$ank[id]'" ));
if($sms1>0){
mysql_query("UPDATE `mail` SET `del_kont` = '$ank[id]' WHERE `id_kont` = '$ank[id]'");
mysql_query("UPDATE `mail` SET `del_user` = '$ank[id]' WHERE  `id_user` = '$ank[id]'");
mysql_query("UPDATE `users_konts` SET `del` = '$ank[id]', `new_msg`='0' where `id_user` = '$ank[id]'");
}
if($sms2>0){
mysql_query("UPDATE `mail` SET `del_kont` = '$ank[id]' WHERE `id_kont` = '$ank[id]'");
mysql_query("UPDATE `users_konts` SET `del` = '$ank[id]', `new_msg`='0' where `id_user` = '$ank[id]'");}
$_SESSION['message'] = 'Все отправленные сообщения удалены!';
header('Location: /'); 
}

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_user` = '".intval($_GET['id'])."' and `del`!='".intval($_GET['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` = '".intval($_GET['id'])."' and `del`!='".intval($_GET['id'])."' ORDER by `time` DESC LIMIT $start, 10");

if($k_post == 0)echo "<div class='player grey'>Нет сообщений</div>";

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` = '".intval($_GET['id'])."' AND `id_kont` = '$ank[id]' and `del_user`!='".intval($_GET['id'])."' and `del_kont`!='".intval($_GET['id'])."' OR `id_user` = '$ank[id]' AND `id_kont` = '".intval($_GET['id'])."' and `del_user`!='".intval($_GET['id'])."' and `del_kont`!='".intval($_GET['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($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'><div class='player menuList'><li><a href='amail3?id=$ank[id]&ank=".intval($_GET['id'])."'>";
echo online($ank['id']);
echo"<font color='$ank[font]'>$ank[nick]</font>";
if($ank['prava']>1){echo" $status";}
echo " <span class='grey'>[".vremja($msg['time'])."]</span>";
echo "<br><span class='$color'>".rez_text($msg['msg'])."</span></a></div></div></li><hr>";
}

$req = mysql_query("SELECT * FROM `note` WHERE `id_user` = '".intval($_GET['id'])."'");
$note=mysql_num_rows($req);
if($k_post==0)echo"<hr>";
echo "<div class='but-list-light'><a href='anote?id=".intval($_GET['id'])."'><img src='/images/icon/st.png' width=12 height=12> Посмотреть блокнот ($note/20)</div></a>

</font></div><hr><div class='foot grey'><center>Сообщения хранятся 30 дней. Потом они автоматически удаляются. </center></div>
";
if ($k_page>1)echo"<hr>";
if ($k_page>1)str('?id='.intval($_GET['id']).'&',$k_page,$page); echo"<hr>";

echo "<div class='but-list-light'><a href='?alldel'><img src='/images/icon/error.png'> Удалить отправленные сообщения</div></a>";
require_once '../core/foot.php';
?>