Файл: public_html/modules/mail/dialog.php
Строк: 159
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Почта";
include_once ($root.'/core/head.php');
?>
<style>
.mtb5 {
margin-top: 5px;
margin-bottom: 5px;
}
.hr3 {
height: 0;
font-size: 0;
border-top: 1px solid #13191e;
border-bottom: 1px solid #445561;
}
.smile {
border-width: 1px;
border-style: solid;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
background-color: #ff8c00;
background-image: linear-gradient(to bottom, #ff8c00, #ff8c00);
background-repeat: repeat-x;
border-color: rgba(0, 0, 0, .1) rgba(0, 0, 0, .1) rgba(0, 0, 0, .25);
padding: 5px 0px;
height: 21px;
width: 40px;
font-size: 13px;
border-radius: 3px;
line-height: 19px;
}
.reset {
border-width: 1px;
border-style: solid;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
background-color: #ff8c00;
background-image: linear-gradient(to bottom, #ff8c00, #ff8c00);
background-repeat: repeat-x;
border-color: rgba(0, 0, 0, .1) rgba(0, 0, 0, .1) rgba(0, 0, 0, .25);
padding: 5px 1px;
height: 21px;
width: 40px;
font-size: 13px;
border-radius: 3px;
line-height: 19px;
}
.pinter {
background-color: #34344C;
padding: 10px;
color: #fff;
word-wrap: break-word;
border-radius: 5px;
border: 1px solid #fff;
margin-bottom: 10px;
max-width: 100%;
margin-left: 0%;
}
.bymin {
width: 240px;
}
.panels {
background-color: #343434;
color: #fff;
word-wrap: break-word;
padding: 15px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
}
</style>
<script type="text/javascript" src="/js/smiles.js"></script>
<script type="text/javascript">
function addSmiley(id, html) {
var e = document.getElementById(id);
if (e != null) {
e.value += ' ' + html + ' ';
e.focus();
}
}
function showSmilies() {
var e = document.getElementById('smiles');
if (e != null) {
if (e.style.display == 'block') { e.style.display = 'none'; } else { e.style.display = 'block'; }
}
}
</script>
<?
$dialog_id = fl($_GET['id']);
$dialog = $db->query("SELECT * FROM `mail_dialogs` WHERE (`user1` = '".$dialog_id."' AND `user2` = '".$u['id']."') OR (`user1` = '".$u['id']."' AND `user2` = '".$dialog_id."')");
if($dialog->num_rows == 0)
{
header("Location: /mail/new/".$dialog_id);
exit;
}
if($ban->num_rows > 0){echo"<div class = 'b'> Запрет на сообщения</div></div>";}else{
$dialog = $dialog->fetch_object();
if($dialog->user1 == $u['id']) $us = $dialog->user2;
else $us = $dialog->user1;
if(isset($_GET['send']))
{
$message = fl($_POST['message']);
$userInfo = $db->query("SELECT * FROM `users` WHERE `id` = '".$us."'")->fetch_object();
if($userInfo->mail_status == 0) redirect('/mail', 'Игрок закрыл почту!');
$issetEnemy = $db->query("SELECT * FROM `blacklist` WHERE `user` = '".$us."' AND `enemy` = '".$u['id']."'")->num_rows;
if($issetEnemy > 0) redirect('/mail', 'Вы в чёрном списке у игрока');
if(empty($message)) redirect('/mail/dialog/'.$dialog_id, 'Введите текст письма');
$ban = $base -> query("SELECT * FROM `ban` WHERE `id_user` = '".$u['id']."' AND `time_ban` > '".time()."' ORDER BY `id` DESC LIMIT 1");
if($ban->num_rows > 0) redirect('/', 'Вы заткнуты!');
$db->query("INSERT INTO `mail_messages` (`user1`,`user2`,`message`,`time`) VALUES ('".$u['id']."', '".$us."', '".$message."', '".time()."')");
$db->query("UPDATE `mail_dialogs` SET `time` = '".time()."' WHERE `id` = '".$dialog->id."'");
header("Location: /mail/dialog/".$dialog_id);
exit;
}
$notReadMessagesInThisDialog = $db->query("SELECT * FROM `mail_messages` WHERE `user1` = '".$us."' AND `user2` = '".$u['id']."' AND `read` = '0'")->num_rows;
if($notReadMessagesInThisDialog > 0)
{
$db->query("UPDATE `mail_messages` SET `read` = '1' WHERE `user1` = '".$us."' AND `user2` = '".$u['id']."' AND `read` = '0'");
}
//echo '<div class = "b"><center>Почта для '.name($us).'</center></div>';
echo'<div class = "b-mini"><center></br>
Почта для '.name($us).'
<div id="smiles" style="display: none;">';
$smiles = $db->query("SELECT * FROM `smiles`");
while($sm = $smiles->fetch_object())
{
echo '<a href="javascript:tag('chatText',''.$sm->tag.'','')"><img src="'.$sm->image.'"></a> ';
}
echo'
</div></center>
<form action="/mail/dialog/'.$dialog_id.'/send" method="post">
<textarea name="message" id="chatText" required></textarea>
<center><div class = "bymin">
<table width="100%">
<tr>
<td width="50px" valign="top">
<a class="form-btn-table" onclick="{ showSmilies(); return false; }" href="?about?smiles"><div class = "smile"><center><img src="/ico-smile.png" width="22" height="22"></center></div></a>
<td valign="top">
<center><input type="submit" name="send" value="Отправить"> </form> </center>
</td>
<td valign="top">
<a href = "?"><div class = "reset"><center> <img src="/ico-refresh.png" width="22" height="22"></center></div></a>
</td>
</tr>
</table></div> </center></div>
<div class = "line"></div>
';
$count = $db -> query("SELECT * FROM `mail_messages` WHERE (`user1` = '".$u['id']."' AND `user2` = '".$us."') OR (`user1` = '".$us."' AND `user2` = '".$u['id']."')")->num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `mail_messages` WHERE (`user1` = '".$u['id']."' AND `user2` = '".$us."') OR (`user1` = '".$us."' AND `user2` = '".$u['id']."') ORDER BY `time` DESC LIMIT $start, 10");
echo '<div class="b">';
while($mess = $sql->fetch_object())
{
if($mess->user1 == $u['id']) $divMess = 'pinter';
else $divMess = 'pinter';
if($mess->read == 0) $notification = '<img src="/images/not.png" width="20" height="20">';
else $notification = null;
echo '<dl class = "'.$divMess.'">
<big><img src="/images/users.png" width="30px"> '.who($mess->user1).'</big><small><span style="float: right;">'.$notification.' '.tm($mess->time).'</small></span>
<br><big>'.setTextColor($mess->user1, $mess->message).'</big></br></dl>';
}
$issetFriend = $db->query("SELECT * FROM `friends` WHERE `user` = '".$u['id']."' AND `friend` = '".$us."'")->num_rows;
$issetBlacklist = $db->query("SELECT * FROM `blacklist` WHERE `user` = '".$u['id']."' AND `enemy` = '".$us."'")->num_rows;
if(isset($_GET['friend']))
{
if($issetFriend > 0) redirect('/mail/dialog/'.$us, 'Игрок уже есть в списке друзей!');
if($issetBlacklist > 0) redirect('/mail/dialog/'.$us, 'Игрок находится в чёрном списке у вас!');
$db->query("INSERT INTO `friends` (`user`,`friend`,`time`) VALUES ('".$u['id']."', '".$us."', '".time()."')");
redirect('/mail/dialog/'.$us, 'Игрок добавлен в список друзей!');
}
if(isset($_GET['blacklist']))
{
if($issetFriend > 0) redirect('/mail/dialog/'.$us, 'Игрок уже есть в списке друзей!');
if($issetBlacklist > 0) redirect('/mail/dialog/'.$us, 'Игрок находится в чёрном списке у вас!');
$db->query("INSERT INTO `blacklist` (`user`,`enemy`,`time`) VALUES ('".$u['id']."', '".$us."', '".time()."')");
redirect('/mail/dialog/'.$us, 'Игрок добавлен в список друзей!');
}
if(isset($_GET['del']))
{
$db->query("DELETE FROM `mail_messages` WHERE (`user1` = '".$us."' AND `user2` = '".$u['id']."') OR (`user1` = '".$u['id']."' AND `user2` = '".$us."')");
$dialog = $db->query("DELETE FROM `mail_dialogs` WHERE (`user1` = '".$dialog_id."' AND `user2` = '".$u['id']."') OR (`user1` = '".$u['id']."' AND `user2` = '".$dialog_id."')");
redirect('/mail', 'Диалог удалён!');
}
if($issetBlacklist == 0 && $issetFriend == 0)
{
echo"<a class = 'clicker ' href = '?friend'>В друзья</a>";
echo"<a class = 'clicker ' href = '?blacklist'>В черный список</a>";
}
echo"<a class = 'clicker _gold' href = '?del'>Удалить переписку</a>";
echo '
</div>';
if($count >= 10) echo str('/mail/dialog/'.$dialog_id.'/?', $k_page, $page);
echo"<div class = 'line'></div><center><a class = 'link' href = '/mail'>В почту</a></center>
";
}
include_once ($root.'/core/foot.php');