Файл: inc/user/mail.php
Строк: 183
<?
$title='Почта';
include_once '../system/config.php';
echo '<img src="http://subdomain.test1.ru/img/general.jpg">';
$req_ban = mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '".$ku['id']."' and `time` > ".time()."");
$ban = mysql_fetch_array($req_ban);
if(!empty($ban['id'])){
echo "<div class='block'><li class='major'><span>".($ban['izg']==1?'Изгнание':"Обет Молчания до ".vremja($ban['time']))."</span>";
echo "<span>, (".output_text($ban['msg']).")</span></li></div>";
} else {
if($ku['level']<=0){
err_game('Просматривать почту вы сможете с 5 уровня.');
include_once '../system/foot.php';
}else{
function cut_msg($text)
{
mb_internal_encoding("UTF-8");
$text = mb_substr($text, 0, 16);
return str_replace(';','',$text);
}
if(isset($_GET['dialog'])){
mysql_query("UPDATE `kolhoz_mail` SET `read` = '1' WHERE `id_user` = '".$ku['id']."' and `read` = '0'");
if(isset($_GET['get'])){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".hsc($_GET['dialog'])."'"));
if($ank['nick'] == ''){
err_game("Фермер ненайден");
}elseif($_POST['msg']==NULL){
err_game("Сообщение слишком короткое");
}elseif($ku['level']<=0) {
err_game("Писать можно с 15 уровня.");
}elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$ku[id]' LIMIT 1"),0)!=0){
err_game("Этот пользователь внес Вас в чёрный список, Вы не можете отправлять ему сообщения.");
}else{
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/list/".$ank['id']);
}
}
echo "<div class="message"><form action='/mail/list/get/".$_GET['dialog']."' method='post'>";
echo "Сообщение:<br><textarea rows='5' class='wide' name='msg'></textarea></label>";
echo "<input type='submit' value='Отправить'></form></div>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."' and `id_kont` = '".intval($_GET['dialog'])."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$req = mysql_query("SELECT * FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."' and `id_kont` = '".intval($_GET['dialog'])."' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($mail = mysql_fetch_array($req)){
$req_us = mysql_query("SELECT `nick`,`id`,`pol` FROM `kolhoz_user` WHERE `id` = '".($mail['type'] == 'at' ? $mail['id_user'] : $_GET['dialog'])."'");
$mail_us = mysql_fetch_array($req_us);
if($mail_us['pol'] == 1){
$pol = 'male';
}if($mail_us['pol'] == 0){
$pol = 'female';
}else{
$pol = 'male';
}
echo '<div class="message"><a href="/user/'.($mail['type'] == 'at' ? $mail['id_user'] : $_GET['dialog']).'" class="cor-icon"><div class="'.$pol.'"></div> <a href="/user/'.($mail['type'] == 'at' ? $mail['id_user'] : $_GET['dialog']).'">'.nc(($mail['type'] == 'at' ? $mail['id_user'] : $_GET['dialog'])).'</a> '.
'('.vremja($mail['time']).')<br />'.
output_text($mail['msg']) .'</div>';
}
echo '<a href="/mail/" class="flat-btn appleBlue font14" style="margin-top: 3px;">Все диалоги</a>';
echo '<center>';
if($k_page>1) str("/mail/list/".$_GET['dialog']."/",$k_page,$page);
echo '</center>';
include_once '../system/foot.php';exit;
}
if(isset($_GET['all'])){
mysql_query("UPDATE `kolhoz_mail` SET `read` = '1' WHERE `id_user` = '".$ku['id']."' and `type` = 'to'");
header("Location:/mail/");
}
if(isset($_GET['new_msg'])){
if(isset($_GET['get'])){
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `nick` = '".hsc($_POST['nick'])."'"));
if($ank['nick'] == ''){
err_game("Фермер ненайден");
}elseif($_POST['msg']==NULL){
err_game("Сообщение слишком короткое");
}elseif($ku['level']<=14) {
err_game("Писать можно с 15 уровня.");
}elseif($ku['nick']==$ank['nick']) {
err_game("Вы не можете написать сами себе");
}elseif(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ank[id]' AND `id_ank` = '$ku[id]' LIMIT 1"),0)!=0){
err_game("Этот пользователь внес Вас в чёрный список, Вы не можете отправлять ему сообщения.");
}else{
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/list/".$ank['id']);
}
}
$us_msg=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['us_msg'])."'"));
echo "<div class="block"><form action='/mail/new_msg/get/' method='post'>";
echo 'Ник:<br /><input type="text" name="nick" value="'.$us_msg['nick'].'"><br />';
echo "Сообщение:<br><textarea rows='5' class='wide' name='msg'></textarea></label>";
echo "<input type='submit' value='Отправить'></form></div>";
include_once '../system/foot.php';exit;
}
if(isset($_GET['info'])){
echo '<span id="ida1" style="display:none"></span>
<div class="flat-tabs tabs-blue">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="33%" align="center"><a class="i-tab" href="/mail/">Сообщения </a></td>
<td width="33%" align="center"><span class="i-tab" href="/mail/info/">Уведомления </span></td>
</tr>
</tbody>
</table>
</div><li class="message">';
$user['set'] = 10;
$post = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".$ku['id']."'"));
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `info_user` WHERE `id_user` = '".$ku['id']."'"),0);
if ($k_post==0)
{
echo "Нет инфо";
}
$k_page=k_page($k_post,$user['set']);
$page=page($k_page);
$start=$user['set']*$page-$user['set'];
$result = mysql_query("SELECT * FROM `info_user` WHERE `id_user` = '$post[id]' ORDER BY time DESC LIMIT $start, ".$user[set]);
while($msg = mysql_fetch_assoc($result)){
echo''.date('d.m.Y в H:i', $msg['time']).' '.($msg['status']).' <img src="/img/icons/ruby.png" alt="o">'.($msg[many]).' ('.($msg[kuda]).')<br>';
}
echo '</li><center>';
if ($k_page>1) str("/mail/info/",$k_page,$page);
echo '</center>';
include_once '../system/foot.php'; exit;
}
$req = mysql_query("SELECT DISTINCT `id_user`,`id_kont` FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."'");
$k_post = mysql_num_rows($req);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$req = mysql_query("SELECT DISTINCT `id_user`,`id_kont` FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo '<span id="ida1" style="display:none"></span>
<div class="flat-tabs tabs-blue">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="33%" align="center"><span class="i-tab" onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href="../../user/dialogs/"; } ;return false">Сообщения </span></td>
<td width="33%" align="center"><a class="i-tab" href="/mail/info/">Уведомления </a></td>
</tr>
</tbody>
</table>
</div><div class="flat-content bg-lightBrown mb0">
<a href="/mail/new_msg" class="flat-btn">Написать сообщение</a>
</div><ul class="row-list mb2">';
if(mysql_num_rows($req) > 0){
while($mail = mysql_fetch_array($req)){
$req_us = mysql_query("SELECT `nick`,`id`,`pol` FROM `kolhoz_user` WHERE `id` = '".$mail['id_kont']."'");
$mail_us = mysql_fetch_array($req_us);
$msg = mysql_fetch_array(mysql_query("SELECT `msg` FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."' and `id_kont` = '".$mail['id_kont']."' ORDER BY `id` DESC"));
$kol_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_mail` WHERE `id_user` = '".$ku['id']."' and `id_kont` = '".$mail['id_kont']."' and `read` = '0'"),0);
if($mail_us['pol'] == 1){
$pol = 'male';
}if($mail_us['pol'] == 0){
$pol = 'female';
}else{
$pol = 'male';
}
if($mail_us['nick'] == ''){
$mail_us['nick'] = 'Система';
}
echo '<li class="message"><a href="/user/'.$mail_us['id'].'" class="cor-icon"><div class="'.$pol.'"></div></a>
<div class="cor-body">
<span><a class="topic-nick" href="/mail/list/'.$mail['id_kont'].'"><span>'.$mail_us['nick'].'</span></a> '.($kol_new > 0 ? '+'.$kol_new : null).'</span>
<a href="/mail/list/'.$mail['id_kont'].'" class="cor-body-link">'.cut_msg($msg['msg']).'...</a>
</div>
<div class="service">
'.($kol_new > 0 ? '<font color="red">NEW</font>' : null).'
</div>
</li>';
}
echo '</ul>';
echo '<center>';
if($k_page>1) str("/mail/",$k_page,$page);
echo '</center>';
}else{
echo '<div class="block">нет новых сообщений</div>';
}
}}
include_once '../system/foot.php'; exit;
?>