<?
session_start();
$selelag = $HTTP_SESSION_VARS["SelLanguage"];
if (empty($selelag)) header("location:../break.php");
require("../config/".$selelag);
require("../_ConnectString.php");       //--連接參數設定值
require("../_function.php");
require("../_image.php");
require("../_search/_mail_search.php");
require("../_search/_datamining.php");
require("../_read_source/_smtp.php");
require("../_read_source/_reject.php");
require("../_read_source/_attachment.php");
require_once("../cd_pos.php");

$_SearchPath = "../_search/mail_search_list.php";
$_DELETE_DIGITAL_PATH = "../remove/";
$Host_ip = $HTTP_SERVER_VARS["HTTP_HOST"];

if ((isset($HTTP_SESSION_VARS["LoginID_Sess"])) && (isset($HTTP_SESSION_VARS["OperateRole_Sess"])) && (isset($HTTP_SESSION_VARS["GroupNo_Sess"]))){
	
	$QUERY_IP					= $HTTP_POST_VARS["QUERY_IP"];     //--HOST IP
	$QUERY_IP_1					= $HTTP_POST_VARS["QUERY_IP_1"];
	//--From search screen
	$QUERY_START_DATETIME		= $HTTP_POST_VARS["QUERY_START_DATETIME"];
	$QUERY_END_DATETIME			= $HTTP_POST_VARS["QUERY_END_DATETIME"];
	$QUERY_SUBJECT				= $HTTP_POST_VARS["QUERY_SUBJECT"];  
	$QUERY_FROM					= $HTTP_POST_VARS["QUERY_FROM"];  
	$QUERY_TO					= $HTTP_POST_VARS["QUERY_TO"];  
	$QUERY_CC					= $HTTP_POST_VARS["QUERY_CC"];
	$QUERY_BCC					= $HTTP_POST_VARS["QUERY_BCC"];
	$QUERY_ID					= $HTTP_POST_VARS["QUERY_ID"];     //--資料庫流水號
	$QUERY_ACCOUNT				= $HTTP_POST_VARS["QUERY_ACCOUNT"];     //--資料庫流水號

	$sizepage					= $HTTP_POST_VARS["sizepage"];       //--每頁筆數
	$DELIGNORE					= $HTTP_POST_VARS["DELIGNORE"];		//--忽略並刪除
	$RunAs						= $HTTP_POST_VARS["RunAs"];			//--刪除 或 忽略
	$Checked					= $HTTP_POST_VARS["Checked"];
	$Send						= $HTTP_POST_VARS["Send"];           //--執行刪除
	$SortField					= $HTTP_POST_VARS["SortField"];      //--排序欄位
	$SortType					= $HTTP_POST_VARS["SortType"];       //--排序方式
	$strWhere					= $HTTP_POST_VARS["strWhere"];		//--search all
	$SMTP						= $HTTP_POST_VARS['SMTP'];			//--全文檢索 -auto 值
	$mime						= $HTTP_POST_VARS['mime'];			//--全文檢索 flag	
	$digital					= $HTTP_POST_VARS['digital'];	    //--數位資產 flag
    $to_page					= $HTTP_POST_VARS['to_page'];

	//相關變數初始化 
	if (!isset($to_page) || empty($to_page)){
		$to_page = 1;
	}//End : if (相關變數初始化)

	if (!isset($sizepage) || empty($sizepage)){
		$sizepage = $HTTP_SESSION_VARS["size_page"];
	}

	$ErrorMsg = "";
	$_Disabled = "";
	//$bgcolorCol = "bgcolor=\"#A0C6E5\"";

	//--畫面設定排序時使用
	if ($SortField == "") $SortField = $DB_SMTP_AUTO;
	include($_SORT_PATH);
	
	//判斷每頁秀的資料筆數
	if ($RunAs == 'UpdatePageSize'){
		if ($sizepage){ 
			$HTTP_SESSION_VARS["size_page"] = $sizepage;
		}//End : if()
	}//End : if(判斷每頁秀的資料筆數)

	//--忽略資料
	if ($RunAs == "Ignore"){
		if ($DELIGNORE == "Delete_Ignore") $_act = 1; else $_act=0;
		$flag = 0;
		for ($i=0; $i<count($chkbox); $i++){
			$strSQL = "Select * from ".$DB_SMTP." where ".$DB_SMTP_AUTO."='".$chkbox[$i]."'";
			$intSQL = mysql_query($strSQL);
			$rowSQL = mysql_fetch_array($intSQL);
			
			$strREJECT = "Select ".$DB_REJECT_ID." from ".$DB_REJECT." where ".$DB_REJECT_MAILFROM."='".$rowSQL[$DB_SMTP_FROM]."' and ".$DB_REJECT_MAILTO."='".$rowSQL[$DB_SMTP_TO]."' and ".$DB_REJECT_MAILCC."='".$rowSQL[$DB_SMTP_CC]."' and ".$DB_REJECT_SUBJECT."='".$rowSQL[$DB_SMTP_SUBJECT]."' and ".$DB_REJECT_SIZE."<='".$rowSQL[$DB_SMTP_SIZE]."'";
			$intREJECT = mysql_query($strREJECT);

			if (mysql_num_rows($intREJECT) > 0){
				$rowREJECT = mysql_fetch_array($intREJECT);
				$strUPD_INS = "Update ".$DB_REJECT." set ".$DB_REJECT_SIZE."='".$rowSQL[$DB_SMTP_SIZE]."' where ".$DB_REJECT_ID."='".$rowREJECT[0]."'";
			}
			else{
				$strUPD_INS = "Insert into ".$DB_REJECT." values ('','".$rowSQL[$DB_SMTP_FROM]."','".$rowSQL[$DB_SMTP_TO]."','".$rowSQL[$DB_SMTP_CC]."','".$rowSQL[$DB_SMTP_SUBJECT]."','".$rowSQL[$DB_SMTP_SIZE]."','".$_act."')";
			}

			//print $strUPD_INS;
			$intUPD_INS = mysql_query($strUPD_INS);
			mysql_free_result($intSQL);
			if(!$intUPD_INS) $flag = 1;
			
			if ($flag) {
				if ($DELIGNORE == "Delete_Ignore") $ErrorMsg = $SMTPM_IGNDELFAIL; else $ErrorMsg = $SMTPM_IGNOREFAIL;
			}else{
				if ($DELIGNORE == "Delete_Ignore") $RunAs = "Delete"; else $ErrorMsg = $SMTPM_IGNORESUCCESS;
			}
		}
	}

	//--刪除資料
	if($RunAs == "Delete"){
		$_FILE = "SMTP_".date("Y-m-d")."_".date("H:i:s");
		$TMP_FILE = "/tmp/".$_FILE;
		if ((fn_digital_asset()==1)||(fn_data_mining()==1)) $fp = fopen($TMP_FILE,"w+");
		if ($DELIGNORE == "") $flag = 0;
		for($i=0; $i<count($chkbox); $i++){
			$strSQL = "Select * from ".$DB_SMTP." where ".$DB_SMTP_AUTO."='".$chkbox[$i]."'";
			$intSQL = mysql_query($strSQL);
			$rowSQL = mysql_fetch_array($intSQL);
			$DelFilePath = $DATAS_PATH_SMTP.$rowSQL[$DB_SMTP_DBTAG]."/".$rowSQL[$DB_SMTP_BODY_NAME];

			if (file_exists($DelFilePath)){
				system("echo rm -f $DelFilePath >> /tmp/dc.cmd");
			}

			$strDEL = "Delete from ".$DB_SMTP." where ".$DB_SMTP_AUTO."='".$chkbox[$i]."'";
			$intDEL = mysql_query($strDEL);
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fputs($fp,"SMTP.".$chkbox[$i]."\n");
			if (!$intDEL) $flag = 1;

			//Delete the attachment 
			$strDEL = "Select * From ".$DB_ATTACHMENT." where ".$DB_ATTACHMENT_NEWIDX."='".$chkbox[$i]."' and ".$DB_ATTACHMENT_TYPE."='2'";
			$intSQL = mysql_query($strDEL);
			while($rowSQL = mysql_fetch_array($intSQL)){							 $DelAttPath=$DATAS_PATH_WEBMAILS.$rowSQL[$DB_ATTACHMENT_DBTAG]."/".$rowSQL[$DB_ATTACHMENT_DB_NAME];		
				if (file_exists($DelAttPath)){
					system("echo rm -f $DelAttPath >> /tmp/dc.cmd");
					//print $DelAttPath."<br>";
				}
			}

			$strDEL = "Delete from ".$DB_ATTACHMENT." where ".$DB_ATTACHMENT_NEWIDX."='".$chkbox[$i]."' and ".$DB_ATTACHMENT_TYPE."='2'";
			$intDEL = mysql_query($strDEL);
			//if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fputs($fp,"ATTACHMENT.".$chkbox[$i]."\n");
			if (!$intDEL) $flag = 1;
		}
		if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fclose($fp);

		if ($flag){
			if ($DELIGNORE == "Delete_Ignore"){
				$ErrorMsg = $SMTPM_IGNDELFAIL; 
			}else{
				$ErrorMsg = $SMTPM_DELFAIL;
			}
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)) unlink($TMP_FILE);
		}
		else{
			mysql_query("OPTIMIZE TABLE SMTP");
			mysql_query("OPTIMIZE TABLE ATTACHMENT");
			if ($DELIGNORE == "Delete_Ignore"){
				$ErrorMsg = $SMTPM_IGNDELSUCCESS;
			}else{
				$ErrorMsg = $SMTPM_DELSUCCESS;
			}
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)){
				copy($TMP_FILE,$_DELETE_DIGITAL_PATH.$_FILE);
				unlink($TMP_FILE);
			}
		}
	}
    
	
	//-- System super user(PROGRAM ENTRY PLACE)
	$strSQL = "Select count(*) From ".$DB_SMTP;
	
	if ($mime == 1)
	{
		$strSQL = $strSQL." Where ".$DB_SMTP_AUTO." in (".$SMTP.")";
	}
	else{
		$strSQL = $strSQL." Where ".$DB_SMTP_VISIABLE."<>'1'";
		if(fn_NotShowIP()!="''")$strSQL = $strSQL." and ".$DB_SMTP_SIP." not in (".fn_NotShowIP().")";

		if ($HTTP_SESSION_VARS['GroupNo_Sess']!=0){
			$strSQL = $strSQL." and ".$DB_SMTP_SIP." in (".fn_IPcontrol($HTTP_SESSION_VARS['GroupNo_Sess']).")";
		}//End : if()
		if($strWhere["SMTP"] != "") $strSQL = $strSQL.stripcslashes($strWhere["SMTP"]);
	}

	$condition =fn_SearchMail($QUERY_START_DATETIME,$QUERY_END_DATETIME,$QUERY_FROM,$QUERY_TO,$QUERY_CC,$QUERY_BCC,$QUERY_SUBJECT,'',$QUERY_IP,$QUERY_IP_1,$QUERY_ID,$QUERY_ACCOUNT,'smtp');

    $strSQL = $strSQL.$condition; 	
	//print $strSQL;
	//計算符合文章總數 & 初始化分頁變數
    include($_PAGE_PATH);
   
	//為了畫面排序的sql語法
	$strSQL = "Select ".$DB_SMTP_AUTO.",".$DB_SMTP_SIP.",".$DB_SMTP_FROM.",".$DB_SMTP_TO.",".$DB_SMTP_CC.",".reconvert($DB_SMTP_SUBJECT).",".$DB_SMTP_SIZE.",".$DB_SMTP_DBTAG.",".$DB_SMTP_BODY_NAME.",".$DB_SMTP_NUM_ATTACH.",".$DB_SMTP_DB_DATETIME.",".$DB_SMTP_ACCOUNT.",".$DB_SMTP_BCC;
	$strSQL = $strSQL."	From ".$DB_SMTP;
	if ($mime == 1)
	{
		$strSQL = $strSQL.fn_Datamining($SMTP,$DB_SMTP_AUTO,$m,$n,$to_page);
		$m = 0;
	}
	else{
		$strSQL = $strSQL." Where ".$DB_SMTP_VISIABLE."<>'1'";
		if(fn_NotShowIP()!="''")$strSQL = $strSQL." and ".$DB_SMTP_SIP." not in (".fn_NotShowIP().")";

		if ($HTTP_SESSION_VARS['GroupNo_Sess']!=0){
			$strSQL = $strSQL." and ".$DB_SMTP_SIP." in (".fn_IPcontrol($HTTP_SESSION_VARS['GroupNo_Sess']).")";
		}//End : if()
		if($strWhere["SMTP"] != "") $strSQL = $strSQL.stripcslashes($strWhere["SMTP"]);
	}

	$strSQL = $strSQL.$condition; 

	$strSQL = $strSQL."Order by ".$SortField." ".$SortType." limit ".$m.", ".$n;
	$intResult = mysql_query($strSQL);

	//print $strSQL;
	//<--組show畫面字串
	if (mysql_num_rows($intResult) == 0){
		$SMTPList = "<tr class=\"NoData\"><td colspan=\"";
		if (($HTTP_SESSION_VARS["OperateRole_Sess"]=="Super")&&($HTTP_SESSION_VARS["GroupNo_Sess"]=='0')){
			if(fn_ad()) $SMTPList = $SMTPList."11"; else $SMTPList = $SMTPList."10";
		}else{
			if(fn_ad()) $SMTPList = $SMTPList."10"; else $SMTPList = $SMTPList."9";
		}
		include("../no_data.php");
		$SMTPList =  $SMTPList."\"".$NoDataList;
		$_Disabled = "disabled";
	}
	else{
		$SMTPList = "";
		$chkCount = ($to_page-1)*$sizepage+1; 
		while ($row=mysql_fetch_array($intResult)){
			$_SUBJECT  =   convert(trim($row[$DB_SMTP_SUBJECT]));
			if (ereg("\n$",$_SUBJECT)){
				if (strlen($_SUBJECT)>3){
					$CUT_SUBJECT = $_SUBJECT = substr($_SUBJECT,0,strlen($_SUBJECT)-2);
				}
				elseif (strlen($_SUBJECT==2)){
					$CUT_SUBJECT = $SMTP_NONE;
					$_SUBJECT = $SMTP_NONE;
				}//End : if()
			}//End : if()

			if (($_SUBJECT=='(null)')||($_SUBJECT=='')||(empty($_SUBJECT))){
				$CUT_SUBJECT = $SMTP_NONE;
			}
			elseif (strlen($_SUBJECT)>30){    
				$CUT_SUBJECT=substr($_SUBJECT,0,30)."..."; 
			}
			else {
				$CUT_SUBJECT = $_SUBJECT;
			}//End : if()


			$_FROM  =   trim($row[$DB_SMTP_FROM]);
			if (ereg("\n$",$_FROM)){
				if (strlen($_FROM)>3){
					$CUT_FROM = $_FROM = substr($_FROM,0,strlen($_FROM)-2);
				}
				elseif (strlen($_FROM)==2){
					$CUT_FROM = "&nbsp;";
					$_FROM ="&nbsp;";
				}//End : if()
			}//End : if()

			if (($_FROM=='(null)')||($_FROM=='')||(empty($_FROM))){
				$CUT_FROM = "&nbsp;";
			}
			elseif (strlen($_FROM)>23){    
				$CUT_FROM=substr($_FROM,0,23)."..."; 
			}
			else {
				$CUT_FROM = $_FROM;
			}//End : if()

			$_TO      =   trim($row[$DB_SMTP_TO]);
			if (ereg("\n$",$_TO)){
				if (strlen($_TO)>3){
					$CUT_TO = $_TO = substr($_TO,0,strlen($_TO)-2);
				}
				elseif (strlen($_TO)==2){
					$CUT_TO = "&nbsp;";
					$_TO ="&nbsp;";
				}//End : if()
			}//End : if()

			if (($_TO=='(null)')||($_TO=='')||(empty($_TO))){
				$CUT_TO = "&nbsp;";
			}
			elseif (strlen($_TO)>20){    
				$CUT_TO=substr($_TO,0,20)."..."; 
			}
			else {
				$CUT_TO = $_TO;
			}//End : if()

			$_CC      =   trim($row[$DB_SMTP_CC]);
			if (ereg("\n$",$_CC)){
				if (strlen($_CC)>3){
					$CUT_CC = $_CC = substr($_CC,0,strlen($_CC)-2);
				}
				elseif (strlen($_CC)==2){
					$CUT_CC = "&nbsp;";
					$_CC ="&nbsp;";
				}//End : if()
			}//End : if()

			//如果_CC無值，塞none
			if (($_CC=='(null)')||($_CC=='')||(empty($_CC))){
				$CUT_CC = "&nbsp;";
			}
			elseif (strlen($_CC)>8){    
				$CUT_CC=substr($_CC,0,8)."..."; 
			}
			else {
				$CUT_CC = $_CC;
			}//End : if(如果_CC無值，塞none)

			$_BCC      =   trim($row[$DB_SMTP_BCC]);
			if (ereg("\n$",$_BCC)){
				if (strlen($_BCC)>3){
					$CUT_BCC = $_BCC = substr($_BCC,0,strlen($_BCC)-2);
				}
				elseif (strlen($_BCC)==2){
					$CUT_BCC = "&nbsp;";
					$_BCC ="&nbsp;";
				}//End : if()
			}//End : if()

			//如果_BCC無值，塞none
			if (($_BCC=='(null)')||($_BCC=='')||(empty($_BCC))){
				$CUT_BCC = "&nbsp;";
			}
			elseif (strlen($_BCC)>8){    
				$CUT_BCC=substr($_BCC,0,8)."..."; 
			}
			else {
				$CUT_BCC = $_BCC;
			}//End : if(如果_BCC無值，塞none)

			$_SIZE				= $row[$DB_SMTP_SIZE]; 
			$_DBTAG				= $row[$DB_SMTP_DBTAG]; 
			$_BODY_NAME			= $row[$DB_SMTP_BODY_NAME]; 
			
			if ($chkCount%2 == 1){
				$SMTPList = $SMTPList."<tr  class=\"Tr_Do\" onmouseover=\"this.className='Tr_Do_Out'\" onmouseout=\"this.className='Tr_Do_Over'\">";
			}else{
				$SMTPList = $SMTPList."<tr class=\"Tr_De\" onmouseover=\"this.className='Tr_De_Out'\" onmouseout=\"this.className='Tr_De_Over'\">";
			}

			$SMTPList = $SMTPList."<td align=\"center\" title=\"".$row[_AUTO]."\">".$chkCount.".</td>\n";


			//--attachement
			$SMTPList = $SMTPList."<td align=\"center\">\n";
			if($row[$DB_SMTP_NUM_ATTACH] == 0){
				$SMTPList = $SMTPList."&nbsp;</td>\n";
			}
			else {
				$SMTPList = $SMTPList."<img  src=\"../".$DIR_IMAGE.$SMTPP_ATTACH."\"></td>\n";
			}//End : if(attachement)

			//--datetime 
			$SMTPList = $SMTPList."<td align=\"center\"><a href=\"#\" onClick=\"ChangeCondition('_DB_DATETIME','".$row[$DB_SMTP_DB_DATETIME]."')\">".fn_DateTime($row[$DB_SMTP_DB_DATETIME])."</a></td>\n";

			//--from
			$SMTPList = $SMTPList."<td><p title=\"".$_FROM."\"><img src=\"../".$DIR_IMAGE.$SMTPP_IP."\" alt=\"".$row[$DB_SMTP_SIP]."\"><br><a href=\"#\" onClick=\"ChangeCondition('_FROM','".$_FROM."')\">".$CUT_FROM."</a></p></td>\n";

			//--TO
			$SMTPList = $SMTPList."<td>\n";
			$SMTPList = $SMTPList."<p title=\"".$_TO."\">\n";
			$SMTPList = $SMTPList."<a href=\"#\" onClick=\"ChangeCondition('_TO','".$_TO."')\">".$CUT_TO."</a></p></td>\n";

			$SMTPList = $SMTPList."<td align=\"center\"><p title=\"".$_CC."\"><a href=\"#\" onClick=\"ChangeCondition('_CC','".$_CC."')\">".$CUT_CC."</a></p></td>\n";

			$SMTPList = $SMTPList."<td align=\"center\"><p title=\"".$_BCC."\"><a href=\"#\" onClick=\"ChangeCondition('_BCC','".$_BCC."')\">".$CUT_BCC."</a></p></td>\n";
			//--轉換 DBTAG 的格式
			$_DBTAG ='';
			$_DBTAG =str_replace("-","_",$row[$DB_SMTP_DBTAG]);
			$_DBTAG =str_replace(":","_",$_DBTAG);
			//--檢查subject是否有檔，有檔才有連結
			if (file_exists($CD_DIR.":\\".$_DBTAG."\\".$row[$DB_SMTP_BODY_NAME])){
				//download
				$SMTPList.="<td><span title=\"".$Download."".$_SUBJECT."\"><a href=\"../download.php?file=".$CD_DIR.":\\".$_DBTAG."\\".$row["_BODY_NAME"]."\" target=\"_blank\"><img src=\"../".$DIR_IMAGE.$PIC_SORT."\" border=\"0\"></a></span>&nbsp";
				//isubject
				$SMTPList.="<span title=\"".$_SUBJECT."\"><a href=\"javascript:for_xp_sp2('".$_DBTAG."','".$row["_BODY_NAME"]."')\">".$CUT_SUBJECT."</a></span></td>\n";
			}
			else{
				$SMTPList = $SMTPList."<td><p title=\"".$_SUBJECT."\">".$CUT_SUBJECT."</p></td>\n";		
			}//End : if(檢查subject是否有檔，有檔才有連結)

			if (fn_ad()){
				$SMTPList = $SMTPList."<td align=\"center\"><a href=\"#\" onClick=\"ChangeCondition('_ACCOUNT','".$row[$DB_SMTP_ACCOUNT]."')\">".$row[$DB_SMTP_ACCOUNT]."</a></td>\n";
            }
			$SMTPList = $SMTPList."<td align=\"right\">\n";
			//判斷檔案大小的單位
			if ($_SIZE<1000){
				$SMTPList = $SMTPList.$_SIZE."B";
			}
			elseif (($_SIZE)<1000000&&($_SIZE)>=1000){
				$SMTPList = $SMTPList.(round($_SIZE/100)/10)."K";
			}
			else{
				$SMTPList = $SMTPList.(round($_SIZE/100000)/10)."M";
			}//End : if(判斷檔案大小的單位)
			$SMTPList = $SMTPList."</td>\n";
			$SMTPList = $SMTPList."</tr>\n";
			$chkCount++;
		}//End : while(組show畫面字串)
		
	}
}
else{
	include("../no_privilege.php");
}
?>
<html><head><title></title>
<link href="../Display/display.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT language=JavaScript src="../inc/fun.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function for_xp_sp2(DBTAG,FILENAME){
	var URL = "FOR_XP_SP2.php?_DBTAG="+DBTAG+"&_FILENAME="+FILENAME;
	var Features = "scrollbars=yes,width=800,height=600,left=100,top=25";
	window.open(URL,'DC',Features);
}
function get_nva(auto){
	 var objnav=window.navigator;
	 var nav=objnav.browserLanguage;
	 var value   = new Array("GB18030","GB2312","BIG5","HZ","ISO-8859-1");
	 var display =new Array("zh-ch","zh-sg","zh-tw","zh-hk","en");
	 for (var i=0;i< value.length;i++){
		 if(display[i]==nav){
			 var nav_post=value[i];
		 }
	 }
	 fn_OpenWin('sub_con.php?TYPE=SMTP&_CHARSET='+nav_post+'&_AUTO='+auto,'','width=500,height=200,left=225,top=200,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');
}

