class_post.php

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

PHP
2,030
字号
<?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-02-02 17:23:13 +0000 (Thu, 02 Feb 2006) $|   > $Revision: 133 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > Post Class|   > Module written by Matt Mecham|   > Date started: Wednesday 9th March 2005 (15:23)+--------------------------------------------------------------------------*/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 class_post{	# Classes	var $ipsclass;	var $parser;	var $email;	var $han_editor;	    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 $obj        = array();    var $times      = array();    var $root_path  = '';        var $md5_check        = "";    var $module           = "";    var $attach_sum       = -1;    var $is_merging_posts = 0;        # Permissions	var $can_add_poll				   = 0;	var $max_poll_questions            = 0;	var $max_poll_choices_per_question = 0;	var $can_upload                    = 0;    var $can_edit_poll				   = 0; 	var $poll_total_votes			   = 0; 	var $can_set_close_time            = 0; 	var $can_set_open_time             = 0; 	    /*-------------------------------------------------------------------------*/    // INIT    /*-------------------------------------------------------------------------*/        function load_classes()    {        //-----------------------------------------        // Load and config the post parser        //-----------------------------------------                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']);                //-----------------------------------------        // Load and config the std/rte editors        //-----------------------------------------                require_once( ROOT_PATH."sources/handlers/han_editor.php" );        $this->han_editor           = new han_editor();        $this->han_editor->ipsclass =& $this->ipsclass;        $this->han_editor->init();                //-----------------------------------------        // Load the email libby        //-----------------------------------------                require_once( ROOT_PATH."sources/classes/class_email.php" );		$this->email = new emailer();        $this->email->ipsclass =& $this->ipsclass;        $this->email->email_init();                //-----------------------------------------		// Compile the language file		//-----------------------------------------		        $this->ipsclass->load_language('lang_post');        $this->ipsclass->load_template('skin_post');            }        /*-------------------------------------------------------------------------*/	// Build permissions	/*-------------------------------------------------------------------------*/		function convert_open_close_times()	{		//-----------------------------------------		// OPEN...		//-----------------------------------------				if ( $this->can_set_open_time AND $_POST['open_time_date'] AND $_POST['open_time_time'] )		{			list( $month, $day, $year ) = explode( "/", $_POST['open_time_date'] );			list( $hour , $minute     ) = explode( ":", $_POST['open_time_time'] );						if ( checkdate( $month, $day, $year ) )			{				$this->times['open'] = $this->ipsclass->convert_local_date_to_unix( array( 'month'  => intval($month),																						   'day'    => intval($day),																						   'year'   => intval($year),																						   'hour'   => intval($hour),																						   'minute' => intval($minute) ) );			}		}				//-----------------------------------------		// CLOSE...		//-----------------------------------------				if ( $this->can_set_open_time AND $_POST['close_time_date'] AND $_POST['close_time_time'] )		{			list( $month, $day, $year ) = explode( "/", $_POST['close_time_date'] );			list( $hour , $minute     ) = explode( ":", $_POST['close_time_time'] );						if ( checkdate( $month, $day, $year ) )			{				$this->times['close'] = $this->ipsclass->convert_local_date_to_unix( array( 'month'  => intval($month),																							'day'    => intval($day),																							'year'   => intval($year),																							'hour'   => intval($hour),																							'minute' => intval($minute) ) );			}		}	}	    /*-------------------------------------------------------------------------*/	// Build permissions	/*-------------------------------------------------------------------------*/		function build_permissions()	{		//-----------------------------------------        // Can we upload files?        //-----------------------------------------                if ( $this->ipsclass->check_perms($this->forum['upload_perms']) == TRUE )        {        	if ( $this->ipsclass->member['g_attach_max'] != -1 )        	{        		$this->can_upload = 1;				$this->obj['form_extra']   = " enctype='multipart/form-data'";				$this->obj['hidden_field'] = "<input type='hidden' name='MAX_FILE_SIZE' value='".($this->ipsclass->member['g_attach_max']*1024)."' />";        	}        }        		//-----------------------------------------		// Allowed poll?		//-----------------------------------------				$this->can_add_poll                  = intval($this->ipsclass->member['g_post_polls']);		$this->max_poll_choices_per_question = intval($this->ipsclass->vars['max_poll_choices']);		$this->max_poll_questions            = intval($this->ipsclass->vars['max_poll_questions']);		$this->can_edit_poll                 = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['edit_post'] );				if ( ! $this->max_poll_questions )		{			$this->can_add_poll = 0;		}				if ( ! $this->forum['allow_poll'] )		{			$this->can_add_poll = 0;		}				//-----------------------------------------        // Are we a moderator?        //-----------------------------------------                if ( $this->ipsclass->member['id'] != 0 and $this->ipsclass->member['g_is_supmod'] == 0 )        {        	$this->moderator = $this->ipsclass->member['_moderator'][ $this->forum['id'] ];        }				//-----------------------------------------		// Set open and close time		//-----------------------------------------				$this->can_set_open_time  = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_open_time'] );		$this->can_set_close_time = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_close_time'] );	}	    /*-------------------------------------------------------------------------*/    // Show post preview    /*-------------------------------------------------------------------------*/        function show_post_preview( $t="" )    {    	$this->parser->parse_html    = intval($this->ipsclass->input['post_htmlstatus']) AND $this->forum['use_html'] AND $this->ipsclass->member['g_dohtml'] ? 1 : 0;		$this->parser->parse_nl2br   = $this->ipsclass->input['post_htmlstatus'] == 2 ? 1 : 0;		$this->parser->parse_smilies = intval($this->ipsclass->input['enableemo']);		$this->parser->parse_bbcode  = $this->forum['use_ibc'];				# Make sure we have the pre-edit look		$t = $this->parser->pre_display_parse( $this->parser->pre_db_parse( $this->parser->pre_edit_parse($t) ) );				//-----------------------------------------		// Attachments?		//-----------------------------------------				preg_match_all( "#\[attachmentid=(\d+)\]#is", $t, $match );				if ( is_array($match[0]) and count($match[0]) )		{			for ( $i = 0 ; $i < count($match[0]) ; $i++ )			{				if ( $match[1][$i] )				{					$attach_pids[ $match[1][$i] ] = $match[1][$i];				}			}		}				//-----------------------------------------		// Got any?		//-----------------------------------------				if ( is_array( $attach_pids ) and count( $attach_pids ) )		{			//-----------------------------------------			// Get topiclib			//-----------------------------------------						require_once( ROOT_PATH."sources/action_public/topics.php" );			$topic           =  new topics();			$topic->ipsclass =& $this->ipsclass;			$topic->topic_init();						$t = $topic->parse_attachments( $t, $attach_pids, 'attach_id' );		}				return $t;    }        /*-------------------------------------------------------------------------*/    // Get navigation    /*-------------------------------------------------------------------------*/        function show_post_navigation()    {    	 $this->nav = $this->ipsclass->forums->forums_breadcrumb_nav( $this->forum['id'] );    	     	 if ( $this->topic['tid'] )    	 {    	 	$this->nav[] = "<a href='{$this->ipsclass->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>";    	 }    }            /*-------------------------------------------------------------------------*/	// Notify new topic mod Q	/*-------------------------------------------------------------------------*/		function notify_new_topic_approval($tid, $title, $author, $pid=0, $type='new')	{		$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'notify_modq_emails', 'from' => 'forums', 'where' => "id=".$this->forum['id']) );				if ( $tmp['notify_modq_emails'] == "" )		{ 			return;		}				if ( $type == 'new' )		{			$this->email->get_template("new_topic_queue_notify");		}		else		{			$this->email->get_template("new_post_queue_notify");		}				$this->email->build_message( array(											'TOPIC'  => $title,											'FORUM'  => $this->forum['name'],											'POSTER' => $author,											'DATE'   => $this->ipsclass->get_date( time(), 'SHORT' ),											'LINK'   => $this->ipsclass->vars['board_url'].'/index.'.$this->ipsclass->vars['php_ext'].'?act=findpost&pid='.$pid,										  )									);				$email_message = $this->email->message;				foreach( explode( ",", $tmp['notify_modq_emails'] ) as $email )		{			$this->email->message = $email_message;			$this->email->to      = trim($email);			$this->email->send_mail();		}	}		/*-------------------------------------------------------------------------*/	// topic tracker	// ------------------	// Checks and sends out the emails as needed.	/*-------------------------------------------------------------------------*/		function topic_tracker($tid="", $post="", $poster="", $last_post="" )	{		if ($tid == "")		{			return TRUE;		}				$count = 0;				//-----------------------------------------		// Get the email addy's, topic ids and email_full stuff - oh yeah.		// We only return rows that have a member last_activity of greater than the post itself		// Ergo:		//  Last topic post: 8:50am		//  Last topic visit: 9:00am		//  Next topic reply: 9:10am		// if ( last.activity > last.topic.post ) { send.... }		//  Next topic reply: 9:20am		// if ( last.activity > last.topic.post ) { will fail as 9:10 > 8:50 }		//-----------------------------------------				$this->ipsclass->DB->cache_add_query( 'post_topic_tracker', array( 'tid' => $tid, 'mid' => $this->ipsclass->member['id'], 'last_post' => $last_post ) );				$outer = $this->ipsclass->DB->simple_exec();				if ( $this->ipsclass->DB->get_num_rows($outer) )		{			$trids = array();						while ( $r = $this->ipsclass->DB->fetch_row($outer) )			{				//-----------------------------------------				// Test for group permissions				//-----------------------------------------								$mgroup_others = "";				$temp_mgroups  = array();				$mgroup_perms  = array();								if( $r['mgroup_others'] )				{					$r['mgroup_others'] = $this->ipsclass->clean_perm_string( $r['mgroup_others'] );					$temp_mgroups = explode( ",", $r['mgroup_others'] );										if( count($temp_mgroups) )					{						foreach( $temp_mgroups as $other_mgroup )						{							$mgroup_perms[] = $this->ipsclass->cache['group_cache'][ $other_mgroup ]['g_perm_id'];						}					}										if( count($mgroup_perms) )					{						$mgroup_others = ",".implode( ",", $mgroup_perms ).",";					}				}								$perm_id = ( $r['org_perm_id'] ) ? $r['org_perm_id'] : $this->ipsclass->cache['group_cache'][ $r['mgroup'] ]['g_perm_id'].$mgroup_others;								if ( $this->forum['read_perms'] != '*' )				{					if ( ! preg_match("/(^|,)".str_replace( ",", '|', $perm_id )."(,|$)/", $this->forum['read_perms'] ) )        			{        				continue;       				}				}								//-----------------------------------------				// Test for approved/approve perms				//-----------------------------------------								if( $r['approved'] == 0 )				{					$mod = 0;										if( $this->ipsclass->cache['group_cache'][$r['mgroup']]['g_is_supmod'] == 1 )					{						$mod = 1;

⌨️ 快捷键说明

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