Файл: public_html/mail.php
Строк: 124
<?
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">';
?>
<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['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'] < 2) $errors[] = 'Писать можно 1 раз в 1 секунду';
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('ru',
'net',
'com',
'рф',
'tk',
'su',
'us',
'mobi',
'ua',
'www',
'http'), '*', $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){
echo '
<div class='block_zero'>
<form action='/mail/'.$ho['id'].'/' method='post'>
Сообщение:<br/><input name='text' style='width: 90%;' class='text'></a><a href='/smiles'><img src='/images/mini_ulibka.gif'></a><br/>
<span class='btn'><span class='end'><input class='label' type='submit' value='Отправить'>Отправить</span></span>
</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 style='float: right; color: '.(($row['read'] == 0) ? '#90c090':'#909090').';'>'.date('d.m | H:i', $row['time']).'</span>'.($from['id'] != 2 ? '<img src='/images/icon/race/'.$from['r'].($from['online'] > time() - 300 ? '':'-off').'.png' alt='*'/> <a href='/user/'.$from['id'].'/'>'.$from['login'].'</a><br/>':'<img src='/images/icon/race/bot.png' alt="*"/> Система<br/>').''.($from['id'] != 2 ? '<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/31/'><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="*"/> Система ').'</a>';
$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'>+'.$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'></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> </div><div class='dot-line'></div>
</div>
<?
include './system/f.php';
}
?>