//--Check input pagesize num	
function ChangePageSize(){
	var flag = "";
	switch(CheckNum(document.frm.sizepage)){
		case "1":
			alert("<?echo $NUMBERM_INPUTISNULL;?>");
			flag = "1";
		break;
		case "2":
			alert("<?echo $NUMBERM_INPUTISZERO;?>");
			flag = "1";
		break;
		case "3":
			alert("<?echo $NUMBERM_INPUTBIG100;?>");
			flag = "1";
		break;
		case "4":
			alert("<?echo $NUMBERM_INPUTNOTNUM;?>");
			flag = "1";
		break;
	}
	
	if (flag == 1){
		document.frm.sizepage.focus();
		return;
	}
	document.frm.RunAs.value = "UpdatePageSize";
	document.frm.submit();

}


//--DELETE DATA
function checkDEL(){
<?if ($_Disabled == ""){?>
	if (!MainCheck()){
		alert("<?echo $SMTPM_NOTSELECT;?>");
		return;
	}

	if (confirm("<?echo $SMTPM_CHECKDEL;?>")){
		document.frm.RunAs.value = "Delete";
		document.frm.submit();
	}
<?}?>
}

//--igone
function checkIGNORE(value){
<?if($_Disabled == ""){?>
	if (!MainCheck()){
		fn_OpenWin('ignorelist.php','NewWin','width=900,height=590,left=60,top=50,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=no,fullscreen=no');
		return;
	}
<?}else{?>
	fn_OpenWin('ignorelist.php','NewWin','width=900,height=590,left=60,top=50,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=no,fullscreen=no');
	return;
<?}?>
	
	if (value == 2){
		if (confirm("<?echo $SMTPM_IGNOREDEL;?>")){
			document.frm.RunAs.value = "Ignore";
			document.frm.DELIGNORE.value="Delete_Ignore";
			document.frm.submit();
		}
	}
	else{
		document.frm.RunAs.value = "Ignore";
		document.frm.submit();
	}
}

