forums.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,549 行 · 第 1/4 页
PHP
1,549 行
if ( $this->ipsclass->input['f_password'] != $this->forum['password'] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'wrong_pass' ) ); } $this->ipsclass->my_setcookie( "ipbforumpass_".$this->forum['id'], md5($this->ipsclass->input['f_password']) ); $this->ipsclass->print->redirect_screen( $this->ipsclass->lang['logged_in'] , "showforum=".$this->forum['id'] ); } /*-------------------------------------------------------------------------*/ // Main render forum engine /*-------------------------------------------------------------------------*/ function render_forum() { //----------------------------------------- // INIT //----------------------------------------- # If we've changed the filters, bounce back to page 1 $this->ipsclass->input['st'] = ( $this->ipsclass->input['changefilters'] ) ? 0 : intval($this->ipsclass->input['st']); //----------------------------------------- // Are we actually a moderator for this forum? //----------------------------------------- if ( ! $this->ipsclass->member['g_is_supmod'] AND ! $this->ipsclass->member['g_access_cp'] ) { if ( ! is_array( $this->ipsclass->member['_moderator'][ $this->forum['id'] ] ) ) { $this->ipsclass->member['is_mod'] = 0; } } //----------------------------------------- // Announcements //----------------------------------------- if ( is_array( $this->ipsclass->cache['announcements'] ) and count( $this->ipsclass->cache['announcements'] ) ) { $announcements = array(); foreach( $this->ipsclass->cache['announcements'] as $id => $announce ) { $order = $announce['announce_start'] ? $announce['announce_start'].','.$announce['announce_id'] : $announce['announce_id']; if ( $announce['announce_forum'] == '*' ) { $announcements[ $order ] = $announce; } else if ( strstr( ','.$announce['announce_forum'].',', ','.$this->forum['id'].',' ) ) { $announcements[ $order ] = $announce; } } if ( count( $announcements ) ) { //----------------------------------------- // sort by start date //----------------------------------------- $announce_html = ""; rsort( $announcements ); foreach( $announcements as $id => $announce ) { if ( $announce['announce_start'] ) { $announce['announce_start'] = gmdate( 'jS F Y', $announce['announce_start'] ); } else { $announce['announce_start'] = '--'; } $announce['announce_title'] = $this->ipsclass->txt_stripslashes($announce['announce_title']); $announce['forum_id'] = $this->forum['id']; $announce['announce_views'] = intval($announce['announce_views']); $announce_html .= $this->ipsclass->compiled_templates['skin_forum']->announcement_row( $announce ); } $this->announce_out = $this->ipsclass->compiled_templates['skin_forum']->announcement_wrap($announce_html); } } //----------------------------------------- // Read topics //----------------------------------------- $First = intval($this->ipsclass->input['st']); $this->ipsclass->input['last_visit'] = $this->ipsclass->member['last_visit'] > $this->ipsclass->member['members_markers']['board'] ? $this->ipsclass->member['last_visit'] : $this->ipsclass->member['members_markers']['board']; //----------------------------------------- // Over ride with 'master' cookie? //----------------------------------------- if ( $this->ipsclass->forum_read[0] > $this->ipsclass->forum_read[ $this->ipsclass->input['f'] ] ) { $this->ipsclass->forum_read[ $this->ipsclass->input['f'] ] = $this->ipsclass->forum_read[0]; } //----------------------------------------- // Sort options //----------------------------------------- $prune_value = $this->ipsclass->select_var( array( 1 => $this->ipsclass->input['prune_day'], 2 => $this->forum['prune'] , 3 => '100' ) ); $sort_key = $this->ipsclass->select_var( array( 1 => $this->ipsclass->input['sort_key'], 2 => $this->forum['sort_key'], 3 => 'last_post' ) ); $sort_by = $this->ipsclass->select_var( array( 1 => $this->ipsclass->input['sort_by'], 2 => $this->forum['sort_order'] , 3 => 'Z-A' ) ); $topicfilter = $this->ipsclass->select_var( array( 1 => $this->ipsclass->input['topicfilter'], 2 => $this->forum['topicfilter'] , 3 => 'all' ) ); //----------------------------------------- // Figure out sort order, day cut off, etc //----------------------------------------- $Prune = $prune_value != 100 ? (time() - ($prune_value * 60 * 60 * 24)) : 0; $sort_keys = array( 'last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views', ); $prune_by_day = array( '1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', ); $sort_by_keys = array( 'Z-A' => 'descending_order', 'A-Z' => 'ascending_order', ); $filter_keys = array( 'all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved', ); if ( $this->ipsclass->member['id'] ) { $filter_keys['istarted'] = 'topicfilter_istarted'; $filter_keys['ireplied'] = 'topicfilter_ireplied'; } //----------------------------------------- // check for any form funny business by wanna-be hackers //----------------------------------------- if ( (!isset($filter_keys[$topicfilter])) or (!isset($sort_keys[$sort_key])) or (!isset($prune_by_day[$prune_value])) or (!isset($sort_by_keys[$sort_by])) ) { $this->ipsclass->Error( array( LEVEL=> 5, MSG =>'incorrect_use') ); } $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC'; //----------------------------------------- // Additional queries? //----------------------------------------- $add_query_array = array(); $add_query = ""; switch( $topicfilter ) { case 'all': break; case 'open': $add_query_array[] = "t.state='open'"; break; case 'hot': $add_query_array[] = "t.state='open' AND t.posts + 1 >= ".intval($this->ipsclass->vars['hot_topic']); break; case 'locked': $add_query_array[] = "t.state='closed'"; break; case 'moved': $add_query_array[] = "t.state='link'"; break; case 'poll': $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)"; break; default: break; } if ( ! $this->ipsclass->member['g_other_topics'] or $topicfilter == 'istarted' ) { $add_query_array[] = "t.starter_id='".$this->ipsclass->member['id']."'"; } if ( count($add_query_array) ) { $add_query = ' AND '. implode( ' AND ', $add_query_array ); } //----------------------------------------- // Moderator? //----------------------------------------- if ( ! $this->ipsclass->member['is_mod'] ) { $approved = 'and t.approved=1'; } else { $approved = 'and t.approved IN (0,1)'; } //----------------------------------------- // Query the database to see how many topics there are in the forum //----------------------------------------- if ( $topicfilter == 'ireplied' ) { //----------------------------------------- // Checking topics we've replied to? //----------------------------------------- if ( $Prune ) { $prune_filter = "and (t.pinned=1 or t.last_post > $Prune)"; } else { $prune_filter = ""; } $this->ipsclass->DB->cache_add_query( 'forums_get_replied_topics', array( 'mid' => $this->ipsclass->member['id'], 'fid' => $this->forum['id'], 'approved' => $approved, 'prune_filter' => $prune_filter ) ); $this->ipsclass->DB->cache_exec_query(); $total_possible = $this->ipsclass->DB->fetch_row(); } else if ( ( $add_query or $Prune ) and ! $this->ipsclass->input['modfilter'] ) { $this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=".$this->forum['id']." {$approved} and (t.pinned=1 or t.last_post > $Prune)" . $add_query ) ); $this->ipsclass->DB->simple_exec(); $total_possible = $this->ipsclass->DB->fetch_row(); } else { $total_possible['max'] = $this->ipsclass->member['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics']; $Prune = 0; } //----------------------------------------- // Generate the forum page span links //----------------------------------------- $this->forum['SHOW_PAGES'] = $this->ipsclass->build_pagelinks( array( 'TOTAL_POSS' => $total_possible['max'], 'PER_PAGE' => $this->ipsclass->vars['display_max_topics'], 'CUR_ST_VAL' => $this->ipsclass->input['st'], 'L_SINGLE' => $this->ipsclass->lang['single_page_forum'], 'BASE_URL' => $this->ipsclass->base_url."showforum=".$this->forum['id']."&prune_day=$prune_value&sort_by=$sort_by&sort_key=$sort_key&topicfilter={$topicfilter}", ) ); //----------------------------------------- // Do we have any rules to show? //----------------------------------------- $this->output .= $this->ipsclass->print_forum_rules($this->forum); //----------------------------------------- // Start printing the page //----------------------------------------- $this->output .= $this->ipsclass->compiled_templates['skin_forum']->PageTop( $this->forum, $this->can_edit_topics, $this->can_open_topics, $this->can_close_topics ); //----------------------------------------- // Do we have any topics to show? //----------------------------------------- if ($total_possible['max'] < 1) { $this->output .= $this->ipsclass->compiled_templates['skin_forum']->show_no_matches(); } $total_topics_printed = 0; //----------------------------------------- // Get main topics //----------------------------------------- $topic_array = array(); $topic_ids = array(); $topic_sort = ""; //----------------------------------------- // Mod filter? //----------------------------------------- if ( $this->ipsclass->input['modfilter'] == 'invisible_topics' and $this->ipsclass->member['is_mod'] ) { $topic_sort = 't.approved asc,'; } else if ( $this->ipsclass->input['modfilter'] == 'invisible_posts' and $this->ipsclass->member['is_mod'] ) { $topic_sort = 't.topic_queuedposts desc,'; } else if ( $this->ipsclass->input['modfilter'] == 'all' and $this->ipsclass->member['is_mod'] ) { $topic_sort = 't.approved asc, t.topic_queuedposts desc,'; } //----------------------------------------- // Cut off? //----------------------------------------- $parse_dots = 1; if ( $Prune ) { $query = "t.forum_id=".$this->forum['id']." AND t.pinned IN (0,1) {$approved} and (t.last_post > $Prune OR t.pinned=1)"; } else { $query = "t.forum_id=".$this->forum['id']." AND t.pinned IN (0,1) {$approved}"; } if ( $topicfilter == 'ireplied' ) { //----------------------------------------- // Checking topics we've replied to? // No point in getting dots again... //----------------------------------------- $parse_dots = 0; $this->ipsclass->DB->cache_add_query( 'forums_get_replied_topics_actual', array( 'mid' => $this->ipsclass->member['id'], 'fid' => $this->forum['id'], 'query' => $query, 'topic_sort' => $topic_sort, 'sort_key' => "t.".$sort_key, 'r_sort_by' => $r_sort_by, 'limit_a' => intval($First), 'limit_b' => intval($this->ipsclass->vars['display_max_topics']) ) ); $this->ipsclass->DB->cache_exec_query(); } else
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?