WML021.php 7.68 KB
<?php 
//*****************************************************************************
//* 
//* プログラム名:Webメール
//* プログラムID:WML021.php
//* 機能				:メール詳細・表示
//* 作成者			:
//* 
//*****************************************************************************
header('Content-Type: text/html; charset=EUC-JP');
include("include/session_start.inc");
include("include/SessionChk.inc");
include("include/STRING.inc");
include('./include/smarty.conf');

//**** メニュー ****//
//include("inc/header.inc");
//include("menu_opacity.php");

//*** JavaScript ***//
include("inc/WML000.inc");
//include("inc/WML001.inc");

//**** DB接続 ****//
$strDBinc="./include/dbcon.inc";
include($strDBinc);

//*****************************************************************************
//* 文字変換
//*****************************************************************************
function subRetURI($prmStr){

	$prmStr = str_replace("EgruProPlus", "+", $prmStr);
	$prmStr = str_replace("EgruProAnp", "&", $prmStr);
	$prmStr = str_replace("EgruProPer", "%", $prmStr);
	$prmStr = str_replace("EgruProNum", "#", $prmStr);
	$prmStr = str_replace("EgruProSing", "'", $prmStr);
	$prmStr = str_replace("EgruProDoub", '"', $prmStr);		
	$prmStr = str_replace("EgruProDoll", "$", $prmStr);		
	$prmStr = str_replace("EgruProhyph", "-", $prmStr);		
	return $prmStr;	
}
function subRepURI($prmStr){

	$prmStr = str_replace("+", "EgruProPlus", $prmStr);
	$prmStr = str_replace("&", "EgruProAnp", $prmStr);
	$prmStr = str_replace("%", "EgruProPer", $prmStr);
	$prmStr = str_replace("#", "EgruProNum", $prmStr);
	$prmStr = str_replace("'", "EgruProSing", $prmStr);
	$prmStr = str_replace('"', "EgruProDoub", $prmStr);
	$prmStr = str_replace("$", "EgruProDoll", $prmStr);
	$prmStr = str_replace("-", "EgruProhyph", $prmStr);		
	return $prmStr;	
}

//曜日配列
$youbi=array("日","月","火","水","木","金","土");

//メール情報取得
$strSQLseq="Select * from mail_TBL Where syain_cd='$PHP_SYAIN_CD'";
$objRecseq = pg_exec($strSQLseq);
if($objRecseq==false){
	echo("SQL実行に失敗しました(SELECT)");
	exit;
}
if (pg_numrows($objRecseq) > 0){
		$objmail = pg_fetch_object($objRecseq, 0);
		$strMailAdd=$objmail->mail_add;
		$intSrvadd=$objmail->pop3_add;
		$strUserName=$objmail->mail_name;
		$strPASSWORD=$objmail->mail_pass;

		// 登録サーバー名取得
		$strSQLseq="Select * from mailAdmin_TBL Where srv_id=".$intSrvadd." and srv_flg=2";
		$objRecseq = pg_exec($strSQLseq);
		if($objRecseq==false){
				echo("SQL実行に失敗しました(SELECT)");
				exit;
		}
		if (pg_numrows($objRecseq) > 0){
				$objmail = pg_fetch_object($objRecseq, 0);
				$strSrvName=$objmail->srv_add;
		}
}	


$userid = $strUserName;
$passwd = $strPASSWORD;
$server = $strSrvName;
$strMailAdd = $strMailAdd;

// Options
$show_header = FALSE;
$use_apop		= FALSE;
$list_num		= 10;

//文字化け対策
if (function_exists("mb_internal_encoding")) {
		mb_internal_encoding("SJIS");
}

//VIEW_ID変換
$view_uid = subRetURI($view_uid);

//メールの詳細取得
$strSQLview="Select header,subject,comment from mail_get_tbl Where mail_id='".str_replace("'", "''", $view_uid)."' and syain_cd='$PHP_SYAIN_CD'";
$objRecview = pg_exec($strSQLview);
if($objRecview==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}

$strSQLUp = "UPDATE mail_get_tbl SET kind_flg=1 WHERE mail_id='".str_replace("'", "''", $view_uid)."' and syain_cd='$PHP_SYAIN_CD'";
$objRecUp = pg_exec($strSQLUp);
if($objRecUp==false){
		echo("SQL実行に失敗しました(UPDATE)");
		exit;
}

