⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 output_file.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
字号:
<?php

session_start( );
include_once( "inc/conn.php" );
include_once( "inc/phpzip.inc.php" );
if ( $_REQUEST['isall'] == 1 )
{
	$sqlemail = "SELECT EMAIL_ID from EMAIL where BOX_ID={$BOX_ID} and TO_ID='{$LOGIN_USER_ID}'  and SEND_FLAG='1' and DELETE_FLAG!='1' order by SEND_TIME desc";
	$reemail = exequery( $connection, $sqlemail );
	$export_str = "";
	while ( $rowe = mysql_fetch_array( $reemail ) )
	{
		$export_str .= $rowe['EMAIL_ID'].",";
	}
}
if ( $_REQUEST['isall'] == 1 && $_REQUEST['outbox'] == 1 )
{
	$sqlemail = "SELECT * from EMAIL where FROM_ID='{$LOGIN_USER_ID}'  and SEND_FLAG='0' order by SEND_TIME desc";
	$reemail = exequery( $connection, $sqlemail );
	$export_str = "";
	while ( $rowe = mysql_fetch_array( $reemail ) )
	{
		$export_str .= $rowe['EMAIL_ID'].",";
	}
}
if ( $_REQUEST['isall'] == 1 && $_REQUEST['sendbox'] == 1 )
{
	$sqlemail = "SELECT * from EMAIL where FROM_ID='{$LOGIN_USER_ID}'  and SEND_FLAG='1' and DELETE_FLAG!='2' order by SEND_TIME desc";
	$reemail = exequery( $connection, $sqlemail );
	$export_str = "";
	while ( $rowe = mysql_fetch_array( $reemail ) )
	{
		$export_str .= $rowe['EMAIL_ID'].",";
	}
}
if ( $_REQUEST['isall'] == 1 && $_REQUEST['searchbox'] == 1 )
{
	if ( $FROM_ID != "" )
	{
		$query = "SELECT * from USER where USER_NAME like '%{$FROM_ID}%'";
		$cursor = exequery( $connection, $query );
		if ( $ROW = mysql_fetch_array( $cursor ) )
		{
			$FROM_ID1 = $ROW['USER_ID'];
		}
	}
	if ( $TO_ID != "" )
	{
		$query = "SELECT * from USER where USER_NAME like '%{$TO_ID}%'";
		$cursor = exequery( $connection, $query );
		if ( $ROW = mysql_fetch_array( $cursor ) )
		{
			$TO_ID1 = $ROW['USER_ID'];
		}
	}
	if ( $BOX_ID == 0 && $BOX == 1 )
	{
		$query = "SELECT * from EMAIL where TO_ID='{$LOGIN_USER_ID}'  and SEND_FLAG='1' and DELETE_FLAG!='1' and BOX_ID={$BOX_ID}";
		if ( $FROM_ID1 != "" )
		{
			$query .= " and (FROM_ID like '%{$FROM_ID}%' or FROM_ID like '%{$FROM_ID1}%')";
		}
		else if ( $FROM_ID != "" )
		{
			$query .= " and FROM_ID like '%{$FROM_ID}%'";
		}
	}
	else if ( $BOX_ID == 0 && $BOX == 2 )
	{
		$query = "SELECT * from EMAIL where FROM_ID='{$LOGIN_USER_ID}' and SEND_FLAG='0' and BOX_ID={$BOX_ID}";
		if ( $TO_ID1 != "" )
		{
			$query .= " and (TO_ID like '%{$TO_ID}%' or TO_ID like '%{$TO_ID1}%')";
		}
		else if ( $TO_ID != "" )
		{
			$query .= " and TO_ID like '%{$TO_ID}%'";
		}
	}
	else if ( $BOX_ID == 0 && $BOX == 3 )
	{
		$query = "SELECT * from EMAIL where FROM_ID='{$LOGIN_USER_ID}' and SEND_FLAG='1' and DELETE_FLAG!='2' and BOX_ID={$BOX_ID}";
		if ( $TO_ID1 != "" )
		{
			$query .= " and (TO_ID like '%{$TO_ID}%' or TO_ID like '%{$TO_ID1}%')";
		}
		else if ( $TO_ID != "" )
		{
			$query .= " and TO_ID like '%{$TO_ID}%'";
		}
	}
	else
	{
		$query = "SELECT * from EMAIL where TO_ID='{$LOGIN_USER_ID}' and BOX_ID={$BOX_ID}";
		if ( $FROM_ID1 != "" )
		{
			$query .= " and (FROM_ID like '%{$FROM_ID}%' or FROM_ID like '%{$FROM_ID1}%')";
		}
		else if ( $FROM_ID != "" )
		{
			$query .= " and FROM_ID like '%{$FROM_ID}%'";
		}
	}
	if ( $SUBJECT != "" )
	{
		$query .= " and SUBJECT like '%{$SUBJECT}%'";
	}
	if ( $KEY1 != "" )
	{
		$query .= " and CONTENT like '%{$KEY1}%'";
	}
	if ( $KEY2 != "" )
	{
		$query .= " and CONTENT like '%{$KEY2}%'";
	}
	if ( $KEY3 != "" )
	{
		$query .= " and CONTENT like '%{$KEY3}%'";
	}
	if ( $ATTACHMENT_NAME != "" )
	{
		$query .= " and ATTACHMENT_NAME like '%{$ATTACHMENT_NAME}%'";
	}
	$sqlemail = $query;
	$reemail = exequery( $connection, $sqlemail );
	$export_str = "";
	while ( $rowe = mysql_fetch_array( $reemail ) )
	{
		$export_str .= $rowe['EMAIL_ID'].",";
	}
}
$array_mailid = explode( ",", $export_str );
$k = 0;
for ( ;	$k < count( $array_mailid );	++$k	)
{
	$EMAIL_ID = $array_mailid[$k];
	if ( trim( $EMAIL_ID ) == "" )
	{
	}
	else
	{
		$query = "SELECT * from EMAIL where EMAIL_ID={$EMAIL_ID}";
		$cursor = exequery( $connection, $query );
		if ( $ROW = mysql_fetch_array( $cursor ) )
		{
			$FROM_ID = $ROW['FROM_ID'];
			$TO_ID = $ROW['TO_ID'];
			$TO_ID2 = $ROW['TO_ID2'];
			$COPY_TO_ID = $ROW['COPY_TO_ID'];
			$SUBJECT = $ROW['SUBJECT'];
			$SUBJECT = str_replace( "<", "&lt", $SUBJECT );
			$SUBJECT = str_replace( ">", "&gt", $SUBJECT );
			$SUBJECT = stripslashes( $SUBJECT );
			$CONTENT = $ROW['CONTENT'];
			$SEND_TIME = $ROW['SEND_TIME'];
			$ATTACHMENT_ID = $ROW['ATTACHMENT_ID'];
			$ATTACHMENT_NAME = $ROW['ATTACHMENT_NAME'];
			$query1 = "SELECT * from USER where USER_ID='{$FROM_ID}'";
			$cursor1 = exequery( $connection, $query1 );
			if ( $ROW = mysql_fetch_array( $cursor1 ) )
			{
				$FROM_NAME = $ROW['USER_NAME'];
			}
			$TO_NAME = "";
			$TOK = strtok( $TO_ID2, "," );
			while ( $TOK != "" )
			{
				$query1 = "SELECT * from USER where USER_ID='{$TOK}'";
				$cursor1 = exequery( $connection, $query1 );
				if ( $ROW = mysql_fetch_array( $cursor1 ) )
				{
					$TO_NAME .= $ROW['USER_NAME'].",";
				}
				$TOK = strtok( "," );
			}
			$COPY_TO_NAME = "";
			$TOK = strtok( $COPY_TO_ID, "," );
			while ( $TOK != "" )
			{
				$query1 = "SELECT * from USER where USER_ID='{$TOK}'";
				$cursor1 = exequery( $connection, $query1 );
				if ( $ROW = mysql_fetch_array( $cursor1 ) )
				{
					$COPY_TO_NAME .= $ROW['USER_NAME'].",";
				}
				$TOK = strtok( "," );
			}
			$CONTENT = str_replace( "  ", "&nbsp;&nbsp;", $CONTENT );
			$CONTENT = str_replace( "\n", "<br>", $CONTENT );
		}
		if ( substr( $TO_NAME, -1 ) == "," )
		{
			$TO_NAME = substr( $TO_NAME, 0, -1 );
		}
		if ( substr( $COPY_TO_NAME, -1 ) == "," )
		{
			$COPY_TO_NAME = substr( $COPY_TO_NAME, 0, -1 );
		}
		if ( substr( $TO_ID, -1 ) == "," )
		{
			$TO_ID = substr( $TO_ID, 0, -1 );
		}
		if ( substr( $COPY_TO_ID, -1 ) == "," )
		{
			$COPY_TO_ID = substr( $COPY_TO_ID, 0, -1 );
		}
		if ( $TO_ID != $LOGIN_USER_ID && $FROM_ID != $LOGIN_USER_ID )
		{
			message( "警告", "只能导出自己的邮件!" );
			exit( );
		}
		$SUBJECT1 = str_replace( ":", ":", $SUBJECT );
		$SUBJECT1 = str_replace( "\\", "", $SUBJECT1 );
		$SUBJECT1 = str_replace( "/", "", $SUBJECT1 );
		$SUBJECT1 = str_replace( "*", "", $SUBJECT1 );
		$SUBJECT1 = str_replace( "?", "", $SUBJECT1 );
		$SUBJECT1 = str_replace( "\"", "“", $SUBJECT1 );
		$SUBJECT1 = str_replace( "<", "[", $SUBJECT1 );
		$SUBJECT1 = str_replace( ">", "]", $SUBJECT1 );
		$SUBJECT1 = str_replace( "|", "", $SUBJECT1 );
		$ATTACHMENT_ID_ARRAY = explode( ",", $ATTACHMENT_ID );
		$ATTACHMENT_NAME_ARRAY = explode( "*", $ATTACHMENT_NAME );
		$ARRAY_COUNT = sizeof( $ATTACHMENT_ID_ARRAY );
		$I = 0;
		for ( ;	$I < $ARRAY_COUNT - 1;	++$I	)
		{
			$filename = $ATTACH_PATH.$ATTACHMENT_ID_ARRAY[$I]."/".$ATTACHMENT_NAME_ARRAY[$I];
			if ( !file_exists( $filename ) )
			{
			}
			else
			{
				$file_contents = "";
				$handle = fopen( $filename, "r" );
				while ( !feof( $handle ) )
				{
					$file_contents .= fread( $handle, 50000 );
				}
				fclose( $handle );
				$annex[$I]['annexname'] = $ATTACHMENT_NAME_ARRAY[$I];
				$annex[$I]['filename'] = $ATTACHMENT_NAME_ARRAY[$I];
				$annex[$I]['content'] = chunk_split( base64_encode( $file_contents ) );
			}
		}
		$eml['senddate'] = gmdate( "r", strtotime( $SEND_TIME ) );
		$eml['fromname'] = $FROM_NAME;
		$eml['fromemail'] = $FROM_NAME;
		$eml['toname'] = $TO_NAME;
		$eml['toemail'] = $TO_NAME;
		$eml['subject'] = $SUBJECT1;
		$mail_pic_url = ROOT_URL."attachment/editor/";
		$CONTENT = str_replace( "/attachment/editor/", $mail_pic_url, $CONTENT );
		$eml['content'] = chunk_split( base64_encode( $CONTENT ) );
		$tpl_mail = "Date: {senddate}\r\nFrom: {fromname} <{fromemail}> \r\nTo: {toname} <{toemail}> \r\nSubject: {subject} \r\nMime-Version: 1.0 \r\nContent-Type: multipart/mixed; \r\n boundary=\"=====weaver_com_cn_eoffice_=====\" \r\n\r\nThis is a multi-part message in MIME format. \r\n\r\n--=====weaver_com_cn_eoffice_===== \r\nContent-Type: text/html; \r\ncharset=\"GB2312\" \r\nContent-Transfer-Encoding: base64 \r\n\r\n{content} \r\n";
		$tpl_annex = "--=====weaver_com_cn_eoffice_===== \r\nContent-Type: application/octet-stream;\r\n\tname=\"{annexname}\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment;\r\n\tfilename=\"{filename}\"\r\n\r\n{content}";
		$tpl_end = "--=====weaver_com_cn_eoffice_=====";
		$eml_content = str_replace( "{senddate}", $eml['senddate'], $tpl_mail );
		$eml_content = str_replace( "{fromname}", $eml['fromname'], $eml_content );
		$eml_content = str_replace( "{fromemail}", $eml['fromemail'], $eml_content );
		$eml_content = str_replace( "{toname}", $eml['toname'], $eml_content );
		$eml_content = str_replace( "{toemail}", $eml['toemail'], $eml_content );
		$eml_content = str_replace( "{subject}", $eml['subject'], $eml_content );
		$eml_content = str_replace( "{content}", $eml['content'], $eml_content );
		$eml_annex = "";
		$j = 0;
		for ( ;	$j < $I;	++$j	)
		{
			$eml_p_annex = str_replace( "{annexname}", $annex[$j]['annexname'], $tpl_annex );
			$eml_p_annex = str_replace( "{filename}", $annex[$j]['filename'], $eml_p_annex );
			$eml_p_annex = str_replace( "{content}", $annex[$j]['content'], $eml_p_annex );
			$eml_annex .= $eml_p_annex;
		}
		$tmp_dir = get_cfg_var( "upload_tmp_dir" )."/";
		$tmp_f_name = $tmp_dir.$eml['subject'].".eml";
		if ( file_exists( $tmp_f_name ) )
		{
			++$file_name_mount[$eml['subject']]['count'];
			$tmp_f_name = $tmp_dir.$eml['subject']."(".$file_name_mount[$eml['subject']]['count'].").eml";
		}
		$fp = fopen( $tmp_f_name, "w" );
		fwrite( $fp, $eml_content.$eml_annex );
		fclose( $fp );
		$array_file[] = $tmp_f_name;
	}
}
$z = new phpzip( );
$zip_n_t = "eml_mail_".time( ).".zip";
$zip_f_name = $tmp_dir."eml_mail_".time( ).".zip";
$z->zip( $array_file, $zip_f_name );
$m = 0;
for ( ;	$m < count( $array_file );	++$m	)
{
	@unlink( $array_file[$m] );
}
header( "Content-Type: application/x-zi" );
header( "Content-Length: ".filesize( $zip_f_name ) );
header( "Content-disposition: attachment; filename=".$zip_n_t );
readfile( $zip_f_name );
@unlink( $zip_f_name );
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -