func_msg.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,234 行 · 第 1/3 页
PHP
1,234 行
$this->ipsclass->DB->simple_exec(); if ( $extra ) { $this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => $extra, 'where' => 'id='.$mid ) ); $this->ipsclass->DB->simple_exec(); } } return $final; } /*-------------------------------------------------------------------------*/ // POST PROCESS CC /*-------------------------------------------------------------------------*/ function format_cc_string($cc_users, $mid ) { $cc_array = array(); $final = array(); $cc_array = $this->get_cc_array( $cc_users ); foreach( $cc_array as $id => $data ) { if ( $id == $mid ) { continue; } $final[] = $this->ipsclass->make_profile_link( $data['members_display_name'], $data['id'] ); } return implode( ", ", $final ); } /*-------------------------------------------------------------------------*/ // PROCESS CC /*-------------------------------------------------------------------------*/ function get_cc_array($cc_users) { $cc_array = array(); $cc_users = strtolower(str_replace( '|', '|', $cc_users) ); if ( $cc_users ) { //----------------------------------------- // Sort out the array //----------------------------------------- $cc_users = str_replace( "<br><br>", "<br>" , trim($cc_users) ); $cc_users = preg_replace( "/^(<br>){1}/", "" , $cc_users ); $cc_users = preg_replace( "/(<br>){1}$/", "" , $cc_users ); $cc_users = preg_replace( "/<br>\s+/", "," , $cc_users ); $temp_array = explode( "<br>", $cc_users ); //----------------------------------------- // Make SQL'able //----------------------------------------- if ( is_array($temp_array) and count($temp_array) > 0 ) { $new_array = array(); foreach( $temp_array as $name ) { $name = "'".trim(strtolower($name))."'"; if (in_array( $name, $new_array ) ) { continue; } $new_array[] = $name; } } //----------------------------------------- // SQL it //----------------------------------------- if ( is_array($new_array) and count($new_array) > 0 ) { $array_count = count($new_array); $this->ipsclass->DB->cache_add_query( 'msg_get_cc_users', array( 'name_array' => $new_array ) ); $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row() ) { $cc_array[$r['id']] = $r; } } } return $cc_array; } /*-------------------------------------------------------------------------*/ // PROCESS CC /*-------------------------------------------------------------------------*/ function _process_cc() { $this->can_mass_pm = 1; $cc_array = array(); $this->cc_users = strtolower(str_replace( '|', '|', $this->cc_users) ); if (isset($this->cc_users) and $this->cc_users != "") { //----------------------------------------- // Sort out the array //----------------------------------------- $this->cc_users = str_replace( "<br>", "<br />" , trim($this->cc_users) ); $this->cc_users = str_replace( "<br /><br />", "<br />" , trim($this->cc_users) ); $this->cc_users = preg_replace( "#^(<br />){1}#", "" , $this->cc_users ); $this->cc_users = preg_replace( "#(<br />){1}$#", "" , $this->cc_users ); $this->cc_users = preg_replace( "#<br />\s+#", "," , $this->cc_users ); $temp_array = explode( "<br />", $this->cc_users ); //----------------------------------------- // Make SQL'able //----------------------------------------- if ( is_array($temp_array) and count($temp_array) > 0 ) { $new_array = array(); foreach( $temp_array as $name ) { $name = "'".trim(strtolower($name))."'"; if (in_array( $name, $new_array ) ) { continue; } $new_array[] = $name; } } //----------------------------------------- // SQL it //----------------------------------------- if ( is_array($new_array) and count($new_array) > 0 ) { $array_count = count($new_array); $this->ipsclass->DB->cache_add_query( 'msg_get_cc_users', array( 'name_array' => $new_array ) ); $this->ipsclass->DB->simple_exec(); if ( ! $this->ipsclass->DB->get_num_rows() ) { $this->error = $this->ipsclass->lang['pme_no_cc_user']; return; } else { while( $r = $this->ipsclass->DB->fetch_row() ) { $cc_array[$r['id']] = $r; } //----------------------------------------- if ( $this->force_pm != 1 ) { if ( count($cc_array) > $this->ipsclass->member['g_max_mass_pm']) { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $this->ipsclass->lang['pme_too_many']; return; } } //----------------------------------------- // Names exist? //----------------------------------------- $cc_error = ""; if ( count($cc_array) != $array_count ) { foreach( $new_array as $n ) { $seen = 0; foreach( $cc_array as $idx => $cc_user ) { $tmp = "'".strtolower($cc_user['name'])."'"; if ($tmp == $n) { $seen = 1; } } if ($seen != 1) { $cc_error .= "<br>".sprintf( $this->ipsclass->lang['pme_failed_nomem'], $n, $n ); } } } if ($cc_error != "") { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $cc_error; return; } //----------------------------------------- // Can use PM system? //----------------------------------------- $cc_error = ""; $cc_id_array = array(); foreach($cc_array as $idx => $cc_user) { if ( $cc_user['g_use_pm'] != 1 OR $cc_user['members_disable_pm'] ) { $cc_error .= "<br>".sprintf( $this->ipsclass->lang['pme_failed_nopm'], $cc_user['members_display_name'], $cc_user['members_display_name'] ); } $cc_user = $this->_get_real_allowance($cc_user); if ($cc_user['g_max_messages'] > 0 and ($cc_user['msg_total'] + 1 > $cc_user['g_max_messages']) ) { $cc_error .= "<br>".sprintf( $this->ipsclass->lang['pme_failed_maxed'], $cc_user['members_display_name'], $cc_user['members_display_name'] ); } $cc_id_array[] = $cc_user['id']; } if ( $this->force_pm != 1 ) { if ($cc_error != "") { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $cc_error; return; } } //----------------------------------------- // Check the block list.. //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'msg_get_cc_blocked', array( 'mid' => $this->from_member['id'], 'cc_array' => $cc_id_array ) ); $this->ipsclass->DB->simple_exec(); while ( $c = $this->ipsclass->DB->fetch_row() ) { if ($c['allow_msg'] != 1) { $cc_error .= "<br>".sprintf( $this->ipsclass->lang['pme_failed_block'], $c['name'], $c['name'] ); } } if ( $this->force_pm != 1 ) { if ($cc_error != "") { $this->ipsclass->input['MID'] = $this->send_to_member['id']; $this->error = $cc_error; return; } } } } } return $cc_array; } /*-------------------------------------------------------------------------*/ // SAVE stuff /*-------------------------------------------------------------------------*/ function _process_save_only() { if ( $this->save_only ) { $raw = array( 'msg_date' => time(), 'msg_post' => $this->ipsclass->remove_tags($this->msg_post), 'msg_cc_users' => $this->cc_users, 'msg_sent_to_count' => 1, 'msg_post_key' => $this->class->post_key, 'msg_author_id' => $this->from_member['id'] ); $saved = 0; if ( $this->orig_id ) { //----------------------------------------- // We have an OID which means that this message // is already from the unsent folder, lets check that // and if true, update rather than create a new unsent // row //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 'mt_id, mt_msg_id', 'from' => 'message_topics', 'where' => "mt_id=".$this->orig_id." AND mt_owner_id=".$this->from_member['id']." AND mt_vid_folder='unsent'" ) ); $this->ipsclass->DB->simple_exec(); if ( $omsg = $this->ipsclass->DB->fetch_row() ) { $saved = 1; $this->ipsclass->DB->do_update( 'message_text', $raw, "msg_id=".$omsg['mt_msg_id'] ); //----------------------------------------- // Make attachments permanent //----------------------------------------- $no_attachments = $this->postlib->pf_make_attachments_permanent( $this->class->post_key, "", "", $omsg['mt_msg_id'] ); $this->ipsclass->DB->simple_construct( array( 'update' => 'message_topics', 'set' => "mt_hasattach=$no_attachments, mt_date=".time(), 'where' => 'mt_owner_id='.$this->ipsclass->member['id'].' AND mt_id='.$omsg['mt_id'] ) ); $this->ipsclass->DB->simple_exec(); } } if ($saved == 0) { $this->ipsclass->DB->do_insert( 'message_text', $raw); $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 ); $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' => 'unsent', 'mt_hide_cc' => intval($this->ipsclass->input['mt_hide_cc']), 'mt_tracking' => intval($this->ipsclass->input['add_tracking']), 'mt_addtosent' => $this->ipsclass->input['add_sent'] == 'yes' ? 1 : 0, 'mt_hasattach' => intval($no_attachments), 'mt_owner_id' => $this->from_member['id'], ) ); } $this->redirect_url = "&act=Msg&CODE=01"; $this->redirect_lang = $this->ipsclass->lang['pms_redirect']; } } /*-------------------------------------------------------------------------*/ // Return count of current VDIR (quickly) /*-------------------------------------------------------------------------*/ function _get_dir_count( $vdir, $vid ) { preg_match( "#(?:^|\|)$vid:.+?;(\d+)(?:\||$)#i", $vdir, $match ); return intval($match[1]); } /*-------------------------------------------------------------------------*/ // Get real allowance based on multi-groups /*-------------------------------------------------------------------------*/ function _get_real_allowance( $member ) { $groups_id = explode( ',', $member['mgroup_others'] ); if ( count( $groups_id ) ) { foreach( $groups_id as $pid ) { if ( ! $this->ipsclass->cache['group_cache'][ $pid ]['g_id'] ) { continue; } if ( $this->ipsclass->cache['group_cache'][ $pid ]['g_max_messages'] > $member['g_max_messages'] ) { $member['g_max_messages'] = $this->ipsclass->cache['group_cache'][ $pid ]['g_max_messages']; } } } return $member; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?