[ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * index.php 4 * ------------------- 5 * begin : Saturday, Feb 13, 2001 6 * copyright : (C) 2001 The phpBB Group 7 * email : support@phpbb.com 8 * 9 * Id: index.php,v 1.99.2.3 2004/07/11 16:46:15 acydburn Exp 10 * 11 * 12 ***************************************************************************/ 13 14 /*************************************************************************** 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 2 of the License, or 19 * (at your option) any later version. 20 * 21 ***************************************************************************/ 22 23 if ( !defined('MODULE_FILE') ) 24 { 25 die("You can't access this file directly..."); 26 } 27 if ($popup != "1") 28 { 29 $module_name = basename(dirname(__FILE__)); 30 require("modules/".$module_name."/nukebb.php"); 31 } 32 else 33 { 34 $phpbb_root_path = 'modules/Forums/'; 35 } 36 define('IN_PHPBB', true); 37 include ($phpbb_root_path . 'extension.inc'); 38 include($phpbb_root_path . 'common.'.$phpEx); 39 40 // 41 // Start session management 42 // 43 $userdata = session_pagestart($user_ip, PAGE_INDEX, $nukeuser); 44 init_userprefs($userdata); 45 // 46 // End session management 47 // 48 49 $viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1; 50 51 if( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) ) 52 { 53 $mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark']; 54 } 55 else 56 { 57 $mark_read = ''; 58 } 59 60 // 61 // Handle marking posts 62 // 63 if( $mark_read == 'forums' ) 64 { 65 if( $userdata['session_logged_in'] ) 66 { 67 setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); 68 } 69 70 $template->assign_vars(array( 71 "META" => '<meta http-equiv="refresh" content="3;url=' .append_sid("index.$phpEx") . '">') 72 ); 73 74 $message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a> '); 75 76 message_die(GENERAL_MESSAGE, $message); 77 } 78 // 79 // End handle marking posts 80 // 81 82 $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array(); 83 $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array(); 84 85 // 86 // If you don't use these stats on your index you may want to consider 87 // removing them 88 // 89 $total_posts = get_db_stat('postcount'); 90 $total_users = get_db_stat('usercount'); 91 $newest_userdata = get_db_stat('newestuser'); 92 $newest_user = $newest_userdata['username']; 93 $newest_uid = $newest_userdata['user_id']; 94 95 if( $total_posts == 0 ) 96 { 97 $l_total_post_s = $lang['Posted_articles_zero_total']; 98 } 99 else if( $total_posts == 1 ) 100 { 101 $l_total_post_s = $lang['Posted_article_total']; 102 } 103 else 104 { 105 $l_total_post_s = $lang['Posted_articles_total']; 106 } 107 108 if( $total_users == 0 ) 109 { 110 $l_total_user_s = $lang['Registered_users_zero_total']; 111 } 112 else if( $total_users == 1 ) 113 { 114 $l_total_user_s = $lang['Registered_user_total']; 115 } 116 else 117 { 118 $l_total_user_s = $lang['Registered_users_total']; 119 } 120 121 122 // 123 // Start page proper 124 // 125 $sql = "SELECT c.cat_id, c.cat_title, c.cat_order 126 FROM " . CATEGORIES_TABLE . " c 127 ORDER BY c.cat_order"; 128 if( !($result = $db->sql_query($sql)) ) 129 { 130 message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); 131 } 132 $category_rows = array(); 133 while( $category_rows[] = $db->sql_fetchrow($result) ); 134 $db->sql_freeresult($result); 135 136 if( ( $total_categories = count($category_rows) ) ) 137 { 138 // 139 // Define appropriate SQL 140 // 141 switch(SQL_LAYER) 142 { 143 case 'postgresql': 144 $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id 145 FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u 146 WHERE p.post_id = f.forum_last_post_id 147 AND u.user_id = p.poster_id 148 UNION ( 149 SELECT f.*, NULL, NULL, NULL, NULL 150 FROM " . FORUMS_TABLE . " f 151 WHERE NOT EXISTS ( 152 SELECT p.post_time 153 FROM " . POSTS_TABLE . " p 154 WHERE p.post_id = f.forum_last_post_id 155 ) 156 ) 157 ORDER BY cat_id, forum_order"; 158 break; 159 160 case 'oracle': 161 $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id 162 FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u 163 WHERE p.post_id = f.forum_last_post_id(+) 164 AND u.user_id = p.poster_id(+) 165 ORDER BY f.cat_id, f.forum_order"; 166 break; 167 168 default: 169 $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id 170 FROM (( " . FORUMS_TABLE . " f 171 LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id ) 172 LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) 173 ORDER BY f.cat_id, f.forum_order"; 174 break; 175 } 176 if ( !($result = $db->sql_query($sql)) ) 177 { 178 message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); 179 } 180 181 $forum_data = array(); 182 while( $row = $db->sql_fetchrow($result) ) 183 { 184 $forum_data[] = $row; 185 } 186 $db->sql_freeresult($result); 187 188 if ( !($total_forums = count($forum_data)) ) 189 { 190 message_die(GENERAL_MESSAGE, $lang['No_forums']); 191 } 192 193 // 194 // Obtain a list of topic ids which contain 195 // posts made since user last visited 196 // 197 if ( $userdata['session_logged_in'] ) 198 { 199 $sql = "SELECT t.forum_id, t.topic_id, p.post_time 200 FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 201 WHERE p.post_id = t.topic_last_post_id 202 AND p.post_time > " . $userdata['user_lastvisit'] . " 203 AND t.topic_moved_id = '0'"; 204 if ( !($result = $db->sql_query($sql)) ) 205 { 206 message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql); 207 } 208 209 $new_topic_data = array(); 210 while( $topic_data = $db->sql_fetchrow($result) ) 211 { 212 $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time']; 213 } 214 $db->sql_freeresult($result); 215 } 216 217 // 218 // Obtain list of moderators of each forum 219 // First users, then groups ... broken into two queries 220 // 221 $sql = "SELECT aa.forum_id, u.user_id, u.username 222 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u 223 WHERE aa.auth_mod = " . TRUE . " 224 AND g.group_single_user = '1' 225 AND ug.group_id = aa.group_id 226 AND g.group_id = aa.group_id 227 AND u.user_id = ug.user_id 228 GROUP BY u.user_id, u.username, aa.forum_id 229 ORDER BY aa.forum_id, u.user_id"; 230 if ( !($result = $db->sql_query($sql)) ) 231 { 232 message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql); 233 } 234 235 $forum_moderators = array(); 236 while( $row = $db->sql_fetchrow($result) ) 237 { 238 $forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>'; 239 } 240 $db->sql_freeresult($result); 241 242 $sql = "SELECT aa.forum_id, g.group_id, g.group_name 243 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 244 WHERE aa.auth_mod = " . TRUE . " 245 AND g.group_single_user = '0' 246 AND g.group_type <> " . GROUP_HIDDEN . " 247 AND ug.group_id = aa.group_id 248 AND g.group_id = aa.group_id 249 GROUP BY g.group_id, g.group_name, aa.forum_id 250 ORDER BY aa.forum_id, g.group_id"; 251 if ( !($result = $db->sql_query($sql)) ) 252 { 253 message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql); 254 } 255 256 while( $row = $db->sql_fetchrow($result) ) 257 { 258 $forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>'; 259 } 260 $db->sql_freeresult($result); 261 262 // 263 // Find which forums are visible for this user 264 // 265 $is_auth_ary = array(); 266 $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data); 267 268 // 269 // Start output of page 270 // 271 define('SHOW_ONLINE', true); 272 $page_title = $lang['Index']; 273 include ("includes/page_header.php"); 274 275 $template->set_filenames(array( 276 'body' => 'index_body.tpl') 277 ); 278 279 $template->assign_vars(array( 280 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts), 281 'TOTAL_USERS' => sprintf($l_total_user_s, $total_users), 282 'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'), 283 284 'FORUM_IMG' => $images['forum'], 285 'FORUM_NEW_IMG' => $images['forum_new'], 286 'FORUM_LOCKED_IMG' => $images['forum_locked'], 287 288 'L_FORUM' => $lang['Forum'], 289 'L_TOPICS' => $lang['Topics'], 290 'L_REPLIES' => $lang['Replies'], 291 'L_VIEWS' => $lang['Views'], 292 'L_POSTS' => $lang['Posts'], 293 'L_LASTPOST' => $lang['Last_Post'], 294 'L_NO_NEW_POSTS' => $lang['No_new_posts'], 295 'L_NEW_POSTS' => $lang['New_posts'], 296 'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'], 297 'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'], 298 'L_ONLINE_EXPLAIN' => $lang['Online_explain'], 299 300 'L_MODERATOR' => $lang['Moderators'], 301 'L_FORUM_LOCKED' => $lang['Forum_is_locked'], 302 'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'], 303 304 'U_MARK_READ' => append_sid("index.$phpEx?mark=forums")) 305 ); 306 307 // 308 // Okay, let's build the index 309 // 310 for($i = 0; $i < $total_categories; $i++) 311 { 312 $cat_id = $category_rows[$i]['cat_id']; 313 314 // 315 // Should we display this category/forum set? 316 // 317 $display_forums = false; 318 for($j = 0; $j < $total_forums; $j++) 319 { 320 if ( $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'] && $forum_data[$j]['cat_id'] == $cat_id ) 321 { 322 $display_forums = true; 323 } 324 } 325 326 // 327 // Yes, we should, so first dump out the category 328 // title, then, if appropriate the forum list 329 // 330 if ( $display_forums ) 331 { 332 $template->assign_block_vars('catrow', array( 333 'CAT_ID' => $cat_id, 334 'CAT_DESC' => $category_rows[$i]['cat_title'], 335 'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id")) 336 ); 337 338 if ( $viewcat == $cat_id || $viewcat == -1 ) 339 { 340 for($j = 0; $j < $total_forums; $j++) 341 { 342 if ( $forum_data[$j]['cat_id'] == $cat_id ) 343 { 344 $forum_id = $forum_data[$j]['forum_id']; 345 346 if ( $is_auth_ary[$forum_id]['auth_view'] ) 347 { 348 if ( $forum_data[$j]['forum_status'] == FORUM_LOCKED ) 349 { 350 $folder_image = $images['forum_locked']; 351 $folder_alt = $lang['Forum_locked']; 352 } 353 else 354 { 355 $unread_topics = false; 356 if ( $userdata['session_logged_in'] ) 357 { 358 if ( !empty($new_topic_data[$forum_id]) ) 359 { 360 $forum_last_post_time = 0; 361 362 while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) ) 363 { 364 if ( empty($tracking_topics[$check_topic_id]) ) 365 { 366 $unread_topics = true; 367 $forum_last_post_time = max($check_post_time, $forum_last_post_time); 368 369 } 370 else 371 { 372 if ( $tracking_topics[$check_topic_id] < $check_post_time ) 373 { 374 $unread_topics = true; 375 $forum_last_post_time = max($check_post_time, $forum_last_post_time); 376 } 377 } 378 } 379 380 if ( !empty($tracking_forums[$forum_id]) ) 381 { 382 if ( $tracking_forums[$forum_id] > $forum_last_post_time ) 383 { 384 $unread_topics = false; 385 } 386 } 387 388 if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) 389 { 390 if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time ) 391 { 392 $unread_topics = false; 393 } 394 } 395 396 } 397 } 398 399 $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum']; 400 $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts']; 401 } 402 403 $posts = $forum_data[$j]['forum_posts']; 404 $topics = $forum_data[$j]['forum_topics']; 405 406 if ( $forum_data[$j]['forum_last_post_id'] ) 407 { 408 $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']); 409 410 $last_post = $last_post_time . '<br />'; 411 412 $last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> '; 413 414 $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>'; 415 } 416 else 417 { 418 $last_post = $lang['No_Posts']; 419 } 420 421 if ( count($forum_moderators[$forum_id]) > 0 ) 422 { 423 $l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators']; 424 $moderator_list = implode(', ', $forum_moderators[$forum_id]); 425 } 426 else 427 { 428 $l_moderators = ' '; 429 $moderator_list = ' '; 430 } 431 432 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 433 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 434 435 $template->assign_block_vars('catrow.forumrow', array( 436 'ROW_COLOR' => '#' . $row_color, 437 'ROW_CLASS' => $row_class, 438 'FORUM_FOLDER_IMG' => $folder_image, 439 'FORUM_NAME' => $forum_data[$j]['forum_name'], 440 'FORUM_DESC' => $forum_data[$j]['forum_desc'], 441 'POSTS' => $forum_data[$j]['forum_posts'], 442 'TOPICS' => $forum_data[$j]['forum_topics'], 443 'LAST_POST' => $last_post, 444 'MODERATORS' => $moderator_list, 445 446 'L_MODERATOR' => $l_moderators, 447 'L_FORUM_FOLDER_ALT' => $folder_alt, 448 449 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")) 450 ); 451 } 452 } 453 } 454 } 455 } 456 } // for ... categories 457 458 }// if ... total_categories 459 else 460 { 461 message_die(GENERAL_MESSAGE, $lang['No_forums']); 462 } 463 464 // 465 // Generate the page 466 // 467 $template->pparse('body'); 468 469 include ("includes/page_tail.php"); 470 471 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |