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

Размер файла: 10.04Kb
  1. <?php
  2. # Script by seg0ro http://mobilarts.ru
  3. # Not for sale!!!
  4.  
  5. # fixed
  6.  
  7. $set['title'] .= ' | Моя страница';
  8. include H . 'engine/includes/head.php';
  9.  
  10. if (!$user_id){
  11. echo Core::msg_show('Только для авторизованных!<br /><a href="index.php">Форум</a>');
  12. include H . 'engine/includes/foot.php';
  13. }
  14.  
  15. if (isset($_GET['addfavourite']) && $topic){
  16. $check = $sql->query("SELECT COUNT(*) FROM `forum_favourites` WHERE `topic` = '$topic' AND `user_id` = '$user_id' LIMIT 1 ")->result();
  17. if ($check){
  18. echo Core::msg_show('Данная тема уже в избранном!<br /><a href="index.php?topic='.$topic.'&amp;page=end">Назад</a>');
  19. include H . 'engine/includes/foot.php';
  20. }
  21.  
  22. $check = $sql->query("SELECT COUNT(*) FROM `forum_favourites` WHERE `user_id` = '$user_id' ")->result();
  23. if ($check >= 20){
  24. echo Core::msg_show('Максимальное количество тем в избранном (20 шт.)!<br /><a href="index.php?topic='.$topic.'&amp;page='.$page.'">Назад</a>');
  25. include H . 'engine/includes/foot.php';
  26. }
  27.  
  28. $sql->query("INSERT INTO `forum_favourites` SET
  29. `topic` = '$topic',
  30. `user_id` = '$user_id' ");
  31.  
  32. echo '<div class="msg">Тема добавлена в избранное<br /><a href="index.php?act=my&amp;favourites">В избранное</a> | <a href="index.php?topic='.$topic.'&amp;page=end">В тему</a></div>';
  33. include H . 'engine/includes/foot.php';
  34. }
  35.  
  36. if (isset($_GET['delfavourite']) && $topic){
  37. $sql->query("DELETE FROM `forum_favourites` WHERE `topic` = '$topic' AND `user_id` = '$user_id' LIMIT 1 ");
  38. echo '<div class="msg">Тема удалена из избранного<br /><a href="index.php?act=my&amp;favourites">В избранное</a> | <a href="index.php?topic='.$topic.'&amp;page=end">В тему</a></div>';
  39. include H . 'engine/includes/foot.php';
  40. }
  41.  
  42. if (isset($_GET['cleanjournal'])){
  43. if (isset($_POST['yes'])){
  44. if (journal_delete()){
  45. header ('Refresh:1; URL=index.php');
  46. echo '<div class="msg">Журнал очищен<br /><a href="index.php">Форум</a></div>';
  47. include H . 'engine/includes/foot.php';
  48. }else{
  49. echo '<div class="rmenu">Возникла ошибка при очистке журнала!<br /><a href="index.php?act=my&amp;journal">Журнал</a></div>';
  50. include H . 'engine/includes/foot.php';
  51. }
  52. }elseif(isset($_POST['no'])){
  53. header ('Location: index.php?act=my&journal');
  54. }else{
  55. echo '<form action="index.php?act=my&amp;cleanjournal" method="post"><div class="rmenu">Вы действительно хотите очистить журнал?<br />';
  56. echo '<input type="submit" name="yes" value="Очистить" /> <input type="submit" name="no" value="Отмена" /></div></form>';
  57. include H . 'engine/includes/foot.php';
  58. }
  59. }
  60.  
  61. if (isset($_GET['posts'])){
  62. $sqlTotal = 'posts';
  63. $sqls = "* FROM `forum_posts` WHERE `user_id` = '$user_id' ORDER BY `time` DESC";
  64. $url = 'posts';
  65. $hdr = 'Мои посты';
  66. $bottom = 'Постов: ';
  67. $goto = '<a href="index.php?act=my&amp;topics">Темы</a> | <a href="index.php?act=my&amp;files">Файлы</a> | <a href="index.php?act=my&amp;favourites">Избранное</a> | <a href="index.php?act=my&amp;journal">Журнал</a>';
  68. }elseif(isset($_GET['files'])){
  69. $sqlTotal = 'files';
  70. $sqls = "* FROM `forum_files` WHERE `user_id` = '$user_id' ";
  71. $url = 'files';
  72. $hdr = 'Мои файлы';
  73. $bottom = 'Файлов: ';
  74. $goto = '<a href="index.php?act=my&amp;topics">Темы</a> | <a href="index.php?act=my&amp;posts">Посты</a> | <a href="index.php?act=my&amp;favourites">Избранное</a> | <a href="index.php?act=my&amp;journal">Журнал</a>';
  75. }elseif(isset($_GET['favourites'])){
  76. $sqlTotal = 'favourites';
  77. $sqls = "`forum_favourites`.*, `forum_topics`.* FROM `forum_favourites` LEFT JOIN `forum_topics` ON `forum_favourites`.`topic` = `forum_topics`.`id` WHERE `forum_favourites`.`user_id` = '$user_id' ";
  78. $url = 'favourites';
  79. $hdr = 'Избранное';
  80. $bottom = 'Тем: ';
  81. $goto = '<a href="index.php?act=my&amp;topics">Темы</a> | <a href="index.php?act=my&amp;posts">Посты</a> | <a href="index.php?act=my&amp;files">Файлы</a> | <a href="index.php?act=my&amp;journal">Журнал</a>';
  82. }elseif(isset($_GET['journal'])){
  83. $sqlTotal = 'journal';
  84. $sqls = "* FROM `forum_journal` WHERE `user_id` = '$user_id' ORDER BY `time` DESC";
  85. $url = 'journal';
  86. $hdr = 'Журнал';
  87. $bottom = 'Записей (из 100): ';
  88. $goto = '<a href="index.php?act=my&amp;topics">Темы</a> | <a href="index.php?act=my&amp;posts">Посты</a> | <a href="index.php?act=my&amp;files">Файлы</a> | <a href="index.php?act=my&amp;favourites">Избранное</a>';
  89. }else{
  90. $sqlTotal = 'topics';
  91. $sqls = "* FROM `forum_topics` WHERE `user_id` = '$user_id' ORDER BY `time` DESC";
  92. $url = 'topics';
  93. $hdr = 'Мои темы';
  94. $bottom = 'Тем: ';
  95. $goto = '<a href="index.php?act=my&amp;posts">Посты</a> | <a href="index.php?act=my&amp;files">Файлы</a> | <a href="index.php?act=my&amp;favourites">Избранное</a> | <a href="index.php?act=my&amp;journal">Журнал</a>';
  96. }
  97.  
  98.  
  99. echo '<div class="fmenu"><a href="index.php">Форум</a> / '. $hdr.'</div>';
  100.  
  101. $total = $sql->query("SELECT COUNT(*) FROM `forum_$sqlTotal` WHERE `user_id` = '$user_id' ")->result();
  102. $page = new page($total, $set['p_str']);
  103.  
  104. if ($total){
  105.  
  106. $page->display('index.php?act=my&amp;'.$url.'&amp;');
  107.  
  108. $sql->query("SELECT $sqls LIMIT ".$page->limit());
  109. if (isset($_GET['posts'])){
  110. while ($res = $sql->fetch()){
  111. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  112.  
  113. echo Core::time($res['time']).' <a href="index.php?post='.$res['id'].'">#</a> '.'<br />';
  114. echo text::output($res['text']);
  115.  
  116. if ($res['files']){
  117. $file = mysqli_query($sql->db, "SELECT * FROM `forum_files` WHERE `refid` = '".$res['id']."' LIMIT ".$res['files']." ");
  118. echo '<div class="func">Файл(ы):<br />';
  119. while($fileRes = $sql->fetch($file)){
  120. echo show_file($fileRes).'<br />';
  121. }
  122. echo '</div>';
  123. }
  124. $topicRes = mysqli_fetch_assoc(mysqli_query($sql->db, "SELECT * FROM `forum_topics` WHERE `id`='".$res['refid']."' LIMIT 1 "));
  125. echo '<div class="sub">Тема: <a href="index.php?topic='.$topicRes['id'].'">'.$topicRes['name'].'</a></div>';
  126. echo '</div>';
  127. ++$i;
  128. }
  129. if (!$i) echo '<div class="p_m">Неверные данные. Убедитесь в правильности ввода страницы!</div>';
  130. }elseif(isset($_GET['files'])){
  131. while ($res = $sql->fetch()){
  132. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  133. echo '<span class="gray">'.Core::time($res['time']).'</span> <a href="index.php?post='.$res['refid'].'" title="Перейти к сообщению">#</a><br />';
  134. echo show_file($res);
  135. $topicRes = $sql->query("SELECT * FROM `forum_topics` WHERE `id`='".$res['topic']."' LIMIT 1 ")->fetch();
  136. echo '<div class="sub"><a href="index.php?topic='.$topicRes['id'].'">'.$topicRes['name'].'</a></div>';
  137. echo '</div>';
  138. ++$i;
  139. }
  140. if (!$i) echo '<div class="p_m">Неверные данные. Убедитесь в правильности ввода страницы!</div>';
  141.  
  142. }elseif(isset($_GET['favourites'])){
  143. while ($res = $sql->fetch()){
  144. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  145. $sub = 'Автор: '.$res['user'];
  146. if ($res['count'] > 1){
  147. $lastPost = explode(':|:', $res['lastpost']);
  148. $sub .= ' <a href="index.php?post='.$lastPost[1].'">Последн.</a>: '.$lastPost[0];
  149. }
  150. $sub .= ' '.Core::time($res['time']).'<br />';
  151. $sub .= 'Подфорум: <a href="index.php?forum='.$res['refid'].'">'.$res['forum'].'</a>';
  152. $sub .= '<br /><a href="index.php?act=my&amp;delfavourite&amp;topic='.$res['id'].'">Удалить из избранного</a>';
  153. echo show_topic($res, $sub);
  154. echo '</div>';
  155. ++$i;
  156. }
  157. if (!$i) echo '<div class="p_m">Неверные данные. Убедитесь в правильности ввода страницы!</div>';
  158.  
  159. }elseif(isset($_GET['journal'])){
  160. while ($res = $sql->fetch()){
  161. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  162. echo Core::time($res['time']).'<br />'.(!$res['readed'] ? '<img src="images/new.png" alt="+" title="Новая запись" />' : '').'<img src="images/topic.png" alt="-" /> '.$res['text'].'</div>';
  163. if (!$res['readed'])
  164. $sql->query("UPDATE `forum_journal` SET `readed` = '1' WHERE `time` = '".$res['time']."' AND `user_id` = '$user_id' LIMIT 1 ", true);
  165. ++$i;
  166. }
  167. if (!$i) echo '<div class="p_m">Неверные данные. Убедитесь в правильности ввода страницы!</div>';
  168.  
  169. }else{
  170. while ($res = $sql->fetch()){
  171. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  172.  
  173. $sub = '';
  174. $lastPost = explode(':|:', $res['lastpost']);
  175. $sub .= ' <a href="index.php?post='.$lastPost[1].'">Последн.</a>: '.$lastPost[0];
  176. $sub .= ' '.Core::time($res['time']).'<br />';
  177.  
  178. $sub .= 'Подфорум: <a href="index.php?forum='.$res['refid'].'">'.$res['forum'].'</a>';
  179. echo show_topic($res, $sub);
  180. echo '</div>';
  181. ++$i;
  182. }
  183. if (!$i) echo '<div class="p_m">Неверные данные. Убедитесь в правильности ввода страницы!</div>';
  184. }
  185. echo '<div class="fmenu">'.$bottom.$total.'</div>';
  186.  
  187. $page->display('index.php?act=my&amp;'.$url.'&amp;');
  188. if (isset($_GET['journal']) && $total)
  189. echo '<div class="menu_razd"><a href="index.php?act=my&amp;cleanjournal">Очистить журнал</a></div>';
  190. }else{
  191. echo '<div class="p_m">Пусто</div>';
  192. }
  193.  
  194. echo '<div class="fmenu">Показать: '.$goto.'</div>';