<?php
/*
- NTLCMS v 18.1 19.08.2017 г
- Автор скрипта Александр (NTL)
- Скрипт клик клуба v 18.1
- Оф.сайт http://clicks24.ru
- Контакты ntl-jt@mail.ru
- Все права принадлежат разработчику
- Вы не имеете право вносить изменения в код скрипта
- Данный скрипт запрещено распространять
*/
define('NTLCMS', 1);
$module = 'newmes';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
include ('../system/crypt.class.php');
################################################################################
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
################################################################################
if ($set['mails'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><center>Личная почта</center></div>';
echo '<div class="post"><center>'.image('fail.png','16|16').' Модуль закрыт администратором!</center></div>';
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php'); exit;
}
################################################################################
$getlogin = isset($_GET['login']) ? filter_in($_GET['login']) : false;
$mess = DB :: run() -> query("select * from `users` where `login` = ?", array($getlogin)) -> fetch(PDO::FETCH_OBJ);
if (!isset($mess -> login) or $ulogin == $mess -> login){
header('Location: '.URL.'/messages');
$_SESSION['fail'] = 'Произошла ошибка!'; exit;
} else {
################################################################################
echo '<div class="title"><center>Сообщения | Новое сообщение '.$getlogin.'</center></div>';
################################################################################
if (DB :: run() -> querySingle("select count(`id`) from `contacts` where `kogo` = ? and `kto` = ? limit 1", array($mess -> login, $ulogin)) == 0){
DB :: run() -> query("insert into `contacts` (`kto`, `kogo`, `time`, `posl_time`) values (?, ?, ?, ?)", array($ilogin, $mess -> login, TIME, TIME));
DB :: run() -> query("insert into `contacts` (`kto`, `kogo`, `time`, `posl_time`) values (?, ?, ?, ?)", array($mess -> login, $ilogin, TIME, TIME));
}
if (isset($_REQUEST['ok'])){
$text = isset($_POST['text']) ? filter_in($crypt->xoft_encode($_POST['text'], $set['secure'])) : false;
if (empty($text)){
$error.= 'Введите текст сообщения!<br/>';
} elseif (mb_strlen($text, 'UTF-8') < 1 or mb_strlen($text, 'UTF-8') > 2500){
$error.= 'Сообщение должно содержать от 1 до 2500 символов!<br/>';
} elseif (DB :: run() -> querySingle("select (`time`) from `message` where `kto` = ? and `time` > ?", array($ulogin, TIME - $set['antispam']))){
$error.= 'Антиспам! Лимит '.((int) $set['antispam']).' секунд!<br/>';
}/* elseif (DB :: run() -> querySingle("select (`to`) from `blacklist` where `to` = ? and `who` = ?", array($ulogin, $mess['login']))){
$error.= 'Вы у пользователя в черном списке!<br/>';
} elseif (!DB :: run() -> querySingle("select (`to`) from `contactlist` where `to` = ? and `who` = ?", array($ulogin, $_POST['login']))){
$error.= 'Вас нет в списке контактов у пользователя!<br/>';
}*/
if ($error){
echo '<div class="post"><center>'.image('fail.png','16|16').' '.$error.'</center></div>';
} else {
DB :: run() -> query("update `contacts` set `posl_time` = ? where `kogo` = ? and `kto` = ? limit 1", array(TIME, $ilogin, $mess -> login));
DB :: run() -> query("update `contacts` set `posl_time` = ? where `kto` = ? and `kogo` = ? limit 1", array(TIME, $ilogin, $mess -> login));
DB :: run() -> query("insert into `message` (`text`, `kto`, `komy`, `time`, `readlen`) values (?, ?, ?, ?, ?)", array($text, $ilogin, $mess -> login, TIME, 0));
header('Location: '.URL.'/dialog-'.$mess -> login); exit;
}
}
echo '<div class="menu"><form name="form" action="'.URL.'/newmes-'.filter_out($mess -> login).'" method="post">';
echo fast_smile() . panel('text').'<textarea name="text" rows="3" cols="20"></textarea><br/>
<input type="submit" name="ok" value="Написать сообщение"/></form></div>';
}
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/messages">Личная почта</a></div>';
include ('../system/foot.php');
?>