<?if ($ErrorMsg != ""){?>
	fn_ErrorMsg('<?echo $ErrorMsg?>')
	<?if(($flag != 1 && $RunAs != "Delete") || ($DELIGNORE == "Delete_Ignore" && $flag != 1)){?>
		fn_OpenWin('ignorelist.php','NewWin','width=900,height=590,left=60,top=50,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=no,fullscreen=no');
	<?}?>
<?}?>
</SCRIPT>
</head>
<body onLoad="fix();" onScroll="fix();" onResize="fix();"> 
<!-- <body> -->
<!-- search result-->
<form name="frm" action="smtp.php" method="post">
<input type="hidden" name="strWhere[SMTP]" value="<?echo stripcslashes($strWhere["SMTP"]);?>">
<input type="hidden" name="DELIGNORE" value="">
<input type="hidden" name="RunAs" value="">
<input type="hidden" name="SortField" value="<? echo $SortField ?>"><!--sort column-->
<input type="hidden" name="SortType" value="<? echo  $SortType ?>"><!--sort type-->
<input type="hidden" name="Checked" value="<? echo $Checked?>"><!--set checkbox checked or no-->
<input type="hidden" name="QUERY_START_DATETIME" value="<?echo $QUERY_START_DATETIME;?>">
<input type="hidden" name="QUERY_END_DATETIME" value="<?echo $QUERY_END_DATETIME;?>">
<input type="hidden" name="QUERY_SUBJECT" value="<?echo $QUERY_SUBJECT;?>">
<input type="hidden" name="QUERY_FROM" value="<?echo ($QUERY_FROM);?>">
<input type="hidden" name="QUERY_TO" value="<?echo $QUERY_TO;?>">
<input type="hidden" name="QUERY_CC" value="<?echo $QUERY_CC;?>">
<input type="hidden" name="QUERY_BCC" value="<?echo $QUERY_BCC;?>">
<input type="hidden" name="QUERY_IP" value="<?echo $QUERY_IP;?>">
<input type="hidden" name="QUERY_IP_1" value="<?echo $QUERY_IP_1;?>">
<input type="hidden" name="QUERY_ACCOUNT" value="<?echo $QUERY_ACCOUNT;?>">
<input type="hidden" name="to_page" value="<?echo $to_page;?>"><!--current page-->
<input type="hidden" name="mime" value="<?echo $mime;?>">
<input type="hidden" name="SMTP" value="<?echo $SMTP;?>">
<input type="hidden" name="digital" value="<?echo $digital;?>">

