Файл: inc/user/list_msg.php
Строк: 161
<?php
$title='Почта';
include_once '../system/config.php';
if($ban['id']){echo "<div class='block'><li class='major'><span>".($ban['izg']==1?'Изгнание':"Обет Молчания до ".vremja($ban['time']))."</span>, выдал".($us_ban['pol']==0?'a':null)." <span>"; echo on_k($us_ban['id']); echo "<a href='?user=$us_ban[id]'>".nc($us_ban['id'])."</a></span><span>, (".output_text($ban['msg']).")</span></li></div>";} else {
if($ku['level']<=0){
err_game('Просматривать почту вы сможете с 5 уровня.');
include_once 'inc/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['new_msg'])){
echo '<div>
<div class="flat-content mb0 bg-brown">
<span class="text-bold font12">Новое сообщение</span>
</div>
<div class="flat-content bg-lightBrown">
<form id="id13" method="post" action="/mail/new"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"></div>
<p style="margin: 0;">
<input class="w95p font12 dialogs" type="text" name="nick" placeholder="Введите имя">
</p>
<p style="margin: 0;">
<textarea class="w95p font12 dialogs" class="wide" rows="3" name="text" placeholder="Текст сообщения"></textarea>
</p>
<table class="mb5 mt2" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="79%">
<input class="flat-btn" type="submit" id="id14" value="Отправить">
</td>
<td></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>';
include_once '../system/foot.php'; exit;
}
if(isset($_GET['id_kontakt'])){
$req_us = mysql_query("SELECT `nick` FROM `kolhoz_user` WHERE `id` = '".intval($_GET['id_kontakt'])."'");
$us = mysql_fetch_array($req_us);
mysql_query("UPDATE `list_msg` SET `read` = '1' WHERE `kto` = '".intval($_GET['id_kontakt'])."' and `komu` = '".$ku['id']."'");
if(isset($_POST['text'])){
if(empty($_POST['text'])){
$_SESSION['msg'] = 'Вы не ввели сообщение!';
header('Location: /mail/list/'.$_GET['id_kontakt']); exit;
}
mysql_query("INSERT INTO `list_msg` SET
`text` = '".mysql_real_escape_string($_POST['text'])."',
`kto` = '".$ku['id']."',
`komu` = '".intval($_GET['id_kontakt'])."',
`date` = '".time()."',
`read` = '0'");
header('Location: /mail/list/'.$_GET['id_kontakt']);
}
echo '<div>
<div class="flat-content mb0 bg-brown">
<span class="text-bold font12">Переписка с '.$us['nick'].'</span>
</div>
<div class="flat-content bg-lightBrown">
<div class="mb5">
<a href="/mail/list/'.$_GET['id_kontakt'].'">Обновить</a>
</div>
<form id="id13" method="post" action="/mail/list/'.$_GET['id_kontakt'].'"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"></div>
<p style="margin: 0;">
</p>
<p style="margin: 0;">
<textarea class="w95p font12 dialogs" rows="3" name="text" placeholder="Текст сообщения"></textarea>
</p>
<table class="mb5 mt2" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="79%">
<input class="flat-btn" type="submit" id="id14" value="Отправить">
</td>
<td></td>
</tr>
</tbody>
</table>
</form>
</div>
</div><ul class="row-list mb2">';
$req_msg = mysql_query("SELECT * FROM `list_msg` WHERE `komu` = '".$ku['id']."' and `kto` = '".intval($_GET['id_kontakt'])."' or (`kto` = '".$ku['id']."' and `komu` = '".intval($_GET['id_kontakt'])."') ORDER BY `id` DESC");
while($msg = mysql_fetch_array($req_msg)){
$req_us = mysql_query("SELECT `nick`,`id` FROM `kolhoz_user` WHERE `id` = '".$msg['kto']."'");
$mail_us = mysql_fetch_array($req_us);
echo '<li class="message">
<div class="cor-body">
<span><a class="topic-nick" href="/user/'.$mail_us['id'].'"><span>'.$mail_us['nick'].'</span></a> ('.date('d.m.y, H:i', $msg['date']).')</span>
<br />'.output_text($msg['text']).'
</div>
</li>';
}
echo '</ul>';
include_once '../system/foot.php'; exit;
}
if(isset($_GET['kto_del'])){
mysql_query("DELETE FROM `list_msg` WHERE `kto` = '".intval($_GET['kto_del'])."' and `komu` = '".$ku['id']."'");
header('Location: /mail/');
}
$req = mysql_query("SELECT DISTINCT `kto`,`komu` FROM `list_msg` WHERE `komu` = '".$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 `kto`,`komu` FROM `list_msg` WHERE `komu` = '".$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="../../user/notifications">Уведомления </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">';
while($mail = mysql_fetch_array($req)){
$req_us = mysql_query("SELECT `nick`,`id`,`pol` FROM `kolhoz_user` WHERE `id` = '".$mail['kto']."'");
$mail_us = mysql_fetch_array($req_us);
$req_msg = mysql_query("SELECT `text` FROM `list_msg` WHERE `komu` = '".$ku['id']."'");
$msg = mysql_fetch_array($req_msg);
if($mail_us['pol'] == 1){
$pol = 'male';
}if($mail_us['pol'] == 2){
$pol = 'female';
}else{
$pol = 'male';
}
$kol = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `list_msg` WHERE `kto` = '".$mail['kto']."' and `komu` = '".$ku['id']."' and `read` = '0'"),0);
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="/user/'.$mail_us['id'].'"><span>'.$mail_us['nick'].'</span></a> '.($kol > 0 ? '+'.$kol : null).'</span>
<a href="/mail/list/'.$mail_us['id'].'" class="cor-body-link">'.cut_msg($msg['text']).'...</a>
</div>
<div class="service">
<a href="/mail/del/'.$mail['kto'].'" class="mail-delete"></a>
</div>
</li>';
}
echo '</ul>';
}}
include_once '../system/foot.php';
?>