messenger.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,798 行 · 第 1/4 页
PHP
1,798 行
$this->ipsclass->input['number'] = 5; } if ($this->ipsclass->input['number'] > 50) { $this->ipsclass->input['number'] = 50; } if ($this->ipsclass->input['type'] == 'xls') { $type = 'xls'; $file_name = "xls_importable.txt"; $ctype = "text/plain"; } $output = ""; //----------------------------------------- // Start the datafile.. //----------------------------------------- if ($type == 'html') { $output .= $this->ipsclass->compiled_templates['skin_msg']->archive_html_header(); } //----------------------------------------- // Get the messages... //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'msg_get_msg_archive', array( 'mid' => $this->ipsclass->member['id'], 'limit_b' => $this->ipsclass->input['number'], 'older_newer' => $older_newer, 'time_cut' => $time_cut, 'folder_query' => $folder_query ) ); $this->ipsclass->DB->cache_exec_query(); //----------------------------------------- // Repeat after me.. //----------------------------------------- if ( $this->ipsclass->DB->get_num_rows() ) { while ( $r = $this->ipsclass->DB->fetch_row() ) { $info = array(); $msg_ids[] = $r['mt_id']; $this->parser->parse_smilies = 0; $this->parser->parse_html = $this->ipsclass->vars['msg_allow_html']; $this->parser->parse_bbcode = $this->ipsclass->vars['msg_allow_code']; $info['msg_date'] = $this->ipsclass->get_date( $r['mt_date'], 'LONG' ); $info['msg_title'] = $r['mt_title']; $info['msg_sender'] = $r['members_display_name']; $info['msg_content'] = $this->parser->pre_display_parse( $this->parser->pre_db_parse( $r['msg_post'] ) ); if ($type == 'xls') { $output .= '"'.$this->strip_quotes($info['msg_title']).'","'.$this->strip_quotes($info['msg_date']).'","'.$this->strip_quotes($info['msg_sender']).'","'.$this->strip_quotes($info['msg_content']).'"'."\r"; } else { if ( $r['mt_vid_folder'] == 'sent' ) { $output .= $this->ipsclass->compiled_templates['skin_msg']->archive_html_entry_sent($info); } else { $output .= $this->ipsclass->compiled_templates['skin_msg']->archive_html_entry($info); } } } if ($type == 'html') { $output .= $this->ipsclass->compiled_templates['skin_msg']->archive_html_footer(); } $num_msg = count( $msg_ids ); //----------------------------------------- // Delete? //----------------------------------------- if ($this->ipsclass->input['delete'] == 'yes') { $this->msglib->delete_messages( $msg_ids, $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(); } //----------------------------------------- // Process & Print //----------------------------------------- $output = str_replace( "<#IMG_DIR#>", $this->ipsclass->skin['_imagedir'], $output ); $this->email->get_template("pm_archive"); $this->email->build_message( array( 'NAME' => $this->ipsclass->member['members_display_name'] ) ); $this->email->subject = $this->ipsclass->lang['arc_email_subject']; $this->email->to = $this->ipsclass->member['email']; $this->email->add_attachment( $output, $file_name, $ctype ); $this->email->send_mail(); //----------------------------------------- // Done.. //----------------------------------------- $this->ipsclass->lang['arc_complete'] = str_replace( "<#NUM#>", $num_msg, $this->ipsclass->lang['arc_complete'] ); $this->output .= $this->ipsclass->compiled_templates['skin_msg']->archive_complete(); $this->page_title = $this->ipsclass->lang['t_welcome']; $this->nav = array( "<a href='".$this->base_url."act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); } else { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_archive_messages' ) ); } } /*-------------------------------------------------------------------------*/ // Strip Quotes /*-------------------------------------------------------------------------*/ function strip_quotes($text) { return preg_replace( "/\"/", '\\\"', $text ); } /*-------------------------------------------------------------------------*/ // PREFS: // // Create/delete/edit messenger folders /*-------------------------------------------------------------------------*/ function prefs() { $this->output .= $this->ipsclass->compiled_templates['skin_msg']->prefs_header(); $max = 1; foreach( $this->ipsclass->member['dir_data'] as $k => $v ) { $extra = ""; //----------------------------------------- // Can't remove IN and SENT dirs //----------------------------------------- if ( $v['id'] == 'in' or $v['id'] == 'sent' ) { $extra = " ( ".$v['real']." - ".$this->ipsclass->lang['cannot_remove']." )"; } //----------------------------------------- // Can't remove folders w/messages //----------------------------------------- if ( $this->msglib->_get_dir_count( $this->ipsclass->member['vdirs'], $v['id'] ) ) { $extra = " ( ".$v['real']." - ".$this->ipsclass->lang['cannot_remove']." )"; $extra .= "<input type='hidden' name=\"noremove[{$v['id']}]\" value='1' />"; } $this->output .= $this->ipsclass->compiled_templates['skin_msg']->prefs_row( array( 'ID' => $v['id'], 'REAL' => $v['real'], 'EXTRA' => $extra ) ); if ( stristr( $v['id'], 'dir_' ) ) { $max = intval( str_replace( 'dir_', "", $v['id'] ) ) + 1; } } $count = $max + 1; $this->output .= $this->ipsclass->compiled_templates['skin_msg']->prefs_add_dirs(); for ($i = $count; $i < $count + 3; $i++) { $this->output .= $this->ipsclass->compiled_templates['skin_msg']->prefs_row( array( 'ID' => 'dir_'.$i, 'REAL' => '', 'EXTRA' => '' ) ); } $this->output .= $this->ipsclass->compiled_templates['skin_msg']->prefs_footer(); $this->page_title = $this->ipsclass->lang['t_welcome']; $this->nav = array( "<a href='".$this->base_url."act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); } /*-------------------------------------------------------------------------*/ // SAVE FOLDERS /*-------------------------------------------------------------------------*/ function do_prefs() { //----------------------------------------- // Check to ensure than we've not tried to // remove the inbox and sent items directories. //----------------------------------------- if ( ($this->ipsclass->input['sent'] == "") or ($this->ipsclass->input['in'] == "") ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cannot_remove_dir' ) ); } //----------------------------------------- // Did we remove a box we're not allowed to? //----------------------------------------- if ( is_array( $_POST['noremove'] ) ) { foreach( $_POST['noremove'] as $key => $value ) { if ( $value ) { if ( ! $this->ipsclass->input[ $key ] ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cannot_remove_dir' ) ); } } } } $cur_dir = array(); foreach( explode( "|", $this->ipsclass->member['vdirs'] ) as $dir ) { list ($id , $data) = explode( ":", $dir ); list ($real, $count) = explode( ";", $data ); if ( ! $id ) { continue; } if ( $id == $cur_dir ) { $count = $new_count; $count = $count < 1 ? 0 : $count; } $cur_dir[$id] = intval($count); } $v_dir = 'in:'.$this->ipsclass->input['in'].';'.intval($cur_dir['in']).'|sent:'.$this->ipsclass->input['sent'].';'.intval($cur_dir['sent']); //----------------------------------------- // Fetch the rest of the dirs //----------------------------------------- $ids = array(); foreach ($this->ipsclass->input as $key => $value) { if ( preg_match( "/^dir_(\d+)$/", $key, $match ) ) { if ($this->ipsclass->input[$match[0]]) { $count = intval( $cur_dir[ $match[0] ] ); $v_dir .= '|'.$match[0].':'.trim(str_replace( '|', '', str_replace( ";", "", $this->ipsclass->input[$match[0]] ) ) ).';'.$count; } } } $this->ipsclass->DB->simple_construct( array('update' => 'member_extra', 'set' => "vdirs='$v_dir'", 'where' => 'id='.$this->ipsclass->member['id']) ); $this->ipsclass->DB->simple_exec(); $this->ipsclass->boink_it($this->ipsclass->base_url."act=Msg&CODE=07"); } /*-------------------------------------------------------------------------*/ // DELETE_MEMBER: // // Removes a member from address book. /*-------------------------------------------------------------------------*/ function del_member() { if (!$this->ipsclass->input['MID']) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } if (! preg_match( "/^(\d+)$/", $this->ipsclass->input['MID'] ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'contacts', 'where' => "member_id={$this->ipsclass->member['id']} AND contact_id={$this->ipsclass->input['MID']}" ) ); $this->ipsclass->boink_it($this->base_url."act=Msg&CODE=02"); } /*-------------------------------------------------------------------------*/ // EDIT_MEMBER: // // Edit a member from address book. /*-------------------------------------------------------------------------*/ function edit_member() { if (!$this->ipsclass->input['MID']) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } if (! preg_match( "/^(\d+)$/", $this->ipsclass->input['MID'] ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'contacts', 'where' => "member_id={$this->ipsclass->member['id']} AND contact_id={$this->ipsclass->input['MID']}" ) ); $this->ipsclass->DB->simple_exec(); $memb = $this->ipsclass->DB->fetch_row(); if (!$memb['contact_id']) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } $html = "<select name='allow_msg' class='forminput'>"; if ($memb['allow_msg']) { $html .= "<option value='yes' selected>{$this->ipsclass->lang['yes']}</option><option value='no'>{$this->ipsclass->lang['no']}"; } else { $html .= "<option value='yes'>{$this->ipsclass->lang['yes']}</option><option value='no' selected>{$this->ipsclass->lang['no']}"; } $html .= "</select>"; $this->output .= $this->ipsclass->compiled_templates['skin_msg']->address_edit( array( 'SELECT' => $html, 'MEMBER' => $memb ) ); $this->page_title = $this->ipsclass->lang['t_welcome']; $this->nav = array( "<a href='".$this->base_url."&act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>", "<a href='".$this->base_url."act=Msg&CODE=02'>".$this->ipsclass->lang['t_book']."</a>" ); } /*-------------------------------------------------------------------------*/ // DO_EDIT_MEMBER: // // Edit a member from address book. /*-------------------------------------------------------------------------*/ function do_edit() { if (!$this->ipsclass->input['MID']) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } if (! preg_match( "/^(\d+)$/", $this->ipsclass->input['MID'] ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } $this->ipsclass->input['allow_msg'] = $this->ipsclass->input['allow_msg'] == 'yes' ? 1 : 0; $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'contacts', 'where' => "member_id={$this->ipsclass->member['id']} AND contact_id={$this->ipsclass->input['MID']}" ) ); $this->ipsclass->DB->simple_exec(); $memb = $this->ipsclass->DB->fetch_row(); if (!$memb['contact_id']) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_user' ) ); } $this->ipsclass->DB->do_update( 'contacts', array( 'contact_desc' => $this->ipsclass->input['mem_desc'], 'allow_msg' => $this->ipsclass->input['allow_msg'], ), 'id='.$memb['id'] ); $this->ipsclass->boink_it($this->base_url."act=Msg&CODE=02"); } /*-------------------------------------------------------------------------*/ // CONTACT: // // Shows the address book. /*-------------------------------------------------------------------------*/ function contact() { $this->output .= $this->ipsclass->compiled_templates['skin_msg']->Address_header(); $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'contacts', 'where' => "member_id={$this->ipsclass->member['id']}", 'order' => "contact_name ASC" ) ); $this->ipsclass->DB->simple_exec(); if ( $this->ipsclass->DB->get_num_rows() ) { $this->output .= $this->ipsclass->compiled_templates['skin_msg']->Address_table_header(); while ( $row = $this->ipsclass->DB->fetch_row() ) { $row['text'] = $row['allow_msg'] ? $this->ipsclass->lang['can_contact'] : $this->ipsclass->lang['cannot_contact']; $this->output .= $this->ipsclass->compiled_templates['skin_msg']->render_address_row($row); } $this->output .= $this->ipsclass->compiled_templates['skin_msg']->end_address_table(); } else { $this->output .= $this->ipsclass->compiled_templates['skin_msg']->Address_none(); } //----------------------------------------- // Do we have a name to enter? //----------------------------------------- $name_to_enter = ""; if ($this->ipsclass->input['MID']) { if ( preg_match( "/^(\d+)$/", $this->ipsclass->input['MID'] ) ) { $this->ipsclass->DB->simple_construct( array( 'select' => 'members_display_name,id', 'from' => 'members', 'where' => "id={$this->ipsclass->input['MID']}" ) ); $this->ipsclass->DB->simple_exec(); $memb = $this->ipsclass->DB->fetch_row(); if ($memb['id']) { $name_to_enter = $memb['members_display_name']; } } } $this->output .= $this->ipsclass->compiled_templates['skin_msg']->address_add($name_to_enter);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?