//*** メールの詳細取得 ***
$strSQLview="Select * from mail_get_tbl Where mail_id='".str_replace("'", "''", $view_uid)."' and syain_cd='$PHP_SYAIN_CD'";
$objRecview = pg_exec($strSQLview);
if($objRecview==false){
		echo("SQL実行に失敗しました(SELECT)");
		exit;
}
if (pg_numrows($objRecview) < 1) {	
		echo '<span class=Normalfont>メッセージは見つかりませんでした。</span>';
}else{
		$objview = pg_fetch_object($objRecview, 0);

		$header_view[] = array('subject', '件名');
		$header_view[] = array('from', '送信者');
		$header_view[] = array('to', '宛先');
		$header_view[] = array('cc', 'Cc');
		$tmpdir = "temp/".$PHP_FOLDER_NAME."/mail/";

		$data=$objview->comment;
		$data=LINE_BR($data,80);
		$data=str_replace("<br>","\r\n",$data);
		$chk_rows=split("\r\n", $data);
		if (count($chk_rows)>26){
				$row_value=450;
		}else{
				$row_value=count($chk_rows)*17;
		}

		$raw_header=$objview->header;
		$header_list = parse_header($raw_header);
		if (!isset($header_list['content-type'])) {
				$header_list['content-type'] = 'text/plain; charset=us-ascii';
		}
		$ctype = parse_ctype($header_list['content-type']);
		if (isset($header_list['content-transfer-encoding'])) {
				$body = decode_body($body, $header_list['content-transfer-encoding']);
		}
		$header_view_num = count($header_view);
		$strMILID=stripcslashes($view_uid);
		for ($i = 0; $i < $header_view_num; ++$i) {
				if (!isset($header_list[$header_view[$i][0]])) {
					continue;
				}
				$MIL_Title[$i]=$header_view[$i][1];
				if ($header_list[$header_view[$i][0]]==''){
						$MIL_Data[$i]='(no subject)';
				}else{
					if($i==0){
							$MIL_Data[$i]=link_url((LINE_BR(htmlspecialchars(decode_mimeheader($header_list[$header_view[$i][0]], 1)), 100)));
					}else{
							$MIL_Data[$i]=link_url(htmlspecialchars(decode_mimeheader($header_list[$header_view[$i][0]], 1), ENT_QUOTES));
					}
					if ($i==1){
							$str_From=decode_mimeheader(get_name($header_list['from']), 1);
							$str_From=ereg_replace("[\'\"\;]", "", $str_From);
							$str_Addr=decode_mimeheader($header_list['from'], 1);
							$str_Addr=ereg_replace("[\'\"\;]", "", $str_Addr);
							$str_Addr= str_replace("\"","",$str_Addr);
							$intpoint = strlen($str_From);						
							$str_Addr = trim(substr($str_Addr,$intpoint));						
							if (substr($str_Addr,0,1)=="@"){
								$str_Addr = htmlspecialchars(decode_mimeheader($header_list['from'], 1), ENT_QUOTES);
							}
					}
				}
		}

		//日付
		$str_year=substr($objview->get_date,0,4);
		$str_mon=substr($objview->get_date,4,2);
		$str_day=substr($objview->get_date,6,2);
		$str_hour=substr($objview->get_date,8,2);
		$str_min=substr($objview->get_date,10,2);
		$intYoubi=date("w", mktime (0,0,0,$str_mon,$str_day,$str_year));
		$strDate=$str_year."/".$str_mon."/".$str_day."(".$youbi[$intYoubi].")"." ".$str_hour.":".$str_min;

		$str_From=$objview->from_name;
		$str_Addr=$objview->from_addr;

		//添付ファイル
		$strSQLtemp  = "Select * from mail_temp_tbl ";
		$strSQLtemp .= "Where syain_cd='$PHP_SYAIN_CD' and mail_id='".str_replace("'", "''", $view_uid)."' ";
		$strSQLtemp .= "ORDER BY temp_index ";
		$objRectemp = pg_exec($strSQLtemp);
		for ($inttempCnt = 0; $inttempCnt < pg_numrows($objRectemp); $inttempCnt++) {
				$objTempfile = pg_fetch_object($objRectemp, $inttempCnt);
				if($ByteOver[$inttempCnt]==1){
				}else{
					if(trim($objTempfile->temp_name) =="※10MB以上の添付ファイルは受信できません"){
							$strTemp[$inttempCnt] = $objTempfile->temp_name;
					}else{
							$strTemp[$inttempCnt]  = "<a href=\"WML024.php?TempName=".$PHP_SYAIN_CD."-".($inttempCnt+1)."-".subRepURI($view_uid);
							$strTemp[$inttempCnt] .= "&FilePath=".$tmpdir.$PHP_SYAIN_CD."-".($inttempCnt+1)."-".subRepURI($view_uid)."\">";
							$strTemp[$inttempCnt] .= $objTempfile->temp_name."</a>";
					}
				}
		}
}
$o_smarty->assign('PHP_FOLDER',$PHP_FOLDER);

$o_smarty->assign('view_uid',str_replace("'", "''", $view_uid));
$o_smarty->assign('PHP_SYAIN_CD',$PHP_SYAIN_CD);
$o_smarty->assign('row_value',$row_value);

$o_smarty->assign('MIL_Title',$MIL_Title);
$o_smarty->assign('MIL_Data',$MIL_Data);
$o_smarty->assign('strDate',$strDate);
$o_smarty->assign('strTemp',$strTemp);
$o_smarty->assign('str_From',$str_From);
$o_smarty->assign('str_Addr',$str_Addr);

$o_smarty->assign('PHP_TITLE_NAME',$PHP_TITLE_NAME[18]);
$o_smarty->display('WML021.tpl');
?>