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

Размер файла: 1.59Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.pp.ua *
  7. **********************************/
  8. $locate = 'in_chat';
  9. if(!isset($user)) { header('Location: /'); }
  10. if(!isset($_GET['room_id'])) { header('Location: /chat/'); } else {
  11. $room_id = abs(intval($_GET['room_id']));
  12. if($db->query("SELECT * FROM `chat` WHERE `id`= '". $room_id ."'")->rowCount() == 0) { header('Location: /chat/'); }
  13. if(isset($_POST['send'])) {
  14. $text = input($_POST['message']);
  15. if(!empty($_POST['message']) && (mb_strlen($_POST['message']) >= 2 || mb_strlen($_POST['message']) <= 1000)) {
  16. $db->query("INSERT INTO `chat_p`(`room_id`, `user_id`, `text`, `time`) VALUES('". $room_id ."', '". $user['id'] ."', '". $text ."', '". time() ."')");
  17. header('Location: /chat/room/'.$room_id.'/');
  18. exit;
  19. } else { header('Location: /chat/room/'.$room_id.'/'); }
  20. }
  21. $title = $lang->word('add_post');
  22. require_once(SYS.'/view/header.php');
  23. $tpl->div('title', $lang->word('add_post'));
  24. $tpl->div('post', '<form action="/chat/room/'. $room_id .'/add/" method="post">
  25. <textarea name="message" rows="5" cols="25">'.(isset($_GET['reply_to']) ? '[b]'.tnick($_GET['reply_to']).'[/b], ' : NULL).'</textarea>
  26. <br/>
  27. <input type="submit" name="send" value="'. $lang->word('send') .'" /><br/>
  28. </form>');
  29. $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>');
  30. require_once(SYS.'/view/footer.php');
  31. }
  32. ?>