messenger.php

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

PHP
1,798 行
字号
 		$this->page_title = $this->ipsclass->lang['t_welcome']; 		$this->nav        = array( "<a href='".$this->base_url."act=UserCP&amp;CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// ADD MEMBER: 	// 	// Adds a member to the addy book. 	/*-------------------------------------------------------------------------*/ 	 	function add_member() 	{		if (! $this->ipsclass->input['mem_name']) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); 		} 		 		$this->ipsclass->DB->simple_construct( array( 'select' => 'members_display_name,name,id', 'from' => 'members', 'where' => "LOWER(members_display_name)='".$this->ipsclass->input['mem_name']."'" ) );		$this->ipsclass->DB->simple_exec(); 		 		$memb = $this->ipsclass->DB->fetch_row(); 		 		if (! $memb['id']) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); 		} 		 		//----------------------------------------- 		// Do we already have this member in our 		// address book? 		//----------------------------------------- 		 		$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'contacts', 'where' => "member_id={$this->ipsclass->member['id']} AND contact_id={$memb['id']}" ) );		$this->ipsclass->DB->simple_exec(); 		 		if ( $this->ipsclass->DB->get_num_rows() ) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'member_in_add_book' ) ); 		} 		 		//----------------------------------------- 		// Insert it into the DB 		//----------------------------------------- 		 		$this->ipsclass->input['allow_msg'] = $this->ipsclass->input['allow_msg'] == 'yes' ? 1 : 0; 		 		$this->ipsclass->DB->do_insert( 'contacts', array( 										  'member_id'      => $this->ipsclass->member['id'],										  'contact_name'   => $memb['members_display_name'],										  'allow_msg'      => $this->ipsclass->input['allow_msg'],										  'contact_desc'   => $this->ipsclass->input['mem_desc'],										  'contact_id'     => $memb['id']								 )      );				$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=02");	} 		 	/*-------------------------------------------------------------------------*/ 	// Mutli Act: 	// 	// Removes or moves messages. 	/*-------------------------------------------------------------------------*/ 	 	function multi_act() 	{		//----------------------------------------- 		// Get the ID's to delete 		//----------------------------------------- 		 		$ids = array(); 		 		foreach ($this->ipsclass->input as $key => $value) 		{ 			if ( preg_match( "/^msgid_(\d+)$/", $key, $match ) ) 			{ 				if ($this->ipsclass->input[$match[0]]) 				{ 					$ids[] = $match[1]; 				} 			} 		} 		 		$affected_ids = count($ids); 		 		if ( $affected_ids > 0 ) 		{			$ids       = $this->ipsclass->clean_int_array( $ids ); 			$id_string = implode( ",", $ids ); 			 			if ($this->ipsclass->input['delete']) 			{ 				$this->msglib->delete_messages( $ids, $this->ipsclass->member['id'] ); 				 				if ($this->ipsclass->input['saved']) 				{ 					//----------------------------------------- 					// Did we delete from the saved folder? If so, don't update the msg stats and 					// redirect back to the saved folder. 					//----------------------------------------- 					 					$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=20"); 				} 				else 				{ 					$this->msglib->rebuild_dir_count( $this->ipsclass->member['id'],												   $this->ipsclass->member['vdirs'],												   $this->lib->vid,												   $this->ipsclass->member['dir_data'][ $this->lib->vid ]['count'] - $affected_ids,												   'save',												   "msg_total=msg_total-$affected_ids"												 );										$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=01&VID={$this->lib->vid}");					 				} 				 			} 			else if ($this->ipsclass->input['move']) 			{ 				$this->ipsclass->DB->simple_construct( array( 'update' => 'message_topics', 'set' => "mt_vid_folder='{$this->lib->vid}', mt_to_id={$this->ipsclass->member['id']}", 'where' => "mt_vid_folder != '{$this->lib->vid}' AND mt_owner_id=".$this->ipsclass->member['id']." AND mt_id IN ($id_string)" ) ); 				$this->ipsclass->DB->simple_exec();								if ( $this->ipsclass->DB->get_affected_rows() )				{			   					$this->msglib->rebuild_dir_count( $this->ipsclass->member['id'],												   $this->msglib->rebuild_dir_count( $this->ipsclass->member['id'],																				  $this->ipsclass->member['vdirs'],																				  $this->ipsclass->input['curvid'],																				  $this->ipsclass->member['dir_data'][ $this->ipsclass->input['curvid'] ]['count'] - $affected_ids,																				  'nosave'																				),												   $this->lib->vid,												   $this->ipsclass->member['dir_data'][ $this->lib->vid ]['count'] + $affected_ids,												   'save'												 );				}												 	 				$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=01&VID={$this->lib->vid}"); 				 			} 			else 			{ 				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_msg_chosen' ) ); 			} 		} 		else 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_msg_chosen' ) ); 		} 	} 	 	/*-------------------------------------------------------------------------*/ 	// END TRACKING 	// 	// Removes read tracked messages 	/*-------------------------------------------------------------------------*/ 	 	function end_tracking() 	{		//----------------------------------------- 		// Get the ID's to delete 		//----------------------------------------- 		 		$ids = array(); 		 		foreach ($this->ipsclass->input as $key => $value) 		{ 			if ( preg_match( "/^msgid_(\d+)$/", $key, $match ) ) 			{ 				if ($this->ipsclass->input[$match[0]]) 				{ 					$ids[] = $match[1]; 				} 			} 		} 		 		$affected_ids = count($ids); 		 		if ( $affected_ids > 0 ) 		{ 			$id_string = implode( ",", $ids ); 			 			$this->ipsclass->DB->simple_construct( array( 'update' => 'message_topics', 'set' => 'mt_tracking=0', 'where' => "mt_tracking=1 AND mt_read=1 AND mt_from_id={$this->ipsclass->member['id']} AND mt_id IN ($id_string)" ) ); 			$this->ipsclass->DB->simple_exec(); 			 					 			$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=30"); 		} 		else 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_msg_chosen' ) ); 		} 	} 	 	/*-------------------------------------------------------------------------*/ 	// Delete tracked messages 	/*-------------------------------------------------------------------------*/ 	 	function del_tracked() 	{		//----------------------------------------- 		// Get the ID's to delete 		//----------------------------------------- 		 		$ids = array(); 		 		foreach ($this->ipsclass->input as $key => $value) 		{ 			if ( preg_match( "/^msgid_(\d+)$/", $key, $match ) ) 			{ 				if ($this->ipsclass->input[$match[0]]) 				{ 					$ids[] = $match[1]; 				} 			} 		} 		 		$affected_ids = count($ids); 		 		if ( $affected_ids > 0 ) 		{ 			$id_string = implode( ",", $ids ); 			 			$this->msglib->delete_messages( $ids, $this->ipsclass->member['id'], "mt_read=0 and mt_tracking=1 AND mt_from_id=".$this->ipsclass->member['id'] ); 			 			$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=30"); 		} 		else 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_msg_chosen' ) ); 		} 	} 	 	/*-------------------------------------------------------------------------*/ 	// DELETE MESSAGE: 	/*-------------------------------------------------------------------------*/ 	 	function delete() 	{		//----------------------------------------- 		// check for a msg ID 		//----------------------------------------- 		 		$this->ipsclass->input['MSID'] = intval($this->ipsclass->input['MSID']); 		 		if ( ! $this->ipsclass->input['MSID'] ) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_msg_chosen' ) ); 		} 		 		//----------------------------------------- 		// Delete it from the DB 		//----------------------------------------- 		 		$this->msglib->delete_messages( $this->ipsclass->input['MSID'], $this->ipsclass->member['id'] ); 		 		$this->msglib->rebuild_dir_count( $this->ipsclass->member['id'],										  $this->ipsclass->member['vdirs'],										  $this->lib->vid,										  $this->ipsclass->member['dir_data'][ $this->lib->vid ]['count'] - 1,										  'save',										  "msg_total=msg_total-1"										); 		 		$this->ipsclass->boink_it($this->base_url."act=Msg&CODE=01&VID={$this->lib->vid}"); 	} 	 	/*-------------------------------------------------------------------------*/ 	// VIEW MESSAGE: 	// 	// Views a message, thats it. No, it doesn't do anything else 	// I don't know why. It just does. Accept it and move on dude. 	/*-------------------------------------------------------------------------*/ 	 	function view_msg() 	{		//----------------------------------------- 		// Get extra LIBBIES 		//----------------------------------------- 		 		require_once( ROOT_PATH.'sources/action_public/topics.php' ); 		 		$this->topiclib           =  new topics(); 		$this->topiclib->ipsclass =& $this->ipsclass; 		 		$this->topiclib->topic_init(); 		 		//----------------------------------------- 		// check for a msg ID 		//----------------------------------------- 		 		$this->ipsclass->input['MSID'] = intval($this->ipsclass->input['MSID']); 		 		if (! $this->ipsclass->input['MSID'] ) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_msg' ) ); 		} 		 		$this->ipsclass->DB->cache_add_query( 'msg_get_msg_to_show', array( 'msgid' => $this->ipsclass->input['MSID'], 'mid' => $this->ipsclass->member['id'] ) ); 		$this->ipsclass->DB->simple_exec(); 		 		if ( ! $msg = $this->ipsclass->DB->fetch_row() ) 		{ 			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_msg' ) ); 		} 		 		//----------------------------------------- 		// Did we read this in the pop up? 		// If so, reduce new count by 1 (this msg) 		// 'cos if we went via inbox, we'd have 		// no new msg 		//----------------------------------------- 		 		if ($this->ipsclass->member['new_msg'] >= 1) 		{ 			$this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => "new_msg=new_msg-1", 'where' => "id=".$this->ipsclass->member['id'] ) ); 			$this->ipsclass->DB->simple_exec(); 		} 				//----------------------------------------- 		// Is this an unread message? 		//----------------------------------------- 		 		if ($msg['mt_read'] < 1) 		{ 			$this->ipsclass->DB->simple_construct( array( 'update' => 'message_topics', 'set' => "mt_read=1, mt_user_read=".time(), 'where' => "mt_id=".$this->ipsclass->input['MSID'] ) ); 			$this->ipsclass->DB->simple_exec(); 		} 		 		//-----------------------------------------		// Remove potential [attachmentid= tag in title		//-----------------------------------------				$msg['mt_title'] = str_replace( '[attachmentid=', '&#91;attachmentid=', $msg['mt_title'] );		 		$msg['msg_date'] = $this->ipsclass->get_date( $msg['msg_date'], 'LONG' ); 		 		$member = $this->topiclib->parse_member( $msg ); 				$this->topiclib->parser->parse_smilies = 1;		$this->topiclib->parser->parse_html    = $this->ipsclass->vars['msg_allow_html'];		$this->topiclib->parser->parse_bbcode  = $this->ipsclass->vars['msg_allow_code'];		$this->topiclib->parser->parse_nl2br   = 1;				$msg['msg_post'] = $this->topiclib->parser->pre_display_parse( $this->topiclib->parser->pre_db_parse( $msg['msg_post'] ) );					if ( $this->ipsclass->member['view_sigs'] and $member['signature'] )		{			$this->topiclib->parser->parse_smilies = 0;			$this->topiclib->parser->parse_html    = $this->ipsclass->vars['sig_allow_html'];			$this->topiclib->parser->parse_bbcode  = $this->ipsclass->vars['sig_allow_ibc'];					$member['signature'] = $this->topiclib->parser->pre_display_parse( $this->topiclib->parser->pre_db_parse( $member['signature'] ) );			$member['signature'] = $this->ipsclass->compiled_templates['skin_global']->signature_separator($member['signature']);		}		else		{			$member['signature'] = "";		}				$member['VID'] = $this->ipsclass->member['current_id'];				//-----------------------------------------		// To , CC, etc?		//-----------------------------------------				if ( ! $msg['mt_hide_cc'] )		{			$cc_users = $this->msglib->format_cc_string( $msg['msg_cc_users'], $this->ipsclass->member['id'] );						if ( $cc_users )			{				$msg['show_cc_users'] = $this->ipsclass->compiled_templates['skin_msg']->render_msg_show_cc( $cc_users );			}		}				//-----------------------------------------		// IP Address: Is Admin not viewing other		// admin message		//-----------------------------------------				if ( $msg['msg_ip_address'] AND $this->ipsclass->member['g_is_supmod'] == 1 AND $member['mgroup'] != $this->ipsclass->vars['admin_group'] )		{			$msg['_ip_address'] = $msg['msg_ip_address'];		}				//-----------------------------------------		// Show...		//-----------------------------------------				$html = $this->ipsclass->compiled_templates['skin_msg']->Render_msg( $msg, $member, $this->lib->jump_html );				//-----------------------------------------		// Attachments?		//-----------------------------------------				if ( $msg['mt_hasattach'] )		{			$html = $this->topiclib->parse_attachments( $html, array( $msg['msg_id'] ), 'attach_msg', 'msg', 'msg' );		}				$this->output .= $html;				$this->page_title = $this->ipsclass->lang['t_welcome'];				$this->nav        = array( "<a href='".$this->base_url."&amp;act=UserCP&amp;CODE=00'>".$this->ipsclass->lang['t_title']."</a>",								   "<a href='".$this->base_url."act=Msg&CODE=01&VID={$member['VID']}'>".$this->ipsclass->member['current_dir']."</a>",								   $msg['mt_title']								 );						    	} 	 	/*-------------------------------------------------------------------------*/ 	// SEND MESSAGE: 	// 	// Sends a message. Yes, it's that simple. Why so much code? 	// Because typing "send a message to member X" doesnt actually 	// do anything. 	/*-------------------------------------------------------------------------*/ 	 	function send() 	{		//----------------------------------------- 		// Set up and stuff 		//----------------------------------------- 		 		$show_form = 0; 		 		$this->post_key = $this->ipsclass->input['post_key'] ? $this->ipsclass->input['post_key'] : md5(microtime());  		 		$this->msglib->init(); 		$this->msglib->register_class( $this ); 		 		//-----------------------------------------		// Did we remove an attachment?		//-----------------------------------------				if ( $this->ipsclass->input['removeattachid'] )		{			if ( $this->ipsclass->input[ 'removeattach_'. $this->ipsclass->input['removeattachid'] ] )			{				$this->msglib->postlib->pf_remove_attachment( intval($this->ipsclass->input['removeattachid']), $this->post_key );				$this->show_form = 1;			}		}				//-----------------------------------------		// Did we add an attachment?		//-----------------------------------------				if ( $this->ipsclass->input['attachgo'] )		{

⌨️ 快捷键说明

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