Вход Регистрация
Файл: modules/mail/chat.php
Строк: 65
<?php
if(!isset($_GET['user_id']) || $_GET['user_id'] == 0) header('location: /');
if(isset(
$user) && $_GET['user_id'] != $user['id']) { 
$locate = 'in_mail'; 

if (
$db->query("SELECT * FROM `mail_chat` WHERE `user_id` = '$user[id]' AND `who_id` = '". abs(intval($_GET['user_id'])) ."'")->rowCount() != 0) $chat_id = $db->query("SELECT id FROM `mail_chat` WHERE `user_id` = '$user[id]' AND `who_id` = '". abs(intval($_GET['user_id'])) ."'")->fetchColumn(); 
else 
$chat_id = $db->query("SELECT `id` FROM `mail_chat` WHERE `who_id` = '$user[id]' AND `user_id` = '". intval($_GET['user_id']) ."'")->fetchColumn(); 
$chat_id = abs(intval($chat_id));
if (
$db->query("SELECT * FROM `mail_chat` WHERE (`user_id` = '$user[id]' OR `who_id` = '$user[id]') AND (`who_id` = '". abs(intval($_GET['user_id'])) ."' OR `user_id` = '". abs(intval($_GET['user_id'])) ."')")->rowCount() == 0) { 
$db->query("INSERT INTO `mail_chat` SET `user_id` = '$user[id]', `who_id` = '". abs(intval($_GET['user_id'])) ."', `time_last_message` = '". time() ."'"); 
// print_r($db->errorInfo()); 
} 
if(
$_POST['send'] && $_GET['act'] == 'send') { 

$message = input($_POST['text']); 
if(!empty(
$message)) { $text = substr($message, 0, 5000); } else { $err = 'Message is empty'; } 
if(!isset(
$err)) { 
$db->query("INSERT INTO `mail` SET `mail_chat_id` = '$chat_id', `user_id` = '$user[id]', `who_id` = '". abs(intval($_GET['user_id'])) ."', `text` = '". $text ."', `time` = '". time() ."', `read`='0'"); 
// print_r($db->errorInfo()); 
$db->query("UPDATE `mail_chat` SET `time_last_message` = '". time() ."' WHERE `id` = '$chat_id'"); 
// print_r($db->errorInfo()); 
header('Location: /mail/chat/'.abs(intval($_GET['user_id'])).'/?act=added'); 
} 
} 
$title = $lang->word('chat_with_user').' '.tnick($_GET['user_id']); 
require_once(
SYS.'/view/header.php'); 
$tpl->div('title', $lang->word('chat_with_user').' '.tnick($_GET['user_id'])); 
if(isset(
$_GET['act']) && $_GET['act'] == 'added') { 
$tpl->div('block', $lang->word('mess_added')); 
} 

echo 
'<div class="menu">';
require_once(
SYS.'/inc/bb.php');
                    echo 
'<form action="/mail/chat/'.abs(intval($_GET['user_id'])).'/?act=send" method="post"> 
                    <textarea name="text" id="view_bar"></textarea><br/> 
                    [ <a href="/pages/smiles.php">'
. $lang->word('smiles') .'</a> | <a href="/pages/tags.php">'. $lang->word('tags') .'</a> ]<br/><input name="send" type="submit" value="'. $lang->word('send').'"/>&#160;<a href="/mail/chat/'.abs(intval($_GET['user_id'])).'/" title="'. $lang->word('update') .'">'.img('refresh.png').'</a>
                    </form> </div>'
;
$chat_r = $db->query("SELECT * FROM `mail` WHERE `mail_chat_id` = '$chat_id'")->rowCount(); 
$pages = new Paginator($chat_r, $ames); 
if(
$chat_r == 0) { 
$tpl->div('menu', $lang->word('no_posts')); 
} else { 
$chat_q = $db->query("SELECT * FROM `mail` WHERE `mail_chat_id` = '$chat_id' ORDER BY time DESC LIMIT $start, $ames"); 
while(
$chat = $chat_q->fetch()) { 
if (
$user['id'] == $chat['who_id']) $db->query("UPDATE `mail` SET `read` = '1' WHERE `id` = '$chat[id]'"); 
echo 
'<div class="'.($chat['read'] == 0 ? 'mail': 'post').'"> 

        '
. nick($chat['user_id']) .' ['. rtime($chat['time']) .']<br/> 
                 '
. output($chat['text']) .' 
    </div>'
; 
} 
$pages->view('/mail/chat/'.abs(intval($_GET['user_id'])).'/?'); 
} 
echo 
'<a name="reply"></a>'; 
$tpl->div('block', img('mail.png') .'<a href="/mail/">'.$lang->word('u_mail').'</a><br/>' 
                    
. NAV .'<a href="/user/panel/">'.$lang->word('user_panel').'</a><br/>' 
                    
. HICO .'<a href="/">'. $lang->word('home').'</a>'); 
require_once(
SYS.'/view/footer.php'); 
} else { 
go('/'); }
?>
Онлайн: 3
Реклама