messenger.php

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

PHP
1,798
字号
<?php/*+--------------------------------------------------------------------------|   Invision Power Board v2.1.6|   =============================================|   by Matthew Mecham|   (c) 2001 - 2005 Invision Power Services, Inc.|   http://www.invisionpower.com|   =============================================|   Web: http://www.invisionboard.com|   Time: Thu, 04 May 2006 17:39:49 GMT|   Release: b415613eeb952a2741ff6d53e0266428|   Licence Info: http://www.invisionboard.com/?license+---------------------------------------------------------------------------|   > $Date: 2005-12-07 15:18:13 +0000 (Wed, 07 Dec 2005) $|   > $Revision: 95 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > Messenger functions|   > Module written by Matt Mecham|   > Date started: 26th February 2002||	> Module Version Number: 1.0.0|   > DBA Checked: Wed 19 May 2004|   > Quality Checked: Wed 15 Sept. 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 messenger{    var $output     = "";    var $page_title = "";    var $nav        = array();    var $html       = "";    var $email      = "";        var $msg_stats  = array();    var $prefs      = "";        var $member     = array();    var $m_group    = array();        var $to_mem     = array();        var $jump_html  = "";        var $vid        = "in";    var $mem_groups = array();    var $mem_titles = array();        var $topiclib   = "";    var $postlib    = "";        var $parser     = "";        var $cp_html    = "";    var $edit_saved = "";        /*-------------------------------------------------------------------------*/    // Auto-run    /*-------------------------------------------------------------------------*/        function auto_run()    {		//-----------------------------------------    	// Require the HTML and language modules    	//-----------------------------------------    			$this->ipsclass->load_language('lang_msg');		$this->ipsclass->load_language('lang_ucp');    	$this->ipsclass->load_template('skin_msg');    	$this->ipsclass->load_template('skin_ucp');    	    	//-----------------------------------------    	// Load classes    	//-----------------------------------------    	    	require_once( ROOT_PATH.'sources/lib/func_msg.php' ); 		require_once( ROOT_PATH."sources/lib/func_usercp.php" ); 		 		$this->msglib = new func_msg();    	$this->msglib->ipsclass =& $this->ipsclass;    	    	//-----------------------------------------		// INIT da func		//-----------------------------------------		    	$this->lib   = new func_usercp($this);    	$this->lib->ipsclass =& $this->ipsclass;    	    	//-----------------------------------------    	// Set up defaults    	//-----------------------------------------    	    	$this->base_url        = $this->ipsclass->base_url;    	$this->base_url_nosess = "{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}";    	    	//-----------------------------------------    	// Check viewing permissions, etc		//-----------------------------------------				if ( ! $this->ipsclass->member['g_use_pm'] )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_use_messenger' ) );		}				if ( $this->ipsclass->member['members_disable_pm'] )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_use_messenger' ) );		}				if ( ! $this->ipsclass->member['id'] )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );		}				//-----------------------------------------    	// Print menu    	//-----------------------------------------    	    	$this->ipsclass->print->add_output( $this->lib->ucp_generate_menu() );    	    	//-----------------------------------------    	// What to do?    	//-----------------------------------------    	    	switch($this->ipsclass->input['CODE'])    	{    		case '01':    			$this->msg_list();    			break;    		case '02':    			$this->contact();    			break;    		case '03':    			$this->view_msg();    			break;    		case '04';    			$this->send();    			break;    		case '05':    			$this->delete();    			break;    		case '06':    			$this->multi_act();    			break;    		case '07':    			$this->prefs();    			break;    		case '08':    			$this->do_prefs();    			break;    		case '09':    			$this->add_member();    			break;    		case '10':    			$this->del_member();    			break;    		case '11':    			$this->edit_member();    			break;    		case '12':    			$this->do_edit();    			break;    		case '14':    			$this->archive();    			break;    		case '15':    			$this->do_archive();    			break;    			    		case '20':    			$this->view_saved();    			break;    			    		case '21':    			$this->edit_saved = 1;    			$this->send();    			break;    			    		case '30':    			$this->show_tracking();    			break;    			    		case '31':    			$this->end_tracking();    			break;    			    		case '32':    			$this->del_tracked();    			break;    			    		case 'delete':    			$this->start_empty_folders();    			break;    		case 'dofolderdelete':    			$this->end_empty_folders();    			break;    			    		default:    			$this->msg_list();    			break;    	}    	    	// If we have any HTML to print, do so...    	    	$fj = $this->ipsclass->build_forum_jump();		$fj = preg_replace( "!#Forum Jump#!", $this->ipsclass->lang['forum_jump'], $fj);				$this->output .= $this->ipsclass->compiled_templates['skin_ucp']->CP_end();				$this->output .= $this->ipsclass->compiled_templates['skin_ucp']->forum_jump($fj);    	    	$this->ipsclass->print->add_output("$this->output");        $this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// Empty PM folders: 	// 	// Interface for removing PM's on a folder by folder basis 	/*-------------------------------------------------------------------------*/ 	 	function start_empty_folders() 	{		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->empty_folder_header(); 		 		//----------------------------------------- 		// Get the PM count - 1 query? 		//----------------------------------------- 		 		$count = array( 'unsent' => 0 ); 		$names = array( 'unsent' => $this->ipsclass->lang['fd_unsent'] ); 		 		foreach( $this->ipsclass->member['dir_data'] as $k => $v ) 		{ 			$count[ $v['id'] ] = 0; 			$names[ $v['id'] ] = $v['real']; 		} 		 		$this->ipsclass->DB->simple_construct( array( 'select' => 'mt_id, mt_vid_folder, mt_msg_id', 'from' => 'message_topics', 'where' => 'mt_owner_id='.$this->ipsclass->member['id'] ) ); 		$this->ipsclass->DB->simple_exec(); 		 		while( $r = $this->ipsclass->DB->fetch_row() ) 		{ 			if ( $r['mt_vid_folder'] == "" ) 			{ 				$count['in']++; 			} 			else 			{ 				$count[ $r['mt_vid_folder'] ]++; 			} 		} 		 		foreach( $names as $vid => $name ) 		{ 			$this->output .= $this->ipsclass->compiled_templates['skin_msg']->empty_folder_row( $name, $vid, $count[$vid] ); 		} 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->empty_folder_save_unread(); 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->empty_folder_footer(); 		 		$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>" ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// DELETE emptied PMS 	/*-------------------------------------------------------------------------*/ 	 	function end_empty_folders() 	{		$names = array( 'unsent' => $this->ipsclass->lang['fd_unsent'] ); 		$ids   = array(); 		$qe = ""; 		 		foreach( $this->ipsclass->member['dir_data'] as $k => $v ) 		{ 			$names[ $v['id'] ] = $v['real']; 		} 		 		//----------------------------------------- 		// Did we check any boxes? 		//----------------------------------------- 		 		foreach( $names as $vid => $name ) 		{ 			if ( $this->ipsclass->input['its_'.$vid] == 1 ) 			{ 				$ids[] = $vid; 			} 		} 		 		if ( count($ids) < 1 ) 		{ 			$this->ipsclass->Error( array(  'LEVEL' => 1, 'MSG' => 'fd_noneselected' ) ); 		} 		 		//----------------------------------------- 		// Delete em! 		//----------------------------------------- 		 		if ( $this->ipsclass->input['save_unread'] ) 		{ 			$qe = ' AND mt_read=1'; 		} 		 		$mtids = array(); 		 		$this->ipsclass->DB->simple_construct( array( 'select' => 'mt_id', 'from' => 'message_topics', 'where' => 'mt_owner_id='.$this->ipsclass->member['id']." AND mt_vid_folder IN('".implode("','", $ids)."')".$qe ) ); 		$this->ipsclass->DB->simple_exec(); 		 		while( $d = $this->ipsclass->DB->fetch_row() ) 		{ 			$mtids[] = $d['mt_id']; 		} 		 		$this->msglib->delete_messages( $mtids, $this->ipsclass->member['id'] ); 		 		$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']); 		 		$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(); 		 		//----------------------------------------- 		// Update directory counts 		//----------------------------------------- 		 		$current_dirs = $this->ipsclass->member['vdirs']; 		 		 		foreach( $ids as $k => $v ) 		{	 		$foldertotal['total'] = 0;	 			 		$this->ipsclass->DB->simple_construct( array ( 'select' => 'COUNT(*) as total', 'from' => 'message_topics', 'where' => "mt_owner_id=".$this->ipsclass->member['id']." AND mt_vid_folder = '{$v}'" ) );	 		$this->ipsclass->DB->simple_exec();	 			 		$foldertotal = $this->ipsclass->DB->fetch_row();	 			 		$current_dirs = $this->msglib->rebuild_dir_count( $this->ipsclass->member['id'],															  $current_dirs,															  $v,															  $foldertotal['total'],															  'save'															);		}		 		$this->ipsclass->boink_it($this->ipsclass->base_url."act=Msg&CODE=delete"); 	} 	 	 	/*-------------------------------------------------------------------------*/ 	// ARCHIVE: 	// 	// Allows a user to archive and email a HTML file 	/*-------------------------------------------------------------------------*/ 	 	function archive()  	{		$this->lib->jump_html = preg_replace("/<!--EXTRA-->/", "<option value='all'>".$this->ipsclass->lang['all_folders']."</option>", $this->lib->jump_html ); 		 		$this->output .= $this->ipsclass->compiled_templates['skin_msg']->archive_form( $this->lib->jump_html ); 		 		$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>" ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// Process archive 	/*-------------------------------------------------------------------------*/ 	 	function do_archive() 	{ 		//----------------------------------------- 		// INIT 		//----------------------------------------- 		 		$folder_query  = ""; 		$msg_ids       = array(); 		$older_newer   = '>'; 		$type          = 'html'; 		$file_name     = "pm_archive.html"; 		$ctype         = "text/html"; 		 		//----------------------------------------- 		// Get email library 		//----------------------------------------- 				require_once( ROOT_PATH."sources/classes/class_email.php" );		$this->email = new emailer(); 		$this->email->ipsclass =& $this->ipsclass; 		$this->email->email_init(); 		 		//----------------------------------------- 		// Require BBCode library 		//----------------------------------------- 		 		require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );        $this->parser                      = new parse_bbcode();        $this->parser->ipsclass            = $this->ipsclass;        $this->parser->allow_update_caches = 1;                $this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);         		//----------------------------------------- 		// Did we specify a folder, or choose all? 		//----------------------------------------- 		 		if ( $this->ipsclass->input['oldnew'] == 'older' ) 		{ 			$older_newer = '<'; 		} 		 		if ($this->ipsclass->input['VID'] != 'all') 		{ 			$folder_query = " AND mt.mt_vid_folder='".$this->ipsclass->input['VID']."'"; 		} 		 		if ( $this->ipsclass->input['dateline'] == 'all' ) 		{ 			$time_cut    = 0; 			$older_newer = '>'; 		} 		else 		{ 			$time_cut = time() - ($this->ipsclass->input['dateline'] * 60 * 60 *24); 		} 		 		//----------------------------------------- 		// Check the input... 		//----------------------------------------- 		 		$this->ipsclass->input['number'] = intval( $this->ipsclass->input['number'] ); 		 		if ($this->ipsclass->input['number'] < 5) 		{

⌨️ 快捷键说明

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