print_page.php

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

PHP
472
字号
<?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: 2005-10-24 22:17:00 +0100 (Mon, 24 Oct 2005) $
|   > $Revision: 64 $
|   > $Author: bfarber $
+---------------------------------------------------------------------------
|
|   > Topic display in printable format module
|   > Module written by Matt Mecham
|   > Date started: 25th March 2002
|
|	> Module Version Number: 1.0.0
|   > DBA Checked: Mon 24th May 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 printpage {

    var $output    = "";
    var $base_url  = "";
    var $html      = "";
    var $moderator = array();
    var $forum     = array();
    var $topic     = array();
    var $category  = array();
    var $mem_groups = array();
    var $mem_titles = array();
    var $mod_action = array();
    var $poll_html  = "";
    var $parser     = "";
    
    /*-------------------------------------------------------------------------*/
	//
	// Our constructor, load words, load skin, print the topic listing
	//
	/*-------------------------------------------------------------------------*/
    
    function auto_run()
    {
		//-----------------------------------------
		// Compile the language file
		//-----------------------------------------
		
        $this->ipsclass->load_language('lang_printpage');
        $this->ipsclass->load_template('skin_printpage');
        
        require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
        $this->parser                      = new parse_bbcode();
        $this->parser->ipsclass            = $this->ipsclass;
        $this->parser->allow_update_caches = 1;
        
        $this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);
        
        //-----------------------------------------
        // Check the input
        //-----------------------------------------
        
        $this->ipsclass->input['t'] = intval($this->ipsclass->input['t']);
        $this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
        
        if ( ! $this->ipsclass->input['t'] or ! $this->ipsclass->input['f'] )
        {
            $this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
        }
        
        //-----------------------------------------
        // Get the forum info based on the
        // forum ID, get the category name, ID,
        // and get the topic details
        //-----------------------------------------
        
        $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=".$this->ipsclass->input['t'] ) );
		$this->ipsclass->DB->simple_exec();
        
        $this->topic = $this->ipsclass->DB->fetch_row();
        
        $this->forum = $this->ipsclass->forums->forum_by_id[ $this->topic['forum_id'] ];
        					
        //-----------------------------------------
        // Error out if we can not find the forum
        //-----------------------------------------
        
        if ( ! $this->forum['id'])
        {
        	$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
        }
        
        //-----------------------------------------
        // Error out if we can not find the topic
        //-----------------------------------------
        
        if (!$this->topic['tid'])
        {
        	$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
        }
        
        //-----------------------------------------
        // Check viewing permissions, private forums,
        // password forums, etc
        //-----------------------------------------
        
        if ( ( ! $this->topic['pinned']) and ( ! $this->ipsclass->member['g_other_topics'] ) )
        {
        	$this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
        }
        
        //-----------------------------------------
        // Check access
        //-----------------------------------------
        
        $this->ipsclass->forums->forums_check_access( $this->forum['id'], 1, 'topic' );
        
        //-----------------------------------------
        //
        // Main logic engine
        //
        //-----------------------------------------
        
        if ($this->ipsclass->input['client'] == 'choose')
        {
        	// Show the "choose page"
        	
        	$this->page_title = $this->topic['title'];
		
			$this->nav = array ( "<a href='{$this->ipsclass->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
							 	 "<a href='{$this->ipsclass->base_url}&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>"
						       );
						       
						       
			$this->output = $this->ipsclass->compiled_templates['skin_printpage']->choose_form($this->forum['id'], $this->topic['tid'], $this->topic['title']);
						       
			$this->ipsclass->print->add_output("$this->output");
			
        	$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
        	
        	exit(); // Incase we haven't already done so :p
        }
        else
        {
        	$header = 'text/html';
        	$ext    = '.html';
        	
        	switch ($this->ipsclass->input['client'])
        	{
        		case 'printer':
        			$header = 'text/html';
        			$ext    = '.html';
        			break;
        		case 'html':
        			$header = 'unknown/unknown';
        			$ext    = '.html';
        			break;
        		default:
        			$header = 'application/msword';
        			$ext    = '.doc';
        	}
        }
        
        $title = substr( str_replace( " ", "_" , preg_replace( "/&(lt|gt|quot|#124|#036|#33|#39);/", "", $this->topic['title'] ) ), 0, 12);
        
		//$this->output .= "<br><br><font size='1'><center>Powered by Invision Power Board<br>&copy; 2002 Invision PS</center></font></body></html>";
		
		@header("Content-type: $header");
		
		if ($this->ipsclass->input['client'] != 'printer')
		{
			@header("Content-Disposition: attachment; filename=$title".$ext);
		}
		
		print $this->get_posts();
		
		exit;
		
				        
	}
	
	/*-------------------------------------------------------------------------*/
	// GET POSTS
	/*-------------------------------------------------------------------------*/
	
	function get_posts()
	{
		//-----------------------------------------
		// Render the page top
		//-----------------------------------------
		
		$posts_html = $this->ipsclass->compiled_templates['skin_printpage']->pp_header( $this->forum['name'], $this->topic['title'], $this->topic['starter_name'] , $this->forum['id'], $this->topic['tid']);

		$max_posts   = 300;
		$attach_pids = array();
		
		$this->ipsclass->DB->simple_construct( array ( 'select' => '*',
													   'from'   => 'posts',
													   'where'  => "topic_id={$this->topic['tid']} and queued=0",
													   'order'  => 'pid',
													   'limit'  => array(0, $max_posts)
												   )   );
		$this->ipsclass->DB->simple_exec();
		
		//-----------------------------------------    
		// Loop through to pick out the correct member IDs.
		// and push the post info into an array - maybe in the future
		// we can add page spans, or maybe save to a PDF file?
		//-----------------------------------------
		
		$the_posts      = array();
		$mem_ids        = "";
		$member_array   = array();
		$cached_members = array();
		
		while ( $i = $this->ipsclass->DB->fetch_row() )
		{
			$the_posts[] = $i;
			
			if ($i['author_id'] != 0)
			{

⌨️ 快捷键说明

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