forums.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,549 行 · 第 1/4 页
PHP
1,549 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:27 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2006-01-30 18:53:19 +0000 (Mon, 30 Jan 2006) $| > $Revision: 127 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > Forum topic index module| > Module written by Matt Mecham| > Date started: 14th February 2002|| > Module Version Number: 1.0.0| > DBA Checked: Wed 19 May 2004| > Quality Checked: Wed 15 Sept. 2004+--------------------------------------------------------------------------*/if ( ! defined( 'IN_IPB' ) ){ print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit();}class forums { # Global var $ipsclass; var $output = ""; var $base_url = ""; var $html = ""; var $moderator = array(); var $forum = array(); var $mods = array(); var $show_dots = ""; var $nav_extra = ""; var $read_array = array(); var $board_html = ""; var $sub_output = ""; var $pinned_print = 0; var $new_posts = 0; var $is_mod = 0; var $auth_key = 0; var $announce_out = ""; var $pinned_topic_count = 0; var $forum_has_unread_topics = 0; var $db_row; # Permission var $can_edit_topics = 0; var $can_close_topics = 0; var $can_open_topics = 0; # Update... var $update_topics_close = array(); var $update_topics_open = array(); /*-------------------------------------------------------------------------*/ // Init functions /*-------------------------------------------------------------------------*/ function init() { $this->ipsclass->load_language('lang_forum'); $this->ipsclass->load_template('skin_forum'); $this->auth_key = $this->ipsclass->return_md5_check(); if ( $read = $this->ipsclass->my_getcookie('topicsread') ) { $this->read_array = $this->ipsclass->clean_int_array( unserialize(stripslashes($read)) ); } //----------------------------------------- // Multi TIDS? // If st is not defined then kill cookie // st will always be defined across pages //----------------------------------------- if ( ! isset( $this->ipsclass->input['st'] ) ) { $this->ipsclass->my_setcookie('modtids', ',', 0); $this->ipsclass->input['selectedtids'] = ""; } else { $this->ipsclass->input['selectedtids'] = $this->ipsclass->my_getcookie('modtids'); } } /*-------------------------------------------------------------------------*/ // Build permissions /*-------------------------------------------------------------------------*/ function build_permissions() { if ( $this->ipsclass->member['g_is_supmod'] ) { $this->can_edit_topics = 1; $this->can_close_topics = 1; $this->can_open_topics = 1; } else if ( is_array( $this->ipsclass->member['_moderator'][ $this->forum['id'] ] ) ) { if ( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['edit_topic'] ) { $this->can_edit_topics = 1; } if ( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['close_topic'] ) { $this->can_close_topics = 1; } if ( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['open_topic'] ) { $this->can_open_topics = 1; } } /*else if ( $this->ipsclass->member['g_edit_topic'] == 1 ) { $this->can_edit_topics = 1; would need to check per tid }*/ } /*-------------------------------------------------------------------------*/ // Our constructor, load words, load skin, get DB forum/cat data /*-------------------------------------------------------------------------*/ function auto_run() { //----------------------------------------- // Are we doing anything with "site jump?" //----------------------------------------- switch( $this->ipsclass->input['f'] ) { case 'sj_home': $this->ipsclass->boink_it($this->ipsclass->base_url."act=idx"); break; case 'sj_search': $this->ipsclass->boink_it($this->ipsclass->base_url."act=Search"); break; case 'sj_help': $this->ipsclass->boink_it($this->ipsclass->base_url."act=Help"); break; default: $this->ipsclass->input['f'] = intval($this->ipsclass->input['f']); break; } $this->init(); //----------------------------------------- // Get the forum info based on the forum ID, // and get the category name, ID, etc. //----------------------------------------- $this->forum = $this->ipsclass->forums->forum_by_id[ $this->ipsclass->input['f'] ]; //----------------------------------------- // Error out if we can not find the forum //----------------------------------------- if ( ! $this->forum['id'] ) { $this->ipsclass->Error( array( LEVEL => 1, MSG => 'is_broken_link') ); } //----------------------------------------- // Build permissions //----------------------------------------- $this->build_permissions(); //----------------------------------------- // Is it a redirect forum? //----------------------------------------- if ( $this->forum['redirect_on'] ) { $redirect = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'redirect_url', 'from' => 'forums', 'where' => "id=".$this->forum['id']) ); if ( $redirect['redirect_url'] ) { //----------------------------------------- // Update hits: //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'update' => 'forums', 'set' => 'redirect_hits=redirect_hits+1', 'where' => "id=".$this->forum['id']) ); //----------------------------------------- // Recache forum //----------------------------------------- $this->ipsclass->cache['forum_cache'][ $this->forum['id'] ][ 'redirect_hits' ] = $this->forum['redirect_hits'] + 1; //----------------------------------------- // Turn off shutdown queries to get this // parsed before the redirect //----------------------------------------- $this->ipsclass->DB->obj['use_shutdown'] = 0; $this->ipsclass->update_forum_cache(); //----------------------------------------- // Boink! //----------------------------------------- $this->ipsclass->boink_it( $redirect['redirect_url'] ); // Game over man! } } //----------------------------------------- // If this is a sub forum, we need to get // the cat details, and parent details //----------------------------------------- $this->nav = $this->ipsclass->forums->forums_breadcrumb_nav( $this->forum['id'] ); $this->forum['FORUM_JUMP'] = $this->ipsclass->build_forum_jump(1,0,0); //----------------------------------------- // Check forum access perms //----------------------------------------- if ( ! $this->ipsclass->input['L'] ) { $this->ipsclass->forums->forums_check_access( $this->forum['id'], 1 ); } //----------------------------------------- // Are we viewing the forum, or viewing the forum rules? //----------------------------------------- if ( $this->ipsclass->input['act'] == 'SR' ) { $this->show_rules(); } else { $this->show_subforums(); if ( $this->forum['sub_can_post'] ) { $this->show_forum(); } else { //----------------------------------------- // No forum to show, just use the HTML in $this->sub_output // or there will be no HTML to use in the str_replace! //----------------------------------------- $this->output = $this->ipsclass->print_forum_rules($this->forum); $this->output .= $this->sub_output; } } //----------------------------------------- // Subforums //----------------------------------------- if ($this->sub_output != "") { $this->output = str_replace( "<!--IBF.SUBFORUMS-->", $this->sub_output, $this->output ); } if ( $this->announce_out ) { $this->output = str_replace( "<!--IBF.ANNOUNCEMENTS-->", $this->announce_out, $this->output ); } $this->ipsclass->print->add_output($this->output); $this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->vars['board_name']." -> ".$this->forum['name'], 'JS' => 0, 'NAV' => $this->nav, ) ); } /*-------------------------------------------------------------------------*/ // Display any sub forums /*-------------------------------------------------------------------------*/ function show_subforums() { if ( $this->ipsclass->forums->read_topic_only == 1 ) { //$this->sub_output = ""; //return; } $boards = $this->ipsclass->load_class( ROOT_PATH.'sources/action_public/boards.php', 'boards' ); //----------------------------------------- // Load DB tracked topics //----------------------------------------- $boards->boards_get_db_tracker(); $this->sub_output = $boards->show_subforums($this->ipsclass->input['f']); } /*-------------------------------------------------------------------------*/ // Show the forum rules on a separate page /*-------------------------------------------------------------------------*/ function show_rules() { //----------------------------------------- // Do we have permission to view these rules? //----------------------------------------- $bad_entry = $this->ipsclass->forums->forums_check_access($this->forum['id'], 1); if ($bad_entry == 1) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') ); } $tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'rules_title, rules_text', 'from' => 'forums', 'where' => "id=".$this->forum['id']) ); if ( $tmp['rules_title'] ) { $rules['title'] = $tmp['rules_title']; $rules['body'] = $tmp['rules_text']; $rules['fid'] = $this->forum['id']; $this->output .= $this->ipsclass->compiled_templates['skin_forum']->show_rules($rules); $this->ipsclass->print->add_output( $this->output ); $this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->vars['board_name']." -> ".$this->forum['name'], 'JS' => 0, 'NAV' => array( $this->forum['name'] ), ) ); } else { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') ); } } /*-------------------------------------------------------------------------*/ // Forum view check for authentication /*-------------------------------------------------------------------------*/ function show_forum() { // are we checking for user authentication via the log in form // for a private forum w/password protection? if ( isset($this->ipsclass->input['L']) && $this->ipsclass->input['L'] > 1 ) { $this->ipsclass->Error( array( LEVEL=> 5, MSG =>'incorrect_use') ); } $this->ipsclass->input['L'] == 1 ? $this->authenticate_user() : $this->render_forum(); } /*-------------------------------------------------------------------------*/ // Authenicate the log in for a password protected forum /*-------------------------------------------------------------------------*/ function authenticate_user() { if ($this->ipsclass->input['f_password'] == "") { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) ); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?