func_msg.php

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

PHP
1,234
字号
<?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:29 GMT|   Release: |   Licence Info: +---------------------------------------------------------------------------|   > $Date: 2005-12-06 17:36:43 +0000 (Tue, 06 Dec 2005) $|   > $Revision: 94 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > Msg Func module|   > Module written by Matt Mecham|   > Date started: 14th February 2002||   > Module Version 1.0.0|   > DBA Checked: Fri 21 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 func_msg{	# Classes	var $ipsclass;		# Others	var $postlib      = "";	var $class        = "";	var $output       = "";	var $can_upload   = 0;	var $form_extra   = "";	var $hidden_field = "";	var $redirect_url = "";	var $redirect_lang= "";		var $force_pm     = 0;		function register_class( &$class )	{		$this->class = &$class;	}		/*-------------------------------------------------------------------------*/	// Initiate	/*-------------------------------------------------------------------------*/		function init()	{		//-----------------------------------------		// Get post stuff		//-----------------------------------------				require_once( ROOT_PATH.'sources/classes/post/class_post.php' );		$this->postlib = new class_post();		$this->postlib->ipsclass =& $this->ipsclass;				$this->postlib->load_classes();				if ( $this->ipsclass->member['g_attach_max'] != -1 and $this->ipsclass->member['g_can_msg_attach'] )		{			$this->can_upload   = 1;			$this->form_extra   = " enctype='multipart/form-data'";			$this->hidden_field = "<input type='hidden' name='MAX_FILE_SIZE' value='".($this->ipsclass->member['g_attach_max']*1024)."' />";		}				$this->postlib->can_upload = $this->can_upload;	}		/*-------------------------------------------------------------------------*/	// Send form stuff	/*-------------------------------------------------------------------------*/		function send_form($preview=0, $errors="") 	{		$this->form_mid     = intval($this->ipsclass->input['MID']); 		$this->form_orig_id = intval($this->ipsclass->input['MSID']); 		 		$_POST['Post-NS']   = $_POST['Post']; 		$_POST['Post']      = $this->ipsclass->remove_tags( $this->ipsclass->txt_raw2form( $_POST['Post'] ) ); 		 		//----------------------------------------- 		// Fix up errors 		//----------------------------------------- 		 		$errors = preg_replace( "/^<br>/", "", $errors ); 		    	//-----------------------------------------    	// Preview post?    	//-----------------------------------------    	    	if ( $preview )    	{    		$this->postlib->parser->parse_html    = $this->ipsclass->vars['msg_allow_html'];			$this->postlib->parser->parse_nl2br   = 1;			$this->postlib->parser->parse_smilies = 1;//intval($this->ipsclass->input['enableemo']);			$this->postlib->parser->parse_bbcode  = $this->ipsclass->vars['msg_allow_code'];						$old_msg = $this->postlib->han_editor->process_raw_post( 'Post-NS' );			$old_msg = $this->postlib->parser->pre_display_parse( $this->postlib->parser->pre_db_parse( $old_msg ) );						$this->output .= $this->ipsclass->compiled_templates['skin_msg']->preview($old_msg);    	}    	    	if ($errors != "")    	{    		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->pm_errors($errors);    		$preview = 1;    	}    	    	//----------------------------------------- 		// Load the contacts 		//----------------------------------------- 		 		$contacts = $this->build_contact_list(); 		 		$name_to_enter = ""; 		$old_message   = ""; 		$old_title     = "";    	    	//----------------------------------------- 		// Did we come from a button with a user ID? 		//----------------------------------------- 				if ( $this->form_mid )		{			$this->ipsclass->DB->simple_construct( array( 'select' => 'members_display_name, name, id', 'from' => 'members', 'where' => "id=".$this->form_mid ) );			$this->ipsclass->DB->simple_exec();						$name = $this->ipsclass->DB->fetch_row();						if ($this->ipsclass->input['fwd'] != 1)			{				if ($name['id'])				{					$name_to_enter = $name['members_display_name'];				}			}		}		else		{			$name_to_enter = $this->ipsclass->input['entered_name'];		} 		 		//----------------------------------------- 		// Are we quoting an old message? 		//----------------------------------------- 		 		if ( $preview or $this->class->show_form ) 		{ 			$old_message = $_POST['Post-NS']; 			$old_title   = preg_replace( "/'/", "&#39;", $this->ipsclass->txt_stripslashes($_POST['msg_title']) );			// If we preview and check these boxes, they should default to checked			$footer_defaults = array(								 	 'add_sent' 	=> $this->ipsclass->input['add_sent'] == 'yes' ? "checked='checked' " : "",								 	 'add_tracking' => $this->ipsclass->input['add_tracking'] == '1' ? "checked='checked' " : "",								 	); 		} 		else if ( $this->form_orig_id ) 		{ 			$this->ipsclass->DB->cache_add_query( 'msg_get_saved_msg', array( 'msgid' => $this->form_orig_id, 'mid' => $this->ipsclass->member['id'] ) ); 			$this->ipsclass->DB->simple_exec(); 			 			$old_msg = $this->ipsclass->DB->fetch_row(); 			 			if ($old_msg['mt_title']) 			{ 				if ( $this->class->edit_saved ) 				{					$name_to_enter         = $old_msg['members_display_name'];					$cc_text               = $old_msg['msg_cc_users'];					$cc_hide			   = $old_msg['mt_hide_cc'];					$old_track			   = $old_msg['mt_tracking'];					$old_addsent		   = $old_msg['mt_addtosent'];					$old_title             = $old_msg['mt_title'];					$old_message           = $this->postlib->parser->bad_words( $this->ipsclass->my_br2nl( $old_msg['msg_post'] ) );										if( $this->postlib->han_editor->method == 'rte' )					{						$_POST['tmp_for_msg_edit'] = $old_message;												$old_message = $this->postlib->han_editor->process_raw_post( 'tmp_for_msg_edit' );						$old_message = $this->postlib->parser->pre_display_parse( $this->postlib->parser->pre_db_parse( $old_message ) );												unset($_POST['tmp_for_msg_edit']);					}										$this->class->post_key = $old_msg['msg_post_key'];					$this->ipsclass->input['OID']= $old_msg['mt_id'];				} 				else if ($this->ipsclass->input['fwd'] == 1) 				{ 					$old_title     = "Fwd:".$old_msg['mt_title']; 					$old_title     = preg_replace( "/^(?:Fwd\:){1,}/i", "Fwd:", $old_title ); 					$old_message   = '[QUOTE]'.sprintf($this->ipsclass->lang['vm_forward_text'], $name['members_display_name'])."\n\n".$old_msg['msg_post'].'[/QUOTE]'."\n"; 					$old_message   = $this->postlib->parser->bad_words( $this->ipsclass->my_br2nl( $old_message ) ); 				} 				else 				{ 					$old_title   = "Re:".$old_msg['mt_title']; 					$old_title   = preg_replace( "/^(?:Re\:){1,}/i", "Re:", $old_title ); 					$old_message = '[QUOTE]'.$old_msg['msg_post'].'[/QUOTE]'."\n"; 					$old_message = $this->postlib->parser->bad_words( $this->ipsclass->my_br2nl( $old_message ) ); 				} 			} 						$footer_defaults = array(								 	 'add_sent' 	=> $old_addsent == '1' ? "checked='checked' " : "",								 	 'add_tracking' => $old_track == '1' ? "checked='checked' " : "",								 	); 			 		} 		 		//----------------------------------------- 		// PM returns 		//----------------------------------------- 		 		if ( $this->postlib->han_editor->method == 'rte' AND $old_message AND $this->form_orig_id ) 		{ 			$old_message = $this->ipsclass->my_nl2br( $old_message ); 		} 		 		//----------------------------------------- 		// Build up the HTML for the send form 		//----------------------------------------- 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->Send_form( array (																							 'CONTACTS'  => $contacts,																							 'MEMBER'    => $this->member,																							 'N_ENTER'   => $name_to_enter,																							 'O_TITLE'   => $old_title,																							 'OID'       => $this->ipsclass->input['OID'], // Old unsent msg id for restoring saved msg - used to delete saved when sent																							 'post_key'  => $this->class->post_key,																							 'form_extra'=> $this->form_extra,																							 'upload'    => $this->hidden_field,																							 																				   )       ); 		 		$this->ipsclass->lang['the_max_length'] = $this->ipsclass->vars['max_post_length'] * 1024; 		 		//----------------------------------------- 		// Show editor HTML 		//----------------------------------------- 		 		$this->postlib->han_editor->ed_width = $this->ipsclass->vars['rte_pm_width'] ? $this->ipsclass->vars['rte_pm_width'] : $this->ipsclass->vars['rte_width']; 		 		//----------------------------------------- 		// Is this RTE? If so, convert BBCode 		//----------------------------------------- 		 		if ( $this->postlib->han_editor->method == 'rte' AND $old_message ) 		{ 			$old_message = $this->postlib->parser->convert_ipb_html_to_html( $old_message ); 		} 		else if ( $old_message ) 		{ 			$old_message = $this->ipsclass->txt_stripslashes( $old_message ); 		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->postbox_wrap( $this->postlib->han_editor->show_editor( $old_message, 'Post' ) ); 		 		//----------------------------------------- 		// Show upload stuff? 		//----------------------------------------- 		 		if ($this->can_upload)		{			$this->output .= $this->postlib->html_build_uploads($this->class->post_key,'msg');		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->send_form_footer( $footer_defaults ); 		 		//----------------------------------------- 		// Add in the smilies box 		//----------------------------------------- 		 		$this->output = $this->postlib->html_add_smilie_box($this->output);				$this->class->page_title = $this->ipsclass->lang['t_welcome']; 		$this->class->nav        = array( "<a href='".$this->ipsclass->base_url."act=UserCP&amp;CODE=00'>".$this->ipsclass->lang['t_title']."</a>" );				//----------------------------------------- 		// Do we have permission to mass PM peeps? 		//----------------------------------------- 		 		if ($this->ipsclass->member['g_max_mass_pm'] > 0) 		{ 			$this->ipsclass->lang['carbon_copy_desc'] = sprintf( $this->ipsclass->lang['carbon_copy_desc'], $this->ipsclass->member['g_max_mass_pm'] ); 			 			if ( isset($_POST['carbon_copy']) or $cc_text ) 			{ 				$cc_text = $cc_text ? $cc_text : $this->ipsclass->txt_htmlspecialchars($_POST['carbon_copy']); 				 				$cc_box = preg_replace( "#</textarea>#i", "", $this->ipsclass->txt_stripslashes($cc_text) ); 			} 			 			if ( intval($this->ipsclass->input['mt_hide_cc']) == 1 or ( isset($cc_hide) AND $cc_hide == 1 ) ) 			{ 				$cc_formbox = $cc_hide ? $cc_hide : intval($this->ipsclass->input['mt_hide_cc']); 				 				$cc_formbox = $cc_formbox == 1 ? "checked='checked' " : ""; 			} 			 			 			$this->output = str_replace( "<!--IBF.MASS_PM_BOX-->", $this->ipsclass->compiled_templates['skin_msg']->mass_pm_box($cc_box, $cc_formbox), $this->output ); 		} 	} 	 	/*-------------------------------------------------------------------------*/ 	// Build contact listy poos 	/*-------------------------------------------------------------------------*/ 	 	function build_contact_list()	{		$contacts = ""; 		 		$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'contacts', 'where' => "member_id=".$this->ipsclass->member['id'], 'order' => "contact_name") ); 		$this->ipsclass->DB->simple_exec(); 		 		if ( $this->ipsclass->DB->get_num_rows() ) 		{ 			$contacts = "<select name='from_contact' class='forminput'><option value='-'>".$this->ipsclass->lang['other']."</option>\n<option value='-'>--------------------</option>\n"; 			 			while ( $entry = $this->ipsclass->DB->fetch_row() ) 			{ 				$selected = ( $this->ipsclass->input['from_contact'] == $entry['contact_id'] ) ? ' selected="selected"' : ''; 				 				$contacts .= "<option value='".$entry['contact_id']."'{$selected}>".$entry['contact_name']."</option>\n"; 			} 			 			$contacts .= "</select>\n"; 		} 		else 		{ 			$contacts = $this->ipsclass->lang['address_list_empty']; 		} 		 		return $contacts; 	} 	 	 	//----------------------------------------- 	// API for deleting messages 	//----------------------------------------- 	 	function delete_messages($ids, $owner_id, $extra="") 	{		//----------------------------------------- 		// Basic WHERE 		//----------------------------------------- 		 		if ( ! $extra ) 		{ 			$extra = "mt_owner_id=$owner_id"; 		} 		 		$id_string = ""; 		 		if ( is_array( $ids ) ) 		{ 			if ( ! count($ids) ) 			{ 				return; 			} 			 			$id_string = 'IN ('.implode( ",", $ids ).')'; 		} 		else 		{ 			if ( ! $ids ) 			{ 				return; 			} 			 			$id_string = '='.$ids; 		} 		 		//----------------------------------------- 		// Are these our messages? 		//----------------------------------------- 		 		$this->ipsclass->DB->simple_construct( array( 'select' => 'mt_id, mt_msg_id', 'from' => 'message_topics', 'where' => "$extra AND mt_id $id_string" ) ); 		$this->ipsclass->DB->simple_exec(); 		 		$final_ids = array(); 		$final_mts = array(); 		 		while ( $i = $this->ipsclass->DB->fetch_row() ) 		{ 			$final_ids[ $i['mt_id'] ] = $i['mt_msg_id']; 			$final_mts[] = $i['mt_id']; 		} 		 		//----------------------------------------- 		// Delete MT topics 		//----------------------------------------- 		 		if ( count($final_mts) ) 		{

⌨️ 快捷键说明

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