<span id="bar" style="position:absolute;z-index:2;  width:100%; height:100%" align="center">
<table width="100%" cellSpacing="0" cellPadding="0" border="0">
  <tr  id="Tr_F">
    <td>
	  &nbsp;&nbsp;<a href="smtp.php"  title="<?echo $SMTP_SMTP;?>"><img src="../<?echo $DIR_IMAGE.$SMTPP_SMTP;?>" border="0" align="top"> <?echo $SMTP_SMTP_SHOW;?></a> | 
	  <a href="javascript:fn_OpenWin('<?echo $_SearchPath;?>?Status=smtp&digital=<?echo $digital;?>','NewWin','width=420,height=360,left=320,top=220,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');"  title="<?echo $SMTP_SEARCH;?>"><img src="../<?echo $DIR_IMAGE.$SMTPP_SEARCH;?>" align="top" border="0"> <?echo $SMTP_SEARCH_SHOW;?></a>
	</td>
	<td class="EveryPage"> 
	  <span title="<?echo $SMTP_PAGEVIEW;?>"><?echo $SMTP_PAGEVIEW_SHOW;?></span><input type="text" size="1" name="sizepage" value="<?echo $sizepage?>" class="Text_P"> <?echo $SMTP_LIST_COUNT;?> 
	  <input type="button" name="bntPageSize" value="<?echo $SMTPB_OK_SHOW;?>" onClick="ChangePageSize();" class="Btn_C" title="<?echo $SMTPB_OK;?>">&nbsp;
	</td>
  </tr>
