topics.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,929 行 · 第 1/5 页

PHP
1,929
字号
<?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:28 GMT|   Release: |   Licence Info: +---------------------------------------------------------------------------|   > $Date: 2006-01-05 11:02:13 +0000 (Thu, 05 Jan 2006) $|   > $Revision: 114 $|   > $Author: matt $+---------------------------------------------------------------------------||   > Topic display module|   > Module written by Matt Mecham|   > Date started: 18th February 2002||	> Module Version Number: 1.1.0|   > DBA Checked: Thu 20 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 topics{	# Global	var $ipsclass;	    var $output         = "";    var $base_url       = "";    var $html           = "";    var $moderator      = array();    var $forum          = array();    var $topic          = array();    var $mem_titles     = array();    var $mod_action     = array();    var $poll_html      = "";    var $parser         = "";    var $mimetypes      = "";    var $nav_extra      = "";    var $read_array     = array();    var $mod_panel_html = "";    var $warn_range     = 0;    var $warn_done      = 0;    var $md5_check      = "";    var $post_count     = 0;    var $cached_members = array();    var $first_printed  = 0;    var $pids           = array();    var $attach_pids    = array();    var $first          = "";    var $qpids          = "";    var $custom_fields  = "";    var $last_read_tid  = "";        # Permissions    var $can_vote		= 0;	var $can_rate       = 0;	    /*-------------------------------------------------------------------------*/	//	// Our constructor, load words, load skin, print the topic listing	//	/*-------------------------------------------------------------------------*/	    function auto_run()    {    	//-----------------------------------------    	// Build all permissions    	//-----------------------------------------    	    	$this->build_permissions();    	    	//-----------------------------------------    	// Are we just adding a poll vote?    	//-----------------------------------------    	    	if ( $this->ipsclass->input['addpoll'] )    	{    		$this->topic_add_vote_to_poll();    	}    	    	//-----------------------------------------    	// INIT module    	//-----------------------------------------    	        $this->init();                //-----------------------------------------    	// Are we just adding a rating vote?    	//-----------------------------------------    	    	if ( $this->ipsclass->input['addrating'] )    	{    		$this->topic_add_vote_to_rating();    	}    	        //-----------------------------------------		// Process the topic		//-----------------------------------------                $this->topic_set_up();                //-----------------------------------------		// Which view are we using?		//-----------------------------------------				if ( $this->ipsclass->input['mode'] )		{			$this->topic_view_mode = $this->ipsclass->input['mode'];			$this->ipsclass->my_setcookie( 'topicmode', $this->ipsclass->input['mode'], 1 );		}		else		{			$this->topic_view_mode = $this->ipsclass->my_getcookie('topicmode');		}				if ( ! $this->topic_view_mode )		{			//-----------------------------------------			// No cookie and no URL			//-----------------------------------------						$this->topic_view_mode = $this->ipsclass->vars['topicmode_default'] ? $this->ipsclass->vars['topicmode_default'] : 'linear';		}                //-----------------------------------------        // VIEWS        //-----------------------------------------                if ( isset($this->ipsclass->input['view']) )        {        	if ($this->ipsclass->input['view'] == 'new')        	{        		//-----------------------------------------        		// Newer         		//-----------------------------------------        		        		$this->ipsclass->DB->simple_construct( array( 'select' => 'tid',															  'from'   => 'topics',															  'where'  => "forum_id=".$this->forum['id']." AND approved=1 AND state <> 'link' AND last_post > ".$this->topic['last_post'],															  'order'  => 'last_post',															  'limit'  => array( 0,1 )													)      );													$this->ipsclass->DB->simple_exec();        		        		if ( $this->ipsclass->DB->get_num_rows() )        		{        			$this->topic = $this->ipsclass->DB->fetch_row();        			        			$this->ipsclass->boink_it($this->ipsclass->base_url."showtopic=".$this->topic['tid']);        		}        		else        		{        			$this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_newer') );        		}        	}        	else if ($this->ipsclass->input['view'] == 'old')        	{        		//-----------------------------------------        		// Older        		//-----------------------------------------        						$this->ipsclass->DB->simple_construct( array( 'select' => 'tid',															  'from'   => 'topics',															  'where'  => "forum_id=".$this->forum['id']." AND approved=1 AND state <> 'link' AND last_post < ".$this->topic['last_post'],															  'order'  => 'last_post DESC',															  'limit'  => array( 0,1 )													)      );													$this->ipsclass->DB->simple_exec();									if ( $this->ipsclass->DB->get_num_rows() )        		{        			$this->topic = $this->ipsclass->DB->fetch_row();        			        			$this->ipsclass->boink_it($this->ipsclass->base_url."showtopic=".$this->topic['tid']);        		}        		else        		{        			$this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_older') );        		}        	}        	else if ($this->ipsclass->input['view'] == 'getlastpost')        	{        		//-----------------------------------------        		// Last post        		//-----------------------------------------        		        		$this->return_last_post();			}			else if ($this->ipsclass->input['view'] == 'getnewpost')			{				//-----------------------------------------				// Newest post				//-----------------------------------------								$st  = 0;				$pid = "";								if ( $this->ipsclass->vars['db_topic_read_cutoff'] and $this->ipsclass->member['id'] )				{					$last_time = intval( $this->my_topics_read[ $this->topic['tid'] ] ) ? intval( $this->my_topics_read[ $this->topic['tid'] ] ) : intval( $this->db_row['marker_last_cleared'] );				}								$last_time = $last_time ? $last_time : $this->ipsclass->input['last_visit'];								$this->ipsclass->DB->simple_construct( array( 'select' => 'MIN(pid) as pid',															  'from'   => 'posts',															  'where'  => "queued=0 AND topic_id=".$this->topic['tid']." AND post_date > ".intval($last_time),															  'limit'  => array( 0,1 )													)      );										$this->ipsclass->DB->simple_exec();								$post = $this->ipsclass->DB->fetch_row();								if ( $post['pid'] )				{					$pid = "&#entry".$post['pid'];										$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(*) as posts',																  'from'   => 'posts',																  'where'  => "topic_id=".$this->topic['tid']." AND pid <= ".$post['pid'],														)      );															$this->ipsclass->DB->simple_exec();									$cposts = $this->ipsclass->DB->fetch_row();										if ( (($cposts['posts']) % $this->ipsclass->vars['display_max_posts']) == 0 )					{						$pages = ($cposts['posts']) / $this->ipsclass->vars['display_max_posts'];					}					else					{						$number = ( ($cposts['posts']) / $this->ipsclass->vars['display_max_posts'] );						$pages = ceil( $number);					}										$st = ($pages - 1) * $this->ipsclass->vars['display_max_posts'];										$this->ipsclass->boink_it($this->ipsclass->base_url."showtopic=".$this->topic['tid']."&st=$st".$pid);				}				else				{					$this->return_last_post();				}			}			else if ($this->ipsclass->input['view'] == 'findpost')			{				//-----------------------------------------				// Find a post				//-----------------------------------------								$pid = intval($this->ipsclass->input['p']);								if ( $pid > 0 )				{					$this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(*) as posts',																  'from'   => 'posts',																  'where'  => "topic_id=".$this->topic['tid']." AND pid <= ".$pid,														)      );															$this->ipsclass->DB->simple_exec();										$cposts = $this->ipsclass->DB->fetch_row();										if ( (($cposts['posts']) % $this->ipsclass->vars['display_max_posts']) == 0 )					{						$pages = ($cposts['posts']) / $this->ipsclass->vars['display_max_posts'];					}					else					{						$number = ( ($cposts['posts']) / $this->ipsclass->vars['display_max_posts'] );						$pages = ceil( $number);					}										$st = ($pages - 1) * $this->ipsclass->vars['display_max_posts'];										$this->ipsclass->boink_it($this->ipsclass->base_url."showtopic=".$this->topic['tid']."&st=$st&p=$pid"."&#entry".$pid);				}				else				{					$this->return_last_post();				}			}		}				//-----------------------------------------		// UPDATE TOPIC?		//-----------------------------------------				if ( ! $this->ipsclass->input['b'] )		{			if ( $this->topic['topic_firstpost'] < 1 )			{				//--------------------------------------				// No first topic set - old topic, update				//--------------------------------------								$this->ipsclass->DB->simple_construct( array (												'select' => 'pid',												'from'   => 'posts',												'where'  => 'topic_id='.$this->topic['tid'].' AND new_topic=1'									 )       );									 				$this->ipsclass->DB->simple_exec();								$post = $this->ipsclass->DB->fetch_row();								if ( ! $post['pid'] )				{					//-----------------------------------------					// Get first post info					//-----------------------------------------										$this->ipsclass->DB->simple_construct( array( 'select' => 'pid',																  'from'   => 'posts',																  'where'  => "topic_id={$this->topic['tid']}",																  'order'  => 'pid ASC',																  'limit'  => array(0,1) ) );					$this->ipsclass->DB->simple_exec();										$first_post  = $this->ipsclass->DB->fetch_row();					$post['pid'] = $first_post['pid'];				}								if ( $post['pid'] )				{					$this->ipsclass->DB->simple_construct( array (																  'update' => 'topics',																  'set'    => 'topic_firstpost='.$post['pid'],																  'where'  => 'tid='.$this->topic['tid']										 )       );										 					$this->ipsclass->DB->simple_exec();				}								//--------------------------------------				// Reload "fixed" topic				//--------------------------------------								$this->ipsclass->boink_it($this->ipsclass->base_url."showtopic=".$this->topic['tid']."&b=1&st={$this->ipsclass->input['st']}&p={$this->ipsclass->input['p']}"."&#entry".$this->ipsclass->input['p']);			}		}				$find_pid = $this->ipsclass->input['pid'] == "" ? $this->ipsclass->input['p'] : $this->ipsclass->input['pid'];				if ( $find_pid )		{			$threaded_pid = '&amp;pid='.$find_pid;			$linear_pid   = '&amp;view=findpost&amp;p='.$find_pid;		}				if ( $this->topic_view_mode == 'threaded' )		{			$require = 'topic_threaded.php';						$this->topic['to_button_threaded'] = $this->ipsclass->compiled_templates['skin_topic']->toutline_mode_choice_on(  "{$this->ipsclass->base_url}showtopic={$this->topic['tid']}&amp;mode=threaded".$threaded_pid, $this->ipsclass->lang['tom_outline'] );			$this->topic['to_button_standard'] = $this->ipsclass->compiled_templates['skin_topic']->toutline_mode_choice_off( "{$this->ipsclass->base_url}showtopic={$this->topic['tid']}&amp;mode=linear".$linear_pid, $this->ipsclass->lang['tom_standard'] );			$this->topic['to_button_linearpl'] = $this->ipsclass->compiled_templates['skin_topic']->toutline_mode_choice_off( "{$this->ipsclass->base_url}showtopic={$this->topic['tid']}&amp;mode=linearplus".$linear_pid, $this->ipsclass->lang['tom_linear'] );					}		else		{			$require = 'topic_linear.php';						$this->topic['to_button_threaded'] = $this->ipsclass->compiled_templates['skin_topic']->toutline_mode_choice_off( "{$this->ipsclass->base_url}showtopic={$this->topic['tid']}&amp;mode=threaded".$threaded_pid, $this->ipsclass->lang['tom_outline'] );			

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?