class_post_reply.php

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

PHP
649
字号
<?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-11 22:47:48 +0000 (Wed, 11 Jan 2006) $|   > $Revision: 122 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > Post Sub-Class|   > Module written by Matt Mecham|   > Date started: Wednesday 9th March 2005 (15:23)|+--------------------------------------------------------------------------*/class post_functions extends class_post{	var $nav         = array();	var $title       = "";	var $post        = array();	var $upload      = array();	var $mod_topic   = array();	var $m_group     = "";	var $post_key    = "";	var $quote_pids  = array();	var $quote_posts = array();		/*-------------------------------------------------------------------------*/	// Sub class init	/*-------------------------------------------------------------------------*/		function main_init()	{		//-----------------------------------------		// Load classes		//-----------------------------------------				$this->load_classes();		$this->build_permissions();				//-----------------------------------------		// Set up post key		//-----------------------------------------				$this->post_key = $this->ipsclass->input['post_key'] ? $this->ipsclass->input['post_key'] : md5( microtime() );				//-----------------------------------------		// Lets load the topic from the database		// before we do anything else.		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "forum_id=".intval($this->forum['id'])." AND tid=".intval($this->ipsclass->input['t']) ) );		$this->ipsclass->DB->simple_exec();				$this->topic = $this->ipsclass->DB->fetch_row();				//-----------------------------------------		// Check permissions, etc		//-----------------------------------------				if ( ! $this->topic['tid'] )		{			$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );		}				//-----------------------------------------		// Lets do some tests to make sure that we are		// allowed to reply to this topic		//-----------------------------------------				$this->check_for_reply($this->topic);				//-----------------------------------------		// POLL BOX ( Either topic starter or admin)		// and without a current poll		//-----------------------------------------				if ( $this->can_add_poll )		{			$this->can_add_poll = 0;						if ( ! $this->topic['poll_state'] )			{				if ( $this->ipsclass->member['id'] and ! $this->obj['moderate'] )				{					if ( $this->ipsclass->member['g_is_supmod'] == 1 )					{						$this->can_add_poll = 1;					}					else if ( $this->topic['starter_id'] == $this->ipsclass->member['id'] )					{						if ( ($this->ipsclass->vars['startpoll_cutoff'] > 0) AND ( $this->topic['start_date'] + ($this->ipsclass->vars['startpoll_cutoff'] * 3600) > time() ) )						{							$this->can_add_poll = 1;						}					}				}			}		}	}		/*-------------------------------------------------------------------------*/	// MAIN PROCESS FUNCTION	/*-------------------------------------------------------------------------*/		function process_post()	{		//-----------------------------------------		// Convert times...		//-----------------------------------------				$this->convert_open_close_times();				//-----------------------------------------		// Did we remove an attachment?		//-----------------------------------------				if ( $this->ipsclass->input['removeattachid'] )		{			if ( $this->ipsclass->input[ 'removeattach_'. $this->ipsclass->input['removeattachid'] ] )			{				$this->pf_remove_attachment( intval($this->ipsclass->input['removeattachid']), $this->post_key );				$this->show_form();			}		}				//-----------------------------------------		// Did we add an attachment?		//-----------------------------------------				if ( $this->ipsclass->input['attachgo'] )		{			$this->obj['post_errors'] = "";			$this->upload_id = $this->process_upload();			$this->show_form();		}				//-----------------------------------------		// Parse the post, and check for any errors.		//-----------------------------------------				$this->post = $this->compile_post();				//-----------------------------------------		// Compile the poll		//-----------------------------------------				$this->poll_questions = $this->compile_poll();				if ($this->obj['post_errors'] == "")		{			$this->upload = $this->process_upload();		}				if ( ($this->obj['post_errors'] != "") or ($this->obj['preview_post'] != "") )		{			//-----------------------------------------			// Show the form again			//-----------------------------------------						$this->show_form($class);		}		else		{			$this->save_post($class);		}	}		/*-------------------------------------------------------------------------*/	// ADD THE REPLY	/*-------------------------------------------------------------------------*/		function save_post()	{		//-----------------------------------------		// Insert the post into the database to get the		// last inserted value of the auto_increment field		//-----------------------------------------				$this->post['topic_id'] = $this->topic['tid'];				//-----------------------------------------		// Get the last post time of this topic not counting		// this new reply		//-----------------------------------------				$this->last_post = $this->topic['last_post'];				//-----------------------------------------		// Are we a mod, and can we change the topic state?		//-----------------------------------------				$return_to_move = 0;				if ( ($this->ipsclass->input['mod_options'] != "") or ($this->ipsclass->input['mod_options'] != 'nowt') )		{			if ($this->ipsclass->input['mod_options'] == 'pin')			{				if ($this->ipsclass->member['g_is_supmod'] == 1 or $this->moderator['pin_topic'] == 1)				{					$this->topic['pinned'] = 1;										$this->moderate_log('Pinned topic from post form', $this->topic['title']);				}			}			else if ($this->ipsclass->input['mod_options'] == 'close')			{				if ($this->ipsclass->member['g_is_supmod'] == 1 or $this->moderator['close_topic'] == 1)				{					$this->topic['state'] = 'closed';										$this->moderate_log('Closed topic from post form', $this->topic['title']);				}			}			else if ($this->ipsclass->input['mod_options'] == 'move')			{				if ($this->ipsclass->member['g_is_supmod'] == 1 or $this->moderator['move_topic'] == 1)				{					$return_to_move = 1;				}			}			else if ($this->ipsclass->input['mod_options'] == 'pinclose')			{				if ($this->ipsclass->member['g_is_supmod'] == 1 or ( $this->moderator['pin_topic'] == 1 AND $this->moderator['close_topic'] == 1 ) )				{					$this->topic['pinned'] = 1;					$this->topic['state']  = 'closed';										$this->moderate_log('Pinned & closed topic from post form', $this->topic['title']);				}			}		}				//-----------------------------------------		// Check close times...		//-----------------------------------------				if ( $this->topic['state'] == 'open' AND ( $this->times['close'] AND $this->times['close'] <= time() ) )		{			$this->topic['state'] = 'closed';		}		else if ( $this->topic['state'] == 'closed' AND ( $this->times['open'] AND $this->times['open'] >= time() ) )		{			$this->topic['state'] = 'open';		}				//-----------------------------------------		// Merge concurrent posts?		//-----------------------------------------				if ( $this->ipsclass->member['id'] AND $this->ipsclass->vars['post_merge_conc'] )		{			//-----------------------------------------			// Get check time			//-----------------------------------------						$time_check = time() - ( $this->ipsclass->vars['post_merge_conc'] * 60 );						//-----------------------------------------			// Last to post?			//-----------------------------------------						if ( ( $this->topic['last_post'] > $time_check ) AND ( $this->topic['last_poster_id'] == $this->ipsclass->member['id'] ) )			{				//-----------------------------------------				// Get the last post. 2 queries more efficient				// than one... trust me				//-----------------------------------------								$last_pid = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'MAX(pid) as maxpid',																			  'from'   => 'posts',																			  'where'  => 'topic_id='.$this->topic['tid'],																			  'limit'  => array( 0, 1 ) ) );								$last_post = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*',																			   'from'   => 'posts',																			   'where'  => 'pid='.$last_pid['maxpid'] ) );								//-----------------------------------------				// Sure we're the last poster?				//-----------------------------------------								if ( $last_post['author_id'] == $this->ipsclass->member['id'] )				{					$new_post  = $last_post['post'].'<br /><br />'.$this->post['post'];										//-----------------------------------------					// Update post row					//-----------------------------------------										$this->ipsclass->DB->force_data_type = array( 'pid'  => 'int',																  'post' => 'string' );									$this->ipsclass->DB->do_update( 'posts', array( 'post' => $new_post, 'post_date' => time() ), 'pid='.$last_post['pid'] );										$this->post['pid']      = $last_post['pid'];					$this->post['post_key'] = $last_post['post_key'];					$post_saved             = 1;					$this->is_merging_posts = 1;				}			}		}				//-----------------------------------------		// No?		//-----------------------------------------				if ( ! $this->is_merging_posts )		{			//-----------------------------------------			// Add post to DB			//-----------------------------------------			

⌨️ 快捷键说明

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