📄 messenger.php
字号:
$ibforums->input['MODE'] ? $this->send_msg( ) : $this->send_form( );
}
function send_form( $preview = 0, $errors = "" )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
$errors = preg_replace( "/^<br>/", "", $errors );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_post", $ibforums->lang_id );
$this->post_html = $std->load_template( "skin_post" );
if ( $preview == 1 )
{
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( );
$old_msg = $this->parser->convert( array(
TEXT => $std->remove_tags( $ibforums->input['Post'] ),
1,
CODE => $ibforums->vars['msg_allow_code'],
HTML => $ibforums->vars['msg_allow_html']
) );
$this->output .= $this->html->preview( $old_msg );
}
if ( $errors != "" )
{
$this->output .= $this->html->pm_errors( $errors );
$preview = 1;
}
$contacts = $this->build_contact_list( );
$name_to_enter = "";
$old_message = "";
$old_title = "";
if ( !empty( $ibforums->input['MID'] ) )
{
$DB->query( "SELECT name, id FROM ibf_members WHERE id='".$ibforums->input['MID']."'" );
$name = $DB->fetch_row( );
if ( $ibforums->input['fwd'] != 1 && $name['id'] )
{
$name_to_enter = $name['name'];
}
}
if ( $preview == 1 )
{
$old_message = htmlspecialchars( stripslashes( $HTTP_POST_VARS['Post'] ) );
$old_title = preg_replace( "/'/", "'", stripslashes( $HTTP_POST_VARS['msg_title'] ) );
}
else if ( !empty( $ibforums->input['MSID'] ) )
{
$DB->query( "SELECT message, title from ibf_messages WHERE msg_id='".$ibforums->input['MSID']."' and member_id='".$this->member['id']."'" );
$old_msg = $DB->fetch_row( );
if ( $old_msg['title'] )
{
if ( $ibforums->input['fwd'] == 1 )
{
$old_title = "Fwd:".$old_msg['title'];
$old_title = preg_replace( "/^(?:Fwd\\:){1,}/i", "Fwd:", $old_title );
$old_message = "[QUOTE]".sprintf( $ibforums->lang['vm_forward_text'], $name['name'] )."\n\n".$old_msg['message']."[/QUOTE]"."\n";
$old_message = str_replace( "<br>", "\n", $old_message );
}
else
{
$old_title = "Re:".$old_msg['title'];
$old_title = preg_replace( "/^(?:Re\\:){1,}/i", "Re:", $old_title );
$old_message = "[QUOTE]".$old_msg['message']."[/QUOTE]"."\n";
$old_message = str_replace( "<br>", "\n", $old_message );
}
}
}
$this->output .= $this->html->send_form( array(
"CONTACTS" => $contacts,
"MEMBER" => $this->member,
"N_ENTER" => $name_to_enter,
"O_TITLE" => $old_title,
"OID" => $ibforums->input['OID']
) );
$ibforums->lang['the_max_length'] = $ibforums->vars['max_post_length'] * 1024;
$this->output .= $this->post_html->pm_postbox_buttons( $old_message );
$this->output .= $this->html->send_form_footer( );
$this->html_add_smilie_box( );
$this->page_title = $ibforums->lang['t_welcome'];
$this->nav = array(
"<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>"
);
if ( 0 < $ibforums->member['g_max_mass_pm'] )
{
$ibforums->lang['carbon_copy_desc'] = sprintf( $ibforums->lang['carbon_copy_desc'], $ibforums->member['g_max_mass_pm'] );
if ( isset( $HTTP_POST_VARS['carbon_copy'] ) )
{
$cc_box = preg_replace( "#</textarea>#i", "", stripslashes( $HTTP_POST_VARS['carbon_copy'] ) );
}
$this->output = str_replace( "<!--IBF.MASS_PM_BOX-->", $this->html->mass_pm_box( $cc_box ), $this->output );
}
}
function edit_saved( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$errors = preg_replace( "/^<br>/", "", $errors );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_post", $ibforums->lang_id );
$this->post_html = $std->load_template( "skin_post" );
$contacts = $this->build_contact_list( );
$DB->query( "SELECT mg.*, m.name as to_name, m.id as to_id from ibf_messages mg, ibf_members m WHERE msg_id='".$ibforums->input['MSID']."' and member_id='".$this->member['id']."' AND m.id=mg.recipient_id" );
$msg = $DB->fetch_row( );
if ( !$msg['msg_id'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_such_msg" ) );
}
$this->output .= $this->html->send_form( array(
"CONTACTS" => $contacts,
"MEMBER" => $this->member,
"N_ENTER" => $msg['to_name'],
"O_TITLE" => $msg['title'],
"OID" => $msg['msg_id']
) );
$ibforums->lang['the_max_length'] = $ibforums->vars['max_post_length'] * 1024;
$this->output .= $this->post_html->postbox_buttons( str_replace( "<br>", "\n", $msg['message'] ) );
$this->output .= $this->html->send_form_footer( );
$this->html_add_smilie_box( );
$this->page_title = $ibforums->lang['t_welcome'];
$this->nav = array(
"<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>"
);
if ( 0 < $ibforums->member['g_max_mass_pm'] )
{
$ibforums->lang['carbon_copy_desc'] = sprintf( $ibforums->lang['carbon_copy_desc'], $ibforums->member['g_max_mass_pm'] );
if ( isset( $msg['cc_users'] ) )
{
$cc_box = preg_replace( "#</textarea>#i", "", $msg['cc_users'] );
$cc_box = str_replace( "<br>", "\n", $cc_box );
}
$this->output = str_replace( "<!--IBF.MASS_PM_BOX-->", $this->html->mass_pm_box( $cc_box ), $this->output );
}
}
function send_msg( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_error", $ibforums->lang_id );
$ibforums->input['from_contact'] = $ibforums->input['from_contact'] ? $ibforums->input['from_contact'] : "-";
if ( strlen( $ibforums->input['msg_title'] ) < 2 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_msg_title" ) );
}
if ( strlen( $ibforums->input['Post'] ) < 2 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_msg" ) );
}
if ( $ibforums->input['from_contact'] == "-" && $ibforums->input['entered_name'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_chosen_member" ) );
}
require( "./sources/lib/emailer.php" );
$this->email = new emailer( );
$to_member = array( );
if ( $ibforums->input['from_contact'] == "-" )
{
$query = "LOWER(name)='".$ibforums->input['entered_name']."'";
}
else
{
$query = "id='".$ibforums->input['from_contact']."'";
}
$DB->query( "SELECT name, id, view_pop, mgroup, email_pm, language, email FROM ibf_members WHERE ".$query );
$to_member = $DB->fetch_row( );
if ( empty( $to_member['id'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_to_member" ) );
}
if ( $ibforums->input['save'] != "" )
{
$raw = array(
"member_id" => $this->member['id'],
"msg_date" => time( ),
"read_state" => 0,
"title" => $ibforums->input['msg_title'],
"message" => $ibforums->input['Post'],
"from_id" => $this->member['id'],
"vid" => "unsent",
"recipient_id" => $to_member['id'],
"cc_users" => $ibforums->input['carbon_copy']
);
$saved = 0;
if ( $ibforums->input['OID'] )
{
$DB->query( "SELECT msg_id from ibf_messages WHERE msg_id='".$ibforums->input['OID']."' AND member_id='".$ibforums->member['id']."' AND vid='unsent'" );
if ( $DB->get_num_rows( ) )
{
$saved = 1;
$db_string = $DB->compile_db_update_string( $raw );
$DB->query( "UPDATE ibf_messages SET {$db_string} WHERE msg_id='".$ibforums->input['OID']."'" );
}
}
if ( $saved == 0 )
{
$db_string = $DB->compile_db_insert_string( $raw );
$DB->query( "INSERT INTO ibf_messages (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")" );
}
$print->redirect_screen( $ibforums->lang['pms_redirect'], "&act=Msg&CODE=01" );
}
$DB->query( "SELECT m.msg_total, g.g_use_pm, g.g_max_messages FROM ibf_groups g, ibf_members m WHERE m.id='".$to_member['id']."' AND g.g_id=m.mgroup" );
$to_msg_stats = $DB->fetch_row( );
if ( $to_msg_stats['g_use_pm'] != 1 )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $ibforums->lang['no_usepm_member'] );
}
else
{
if ( $to_msg_stats['g_max_messages'] <= $to_msg_stats['msg_total'] && 0 < $to_msg_stats['g_max_messages'] )
{
$std->error( array( "LEVEL" => 1, "MSG" => "max_message_to" ) );
}
$DB->query( "SELECT contact_id, allow_msg FROM ibf_contacts WHERE contact_id='".$this->member['id']."' AND member_id='".$to_member['id']."'" );
$can_msg = $DB->fetch_row( );
if ( isset( $can_msg['contact_id'] ) && $can_msg['allow_msg'] != 1 )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $ibforums->lang['msg_blocked'] );
}
else
{
if ( $ibforums->input['add_sent'] && 0 < $ibforums->member['g_max_messages'] && $ibforums->member['g_max_messages'] <= $this->msg_stats['msg_total'] + 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "max_message_from" ) );
}
$can_mass_pm = 0;
$cc_array = array( );
if ( 0 < $ibforums->member['g_max_mass_pm'] )
{
$can_mass_pm = 1;
if ( isset( $ibforums->input['carbon_copy'] ) && $ibforums->input['carbon_copy'] != "" )
{
$ibforums->input['carbon_copy'] = str_replace( "<br><br>", "<br>", trim( $ibforums->input['carbon_copy'] ) );
$ibforums->input['carbon_copy'] = preg_replace( "/^(<br>){1}/", "", $ibforums->input['carbon_copy'] );
$ibforums->input['carbon_copy'] = preg_replace( "/(<br>){1}\$/", "", $ibforums->input['carbon_copy'] );
$ibforums->input['carbon_copy'] = preg_replace( "/<br>\\s+/", ",", $ibforums->input['carbon_copy'] );
$temp_array = explode( "<br>", $ibforums->input['carbon_copy'] );
if ( is_array( $temp_array ) && 0 < count( $temp_array ) )
{
$new_array = array( );
foreach ( $temp_array as $name )
{
$name = "'".trim( strtolower( $name ) )."'";
if ( in_array( $name, $new_array ) )
{
}
else
{
$new_array[] = $name;
}
}
}
if ( is_array( $new_array ) && 0 < count( $new_array ) )
{
$array_count = count( $new_array );
$DB->query( "SELECT m.id, m.name, m.msg_total, m.view_pop, m.email_pm, m.language, m.email, g.g_max_messages, g.g_use_pm FROM ibf_members m, ibf_groups g WHERE LOWER(m.name) IN (".implode( ",", $new_array ).") "."AND m.mgroup=g.g_id" );
if ( !$DB->get_num_rows( ) )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $ibforums->lang['pme_no_cc_user'] );
return;
}
else
{
while ( $r = $DB->fetch_row( ) )
{
$cc_array[$r['id']] = $r;
}
if ( $ibforums->member['g_max_mass_pm'] < count( $cc_array ) )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $ibforums->lang['pme_too_many'] );
}
else
{
$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( $ibforums->lang['pme_failed_nomem'], $n, $n );
}
}
}
if ( $cc_error != "" )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $cc_error );
}
else
{
$cc_error = "";
$cc_id_array = array( );
foreach ( $cc_array as $idx => $cc_user )
{
if ( $cc_user['g_use_pm'] != 1 )
{
$cc_error .= "<br>".sprintf( $ibforums->lang['pme_failed_nopm'], $cc_user['name'], $cc_user['name'] );
}
if ( 0 < $cc_user['g_max_messages'] && $cc_user['g_max_messages'] < $cc_user['msg_total'] + 1 )
{
$cc_error .= "<br>".sprintf( $ibforums->lang['pme_failed_maxed'], $cc_user['name'], $cc_user['name'] );
}
$cc_id_array[] = $cc_user['id'];
}
if ( $cc_error != "" )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $cc_error );
}
else
{
$DB->query( "SELECT m.name, c.allow_msg FROM ibf_members m, ibf_contacts c WHERE contact_id='".$ibforums->member['id']."' AND member_id IN (".implode( ",", $cc_id_array ).") AND m.id=c.member_id" );
while ( $c = $DB->fetch_row( ) )
{
if ( $c['allow_msg'] != 1 )
{
$cc_error .= "<br>".sprintf( $ibforums->lang['pme_failed_block'], $c['name'], $c['name'] );
}
}
if ( $cc_error != "" )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 0, $cc_error );
return;
}
}
}
}
}
}
}
}
if ( $ibforums->input['preview'] != "" )
{
$ibforums->input['MID'] = $to_member['id'];
$this->send_form( 1 );
}
else
{
$cc_array[$to_member['id']] = $to_member;
unset( $to_member );
$ibforums->input['add_tracking'] = $ibforums->input['add_tracking'] == 1 ? 1 : 0;
foreach ( $cc_array as $user_id => $to_member )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -