📄 newmsg.php
字号:
<?php
require( "./inc/inc.php" );
echo $nocache;
if ( $tipo == "send" )
{
require( "./inc/class.smtp.php" );
$ARTo = $UM->get_names( stripslashes( $to ) );
$ARCc = $UM->get_names( stripslashes( $cc ) );
$ARBcc = $UM->get_names( stripslashes( $bcc ) );
if ( 0 < count( $ARTo ) + count( $ARCc ) + count( $ARBcc ) )
{
$mail = new phpmailer( );
if ( $use_password_for_smtp )
{
$mail->useauthlogin( $sess['user'], $sess['pass'] );
}
if ( $is_html == "true" )
{
$mail->ishtml( 1 );
if ( $footer != "" )
{
$footer = ereg_replace( "\n", "", $footer );
$footer = ereg_replace( "\r", "<br>\r\n", $footer );
$body .= $footer;
}
}
else if ( $footer != "" )
{
$body .= $footer;
}
$mail->CharSet = $default_char_set;
$mail->IPAddress = getenv( "REMOTE_ADDR" );
$mail->timezone = $server_time_zone;
$mail->From = $sess['email'];
$mail->FromName = $UM->mime_encode_headers( $prefs['real-name'] );
$mail->addreplyto( $prefs['reply-to'], $UM->mime_encode_headers( $prefs['real-name'] ) );
$mail->Host = $smtp_server;
$mail->WordWrap = 76;
$mail->Priority = $priority;
if ( count( $ARTo ) != 0 )
{
$i = 0;
for ( ; $i < count( $ARTo ); ++$i )
{
$name = $ARTo[$i]['name'];
$email = $ARTo[$i]['mail'];
if ( $name != $email )
{
$mail->addaddress( $email, $UM->mime_encode_headers( $name ) );
}
else
{
$mail->addaddress( $email );
}
}
}
if ( count( $ARCc ) != 0 )
{
$i = 0;
for ( ; $i < count( $ARCc ); ++$i )
{
$name = $ARCc[$i]['name'];
$email = $ARCc[$i]['mail'];
if ( $name != $email )
{
$mail->addcc( $email, $UM->mime_encode_headers( $name ) );
}
else
{
$mail->addcc( $email );
}
}
}
if ( count( $ARBcc ) != 0 )
{
$i = 0;
for ( ; $i < count( $ARBcc ); ++$i )
{
$name = $ARBcc[$i]['name'];
$email = $ARBcc[$i]['mail'];
if ( $name != $email )
{
$mail->addbcc( $email, $UM->mime_encode_headers( $name ) );
}
else
{
$mail->addbcc( $email );
}
}
}
if ( is_array( $attachs = $sess['attachments'] ) )
{
$i = 0;
for ( ; $i < count( $attachs ); ++$i )
{
if ( file_exists( $attachs[$i]['localname'] ) )
{
$mail->addattachment( $attachs[$i]['localname'], $attachs[$i]['name'], $attachs[$i]['type'] );
}
}
}
$mail->Subject = $UM->mime_encode_headers( stripslashes( $subject ) );
$mail->Body = stripslashes( $body );
if ( ( $resultmail = $mail->send( ) ) === false )
{
$err = $mail->ErrorAlerts[count( $mail->ErrorAlerts ) - 1];
$smarty->assign( "umMailSent", false );
$smarty->assign( "umErrorMessage", $err );
}
else
{
$smarty->assign( "umMailSent", true );
if ( is_array( $attachs = $sess['attachments'] ) )
{
$i = 0;
for ( ; $i < count( $attachs ); ++$i )
{
if ( file_exists( $attachs[$i]['localname'] ) )
{
@unlink( $attachs[$i]['localname'] );
}
}
unset( $sess->'attachments' );
reset( $sess );
$SS->save( $sess );
}
if ( $prefs['save-to-sent'] )
{
if ( !$UM->mail_connect( ) )
{
header( "Location: error.php?err=1&sid={$sid}&tid={$tid}&lid={$lid}\r\n" );
exit( );
}
else if ( !$UM->mail_auth( false ) )
{
header( "Location: badlogin.php?sid={$sid}&tid={$tid}&lid={$lid}\r\n" );
exit( );
}
else
{
$UM->mail_save_message( "sent", $resultmail, "\\SEEN" );
unset( $this->headers->base64_encode( "sent" ) );
$UM->mail_disconnect( );
$SS->save( $sess );
}
}
}
}
else
{
exit( "<script language=\"javascript\">location = 'error.php?err=3&sid={$sid}&tid={$tid}&lid={$lid}';</script>" );
}
$jssource = "\r\n\t<script language=\"javascript\">\r\n\tfunction newmsg() { location = 'newmsg.php?pag={$pag}&folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction folderlist() { location = 'folders.php?folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}'}\r\n\tfunction refreshlist() { location = 'msglist.php?refr=true&folder=".urlencode( $folder )."&pag={$pag}&sid={$sid}&tid={$tid}&lid={$lid}' }\r\n\tfunction goend() { location = 'logout.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction goinbox() { location = 'msglist.php?folder=inbox&sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction emptytrash() {\tlocation = 'folders.php?empty=trash&folder=".urlencode( $folder )."&goback=true&sid={$sid}&tid={$tid}&lid={$lid}';}\r\n\tfunction search() {\tlocation = 'search.php?folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}';}\r\n\tfunction addresses() { location = 'addressbook.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction prefs() { location = 'preferences.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\t</script>\r\n\t";
$smarty->assign( "umSid", $sid );
$smarty->assign( "umLid", $lid );
$smarty->assign( "umTid", $tid );
$smarty->assign( "umJS", $jssource );
$smarty->display( "neotech.net/newmsg-result.htm" );
}
else
{
$priority_level = !$priority ? 3 : $priority;
$uagent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
$isMac = ereg( "Mac", $uagent );
$isOpera = ereg( "Opera", $uagent );
$uagent = explode( "; ", $uagent );
$uagent = explode( " ", $uagent[1] );
$bname = strtoupper( $uagent[0] );
$bvers = $uagent[1];
$show_advanced = $bname == "MSIE" && 5 <= intval( $bvers ) && !$textmode && !$isMac && !$isOpera && $prefs['editor-mode'] != "text" ? 1 : 0;
$js_advanced = $show_advanced ? "true" : "false";
$signature = $prefs['signature'];
if ( $show_advanced )
{
$signature = nl2br( $signature );
}
$add_sig = $prefs['add-sig'];
$umAddSig = $add_sig ? 1 : 0;
$forms = "<input type=hidden name=tipo value=edit>\r\n\t<input type=hidden name=is_html value=\"{$js_advanced}\">\r\n\t<input type=hidden name=sid value=\"{$sid}\">\r\n\t<input type=hidden name=lid value=\"{$lid}\">\r\n\t<input type=hidden name=folder value=\"{$folder}\">\r\n\t<input type=hidden name=sig value=\"".htmlspecialchars( $signature )."\">\r\n\t<input type=hidden name=textmode value=\"{$textmode}\">\r\n\t";
$jssource = "\r\n\t<script language=\"javascript\">\r\n\tbIs_html = {$js_advanced};\r\n\tbsig_added = false;\r\n\tfunction addsig() {\r\n\t\twith(document.composeForm) {\r\n\t\t\tif(bsig_added || sig.value == '') return false;\r\n\t\t\tif(cksig.checked) {\r\n\t\t\t\tif(bIs_html) {\r\n\t\t\t\t\tcur = GetHtml()\r\n\t\t\t\t\tSetHtml(cur+'<br><br>--<br>'+sig.value);\r\n\t\t\t\t} else\r\n\t\t\t\t\tbody.value += '\\r\\n\\r\\n--\\r\\n'+sig.value;\r\n\t\t\t}\r\n\t\t\tcksig.disabled = true;\r\n\t\t\tbsig_added = true;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\tfunction upwin(rem) { \r\n\t\tmywin = 'upload.php';\r\n\t\tif (rem != null) mywin += '?rem='+rem+'&sid={$sid}';\r\n\t\telse mywin += '?sid={$sid}&tid={$tid}&lid={$lid}';\r\n\t\twindow.open(mywin,'Upload','width=300,height=50,left=200,top=200,scrollbars=0,menubar=0,status=0'); \r\n\t}\r\n\r\n\tfunction doupload() {\r\n\t\tif(bIs_html) document.composeForm.body.value = GetHtml();\r\n\t\tdocument.composeForm.tipo.value = 'edit';\r\n\t\tdocument.composeForm.submit();\r\n\t}\r\n\tfunction textmode() {\r\n\t\twith(document.composeForm) {\r\n\t\t\tif(bIs_html) body.value = GetText();\r\n\t\t\ttextmode.value = 1;\r\n\t\t\ttipo.value = 'edit';\r\n\t\t\tsubmit();\r\n\t\t}\r\n\t}\r\n\r\n\tfunction enviar() {\r\n\t\terror_msg = new Array();\r\n\t\tfrm = document.composeForm;\r\n\t\tcheck_mail(frm.to.value);\r\n\t\tcheck_mail(frm.cc.value);\r\n\t\tcheck_mail(frm.bcc.value);\r\n\t\terrors = error_msg.length;\r\n\r\n\t\tif(frm.to.value == '' && frm.cc.value == '' && frm.bcc.value == '')\r\n\t\t\talert('".ereg_replace( "'", "\\'", $error_no_recipients )."');\r\n\r\n\t\telse if (errors > 0) {\r\n\r\n\t\t\tif (errors == 1) errmsg = '".ereg_replace( "'", "\\'", $error_compose_invalid_mail1_s )."\\r\\r';\r\n\t\t\telse errmsg = '".ereg_replace( "'", "\\'", $error_compose_invalid_mail1_p )."\\r\\r';\r\n\r\n\t\t\tfor(i=0;i<errors;i++)\r\n\t\t\t\terrmsg += error_msg[i]+'\\r';\r\n\r\n\t\t\tif (errors == 1) errmsg += '\\r".ereg_replace( "'", "\\'", $error_compose_invalid_mail2_s )."s';\r\n\t\t\telse errmsg += '\\r".ereg_replace( "'", "\\'", $error_compose_invalid_mail2_p )."';\r\n\r\n\t\t\talert(errmsg)\r\n\t\r\n\t\t} else {\r\n\t\t\tif(bIs_html) frm.body.value = GetHtml();\r\n\t\t\tfrm.tipo.value = 'send';\r\n\t\t\tfrm.submit();\r\n\t\t}\r\n\t}\r\n\t\r\n\tfunction newmsg() { location = 'newmsg.php?pag={$pag}&folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction folderlist() { location = 'folders.php?folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}'}\r\n\tfunction goend() { location = 'logout.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction goinbox() { location = 'msglist.php?folder=inbox&sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction emptytrash() {\tlocation = 'folders.php?empty=trash&folder=".urlencode( $folder )."&goback=true&sid={$sid}&tid={$tid}&lid={$lid}';}\r\n\tfunction search() {\tlocation = 'search.php?folder=".urlencode( $folder )."&sid={$sid}&tid={$tid}&lid={$lid}';}\r\n\tfunction addrpopup() {\tmywin = window.open('quick_address.php?sid={$sid}&tid={$tid}&lid={$lid}','AddressBook','width=480,height=220,top=200,left=200'); }\r\n\tfunction addresses() { location = 'addressbook.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction prefs() { location = 'preferences.php?sid={$sid}&tid={$tid}&lid={$lid}'; }\r\n\tfunction AddAddress(strType,strAddress) {\r\n\t\tobj = eval('document.composeForm.'+strType);\r\n\t\tif(obj.value == '') obj.value = strAddress\r\n\t\telse obj.value = obj.value + ', ' + strAddress\r\n\t}\r\n\t\r\n\tfunction check_mail(strmail) {\r\n\t\tif(strmail == '') return;\r\n\t\tchartosplit = ',;';\r\n\t\tprotectchar = '\"';\r\n\t\ttemp = '';\r\n\t\tarmail = new Array();\r\n\t\tinthechar = false; \r\n\t\tlt = '<';\r\n\t\tgt = '>'; \r\n\t\tisclosed = true;\r\n\t\r\n\t\tfor(i=0;i<strmail.length;i++) {\r\n\t\t\tthischar = strmail.charAt(i);\r\n\t\t\tif(thischar == lt && isclosed) isclosed = false;\r\n\t\t\tif(thischar == gt && !isclosed) isclosed = true;\r\n\t\t\tif(thischar == protectchar) inthechar = (inthechar)?0:1;\r\n\t\t\tif(chartosplit.indexOf(thischar) != -1 && !inthechar && isclosed) {\r\n\t\t\t\tarmail[armail.length] = temp; temp = '';\r\n\t\t\t} else temp += thischar;\r\n\t\t}\r\n\t\r\n\t\tarmail[armail.length] = temp; \r\n\t\r\n\t\tfor(i=0;i<armail.length;i++) {\r\n\t\t\tthismail = armail[i]; strPat = /(.*)<(.*)>/;\r\n\t\t\tmatchArray = thismail.match(strPat); \r\n\t\t\tif (matchArray != null) strEmail = matchArray[2];\r\n\t\t\telse {\r\n\t\t\t\tstrPat = /([-a-zA-Z0-9_\$+.]+@[-a-zA-Z0-9_.]+[-a-zA-Z0-9_]+)((.*))/; matchArray = thismail.match(strPat); \r\n\t\t\t\tif (matchArray != null) strEmail = matchArray[1];\r\n\t\t\t\telse strEmail = thismail;\r\n\t\t\t}\r\n\t\t\tif(strEmail.charAt(0) == '\"' && strEmail.charAt(strEmail.length-1) == '\"') strEmail = strEmail.substring(1,strEmail.length-1)\r\n\t\t\tif(strEmail.charAt(0) == '<' && strEmail.charAt(strEmail.length-1) == '>') strEmail = strEmail.substring(1,strEmail.length-1)\r\n\t\r\n\t\t\tstrPat = /([-a-zA-Z0-9_\$+.]+@[-a-zA-Z0-9_.]+[-a-zA-Z0-9_]+)((.*))/;\r\n\t\t\tmatchArray = strEmail.match(strPat); \r\n\t\t\tif(matchArray == null)\r\n\t\t\t\terror_msg[error_msg.length] = strEmail;\r\n\t\t}\r\n\t}\r\n\t\r\n\t\r\n\t</script>\r\n\t";
$smarty->assign( "umPriority", $priority_level );
$smarty->assign( "umAddSignature", $umAddSig );
$smarty->assign( "umForms", $forms );
$smarty->assign( "umJS", $jssource );
$body = stripslashes( $body );
if ( isset( $rtype ) )
{
$mail_info = $sess['headers'][base64_encode( strtolower( $folder ) )][$ix];
if ( !eregi( "\\ANSWERED", $mail_info['flags'] ) )
{
if ( !$UM->mail_connect( ) )
{
exit( "<script>location = 'error.php?err=1&sid={$sid}&tid={$tid}&lid={$lid}'</script>" );
}
else
{
if ( !$UM->mail_auth( ) )
{
exit( "<script>location = 'badlogin.php?sid={$sid}&tid={$tid}&lid={$lid}'</script>" );
}
else
{
if ( $UM->mail_set_flag( $mail_info, "\\ANSWERED", "+" ) )
{
$sess['headers'][base64_encode( strtolower( $folder ) )][$ix] = $mail_info;
$SS->save( $sess );
}
$UM->mail_disconnect( );
}
}
}
$filename = $mail_info['localname'];
if ( !file_exists( $filename ) )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -