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

Размер файла: 10.99Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', true);
  7. $phpbb_root_path = './';
  8. include($phpbb_root_path . 'extension.inc');
  9. include($phpbb_root_path . 'common.'.$phpEx);
  10.  
  11. if (!empty($board_config['index_announcement']))
  12. {
  13. include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  14. }
  15.  
  16. $userdata = session_pagestart($user_ip, PAGE_INDEX);
  17. init_userprefs($userdata);
  18.  
  19. $viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;
  20.  
  21. // if( (!$board_config['index_spisok'] && !$userdata['session_logged_in']) || ($userdata['session_logged_in'] && !$userdata['user_index_spisok']) )
  22. // {
  23. // if ( $viewcat < 0 )
  24. // $viewcat = -2 ;
  25. // }
  26.  
  27. $verh = '';
  28. $niz = '';
  29.  
  30. $sql = "SELECT *
  31. FROM ".$table_prefix."shop_sites
  32. ORDER BY id ASC";
  33. if( !($result = $db->sql_query($sql)) )
  34. {
  35. message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
  36. }
  37.  
  38. if ( $row = $db->sql_fetchrow($result) )
  39. {
  40. $i = 0;
  41. do
  42. {
  43. if ( $row['site_order'] )
  44. {
  45. if ( $row['site_time'] < time() )
  46. {
  47. $sqldel = "DELETE FROM ".$table_prefix."shop_sites WHERE id = " . $row['id'];
  48. $resultdel = $db->sql_query($sqldel);
  49. } else {
  50. $niz .= '<a href="http://' . $row['site_url'] . '">' . $row['site_desc'] . '</a><br/>';
  51. }
  52. } else {
  53. if ( $row['site_time'] < time() )
  54. {
  55. $sqldel = "DELETE FROM ".$table_prefix."shop_sites WHERE id = " . $row['id'];
  56. $resultdel = $db->sql_query($sqldel);
  57. } else {
  58. $verh .= '<a href="http://' . $row['site_url'] . '">' . $row['site_desc'] . '</a><br/>';
  59. }
  60. }
  61.  
  62. $i++;
  63. }
  64. while ( $row = $db->sql_fetchrow($result) );
  65. $db->sql_freeresult($result);
  66. }
  67.  
  68. $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
  69. $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
  70.  
  71. $total_posts = get_db_stat('postcount');
  72. $total_users = get_db_stat('usercount');
  73. $total_attach = get_db_stat('attachcount');
  74. $newest_userdata = get_db_stat('newestuser');
  75. $newest_user = $newest_userdata['username'];
  76. $newest_uid = $newest_userdata['user_id'];
  77.  
  78. $statistika = "<p>".sprintf($lang['Posted_articles_total'], $total_posts)."<br/>\n".sprintf($lang['Attach_total'], $total_attach)."<br/>\n".sprintf($lang['Registered_users_total'], $total_users)."<br/>\n".sprintf($lang['Newest_user'], '<a href="' . append_sid("../pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>')."</p>";
  79.  
  80. $ban_information = session_userban($user_ip, $userdata['user_id']);
  81. if ($ban_information)
  82. {
  83. $ban = '<div class="text" style="color: red; font-weight: bold;">Внимание!<br/></div><div style="border: 1px solid #d4d6d4; background: #333;">Ваш '.$ban_information.'</div>';
  84. } else {
  85. $ban = '';
  86. }
  87.  
  88. $sql = "SELECT c.cat_id, c.cat_title, c.cat_order
  89. FROM " . CATEGORIES_TABLE . " c
  90. ORDER BY c.cat_order";
  91. if( !($result = $db->sql_query($sql)) )
  92. {
  93. message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
  94. }
  95.  
  96. $category_rows = array();
  97. while ($row = $db->sql_fetchrow($result))
  98. {
  99. $category_rows[] = $row;
  100. if ($row['cat_id'] == $viewcat) {$keywords= ($row['cat_keywords'] == '') ? $board_config['index_keywords'] : $row['cat_keywords'];}
  101. }
  102. $db->sql_freeresult($result);
  103. $total_categories = count($category_rows);
  104.  
  105. $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
  106. FROM (( " . FORUMS_TABLE . " f
  107. LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
  108. LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
  109. ORDER BY f.cat_id, f.forum_order";
  110. if ( !($result = $db->sql_query($sql)) )
  111. {
  112. message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
  113. }
  114.  
  115. $forum_data = array();
  116. while( $row = $db->sql_fetchrow($result) )
  117. {
  118. $forum_data[] = $row;
  119. }
  120. $db->sql_freeresult($result);
  121.  
  122. $total_forums = count($forum_data);
  123.  
  124. if ($userdata['session_logged_in'])
  125. {
  126. if ($userdata['user_lastvisit'] < (time() - 5184000))
  127. {
  128. $userdata['user_lastvisit'] = time() - 5184000;
  129. }
  130.  
  131. $sql = "SELECT t.forum_id, t.topic_id, p.post_time
  132. FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
  133. WHERE p.post_id = t.topic_last_post_id
  134. AND p.post_time > " . $userdata['user_lastvisit'] . "
  135. AND t.topic_moved_id = 0";
  136. if ( !($result = $db->sql_query($sql)) )
  137. {
  138. message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
  139. }
  140.  
  141. $new_topic_data = array();
  142. while( $topic_data = $db->sql_fetchrow($result) )
  143. {
  144. $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
  145. }
  146. $db->sql_freeresult($result);
  147. }
  148. if( $userdata['session_logged_in'] )
  149.  
  150. $sql = "SELECT COUNT(post_id) as total
  151. FROM " . POSTS_TABLE . "
  152. WHERE post_time >= " . $userdata['user_lastvisit'];
  153. $result = $db->sql_query($sql);
  154. if( $result )
  155. {
  156. $row = $db->sql_fetchrow($result);
  157. $lang['Search_new'] = $lang['Search_new'] . "&nbsp;[" . $row['total'] . "]";
  158. }
  159. $admin_link = ( $userdata['user_level'] == ADMIN ) ? '&raquo; <a href="admin/index.' . $phpEx . '?sid=' . $userdata['session_id'] . '">' . $lang['Admin_panel'] . '</a>' : '';
  160.  
  161. $is_auth_ary = array();
  162. $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
  163.  
  164. $sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :"";
  165. if($result = $db->sql_query($sql))
  166. {
  167. if (!empty($result))
  168. {
  169. $time_now = time();
  170. $this_year = create_date('Y', $time_now, $board_config['board_timezone']);
  171. $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
  172. $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
  173. while ($birthdayrow = $db->sql_fetchrow($result))
  174. {
  175. $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
  176. if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000;
  177. if ( $user_birthday2 > $date_today && $user_birthday2 <= $date_forward )
  178. {
  179. $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
  180. switch ($birthdayrow['user_level'])
  181. {
  182. case ADMIN :
  183. $birthdayrow['username'] = $birthdayrow['username'];
  184. $style_color = 'style="color:#ffcc00"';
  185. break;
  186. case MOD :
  187. $birthdayrow['username'] = $birthdayrow['username'];
  188. $style_color = 'style="color:#943043"';
  189. break;
  190. default: $style_color = '';
  191. }
  192. $birthday_week_list .= ' <a href="' . append_sid("pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
  193.  
  194. } else if ( $user_birthday2 == $date_today ) {
  195.  
  196. $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
  197. switch ($birthdayrow['user_level'])
  198. {
  199. case ADMIN :
  200. $birthdayrow['username'] = $birthdayrow['username'];
  201. $style_color = 'style="color:#ffcc00"';
  202. break;
  203. case MOD :
  204. $birthdayrow['username'] = $birthdayrow['username'];
  205. $style_color = 'style="color:#943043"';
  206. break;
  207. default: $style_color = '';
  208. }
  209.  
  210. $birthday_today_list .= ' <a href="' . append_sid("pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
  211. }
  212. }
  213. if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
  214. if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
  215. }
  216. $db->sql_freeresult($result);
  217. }
  218. // meta tags mod start
  219. if ($viewcat == -1) {$keywords = $board_config['index_keywords'];}
  220. $keywords = $board_config['index_keywords'];
  221. // meta tags mod end
  222. $page_title = 'Форум';
  223. include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  224.  
  225. $template->set_filenames(array(
  226. 'body' => 'forum.tpl')
  227. );
  228.  
  229. if (function_exists('get_html_translation_table'))
  230. {
  231. $u_search_author = urlencode(strtr($userdata['username'], array_flip(get_html_translation_table(HTML_ENTITIES))));
  232. }
  233. else
  234. {
  235. $u_search_author = urlencode(str_replace(array('&amp;', '&#039;', '&quot;', '&lt;', '&gt;'), array('&', "'", '"', '<', '>'), $userdata['username']));
  236. }
  237.  
  238. $template->assign_vars(array(
  239. 'my_tm' => append_sid("../pages/search.$phpEx?search_author=" . $u_search_author),
  240. 'STATISTIKA' => $statistika,
  241. 'L_WHOSBIRTHDAY_WEEK' => ($board_config['birthday_check_day'] > 1) ? sprintf( (($birthday_week_list) ? $lang['Birthday_week'] : $lang['Nobirthday_week']), $board_config['birthday_check_day']).$birthday_week_list : '',
  242. 'L_WHOSBIRTHDAY_TODAY' => ($board_config['birthday_check_day']) ? ($birthday_today_list) ? $lang['Birthday_today'].$birthday_today_list : $lang['Nobirthday_today'] : '',
  243. 'ADMIN_LINK' => $admin_link,
  244. 'VERH' => $verh,
  245. 'NIZ' => $niz,
  246. 'BAN_INFO' => $ban)
  247. );
  248.  
  249. if (!empty($board_config['index_announcement']))
  250. {
  251. $announcement = smilies_pass($board_config['index_announcement']);
  252. $announcement = str_replace("\n", "\n<br/>\n", $announcement);
  253.  
  254. $template->assign_block_vars('announcement', array(
  255. 'ANNOUNCEMENT' => $announcement)
  256. );
  257. }
  258.  
  259. $display_categories = array();
  260.  
  261. for ($i = 0; $i < $total_forums; $i++ )
  262. {
  263. if ($is_auth_ary[$forum_data[$i]['forum_id']]['auth_view'])
  264. {
  265. $display_categories[$forum_data[$i]['cat_id']] = true;
  266. }
  267. }
  268.  
  269. for($i = 0; $i < $total_categories; $i++)
  270. {
  271. $cat_id = $category_rows[$i]['cat_id'];
  272.  
  273. if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
  274. {
  275. $template->assign_block_vars('catrow', array(
  276. 'CAT_DESC' => $category_rows[$i]['cat_title'],
  277. 'U_VIEWCAT' => append_sid("forum.$phpEx?" . POST_CAT_URL . "=$cat_id"))
  278. );
  279.  
  280. if ( $viewcat == $cat_id || $viewcat == -1 )
  281. {
  282. for($j = 0; $j < $total_forums; $j++)
  283. {
  284. if ( $forum_data[$j]['cat_id'] == $cat_id )
  285. {
  286. $forum_id = $forum_data[$j]['forum_id'];
  287.  
  288. if ( $is_auth_ary[$forum_id]['auth_view'] )
  289. {
  290. $posts = $forum_data[$j]['forum_posts'];
  291. //////////// новый список подфорумов
  292. // if($userdata['user_index_spisok'] == 0)
  293. // {
  294. // $template->set_filenames(array(
  295. // 'body' => 'cat_body.tpl')
  296. // );
  297. // }
  298. //////////////////
  299.  
  300. $template->assign_block_vars('catrow.forumrow', array(
  301. 'FORUM_NAME' => $forum_data[$j]['forum_name'],
  302. 'POSTS' => $forum_data[$j]['forum_posts'],
  303. 'TOPICS' => $forum_data[$j]['forum_topics'],
  304. 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
  305. );
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312.  
  313. $template->pparse('body');
  314.  
  315. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  316.  
  317. ?>