func_msg.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,234 行 · 第 1/3 页
PHP
1,234 行
$this->ipsclass->DB->simple_construct( array( 'delete' => 'message_topics', 'where' => "mt_id IN (".implode( ',',$final_mts ).")" ) ); $this->ipsclass->DB->simple_exec(); } //----------------------------------------- // Update delete count //----------------------------------------- if ( count($final_ids) ) { $this->ipsclass->DB->simple_construct( array( 'update' => 'message_text', 'set' => "msg_deleted_count=msg_deleted_count+1", 'where' => "msg_id IN (".implode( ',',$final_ids ).")" ) ); $this->ipsclass->DB->simple_exec(); } //----------------------------------------- // Run through and delete dead msgs //----------------------------------------- $deleted_ids = array(); $attach_ids = array(); $this->ipsclass->DB->simple_construct( array( 'select' => 'msg_id', 'from' => 'message_text', 'where' => 'msg_deleted_count >= msg_sent_to_count' ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $deleted_ids[] = $r['msg_id']; } if ( count($deleted_ids) ) { $this->ipsclass->DB->simple_construct( array( 'delete' => 'message_text', 'where' => "msg_id IN (".implode( ',',$deleted_ids ).")") ); $this->ipsclass->DB->simple_exec(); $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_msg IN (".implode( ',',$deleted_ids ).")") ); $this->ipsclass->DB->simple_exec(); while ( $a = $this->ipsclass->DB->fetch_row() ) { $attach_ids[] = $a['attach_id']; if ( $a['attach_location'] ) { @unlink( $this->ipsclass->vars['upload_dir']."/".$a['attach_location'] ); } if ( $a['attach_thumb_location'] ) { @unlink( $this->ipsclass->vars['upload_dir']."/".$a['attach_thumb_location'] ); } } if ( count($attach_ids) ) { $this->ipsclass->DB->simple_construct( array( 'delete' => 'attachments', 'where' => "attach_id IN (".implode( ',',$attach_ids ).")") ); $this->ipsclass->DB->simple_exec(); } } } /*-------------------------------------------------------------------------*/ // Send form stuff /*-------------------------------------------------------------------------*/ function send_pm( $opts=array() ) { //----------------------------------------- // INIT some vars //----------------------------------------- if ( ! $this->to and $this->to_by_id ) { //----------------------------------------- // Just an id... //----------------------------------------- $tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'name, members_display_name', 'from' => 'members', 'where' => 'id='.$this->to_by_id ) ); $this->to = $tmp['members_display_name']; } $this->to = strtolower(str_replace( '|', '|', $this->to) ); $this->ipsclass->DB->cache_add_query( 'msg_get_cc_users', array( 'name_array' => array( 0 => "'".$this->to."'" ) ) ); $this->ipsclass->DB->simple_exec(); if ( ! $this->send_to_member = $this->ipsclass->DB->fetch_row() ) { $this->error = $this->ipsclass->lang['err_no_such_member']; return; } $this->error = ""; $this->save_only = $opts['save_only']; $this->orig_id = $opts['orig_id']; $this->preview = $opts['preview']; $this->add_tracking = $opts['track']; $this->add_sent = $opts['add_sent']; $this->hide_cc = $opts['hide_cc']; //----------------------------------------- // Are we simply saving this for later? //----------------------------------------- $this->_process_save_only(); if ( $this->redirect_url ) { return; } if ( $this->force_pm != 1 ) { //----------------------------------------- // Can the reciepient use the PM system? //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'msg_get_msg_poster', array( 'mid' => $this->send_to_member['id'] ) ); $this->ipsclass->DB->simple_exec(); $to_msg_stats = $this->ipsclass->DB->fetch_row(); if ( $to_msg_stats['g_use_pm'] != 1 OR $to_msg_stats['members_disable_pm'] ) { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $this->ipsclass->lang['no_usepm_member']; return; } //----------------------------------------- // Does the target member have enough room // in their inbox for a new message? //----------------------------------------- $to_msg_stats = $this->_get_real_allowance( $to_msg_stats ); if ( (($to_msg_stats['msg_total']) >= $to_msg_stats['g_max_messages']) and ($to_msg_stats['g_max_messages'] > 0) ) { $this->error = $this->ipsclass->lang['no_usepm_member']; return; } //----------------------------------------- // Has the reciepient blocked us? //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 'contact_id, allow_msg', 'from' => 'contacts', 'where' => "contact_id=".$this->from_member['id']." AND member_id=".$this->send_to_member['id'] ) ); $this->ipsclass->DB->simple_exec(); $can_msg = $this->ipsclass->DB->fetch_row(); if ( (isset($can_msg['contact_id'])) and ($can_msg['allow_msg'] != 1) ) { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $this->ipsclass->lang['msg_blocked']; return; } //----------------------------------------- // Do we have enough room to store a // saved copy? //----------------------------------------- if ($this->ipsclass->input['add_sent'] and ($this->ipsclass->member['g_max_messages'] > 0) ) { if ( ($this->msg_stats['msg_total'] + 1) >= $this->ipsclass->member['g_max_messages'] ) { $this->error = $this->ipsclass->lang['max_message_from']; return; } } } //----------------------------------------- // CC PM stuff //----------------------------------------- $this->can_mass_pm = 0; if ( $this->ipsclass->member['g_max_mass_pm'] > 0 or $this->force_pm ) { $cc_array = $this->_process_cc(); } if ( $this->error != "" ) { return; } //----------------------------------------- // Add our original ID //----------------------------------------- $cc_array[ $this->send_to_member['id'] ] = $this->send_to_member; unset($to_member); //----------------------------------------- // Insert the message body //----------------------------------------- $count = count( $cc_array ); if ( $this->add_sent ) { // we're storing a copy locally, so // add 1 to the "sent_to_count" $count++; } $this->ipsclass->DB->do_insert( 'message_text', array( 'msg_date' => time(), 'msg_post' => $this->ipsclass->remove_tags($this->msg_post), 'msg_cc_users' => $this->cc_users, 'msg_sent_to_count' => $count, 'msg_post_key' => $this->class->post_key, 'msg_author_id' => $this->from_member['id'], 'msg_ip_address' => $this->ipsclass->ip_address ) ); $msg_id = $this->ipsclass->DB->get_insert_id(); //----------------------------------------- // Make attachments permanent //----------------------------------------- $no_attachments = $this->postlib->pf_make_attachments_permanent( $this->class->post_key, "", "", $msg_id ); //----------------------------------------- // If we have an original ID - delete it and 'move' // attachments //----------------------------------------- if ( $this->orig_id ) { $this->ipsclass->DB->cache_add_query( 'msg_get_saved_msg', array( 'mid' => $this->from_member['id'], 'msgid' => $this->orig_id ) ); $this->ipsclass->DB->simple_exec(); if( $old = $this->ipsclass->DB->fetch_row() ) { //----------------------------------------- // Update attachments //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'update' => 'attachments', 'set' => "attach_post_key='{$this->class->post_key}', attach_msg=$msg_id", 'where' => "attach_msg={$old['msg_id']}" ) ); $this->ipsclass->DB->simple_exec(); $this->ipsclass->DB->simple_construct( array( 'delete' => 'message_topics', 'where' => "mt_id={$old['mt_id']}" ) ); $this->ipsclass->DB->simple_exec(); $this->ipsclass->DB->simple_construct( array ( 'update' => 'message_text', 'set' => 'msg_deleted_count=msg_deleted_count-1', 'where' => "msg_id={$old['msg_id']}" ) ); $this->ipsclass->DB->simple_exec(); $no_attachments = $old['mt_hasattach']; } } //----------------------------------------- // loop.... //----------------------------------------- foreach ($cc_array as $user_id => $to_member) { //----------------------------------------- // Sort out tracking and pop us status //----------------------------------------- $show_popup = $to_member['view_pop']; //----------------------------------------- // Enter the info into the DB // Target user side. //----------------------------------------- $this->ipsclass->DB->force_data_type = array( 'mt_title' => 'string' ); $this->ipsclass->DB->do_insert( 'message_topics', array( 'mt_msg_id' => $msg_id, 'mt_date' => time(), 'mt_title' => $this->msg_title, 'mt_from_id' => $this->from_member['id'], 'mt_to_id' => $to_member['id'], 'mt_vid_folder' => 'in', 'mt_tracking' => $this->add_tracking, 'mt_addtosent' => $this->add_sent, 'mt_hasattach' => intval($no_attachments), 'mt_owner_id' => $to_member['id'], 'mt_hide_cc' => $this->hide_cc, ) ); $mt_id = $this->ipsclass->DB->get_insert_id(); //----------------------------------------- // Update profile //----------------------------------------- $inbox_count = $this->_get_dir_count( $to_member['vdirs'], 'in' ); $new_vdir = $this->rebuild_dir_count( $to_member['id'], "", 'in', $inbox_count + 1, 'save', "msg_total=msg_total+1,new_msg=new_msg+1,show_popup={$show_popup}" ); //----------------------------------------- // Has this member requested a PM email nofity? //----------------------------------------- if ($to_member['email_pm'] == 1) { $to_member['language'] = $to_member['language'] == "" ? 'en' : $to_member['language']; $this->postlib->email->get_template("pm_notify", $to_member['language']); $this->postlib->email->build_message( array( 'NAME' => $to_member['members_display_name'], 'POSTER' => $this->from_member['members_display_name'], 'TITLE' => $this->msg_title, 'LINK' => "?act=Msg&CODE=03&VID=in&MSID=$mt_id", ) ); $this->postlib->email->subject = $this->ipsclass->lang['pm_email_subject']; $this->postlib->email->to = $to_member['email']; $this->postlib->email->send_mail(); } } //----------------------------------------- // Add the data to the current members DB if we are // adding it to our "sent items" folder //----------------------------------------- if ( $this->add_sent ) { $sent_count = $this->_get_dir_count( $this->from_member['vdirs'], 'sent' ); $this->rebuild_dir_count( $this->from_member['id'], "", 'sent', $sent_count + 1, 'save', "msg_total=msg_total+1" ); $this->ipsclass->DB->do_insert( 'message_topics', array( 'mt_msg_id' => $msg_id, 'mt_date' => time(), 'mt_title' => $this->msg_title, 'mt_from_id' => $this->from_member['id'], 'mt_to_id' => $this->send_to_member['id'], 'mt_vid_folder' => 'sent', 'mt_tracking' => 0, 'mt_addtosent' => 0, 'mt_hasattach' => intval($no_attachments), 'mt_owner_id' => $this->from_member['id'], 'mt_hide_cc' => $this->hide_cc, ) ); } $this->to_by_id = ""; $this->to = ""; } /*-------------------------------------------------------------------------*/ // Rebuild DIR count /*-------------------------------------------------------------------------*/ function rebuild_dir_count($mid, $vdir, $cur_dir, $new_count, $nosave='save', $extra="") { $rebuild = array(); if ( ! $vdir ) { $this->ipsclass->DB->simple_construct( array( "select" => 'vdirs', 'from' => 'member_extra', 'where' => 'id='.$mid ) ); $this->ipsclass->DB->simple_exec(); $mem = $this->ipsclass->DB->fetch_row(); $vdir = $mem['vdirs'] ? $mem['vdirs'] : 'in:Inbox;0|sent:Sent Items;0'; } foreach( explode( "|", $vdir ) 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; } $rebuild[$id] = $id.':'.$real.';'.intval($count); } $final = implode( '|', $rebuild ); if ( $nosave != 'nosave' ) { $this->ipsclass->DB->simple_construct( array( 'update' => 'member_extra', 'set' => 'vdirs="'.$final.'"', 'where' => 'id='.$mid ) );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?