Файл: public_html/mail.php
Строк: 189
<?
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
?>
<div class='main'>
<?
$id = _string(_num($_GET['id']));
if($id) {
$ho = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = ''.$id.'''));
if(!$id OR !$ho OR $id == $user['id']) {
header('location: /mail/');
exit;
}
$title = 'Диалог с '.$ho['login'];
include './system/h.php';
echo '<div class="main">';
?>
<center><img src="https://static.mrush.mobi/view/image/maze/tape/purple_l.png"> <font color="lime">Диалог с <?=$ho['login']?></font> <img src="https://static.mrush.mobi/view/image/maze/tape/purple_r.png"> </center><br><center>
<center><img src='/images/icon/arrow.png'> <span class='better'>Последнее действие: [<?=_times(time() - $ho['online'])?>]</span><img src='/images/<?=$ho['agent']?>.png'></center>
<?
if($ho['id']==1) {
echo "<center><font color='orange'>Создатель проэкта</font><img src='/images/smiles/mini_ulibka.gif'></center>";
}
?>
<div class='menuList'><li><a href='/mail/'><img src='http://tiwar.ru/images/icon/arrow_b.png' alt=''/>Назад в почту</a></li></div><div class='mini-line'></div>
<?
if(mysql_result(mysql_query('SELECT COUNT(*) FROM `contacts` WHERE `user` = ''.$user['id'].'' AND `ho` = ''.$ho['id'].'''),0) == 0) {
mysql_query('INSERT INTO `contacts` (`user`,
`ho`,
`time`) VALUES (''.$user['id'].'',
''.$ho['id'].'',
''.time().'')');
}
if(mysql_result(mysql_query('SELECT COUNT(*) FROM `contacts` WHERE `ho` = "'.$user['id'].'" AND `user` = "'.$ho['id'].'"'),0) == 0) {
mysql_query('INSERT INTO `contacts` (`ho`,
`user`,
`time`) VALUES (''.$user['id'].'',
''.$ho['id'].'',
''.time().'')');
}
if($ho['mailclosed']==1) {
echo "<center><font color='lime'>Почта $ho[login] закрыта</font></center>";
}
if($user['maill']==1) {
echo "<center><font color='lime'>Вы забанены в почте</font></center>";
}
if($ho['r'] != $user['r']) $_s = 100; else $_s = 1;
$text = _string($_POST['text']);
if(mysql_result(mysql_query('SELECT COUNT(*) FROM `blacklist` WHERE `user2` = ''.$user['id'].'' AND `user` = ''.$ho['id'].'''),0) != 0){
echo'<center>Вы в черном списке '.$ho['login'].'</center>';
}else{
if($text) {
$antiflood = mysql_fetch_array(mysql_query('SELECT * FROM `mail` WHERE `from` = ''.$user['id'].'' ORDER BY `time` DESC LIMIT 1'));
if(time() - $antiflood['time'] < 0) $errors[] = 'Писать можно 1 раз в 10 секунд';
if($user['s'] < $_s) $errors[] = 'Не хватает <img src='/images/icon/silver.png' alt='*'/> '.($_s - $user['s']).' серебра<div class='separ'></div><a href='/trade/'>Купить</a>';
if($errors) {
echo '<div class='block' align='center'>';
foreach($errors as $error) {
echo $error.'<br/>';
}
echo '</div>
<div class='mini-line'></div>';
}
else
{
//$text = eregi_replace( "[[:alpha:]]+[^<>[:space:]]+[[:alnum:]/]", "Реклама", $text);
$text = str_replace(array('',
'net',
'',
'рф',
'tk',
'su',
'',
'mobi',
'ua',
'',
''), '*', $text);
mysql_query('UPDATE `users` SET `s` = `s` - '.$_s.' WHERE `id` = ''.$user['id'].''');
mysql_query('INSERT INTO `mail` (`from`,
`to`,
`text`,
`time`) VALUES (''.$user['id'].'',
''.$ho['id'].'',
''.$text.'',
''.time().'')');
mysql_query('UPDATE `contacts` SET `time` = ''.time().'' WHERE `user` = ''.$user['id'].'' AND `ho` = ''.$ho['id'].''');
mysql_query('UPDATE `contacts` SET `time` = ''.time().'' WHERE `ho` = ''.$user['id'].'' AND `user` = ''.$ho['id'].''');
header('location: /mail/'.$ho['id'].'/');
}
}
if($ho['id'] != 2){
//if($user['id'] !=9930) {
if($ho['mailclosed'] !=1) {
if($user['maill']==0) {
?>
<div id="pokazat">
<a href="#" onClick="document.getElementById('pokazat').style.display='none';document.getElementById('skryt').style.display='';return false;"><p align="left"><img src='/images/smiles/happy.gif'></a></p>
</div>
<div id="skryt" style="display:none">
<a href="#" onClick="document.getElementById('skryt').style.display='none';document.getElementById('pokazat').style.display='';return false;"><p align="left">Скрыть</p></a>
<p>
<? echo' <form name='form' action='/mail/'.$ho['id'].'/' method='post'>'; echo bbpanel('form', 'text').'';?>
</div>
<?
echo '
<div class='block_zero'>
<form name='form' action='/mail/'.$ho['id'].'/' method='post'>'; echo'
<span style="float: left;">Сообщение:</span><br/><textarea name='text' style='width: 90%;' ></textarea></a>
<input class='btn22' type='submit' value='Отправить'>
</form>
<center><font color='#909090'><small><small>Стоимость сообщения '.($user['r'] == $ho['r'] ? 'своей':'чужой').' фракции <img src='/images/icon/silver.png' alt='*'/> '.$_s.'</font></small></small></font></center>
</div></div>
<div class='mini-line'></div>';
}
}
}
//}
}
$max = 10;
$count = mysql_result(mysql_query('SELECT COUNT(*) FROM `mail` WHERE `from` = "'.$user['id'].'" AND `to` = "'.$ho['id'].'" OR `to` = "'.$user['id'].'" AND `from` = "'.$ho['id'].'"'),0);
$pages = ceil($count/$max);
$page = _string(_num($_GET['page']));
if($page > $pages) $page = $pages;
if($page < 1) $page = 1;
$start = $page * $max - $max;
if($count > 0) {
$col = array('#ffffff', '#f09060', '#90c0c0');
$q = mysql_query('SELECT * FROM `mail` WHERE `from` = ''.$user['id'].'' AND `to` = ''.$ho['id'].'' OR `to` = ''.$user['id'].'' AND `from` = ''.$ho['id'].'' ORDER BY `time` DESC LIMIT '.$start.', '.$max.'');
echo'';
while($row = mysql_fetch_array($q)) {
$from = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = ''.$row['from'].'''));
echo '<div class='block_zero'><span size='1' style='float: right; color: '.(($row['read'] == 0) ? '#90c090':'#909090').';'>'.date('d.m | H:i', $row['time']).'</span>'.($from['id'] != 1 ? '<img src='/images/icon/race/'.$from['r'].($from['online'] > time() - 300 ? '':'-off').'.png' alt='*'/> <a href='/user/'.$from['id'].'/'>'.$from['login'].'</a><br/>':'<img width="5%" src='http://159acfc9ec557d9797cb052b02bcb9d8.s3.amazonaws.com/file/pic/user/2013/05/7fe889f68431034d3a12554b14ecc81f.png' alt="*"/>Создатель<br/>').''.($from['id'] != 1 ? '<font color=''.$col[$from['access']].''>'.bb(smiles($row['text'])).'</font>' : '<font color=#9DC8E7>'.bb(smiles($row['text']))).'</font></div><div class='dot-line'></div>';
if($row['to'] == $user['id'] && $row['read'] == 0) mysql_query('UPDATE `mail` SET `read` = '1' WHERE `id` = ''.$row['id'].''');
}
echo '<div class='block_zero'>'.pages('/mail/'.$id.'/?').'</div>';
}
else
{
echo '<div class='block_zero'><font color='#909090'>Сообщений нет</font></div>';
}
?>
<div class='mini-line'></div><div class='menuList'><li><a href='/forum/topic/68/'><img src='http://tiwar.ru/images/icon/section_new.png' alt=''/>Важно! Безопасность персонажа</a></li></div>
</div>
<?
include './system/f.php';
}
else
{
$title = 'Почта';
include './system/h.php';
echo '<div class='main'>';
$max = 7;
$count = mysql_result(mysql_query('SELECT COUNT(*) FROM `contacts` WHERE `user` = ''.$user['id'].'''),0);
$pages = ceil($count/$max);
$page = _string(_num($_GET['page']));
if($page > $pages) $page = $pages;
if($page < 1) $page = 1;
$start = $page * $max - $max;
if($count > 0) {
$q = mysql_query('SELECT * FROM `contacts` WHERE `user` = ''.$user['id'].'' ORDER BY `time` DESC LIMIT '.$start.', '.$max.'');
while($row = mysql_fetch_array($q)) {
$ho = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = ''.$row['ho'].'''));
echo '<div class='list'>
<a style='display:block' href='/mail/'.$row['ho'].'/'>'.($row['ho'] != 2 ? '<img src='/images/icon/race/'.$ho['r'].($ho['online'] > time() - 300 ? '':'-off').'.png' alt='*'/> '.$ho['login'].', '.$ho['level'].' ур.' : '<img src='/images/icon/race/bot.png' alt="*"/> Система ').'<br>';
$new = mysql_result(mysql_query('SELECT COUNT(*) FROM `mail` WHERE `from` = ''.$ho['id'].'' AND `to` = ''.$user['id'].'' AND `read` = '0''),0);
$new = mysql_result(mysql_query('SELECT COUNT(*) FROM `mail` WHERE `from` = ''.$ho['id'].'' AND `to` = ''.$user['id'].'' AND `read` = '0''),0);
if($new > 0) echo '<font color='#90c090'> <small>[не прочитано] </small></font>';
if($new == 0) echo '<font color='#90c090'> <small>[прочитано] </small></font>';
$lost = mysql_fetch_array(mysql_query('SELECT * FROM `mail` WHERE `from` = ''.$user['id'].'' AND `to` = ''.$ho['id'].'' OR `to` = ''.$user['id'].'' AND `from` = ''.$ho['id'].'' ORDER BY `time` DESC LIMIT 1'));
if($new > 0) echo '<font color='#90c090'>+'.$new.'</font>';
$lost = mysql_fetch_array(mysql_query('SELECT * FROM `mail` WHERE `from` = ''.$user['id'].'' AND `to` = ''.$ho['id'].'' OR `to` = ''.$user['id'].'' AND `from` = ''.$ho['id'].'' ORDER BY `time` DESC LIMIT 1'));
if($lost) echo '
<font color='#909090'>'.(mb_strlen($lost['text'],'UTF-8') >= 25 ? mb_substr($lost['text'],0, 25, 'UTF-8').'...':$lost['text']).'</font>';
echo'</div><div class='dot-line'></a></div>';
}
echo '<div class='block_zero'>'.pages('/mail/?').'</div>';
}
else
{
echo '<div class='block_zero'><font color='#909090'>Почта пуста</font></div>';
}
?><div class='mini-line'></div>
<div class='block_zero'><img src='http://tiwar.ru/images/icon/crys/1.png' alt=''/> <a href='/mail/friends'>Друзья</a> | <a href='/mail/blacklist'>Чёрный список</a> |
<a href="?act=truncate">Очистить сообщения</a> </div><div class='dot-line'></div>
</div>
<?
if($_GET['act']==truncate) {
mysql_query("DELETE FROM `mail` WHERE `to` = '".$user[id]."'");
mysql_query("DELETE FROM `contacts` WHERE `user` = '".$user[id]."'");
mysql_query("DELETE FROM `contacts` WHERE `ho` = '".$user[id]."'");
mysql_query("DELETE FROM `contacts` WHERE `from` = '".$user[id]."'");
header('location:?');
}
?>
<?
include './system/f.php';
}
?>