Просмотр файла modules/chat/add_post.php

Размер файла: 1.59Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.pp.ua	  *
**********************************/
$locate = 'in_chat';
if(!isset($user)) { header('Location: /'); }
if(!isset($_GET['room_id'])) { header('Location: /chat/'); } else {
$room_id = abs(intval($_GET['room_id']));
if($db->query("SELECT * FROM `chat` WHERE `id`= '". $room_id ."'")->rowCount() == 0) { header('Location: /chat/'); }
if(isset($_POST['send'])) {
$text = input($_POST['message']);
if(!empty($_POST['message']) && (mb_strlen($_POST['message']) >= 2 || mb_strlen($_POST['message']) <= 1000)) {
$db->query("INSERT INTO `chat_p`(`room_id`, `user_id`, `text`, `time`) VALUES('". $room_id ."', '". $user['id'] ."', '". $text ."', '". time() ."')");
header('Location: /chat/room/'.$room_id.'/');
exit;
} else { header('Location: /chat/room/'.$room_id.'/'); }
}
$title = $lang->word('add_post');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('add_post'));
$tpl->div('post', '<form action="/chat/room/'. $room_id .'/add/" method="post">
<textarea name="message" rows="5" cols="25">'.(isset($_GET['reply_to']) ? '[b]'.tnick($_GET['reply_to']).'[/b], ' : NULL).'</textarea>
<br/>
<input type="submit" name="send" value="'. $lang->word('send') .'" /><br/>
</form>');
$tpl->div('block', NAV .'<a href="/chat/room/'.$room_id.'/">'. $lang->word('back') .'</a><br/>' .CHAT_ICON .' <a href="/chat/">'. $lang->word('chat') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
}
?>