</table>

<!--  blank TABLE-->
<table width="100%" class="BlankTb">
	<tr  height="24">
		<td ></td>
	</tr>
</table>

<table class="TitleTb">
  <tr id="Tr_T">
    <td width="3%"><span title="<?echo $SMTP_NO;?>"><?echo $SMTP_NO_SHOW;?></span></td>

    <td width="2%"><img src="../<?echo $DIR_IMAGE.$SMTPP_ATTACH;?>" alt="<?echo $SMTPA_ATTACH;?>"></td>
    <td width="10%" <?echo $colDate;?>>
	  <a href="javascript:ChangeSort('_DB_DATETIME','<? echo $sortDate;?>');"  title="<?echo $SMTP_DATETIME;?>"><?echo $SMTP_DATETIME_SHOW;?><?echo $imgDate;?></a>
	</td>
    <td width="18%" <?echo $colFrom;?>>
	  <a href="javascript:ChangeSort('_FROM', '<?echo $sortFrom;?>');"  title="<?echo $SMTP_FROM?>"><?echo $SMTP_FROM_SHOW?><?echo $imgFrom;?>
	</td>
    <td width="12%" <?echo $colTO;?>>
	  <a href="javascript:ChangeSort('_TO', '<?echo $sortTO;?>');"  title="<?echo $SMTP_TO?>"><?echo $SMTP_TO_SHOW?><?echo $imgTO;?>
	</td>
    <td width="8%" <?echo $colCC;?>>
	  <a href="javascript:ChangeSort('_CC', '<?echo $sortCC;?>');"  title="<?echo $SMTP_CC?>"><?echo $SMTP_CC_SHOW?><?echo $imgCC;?>
	</td>
	<td width="8%" <?echo $colBCC;?>>
	  <a href="javascript:ChangeSort('_BCC', '<?echo $sortBCC;?>');"  title="<?echo $SMTP_BCC?>"><?echo $SMTP_BCC_SHOW?><?echo $imgBCC;?>
	</td>
    <td><span title="<?echo $SMTP_SUBJECT;?>"><?echo $SMTP_SUBJECT_SHOW;?></span></td>
    <? if (fn_ad()){?>
		<td width="7%" <?echo $colAccount;?>>
			<a href="javascript:ChangeSort('_ACCOUNT', '<?echo $sortAccount;?>');"  title="<?echo $SMTP_ACCOUNT;?>"><?echo $SMTP_ACCOUNT_SHOW;?><?echo $imgAccount;?>
		</td>		
    <?}?>
    <td  nowrap width="4%" align="right" <?echo $colSize;?>>
	  <a href="javascript:ChangeSort('_SIZE','<? echo $sortSize;?>');"  title="<?echo $SMTP_SIZE;?>"><? echo $imgSize;?><?echo $SMTP_SIZE_SHOW;?></a>
	</td>
  </tr>
  </table>
</span>

<table width="100%" cellSpacing="0" cellPadding="0" border="0" >
<tr id="Tr_F"><td height="24" valign="middle"></td> </tr>
</table>

<table class="DataTb" >
  <tr  class="Tr_Do" height="26">
    <td width="3%"></td>

    <td width="2%"></td>
    <td width="10%"></td>
    <td width="18%"></td>
    <td width="12%"></td>
    <td width="8%"></td>
	<td width="8%"></td>
    <td></td>
    <? if (fn_ad()){?>
		<td width="7%"></td>		
    <?}?>
    <td width="4%" align="right"></td>
  </tr>
 <!--show screen-->
  <? echo $SMTPList;?>
  <tr bgcolor="<?echo $titletrbgcol;?>">
    <td colSpan="
	  <?
		if (($HTTP_SESSION_VARS["OperateRole_Sess"]=="Super")&&($HTTP_SESSION_VARS["GroupNo_Sess"]=='0')){
		  	if(fn_ad()) echo "11"; else echo "10";
		}else{
			if(fn_ad()) echo "10"; else echo "9";
		}
	  ?>
	" align="center">
	  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr id="Tr_P"><? include("../list_page.php");?></tr>
      </table>
	</td>
 </tr>
</table>
</form>
</body>	
</html>