class_post_edit.php

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

PHP
727
字号
<?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 $moderator         = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );	var $orig_post         = array();	var $edit_title        = 0;	var $post_key		   = "";	var $class             = "";		function main_init()	{		//-----------------------------------------		// Load classes		//-----------------------------------------				$this->load_classes();		$this->build_permissions();				//-----------------------------------------		// Lets load the topic from the database before we do anything else.		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=".intval($this->ipsclass->input['t']) ) );		$this->ipsclass->DB->simple_exec();				$this->topic = $this->ipsclass->DB->fetch_row();				//-----------------------------------------		// Is it legitimate?		//-----------------------------------------				if ( ! $this->topic['tid'] )		{			$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );		}				//-----------------------------------------		// Load the old post		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'posts', 'where' => "pid=".intval($this->ipsclass->input['p']) ) );		$this->ipsclass->DB->simple_exec();				$this->orig_post = $this->ipsclass->DB->fetch_row();				if (! $this->orig_post['pid'])		{			$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );		}				//-----------------------------------------		// Generate post key (do we have one?)		//-----------------------------------------				if ( ! $this->orig_post['post_key'] )		{			//-----------------------------------------			// Generate one and save back to post and attachment			// to ensure 1.3 < compatibility			//-----------------------------------------						$this->post_key = md5(microtime());						$this->ipsclass->DB->do_update( 'posts', array( 'post_key' => $this->post_key ), 'pid='.$this->orig_post['pid'] );						$this->ipsclass->DB->do_update( 'attachments', array( 'attach_post_key' => $this->post_key ), 'attach_pid='.$this->orig_post['pid'] );		}		else		{			$this->post_key = $this->orig_post['post_key'];		}				//-----------------------------------------		// Load the moderator		//-----------------------------------------				if ($this->ipsclass->member['id'])		{			$this->ipsclass->DB->simple_construct( array( 'select' => 'member_id, member_name, mid, edit_post, edit_topic',										  				  'from'   => 'moderators',										  				  'where'  => "forum_id=".$this->forum['id']." AND (member_id='".$this->ipsclass->member['id']."' OR (is_group=1 AND group_id='".$this->ipsclass->member['mgroup']."'))" ) );										  			$this->ipsclass->DB->simple_exec();					$this->moderator = $this->ipsclass->DB->fetch_row();		}				//-----------------------------------------		// Lets do some tests to make sure that we are		// allowed to edit this topic		//-----------------------------------------				$can_edit = 0;				if ($this->ipsclass->member['g_is_supmod'])		{			$can_edit = 1;		}				if ($this->moderator['edit_post'])		{			$can_edit = 1;		}				if ( ($this->orig_post['author_id'] == $this->ipsclass->member['id']) and ($this->ipsclass->member['g_edit_posts']) )		{			//-----------------------------------------			// Have we set a time limit?			//-----------------------------------------						if ($this->ipsclass->member['g_edit_cutoff'] > 0)			{				if ( $this->orig_post['post_date'] > ( time() - ( intval($this->ipsclass->member['g_edit_cutoff']) * 60 ) ) )				{					$can_edit = 1;				}			}			else			{				$can_edit = 1;			}		}				if ( $can_edit != 1 )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'not_op') );		}				//-----------------------------------------		// Check access		//-----------------------------------------				$this->check_for_edit($this->topic);				//-----------------------------------------		// Do we have edit topic abilities?		//-----------------------------------------				# For edit, this means there is a poll and we have perm to edit		$this->can_add_poll = 0;				if ( $this->orig_post['new_topic'] == 1 )		{			if ( $this->ipsclass->member['g_is_supmod'] == 1 )			{				$this->edit_title = 1;								if ( $this->topic['poll_state'] )				{					$this->can_add_poll = 1;				}			}			else if ( $this->moderator['edit_topic'] == 1 )			{				$this->edit_title = 1;								if ( $this->topic['poll_state'] )				{					$this->can_add_poll = 1;				}							}			else if ( $this->ipsclass->member['g_edit_topic'] == 1 )			{				$this->edit_title = 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.		// overwrites saved post intentionally		//-----------------------------------------				$this->post = $this->compile_post();				//-----------------------------------------		// Compile the poll		//-----------------------------------------				$this->poll_questions = $this->compile_poll();				//-----------------------------------------		// Check for errors		//-----------------------------------------				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);		}	}		/*-------------------------------------------------------------------------*/	// COMPLETE EDIT THINGY	/*-------------------------------------------------------------------------*/		function save_post()	{		$time = $this->ipsclass->get_date( time(), 'LONG' );						//-----------------------------------------		// Reset some data		//-----------------------------------------				$this->post['ip_address']  = $this->orig_post['ip_address'];		$this->post['topic_id']    = $this->orig_post['topic_id'];		$this->post['author_id']   = $this->orig_post['author_id'];		$this->post['post_date']   = $this->orig_post['post_date'];		$this->post['author_name'] = $this->orig_post['author_name'];		$this->post['queued']      = $this->orig_post['queued'];		$this->post['edit_time']   = time();		$this->post['edit_name']   = $this->ipsclass->member['members_display_name'];				//-----------------------------------------		// If the post icon has changed, update the topic post icon		//-----------------------------------------				if ($this->orig_post['new_topic'] == 1)		{			if ($this->post['icon_id'] != $this->orig_post['icon_id'])			{				$this->ipsclass->DB->do_update( 'topics', array( 'icon_id' => $this->post['icon_id'] ), 'tid='.$this->topic['tid'] );			}		}				//-----------------------------------------		// Update open and close times		//-----------------------------------------				if ( $this->orig_post['new_topic'] == 1 )		{			$times = array();						if ( $this->can_set_open_time )			{				$times['topic_open_time'] = $this->times['open'];								if( $this->topic['topic_open_time'] AND $this->times['open'] )				{					$times['state'] = "closed";										if( time() > $this->topic['topic_open_time'] )					{						if( time() < $this->topic['topic_close_time'] )						{							$times['state'] = "open";						}					}				}				if ( ! $this->times['open'] AND $this->topic['topic_open_time'] )				{					if ( $this->topic['state'] == 'closed' )					{						$times['state'] = 'open';					}				}							}									if ( $this->can_set_close_time )			{				$times['topic_close_time'] = $this->times['close'];								//-----------------------------------------				// Was a close time, but not now?				//-----------------------------------------								if ( ! $this->times['close'] AND $this->topic['topic_close_time'] )				{					if ( $this->topic['state'] == 'closed' )					{						$times['state'] = 'open';					}				}			}						if ( count( $times ) )			{				$this->ipsclass->DB->do_update( 'topics', $times, "tid=".$this->topic['tid'] );			}		}				//-----------------------------------------		// Update topic title?		//-----------------------------------------		

⌨️ 快捷键说明

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