messenger.php

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

PHP
1,798 行
字号
			$this->upload_id = $this->msglib->postlib->process_upload();			$this->show_form = 1;		}				//-----------------------------------------		// Did we preview?		//-----------------------------------------				if ($this->ipsclass->input['preview'] != "") 		{ 			$this->show_form = 1; 		} 		 		//----------------------------------------- 		// Show form or... 		//----------------------------------------- 		 		if ( $this->ipsclass->input['MODE'] and $this->show_form != 1 ) 		{ 			$this->send_msg(); 		} 		else 		{ 			$this->msglib->send_form($this->ipsclass->input['preview']); 			 			$this->output .= $this->msglib->output; 		} 	} 	 	/*-------------------------------------------------------------------------*/ 	// SEND MESSAGE 	/*-------------------------------------------------------------------------*/ 	 	function send_msg() 	{		$this->ipsclass->load_language('lang_error'); 		 		$this->ipsclass->input['from_contact'] = $this->ipsclass->input['from_contact'] ? $this->ipsclass->input['from_contact'] : '-'; 		 		//----------------------------------------- 		// Error checking 		//----------------------------------------- 		 		if ( strlen($this->ipsclass->input['msg_title']) < 2 ) 		{ 			$this->msglib->send_form( 0, $this->ipsclass->lang['err_no_title'] ); 			$this->output .= $this->msglib->output; 			return; 		} 		 		if ( strlen($_POST['Post']) < 2 ) 		{ 			$this->msglib->send_form( 0, $this->ipsclass->lang['err_no_msg'] ); 			$this->output .= $this->msglib->output; 			return; 		} 		 		if ( $this->ipsclass->input['auth_key'] != $this->ipsclass->md5_check )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );		} 		 		if ($this->ipsclass->input['from_contact'] == '-' and $this->ipsclass->input['entered_name'] == "") 		{ 			$this->msglib->send_form( 0, $this->ipsclass->lang['err_no_chosen_member'] ); 			$this->output .= $this->msglib->output; 			return; 		} 		 		//----------------------------------------- 		// TO: 		//----------------------------------------- 		 		if ($this->ipsclass->input['from_contact'] == '-') 		{ 			$this->msglib->to = $this->ipsclass->input['entered_name']; 		} 		else 		{ 			$this->msglib->to_by_id = intval( $this->ipsclass->input['from_contact'] ); 		} 		 		//-----------------------------------------		// Post process the editor		// Now we have safe HTML and bbcode		//-----------------------------------------		 		$this->ipsclass->input['Post'] = $this->msglib->postlib->han_editor->process_raw_post( 'Post' ); 		 		//----------------------------------------- 		// SEND 		//----------------------------------------- 		 		$this->upload_id           = $this->msglib->postlib->process_upload(); 		$this->msglib->cc_users    = $this->ipsclass->parse_clean_value( $this->ipsclass->txt_UNhtmlspecialchars($_POST['carbon_copy']) ); 		$this->msglib->from_member = $this->ipsclass->member; 		$this->msglib->msg_title   = $this->ipsclass->input['msg_title']; 		$this->msglib->msg_post    = $this->ipsclass->input['Post']; 		 		$this->msglib->send_pm( array( 'save_only' => $this->ipsclass->input['save'],									   'orig_id'   => intval($this->ipsclass->input['OID']),									   'preview'   => $this->ipsclass->input['preview'],									   'track'     => $this->ipsclass->input['add_tracking'],									   'add_sent'  => ($this->ipsclass->input['add_sent'] ? 1 : 0),									   'hide_cc'   => $this->ipsclass->input['mt_hide_cc']							  )     ); 		 		if ( $this->msglib->error != "" ) 		{ 			$this->msglib->send_form( 0,$this->msglib->error ); 			$this->output .= $this->msglib->output; 			return; 		}				if ( $this->msglib->redirect_url )		{			$this->ipsclass->print->redirect_screen( $this->msglib->redirect_lang, $this->msglib->redirect_url );		}				//-----------------------------------------		// Swap and serve...		//-----------------------------------------				$text = preg_replace( "/<#FROM_MEMBER#>/"   , $this->ipsclass->member['members_display_name'] , $this->ipsclass->lang['sent_text'] );		$text = preg_replace( "/<#MESSAGE_TITLE#>/" , $this->ipsclass->input['msg_title'], $text );				$this->ipsclass->print->redirect_screen( $text , "&act=Msg&CODE=01" ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// MSG LIST: 	// 	// Views the inbox / folder of choice 	/*-------------------------------------------------------------------------*/ 	 	function msg_list() 	{		$sort_key = ""; 		 		switch ($this->ipsclass->input['sort']) 		{ 			case 'rdate': 				$sort_key = 'mt.mt_date ASC'; 				break; 			case 'title': 				$sort_key = 'mt.mt_title ASC'; 				break; 			case 'name': 				$sort_key = 'mem.members_display_name ASC'; 				break; 			default: 				$sort_key = 'mt.mt_date DESC'; 				break; 		} 		 		//----------------------------------------- 		// Get the number of messages we have in total. 		//----------------------------------------- 		 		$this->ipsclass->DB->simple_construct( array ( 'select' => 'COUNT(*) as msg_total', 'from' => 'message_topics', 'where' => "mt_owner_id=".$this->ipsclass->member['id']." AND mt_vid_folder != 'unsent'" ) ); 		$this->ipsclass->DB->simple_exec(); 		 		$total = $this->ipsclass->DB->fetch_row(); 		 		$total['msg_total'] = intval($total['msg_total']); 		 		if ( $total['msg_total'] != $this->ipsclass->member['msg_total'] ) 		{ 			$this->ipsclass->DB->simple_construct( array ( 'update'=> 'members', 'set' => "msg_total=".$total['msg_total'], 'where' => "id=".$this->ipsclass->member['id'] ) ) ; 			$this->ipsclass->DB->simple_exec(); 		} 		 		//----------------------------------------- 		// Get the number of messages in our curr folder. 		//----------------------------------------- 		 		$this->ipsclass->DB->simple_construct( array ( 'select' => 'COUNT(*) as msg_total', 'from' => 'message_topics', 'where' => "mt_owner_id=".$this->ipsclass->member['id']." AND mt_vid_folder='{$this->lib->vid}'" ) ); 		$this->ipsclass->DB->simple_exec(); 		 		$total_current = $this->ipsclass->DB->fetch_row(); 		 		$total_current['msg_total'] = intval($total_current['msg_total']); 		 		if ( $total_current['msg_total'] != $this->ipsclass->member['dir_data'][ $this->lib->vid ]['count'] ) 		{ 			$this->msglib->rebuild_dir_count( $this->ipsclass->member['id'], $this->ipsclass->member['vdirs'], $this->lib->vid, $total_current['msg_total'] ); 		} 		 		//----------------------------------------- 		// Make sure we've not exceeded our alloted allowance. 		//----------------------------------------- 		 		$info['full_messenger'] = "<br />"; 		$info['full_text']      = ""; 		$info['total_messages'] = $total['msg_total']; 		$info['img_width']      = 1; 		$info['vid']            = $this->lib->vid; 		$info['date_order']     = $sort_key == 'm.msg_date DESC' ? 'rdate' : 'msg_date'; 		 		$amount_info            = sprintf( $this->ipsclass->lang['pmpc_info_string'], $total['msg_total'] ,$this->ipsclass->lang['pmpc_unlimited'] ); 		 		if ($this->ipsclass->member['g_max_messages'] > 0) 		{ 			$amount_info          = sprintf( $this->ipsclass->lang['pmpc_info_string'], $total['msg_total'] ,$this->ipsclass->member['g_max_messages'] ); 			 			$info['full_percent'] = $total['msg_total'] ? sprintf( "%.0f", ( ($total['msg_total'] / $this->ipsclass->member['g_max_messages']) * 100) ) : 0; 			$info['img_width']    = $info['full_percent'] > 0 ? intval($info['full_percent']) * 2.4 : 1; 			 			if ($info['img_width'] > 300) 			{ 				$info['img_width'] = 300; 			} 			 			if ($total['msg_total'] >=$this->ipsclass->member['g_max_messages']) 			{ 				$info['full_messenger'] = "<span class='highlight'>".$this->ipsclass->lang['folders_full']."</span>"; 			} 			else 			{ 				$info['full_messenger'] = str_replace( "<#PERCENT#>", $info['full_percent'], $this->ipsclass->lang['pmpc_full_string'] ); 			} 		} 		 		//----------------------------------------- 		// Generate Pagination 		//----------------------------------------- 		 		$start = intval($this->ipsclass->input['st']) > 0 ? intval($this->ipsclass->input['st']) : 0; 		$p_end = $this->ipsclass->vars['show_max_msg_list'] > 0 ? $this->ipsclass->vars['show_max_msg_list'] : 50; 	 		 		$pages = $this->ipsclass->build_pagelinks( array( 'TOTAL_POSS'  => $total_current['msg_total'],														  'PER_PAGE'    => $p_end,														  'CUR_ST_VAL'  => $start,														  'L_SINGLE'    => "",														  'L_MULTI'     => $this->ipsclass->lang['msg_pages'],														  'BASE_URL'    => $this->ipsclass->base_url."act=Msg&amp;CODE=1&amp;VID=".$this->lib->vid."&amp;sort=".$this->ipsclass->input['sort'],												 )      ); 		 		//----------------------------------------- 		// Print the header 		//----------------------------------------- 		 		if ($this->lib->vid == 'sent') 		{ 			$this->ipsclass->lang['message_from'] = $this->ipsclass->lang['message_to']; 			 			$this->ipsclass->DB->cache_add_query( 'msg_get_sent_list', array( 'mid' => $this->ipsclass->member['id'], 'vid' => $this->lib->vid, 'sort' => $sort_key, 'limita' => $start, 'limitb' => $p_end ) ); 			$this->ipsclass->DB->simple_exec();  		} 		else 		{ 			$this->ipsclass->DB->cache_add_query( 'msg_get_folder_list', array( 'mid' => $this->ipsclass->member['id'], 'vid' => $this->lib->vid, 'sort' => $sort_key, 'limita' => $start, 'limitb' => $p_end ) ); 			$this->ipsclass->DB->simple_exec();  		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->inbox_table_header( $this->ipsclass->member['current_dir'], $info, $this->lib->jump_html, $pages, $this->lib->vid ); 		 		//----------------------------------------- 		// Get the messages 		//----------------------------------------- 		 		if ( $this->ipsclass->DB->get_num_rows() ) 		{ 			while( $row = $this->ipsclass->DB->fetch_row() ) 			{ 				if ( $row['mt_hasattach'] )				{					$row['attach_img'] = '<{ATTACH_ICON}>';				}			 				if ($this->lib->vid == 'sent') 				{ 					$row['icon'] = "<{M_READ}>"; 				} 				else 				{ 					$row['icon'] = $row['mt_read'] == 1 ? "<{M_READ}>" : "<{M_UNREAD}>"; 				} 				 				$row['date'] = $this->ipsclass->get_date( $row['mt_date'] , 'LONG' ); 				 				if ($this->lib->vid != 'sent') 				{ 					$row['add_to_contacts'] = "[ <a href='{$this->ipsclass->base_url}act=Msg&amp;CODE=02&amp;MID={$row['from_id']}'>{$this->ipsclass->lang[add_to_book]}</a> ]"; 				} 				else 				{ 					//$row['from_id'] = $row['mt_from_id']; 				} 				 				$this->output .= $this->ipsclass->compiled_templates['skin_msg']->inbox_row( $row ); 			} 		} 		else 		{ 			$this->output .= $this->ipsclass->compiled_templates['skin_msg']->No_msg_inbox(); 		} 		 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->end_inbox($this->lib->jump_html, $amount_info, $pages); 		 		//----------------------------------------- 		// Update the message stats if we have to 		//----------------------------------------- 		 		if ($this->ipsclass->member['current_id'] == 'in' and $this->ipsclass->member['new_msg'] > 0 ) 		{ 			$this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => 'new_msg=0', 'where' => 'id='.$this->ipsclass->member['id'] ) ); 			$this->ipsclass->DB->simple_exec(); 		} 		 		$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>" ); 	}	/*-------------------------------------------------------------------------*/ 	// VIEW SAVED: 	// 	// View the saved folder stuff. 	/*-------------------------------------------------------------------------*/ 	 	function view_saved() 	{		//----------------------------------------- 		// Print the header 		//----------------------------------------- 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->unsent_table_header(); 		 		$this->ipsclass->DB->cache_add_query( 'msg_get_sent_list', array( 'mid' => $this->ipsclass->member['id'], 'vid' => 'unsent', 'sort' => 'mt_date DESC', 'limita' => 0, 'limitb' => 5000 ) ); 		$this->ipsclass->DB->simple_exec(); 			 		//----------------------------------------- 		// Get the messages 		//----------------------------------------- 		 		if ( $this->ipsclass->DB->get_num_rows() ) 		{ 			while( $row = $this->ipsclass->DB->fetch_row() ) 			{ 				if ( $row['mt_hasattach'] )				{					$row['attach_img'] = '<{ATTACH_ICON}>';				}				 				$row['icon']     = "<{M_READ}>"; 				$row['date']     = $this->ipsclass->get_date( $row['mt_date'] , 'LONG' ); 				$row['cc_users'] = $row['msg_cc_users'] == "" ? $this->ipsclass->lang['no'] : $this->ipsclass->lang['yes']; 				 				$d_array = array( 'msg' => $row, 'member' => $this->ipsclass->member ); 				 				$this->output .= $this->ipsclass->compiled_templates['skin_msg']->unsent_row( $d_array ); 			} 		} 		else 		{ 			$this->output .= $this->ipsclass->compiled_templates['skin_msg']->No_msg_inbox(); 		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->unsent_end(); 		 		$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>" ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// SHOW TRACKED MESSAGE 	/*-------------------------------------------------------------------------*/ 	 	function show_tracking() 	{		//----------------------------------------- 		// Get all tracked and read messages 		//----------------------------------------- 		 		$this->ipsclass->DB->cache_add_query( 'msg_get_tracking', array( 'mid' => $this->ipsclass->member['id'] ) );		$this->ipsclass->DB->simple_exec();				$read = array();		$unread = array();				while ( $r = $this->ipsclass->DB->fetch_row() )		{			if ( $r['mt_read'] )			{				$read[ $r['mt_user_read'].','.$r['mt_id'] ] = $r;			}			else			{				$unread[ $r['mt_user_read'].','.$r['mt_id'] ] = $r;			}		}				krsort( $read );		krsort( $unread );				//----------------------------------------- 		// READ MESSAGES 		//----------------------------------------- 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackread_table_header();	 		if ( count($read) ) 		{ 			foreach( $read as $id => $row ) 			{ 				$row['icon']     = "<{M_READ}>"; 				$row['date']     = $this->ipsclass->get_date( $row['mt_user_read'] , 'LONG' ); 				$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackread_row( $row ); 			} 		} 		else 		{ 			$this->output .= $this->ipsclass->compiled_templates['skin_msg']->No_msg_inbox(); 		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackread_end(); 		 		//----------------------------------------- 		// UNREAD MESSAGES 		//----------------------------------------- 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackUNread_table_header(); 		 		if ( count($unread) ) 		{ 			foreach( $unread as $id => $row ) 			{ 				$row['icon']     = "<{M_UNREAD}>"; 				$row['date']     = $this->ipsclass->get_date( $row['mt_date'] , 'LONG' ); 				$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackUNread_row( $row ); 			} 		} 		else 		{ 			$this->output .= $this->ipsclass->compiled_templates['skin_msg']->No_msg_inbox(); 		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->trackUNread_end(); 		 		$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>" ); 	}        }?>

⌨️ 快捷键说明

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