Просмотр файла forum/index.php

Размер файла: 9.67Kb
  1. <?php
  2.  
  3. # Forum by seg0ro (http://mobilarts.ru)
  4.  
  5. include '../engine/includes/start.php';
  6. require_once ('includes/functions.php');
  7. include_once 'includes/journal.php';
  8. $set['title'] = 'Форум';
  9. $i = 1;
  10. Core::get(array('page.class', 'text.class'), 'classes');
  11.  
  12. if ($forum){
  13. $sql->query("SELECT * FROM `forum_forums` WHERE `id` = '$forum' LIMIT 1 ");
  14. if (!$sql->num_rows()){
  15. include H . 'engine/includes/head.php';
  16. echo Core::msg_show('Такого форума не существует!<br /><a href="index.php">Форум</a>');
  17. include H . 'engine/includes/foot.php';
  18. }
  19. $forumRes = $sql->fetch();
  20.  
  21. if ($forumRes['refid'])
  22. $forumRefid = $sql->query("SELECT `name` FROM `forum_forums` WHERE `id` = '".$forumRes['refid']."' LIMIT 1 ")->fetch();
  23. $set['title'] = htmlspecialchars($forumRes['name']);
  24. }
  25.  
  26. if($topic){
  27. $topicReq = $sql->query("SELECT * FROM `forum_topics` WHERE `id` = '$topic' LIMIT 1 ");
  28. if (!$sql->num_rows()){
  29. include H . 'engine/includes/head.php';
  30. echo Core::msg_show('Такой темы не существует!<br /><a href="index.php">Форум</a>');
  31. include H . 'engine/includes/foot.php';
  32. }
  33. $topicRes = $sql->fetch();
  34.  
  35. if (!empty($topicRes['poll_name'])){
  36. $pollReq = mysqli_query($sql->db, "SELECT * FROM `forum_polls` WHERE `refid` = '$topic' ORDER BY `id` ASC LIMIT 20 ");
  37. $pollSet = unserialize($topicRes['poll_set']);
  38. }
  39.  
  40. $set['title'] = htmlspecialchars($topicRes['name']);
  41.  
  42. if($post){
  43. $sql->query("SELECT * FROM `forum_posts` WHERE `id` = '$post' LIMIT 1 ");
  44. if (!$sql->num_rows()){
  45. include H . 'engine/includes/head.php';
  46. echo Core::msg_show('Такого поста не существует!<br /><a href="index.php">Форум</a>');
  47. include H . 'engine/includes/foot.php';
  48. }
  49. $postRes = $sql->fetch();
  50.  
  51. $set['title'] = htmlspecialchars($topicRes['name']).' | Пост: '.$post;
  52. }else{
  53. $topicRefid = $sql->query("SELECT `id`, `refid`, `name` FROM `forum_forums` WHERE `id` = '".$topicRes['refid']."' LIMIT 1 ")->result();
  54. }
  55.  
  56. if ($user_id && $topicRes['curator'] == $user_id)
  57. $rights = 3;
  58.  
  59. }
  60.  
  61. if($file){
  62. $fileReq = mysqli_query($sql->db, "SELECT * FROM `forum_files` WHERE `id` = '$file' LIMIT 1 ");
  63. if (!mysqli_num_rows($fileReq)){
  64. include H . 'engine/includes/head.php';
  65. echo Core::msg_show('Такого файла не существует!<br /><a href="index.php">Форум</a>');
  66. include H . 'engine/includes/foot.php';
  67. }
  68. $fileRes = mysqli_fetch_assoc($fileReq);
  69.  
  70. $fileRefid = $sql->query("SELECT `id`, `name`, `close` FROM `forum_topics` WHERE `id` = '".$fileRes['topic']."' LIMIT 1 ")->fetch();
  71.  
  72. $set['title'] = title($fileRefid['name']).' | Файл: '.$file;
  73. }
  74.  
  75. $arrayIncludes = array('addforum', 'addpost', 'addtopic', 'clean', 'delfile', 'delforum', 'delpoll', 'delpost', 'deltopic', 'download', 'editforum', 'editpost', 'edittopic', 'files', 'last', 'loadtopic', 'massdelpost', 'movetopic', 'moveforum', 'my', 'onforum', 'poll', 'polled', 'rating', 'search');
  76.  
  77. if (in_array($act, $arrayIncludes) && file_exists('includes/'.$act.'.php')){
  78. require_once ('includes/'.$act.'.php');
  79. }else{
  80. include H . 'engine/includes/head.php';
  81.  
  82. if ($topic){
  83. if (isset($_GET['unread'])){
  84. $resReaded = $sql->query("SELECT `time`, `lastpost` FROM `forum_readed` WHERE `topic` = '$topic' AND `user_id` = '$user_id' LIMIT 1 ")->fetch();
  85. if ($resReaded['time'] && $resReaded['lastpost'] > 0){
  86. $gopage = ceil($sql->query("SELECT COUNT(*) FROM `forum_posts` WHERE `refid` = '$topic' AND `id` <= '".$resReaded['lastpost']."' ")->result() / $set['p_str']);
  87. header ('Location: index.php?topic='.$topic.'&page='.$gopage.'#p'.$resReaded['lastpost']);
  88. }else{
  89. header ('Location: index.php?topic='.$topic);
  90. }
  91. include H . 'engine/includes/foot.php';
  92. }
  93. require_once('includes/showtopic.php');
  94. include H . 'engine/includes/foot.php';
  95. }
  96. if ($post){
  97. $sql->query("SELECT `refid` FROM `forum_posts` WHERE `id` = '$post' LIMIT 1 ");
  98. if (!$sql->num_rows()){
  99. include H . 'engine/includes/head.php';
  100. echo Core::msg_show('Такого поста не существует!<br /><a href="index.php">Форум</a>');
  101. include H . 'engine/includes/foot.php';
  102. }
  103. $postRes = $sql->fetch();
  104. $go = ceil(($sql->query("SELECT COUNT(*) FROM `forum_posts` WHERE `refid` = '".$postRes['refid']."' AND `id` <= '$post' ")->result()) / $set['p_str']);
  105.  
  106. header('Location: index.php?topic='.$postRes['refid'].'&page='.$go.'#p'.$post);
  107.  
  108. include H . 'engine/includes/foot.php';
  109. }
  110. if ($admin)
  111. echo '
  112. <script language="JavaScript" type="text/javascript">function show_hide(elem) {
  113. obj = document.getElementById(elem);
  114. if(obj.style.display == "none") obj.style.display = "inline";
  115. else obj.style.display = "none";
  116. }</script>
  117. ';
  118. if ($forum){
  119. if ($forumRes['refid'])
  120. $tree = array('<a href="index.php">Форум</a>', '<a href="index.php?forum='.$forumRes['refid'].'">'.text::output($forumRefid['name']).'</a>', text::output($forumRes['name']));
  121. else
  122. $tree = array('<a href="index.php">Форум</a>', text::output($forumRes['name']));
  123. }else{
  124. $tree = array('Форум');
  125. $total = $sql->query("SELECT * FROM `forum_forums` WHERE `refid` < '1' ORDER BY `realid` ASC ")->num_rows();
  126. }
  127. echo forum_counter();
  128. echo '<div class="fmenu">';
  129. foreach ($tree as $menu)
  130. {
  131. echo $menu . ' &nbsp; ';
  132. }
  133. echo '</div>';
  134. if ($user_id && $forum && $forumRes['type'] == 1)
  135. echo '<div class="msg"><a href="index.php?act=addtopic&amp;forum='.$forum.'">Новая тема</a></div>';
  136. if ($forum){
  137. if ($forumRes['type'] == 1){
  138. $total = $sql->query("SELECT COUNT(*) FROM `forum_topics` WHERE `refid` = '$forum' ")->result();
  139. $page = new page($total, $set['p_str']);
  140. if ($total){
  141. $sql->query("SELECT * FROM `forum_topics` WHERE `refid` = '$forum' ORDER BY `time` DESC LIMIT ".$page->limit()); // `sticky` DESC,
  142.  
  143. if ($page->k_page() > 5)
  144. $page->display('index.php?forum='.$forum.'&amp;');
  145. while ($res = $sql->fetch()){
  146.  
  147. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  148. $sub = 'Автор: '.$res['user'];
  149. if ($res['count'] > 1){
  150. $lastPost = explode(':|:', $res['lastpost']);
  151. $sub .= ' <a href="index.php?post='.$lastPost[1].'">Посл.</a>: '.$lastPost[0];
  152. }
  153. $sub .= ' '.Core::time($res['time']).'<br />';
  154. echo show_topic($res, $sub);
  155. echo '</div>';
  156. ++$i;
  157. }
  158. echo '<div class="fmenu">Тем: '.$total.'</div>';
  159. $page->display('index.php?forum='.$forum.'&amp;');
  160. }else{
  161. echo '<div class="p_m">Пусто</div>';
  162. }
  163. $adm = '<a href="index.php?act=editforum&amp;forum='.$forum.'">Изменить форум</a>';
  164. }else{
  165. $req = $sql->query("SELECT * FROM `forum_forums` WHERE `refid` = '$forum' ORDER BY `realid` ASC ");
  166. $total = $sql->num_rows();
  167. if ($total){
  168. while ($res = $sql->fetch()){
  169. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  170. echo show_folder($res);
  171. echo '</div>';
  172. ++$i;
  173. }
  174. echo '<div class="fmenu">Подфорумов: '.$total.'</div>';
  175. }else{
  176. echo '<div class="post">Пусто</div>';
  177. }
  178. $adm = '<a href="index.php?act=addforum&amp;forum='.$forum.'">Создать подфорум</a><br /><a href="index.php?act=editforum&amp;forum='.$forum.'">Изменить форум</a>';
  179. }
  180. }
  181. else
  182. {
  183. $total = $sql->query("SELECT COUNT(*) FROM `forum_forums` WHERE `refid` = '$forum'")->result();
  184. $page = new page($total, $set['p_str']);
  185. $sql->query("SELECT * FROM `forum_forums` WHERE `refid` = '$forum' ORDER BY `realid` DESC LIMIT ". $page->limit());
  186. if($total){
  187. while ($res = $sql->fetch()){
  188. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  189. echo show_folder($res); //echo '<br />'.var_dump($res);
  190. echo '</div>';
  191. ++$i;
  192. }
  193. $topics = $sql->query("SELECT COUNT(*) FROM `forum_topics` ")->result();
  194. $posts = $sql->query("SELECT COUNT(*) FROM `forum_posts` ")->result();
  195. echo '<div class="fmenu">Тем: '.$topics.', Сообщений: '.$posts.'</div>';
  196. }else{
  197. echo '<div class="p_m">Пусто</div>';
  198. }
  199. $adm = '<a href="index.php?act=addforum">Создать форум</a><br /><a href="index.php?act=clean">Чистка форума</a>';
  200. }
  201. echo '<div class="menu"><a href="index.php?act=search">Поиск</a><br /><a href="index.php?act=files">Файлы форума</a></div>';
  202.  
  203. if ($forum && $forumRes['type'] == 1){
  204. echo '<p><img src="images/new.png" alt="+" title="Есть новые сообщения" /> Есть новые сообщения <small>(только для зарегистрированых)</small><br />
  205. <img src="images/sticky.png" alt="^" title="Тема закреплена" /> Прикреплённая тема<br />
  206. <img src="images/close.png" alt="#" title="Тема закрыта" /> Закрытая тема<br />
  207. <img src="images/poll.png" alt="*" title="Голосование" /> В теме есть голосование</p>';
  208. }
  209. if ($admin)
  210. echo '<div class="menu">'.$adm.'</div>';
  211. }
  212.  
  213. include H . 'engine/includes/foot.php';