Просмотр файла lib/includes/comments.php

Размер файла: 1.84Kb
  1. <?php
  2.  
  3. if ($id)
  4. {
  5.  
  6. $arc = $sql->query("SELECT `name`, `author_id` FROM `mod_lib` WHERE `id` = " . $id . " AND `type` = 'arc' AND `mod` = '0'")->fetch();
  7.  
  8. if ($arc !== FALSE)
  9. {
  10.  
  11. echo '<div class="fmenu">' . 'Библиотека' . ' | ' . htmlentities($arc['name'], ENT_QUOTES, 'UTF-8') . '</div>';
  12.  
  13. if (!empty($_POST['text']))
  14. {
  15. $sql->query("insert into `mod_lib_comments` set `text` = '". my_esc($_POST['text']) . "', `time` = ".time().", `sub_id` = ".$id.", `user_id` = ".$user_id);
  16. }
  17.  
  18. Core::get('page.class', 'classes');
  19.  
  20. $total = $sql->query('SELECT count(*) from `mod_lib_comments` where `sub_id` = '.$id)->result();
  21.  
  22. $i = 1;
  23.  
  24. $page = new page($total, $set['p_str']);
  25.  
  26. $sql->query("SELECT * FROM `mod_lib_comments` WHERE `sub_id` = ".$id." ORDER BY `id` DESC LIMIT ".$page->limit());
  27. while ($coms = $sql->fetch())
  28. {
  29. $data = array('status' => $coms['time'], 'is_time' => true, 'post' => $coms['text']);
  30. echo '<div class="'.($i++ % 2 ? 'p_m' : 'p_t').'">'.Core::user_show(Core::get_user($coms['user_id']), $data).'</div>';
  31. }
  32.  
  33. $page->display('?act=comments&amp;id='.$id.'&amp;');
  34.  
  35. if (!$total)
  36. echo '<div class="post">Нет комментариев</div>';
  37.  
  38. ?>
  39. <form method="post" action="?act=comments&amp;id=<?=$id?>">
  40. <textarea name="text"></textarea><br />
  41. <input type="submit" value="Отправить"/>
  42. </form>
  43. <?php
  44.  
  45. echo '<div class="post"><a href="?act=articles&amp;mod=view&amp;id=' . $id . '">Назад</a><br /><a href="index.php">В библиотеку</a></div>';
  46. }
  47. else
  48. {
  49.  
  50. $error = 'Статья не найдена';
  51.  
  52. }
  53.  
  54. }
  55. else
  56. {
  57.  
  58. $error = 'Ошибка принятых данных';
  59.  
  60. }