📄 messenger.php
字号:
<?php
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 $parser = "";
var $cp_html = "";
function messenger( )
{
global $ibforums;
global $DB;
global $std;
global $print;
if ( $ibforums->input['CODE'] == "" )
{
$ibforums->input['CODE'] = 0;
}
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_msg", $ibforums->lang_id );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_ucp", $ibforums->lang_id );
$this->html = $std->load_template( "skin_msg" );
$this->cp_html = $std->load_template( "skin_ucp" );
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_nosess = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
$this->member = $ibforums->member;
if ( empty( $this->member['g_use_pm'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_use_messenger" ) );
}
if ( empty( $this->member['id'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_guests" ) );
}
$DB->query( "SELECT vdirs, msg_total, new_msg, msg_msg_id FROM ibf_members WHERE id='".$this->member['id']."'" );
$this->msg_stats = $DB->fetch_row( );
$this->jump_html = "<select name='VID' class='forminput'>\n";
$this->msg_stats['dir_data'] = array( );
if ( $ibforums->input['VID'] )
{
$this->vid = $ibforums->input['VID'];
}
if ( empty( $this->msg_stats['vdirs'] ) )
{
$this->msg_stats['vdirs'] = "in:短信收件箱|sent:短信发件箱";
}
foreach ( explode( "|", $this->msg_stats['vdirs'] ) as $dir )
{
list( $id, $real ) = explode( ":", $dir );
if ( empty( $id ) )
{
}
else
{
$this->msg_stats['dir_data'][] = array(
"id" => $id,
"real" => $real
);
if ( $this->vid == $id )
{
$this->msg_stats['current_dir'] = $real;
$this->msg_stats['current_id'] = $id;
$this->jump_html .= "<option value='{$id}' selected>{$real}</option>\n";
}
else
{
$this->jump_html .= "<option value='{$id}'>{$real}</option>\n";
}
}
}
$this->jump_html .= "<!--EXTRA--></select>\n\n";
$print->add_output( $this->cp_html->menu_bar( $this->base_url ) );
switch ( $ibforums->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 "99" :
$this->pm_popup( );
break;
case "20" :
$this->view_saved( );
break;
case "21" :
$this->edit_saved( );
break;
case "30" :
$this->show_tracking( );
break;
case "31" :
$this->end_tracking( );
break;
case "32" :
$this->del_tracked( );
break;
default :
$this->msg_list( );
break;
}
$fj = $std->build_forum_jump( );
$fj = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $fj );
$this->output .= $this->cp_html->cp_end( );
$this->output .= $this->cp_html->forum_jump( $fj );
$print->add_output( "{$this->output}" );
$print->do_output( array(
"TITLE" => $this->page_title,
"JS" => 0,
NAV => $this->nav
) );
}
function pm_popup( )
{
global $DB;
global $std;
global $print;
global $ibforums;
$DB->query( "SELECT m.name, msg.title, msg.msg_date, msg.from_id FROM ibf_members m, ibf_messages msg WHERE msg.member_id='".$ibforums->member['id']."' AND msg_id='".$this->msg_stats['msg_msg_id']."' "."AND m.id=msg.from_id" );
$row = $DB->fetch_row( );
$row['msg_date'] = $std->get_date( $row['msg_date'], "LONG" );
$text = preg_replace( "/<#NAME#>/", $row['name'], $ibforums->lang['pmp_string'] );
$text = preg_replace( "/<#TITLE#>/", $row['title'], $text );
$text = preg_replace( "/<#DATE#>/", $row['msg_date'], $text );
$html = $this->html->pm_popup( $text, $this->msg_stats['msg_msg_id'] );
$print->pop_up_window( "PM", $html );
}
function archive( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$this->jump_html = preg_replace( "/<!--EXTRA-->/", "<option value='all'>".$ibforums->lang['all_folders']."</option>", $this->jump_html );
$this->output .= $this->html->archive_form( $this->jump_html );
$this->page_title = $ibforums->lang['t_welcome'];
$this->nav = array(
"<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>"
);
}
function do_archive( )
{
global $ibforums;
global $DB;
global $std;
global $print;
require( "./sources/lib/emailer.php" );
$this->email = new emailer( );
$folder_query = "";
$msg_ids = array( );
if ( $ibforums->input['VID'] != "all" )
{
$folder_query = " AND vid='".$ibforums->input['VID']."'";
}
if ( $ibforums->input['dateline'] == "all" )
{
$time_cut = 0;
}
else
{
$time_cut = time( ) - $ibforums->input['dateline'] * 60 * 60 * 24;
}
$ibforums->input['number'] = preg_replace( "/^(\\d+)\$/", "\\1", $ibforums->input['number'] );
if ( $ibforums->input['number'] < 5 )
{
$ibforums->input['number'] = 5;
}
if ( 50 < $ibforums->input['number'] )
{
$ibforums->input['number'] = 50;
}
$type = "html";
$file_name = "pm_archive.html";
$ctype = "text/html";
if ( $ibforums->input['type'] == "xls" )
{
$type = "xls";
$file_name = "xls_importable.txt";
$ctype = "text/plain";
}
$output = "";
if ( $type == "html" )
{
$output .= $this->html->archive_html_header( );
}
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( );
$archive_query = $DB->query( "SELECT mg.*, m.name, m.id from ibf_messages mg, ibf_members m WHERE mg.member_id=m.id AND mg.member_id='".$this->member['id']."' AND mg.msg_date > {$time_cut}".$folder_query." ORDER BY mg.msg_date LIMIT 0,".$ibforums->input['number'] );
if ( $DB->get_num_rows( $archive_query ) )
{
while ( $r = $DB->fetch_row( $archive_query ) )
{
$info = array( );
$msg_ids[] = $r['msg_id'];
$from_member = $DB->query( "SELECT id, name FROM ibf_members WHERE id='".$r['from_id']."'" );
$from_mem = $DB->fetch_row( $from_member );
$info['msg_date'] = $std->get_date( $r['msg_date'], "LONG" );
$info['msg_title'] = $r['title'];
$info['msg_sender'] = $from_mem['name'];
$info['msg_content'] = $this->parser->convert( array(
"TEXT" => $r['message'],
"SMILIES" => 0,
"CODE" => $ibforums->vars['msg_allow_code'],
"HTML" => $ibforums->vars['msg_allow_html']
) );
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
{
$output .= $this->html->archive_html_entry( $info );
}
}
if ( $type == "html" )
{
$output .= $this->html->archive_html_footer( );
}
$num_msg = count( $msg_ids );
if ( $ibforums->input['delete'] == "yes" )
{
$msg_str = implode( ",", $msg_ids );
if ( !empty( $msg_str ) )
{
$DB->query( "DELETE FROM ibf_messages WHERE msg_id IN ({$msg_str})" );
$DB->query( "UPDATE ibf_members SET msg_total=msg_total-{$num_msg} WHERE id ='".$this->member['id']."'" );
}
}
$this->email->get_template( "pm_archive" );
$this->email->build_message( array(
"NAME" => $this->member['name']
) );
$this->email->subject = $ibforums->lang['arc_email_subject'];
$this->email->to = $this->member['email'];
$this->email->add_attachment( $output, $file_name, $ctype );
$this->email->send_mail( );
$ibforums->lang['arc_complete'] = preg_replace( "/<#NUM#>/", "{$num_msg}", $ibforums->lang['arc_complete'] );
$this->output .= $this->html->archive_complete( );
$this->page_title = $ibforums->lang['t_welcome'];
$this->nav = array(
"<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>"
);
}
else
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_archive_messages" ) );
}
}
function strip_quotes( $text )
{
return preg_replace( "/\"/", "\\\\\"", $text );
}
function prefs( )
{
global $ibforums;
global $DB;
global $std;
global $print;
$this->output .= $this->html->prefs_header( );
$count = 0;
foreach ( $this->msg_stats['dir_data'] as $k => $v )
{
$extra = "";
if ( $v['id'] == "in" || $v['id'] == "sent" )
{
$extra = " ( ".$v['real']." - ".$ibforums->lang['cannot_remove']." )";
}
$this->output .= $this->html->prefs_row( array(
"ID" => $v['id'],
"REAL" => $v['real'],
"EXTRA" => $extra
) );
++$count;
}
$this->output .= $this->html->prefs_add_dirs( );
$i = $count;
for ( ; $i < $count + 3; ++$i )
{
$this->output .= $this->html->prefs_row( array(
"ID" => "dir_".$i,
"REAL" => "",
"EXTRA" => ""
) );
}
$this->output .= $this->html->prefs_footer( );
$this->page_title = $ibforums->lang['t_welcome'];
$this->nav = array(
"<a href='".$this->base_url."&act=UserCP&CODE=00'>".$ibforums->lang['t_title']."</a>"
);
}
function do_prefs( )
{
global $ibforums;
global $DB;
global $std;
global $print;
if ( $ibforums->input['sent'] == "" || $ibforums->input['in'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "cannot_remove_dir" ) );
}
$v_dir = "in:".$ibforums->input['in']."|sent:".$ibforums->input['sent'];
$ids = array( );
foreach ( $ibforums->input as $key => $value )
{
if ( !preg_match( "/^dir_(\\d+)\$/", $key, $match ) && !$ibforums->input[$match[0]] )
{
$v_dir .= "|".$match[0].":".trim( $ibforums->input[$match[0]] );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -