# Подтверждение

- Вы уверены?
- Да, подтверждаю
- Нет, отказываюсь

"; } elseif(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['del'])."' AND `id_user` = '$ku[id]' LIMIT 1"),0)!=0) { mysql_query("DELETE FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['del'])."'"); header("Location:?mail"); } elseif(isset($_GET['msg']) && intval($_GET['msg'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['msg'])."' AND `id_user` = '$ku[id]' LIMIT 1"),0)!=0) { $msg=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_mail` WHERE `id` = '".intval($_GET['msg'])."' AND `id_user` = '$ku[id]' LIMIT 1")); if($msg['type']=='to' && $msg['read']==0) { mysql_query("UPDATE `kolhoz_mail` SET `read` = '1' WHERE `id` = '$msg[id]'"); mysql_query("UPDATE `kolhoz_mail` SET `read` = '1' WHERE `id` = '".($msg['id']+1)."'"); header("Location:?mail&msg=$msg[id]"); } $ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$msg[id_kont]'")); $anku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ank[id_user]'")); echo "

# Просмотр сообщения

"; echo '
'; echo "

- ".($msg['type']=='to'?"От":"Кому").": "; if($msg['id_kont']!=0)echo on_k($anku['id']); echo " ".($msg['id_kont']==0?"Почтовый Сервис":"".nc($ank['id'])."")."

- ".output_text($msg['msg'])."

- ".vremja($msg['time'])."
".($msg['id_kont']==0?"":"
- Ответить")." Удалить Удалить все Переписка

";} elseif(isset($_GET['new_msg'])) { if(isset($_GET['ok']) && isset($_POST['nick']) && isset($_POST['msg'])) { if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` = '".htmlspecialchars($_POST['nick'])."'"),0)!=0) { $anku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '".htmlspecialchars($_POST['nick'])."'")); $ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id_user` = '$anku[id]'")); } if(!isset($ank)) { $err=1; echo "Фермер ненайден"; } if($_POST['msg']==NULL) { $err=1; echo "Сообщение слишком короткое"; } if(!isset($err)) { mysql_query("INSERT INTO `kolhoz_mail` SET `id_user` = '$ank[id]', `id_kont` = '$ku[id]', `msg` = '".my_esc($_POST['msg'])."', `time` = '$time', `type` = 'to'"); mysql_query("INSERT INTO `kolhoz_mail` SET `id_user` = '$ku[id]', `id_kont` = '$ank[id]', `msg` = '".my_esc($_POST['msg'])."', `time` = '$time', `type` = 'at', `read` = '1'"); $_SESSION['msg_ok']=1; $_SESSION['msg_okk']=$ank['id']; header("Location:?mail"); } } else { if($_GET['new_msg']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['new_msg'])."'"),0)!=0 && is_numeric(intval($_GET['new_msg']))) { $ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['new_msg'])."'")); $anku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ank[id_user]'")); } } echo "

# Почта

"; echo '
'; echo "
Кому:
Сообщение:
"; } else { if(isset($_GET['history']) && intval($_GET['history'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['history'])."'"),0)!=0) { $history=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['history'])."'"),0); $historyu=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$history[id_user]'")); } echo "

# Почта

"; if(isset($_SESSION['msg_ok'])) { $ak=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_SESSION['msg_okk'])."'")); $aku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ak[id_user]'")); echo "
Ваше сообщение отправлено '$aku[nick]'.
"; unset($_SESSION['msg_ok']); unset($_SESSION['msg_okk']); } echo '
'; echo "

"; if(!isset($history))echo "
- ".(isset($_GET['new'])?"":null)."Все".(isset($_GET['new'])?"":null)." | ".(!isset($_GET['new'])?"":null)."Новые".(!isset($_GET['new'])?"":null)."
"; $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE ".(isset($history)?"`id_kont` = '$history[id]' AND `id_user` = '$ku[id]'":"".(isset($_GET['new'])?"`read` = '0' AND ":null)."`id_user` = '$ku[id]'").""),0); if ($k_post==0) { echo "".(isset($history)?"У вас нету переписки с $historyu[nick]":"Список пуст...").""; } $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 `kolhoz_mail` WHERE ".(isset($history)?"`id_kont` = '$history[id]' AND `id_user` = '$ku[id]'":"".(isset($_GET['new'])?"`read` = '0' AND ":null)."`id_user` = '$ku[id]'")." ORDER BY `time` DESC LIMIT $start, $set[p_str]"); while($post=mysql_fetch_array($q)) { $ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_kont]'")); $anku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ank[id_user]'")); echo "
- "; if($post['id_kont']!=0)echo on_k($anku['id']); echo " ".($post['id_kont']==0?"Почтовый Сервис":"".nc($ank['id'])."")." (".vremja($post['time']).")
  ".cut_msg($post['msg'])."...
  читать
"; } if($k_page>1)str("?mail".(isset($_GET['new'])?"&new":null)."".(isset($history)?"&history=$history[id]":null)."&",$k_page,$page); // Вывод страниц echo "

"; echo "

- Написать письмо
"; if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0) echo "
- Отметить все как прочитанные
"; echo "
- Удалить все прочитанные
- Внимание! Сообщения хранятся в почте 30 дней, по истечении срока жизни сообщения удаляются автоматически.

"; } ?>