MIL020.php
16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<?php
//*****************************************************************************
//*
//* プログラム名:Webメール受信画面
//* プログラムID:MIL020.php
//* 機能 :メール受信・表示
//* 作成者 :T.Yamamoto
//*
//*****************************************************************************
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');
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;
}
$strDBinc="include/dbcon.inc";
include($strDBinc);
//メール情報取得
$syain_cd = $PHP_SYAIN_CD;
$strSQLseq="Select * from mail_TBL Where syain_cd='$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;
}
}
include("inc/header.inc");
include("inc/MIL001.inc");
include("inc/MIL002.inc");
include("inc/MIL020.inc");
$userid = $strUserName;
$passwd = $strPASSWORD;
$server = $strSrvName;
$strMailAdd = $strMailAdd;
// Options
$show_header = FALSE; // show all headers
$use_apop = FALSE; // use APOP for authentication
$list_num = 10; // listing messages per a page
//**** メニュー ****//
include("menu_opacity.php");
//サーバ内の全メール取得
$init_num = $total_num;
$strMILSQL="Select send_flg8,send_flg9 from sendinfo_tbl Where syain_cd='$PHP_SYAIN_CD'";
$objMILData = pg_exec($strMILSQL);
if($objMILData==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$delmail_flg=0;
$dispmail_flg=10;
if (pg_numrows($objMILData) > 0){
$objchkMail = pg_fetch_object($objMILData, 0);
$delmail_flg = $objchkMail->send_flg9;
if ($objchkMail->send_flg8=="0"){
$dispmail_flg=10;
}else{
$dispmail_flg = $objchkMail->send_flg8;
if ($dispmail_flg==""){
$dispmail_flg=10;
}
}
}else{
$delmail_flg=0;
$dispmail_flg=10;
}
//受信メッセージ取得
$strSQLall = "SELECT ";
$strSQLall .= " from_addr,from_name,mail_id,get_date,header,subject,comment,mail_size,kind_flg,temp_flg ";
$strSQLall .= "FROM ";
$strSQLall .= " mail_get_tbl ";
$strSQLall .= "WHERE ";
$strSQLall .= " syain_cd='$PHP_SYAIN_CD' AND ";
$strSQLall .= " del_flg=0 ";
$strSQLall .= "ORDER BY ";
// ソート情報
$Sort_Disp[1] = "";
$Sort_Disp[2] = "";
$Sort_Disp[3] = "";
$Sort_Disp[4] = "";
$Sort_Val[1] = "";
$Sort_Val[2] = "";
$Sort_Val[3] = "";
$Sort_Val[4] = "";
switch ($Sort_Mode) {
case "1":
//件名
$strSQLall .= "subject ";
if ($Sort_Ptn == "1"){
$Sort_Disp[1] = "▼";
$Sort_Val[1] = "2";
}else{
$Sort_Disp[1] = "▲";
$Sort_Val[1] = "1";
}
$Sort_Disp[2] = "";
$Sort_Val[2] = "1";
$Sort_Disp[3] = "";
$Sort_Val[3] = "1";
$Sort_Disp[4] = "";
$Sort_Val[4] = "1";
break;
case "2":
//送信者
$strSQLall .= "from_name ";
$Sort_Disp[1] = "";
$Sort_Val[1] = "1";
if ($Sort_Ptn == "1"){
$Sort_Disp[2] = "▼";
$Sort_Val[2] = "2";
}else{
$Sort_Disp[2] = "▲";
$Sort_Val[2] = "1";
}
$Sort_Disp[3] = "";
$Sort_Val[3] = "1";
$Sort_Disp[4] = "";
$Sort_Val[4] = "1";
break;
case "3":
//受信日付
$strSQLall .= "get_date ";
$Sort_Disp[1] = "";
$Sort_Val[1] = "1";
$Sort_Disp[2] = "";
$Sort_Val[2] = "1";
if ($Sort_Ptn == "1"){
$Sort_Disp[3] = "▼";
$Sort_Val[3] = "2";
}else{
$Sort_Disp[3] = "▲";
$Sort_Val[3] = "1";
}
$Sort_Disp[4] = "";
$Sort_Val[4] = "1";
break;
case "4":
//サイズ
$strSQLall .= "cast(mail_size as int)";
$Sort_Disp[1] = "";
$Sort_Val[1] = "1";
$Sort_Disp[2] = "";
$Sort_Val[2] = "1";
$Sort_Disp[3] = "";
$Sort_Val[3] = "1";
if ($Sort_Ptn == "1"){
$Sort_Disp[4] = "▼";
$Sort_Val[4] = "2";
}else{
$Sort_Disp[4] = "▲";
$Sort_Val[4] = "1";
}
break;
default:
//受信日付
$Sort_Mode = "3";
$Sort_Disp[1] = "";
$Sort_Val[1] = "1";
$Sort_Disp[2] = "";
$Sort_Val[2] = "1";
$Sort_Disp[3] = "▼";
$Sort_Val[3] = "2";
$Sort_Disp[4] = "";
$Sort_Val[4] = "1";
$strSQLall .= "get_date ";
}
switch ($Sort_Ptn) {
case "1":
$strSQLall .= "ASC ";
break;
case "2":
$strSQLall .= "DESC ";
break;
default:
//受信日付
$Sort_Ptn = "1";
$strSQLall .= "ASC ";
}
$objRecall = pg_exec($strSQLall);
if($objRecall==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
//メールの合計サイズ取得
$str_total=0;
for ($intCnt = 0; $intCnt < pg_numrows($objRecall); $intCnt++) {
$objsize = pg_fetch_object($objRecall, $intCnt);
$str_total=$str_total+$objsize->mail_size;
}
$total_num=pg_numrows($objRecall);
$str_totalsize = format_size($str_total);
//未読メッセージ取得
$strSQLmi="Select mail_id from mail_get_tbl Where syain_cd='$PHP_SYAIN_CD' and kind_flg=0 and del_flg=0";
$objRecmi = pg_exec($strSQLmi);
if($objRecmi==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$PhpMidokuCnt=pg_numrows($objRecmi);
//表示サイズ設定
$list_num=$dispmail_flg;
//ボタン設定
$strButton="";
if ($start_from!="" && $start_from < $total_num && $start_from > 0) {
$init_num = $start_from;
} else {
$init_num = $total_num;
}
if ($total_num > $init_num) {
$intCnt=$init_num + $list_num;
//20131002 ページ遷移時にソート順追加
//$strButton='<input type="button" value="前の'.$dispmail_flg.'件" onclick="Page('.$intCnt.');">';
$strButton='<input type="button" value="前の'.$dispmail_flg.'件" onclick="Page('.$intCnt.','.$Sort_Mode.','.$Sort_Ptn.');">';
}
//20131002 ページ遷移時にソート順追加
//$strButton.='<input type="button" value="先頭へ戻る" onclick="Top();">';
$strButton.='<input type="button" value="先頭へ戻る" onclick="Page(0,'.$Sort_Mode.','.$Sort_Ptn.');">';
if ($init_num > $list_num) {
$intCnt=$init_num - $list_num;
//20131002 ページ遷移時にソート順追加
//$strButton.='<input type="button" value="次の'.$dispmail_flg.'件" onclick="Page('.$intCnt.');">';
$strButton.='<input type="button" value="次の'.$dispmail_flg.'件" onclick="Page('.$intCnt.','.$Sort_Mode.','.$Sort_Ptn.');">';
}
//未読メッセージ
if ($PhpMidokuCnt >0){
$strMsg=' <span class="chufont">未読メッセージが'.$PhpMidokuCnt.'件あります</span>';
}else{
$strMsg=' <span class="chufont">未読メッセージはありません</span>';
}
?>
<form name="e_gru">
<table width="100%" border="0" cellspacing="0">
<tr>
<td class="midashi">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="50%" scope="col"><div align="left"><img src="image/mail.gif" border="0"><span class="MiddleBold"><?php echo $PHP_TITLE_NAME[13] ?></span></div></th>
<th width="50%" scope="col"><div align="right"><a href='javascript:Disp_Help("MILHLP.htm")'><img src="image/help.gif" border="0"></a> <a href='javascript:Disp_Help("MILHLP.htm")'>ヘルプ</a></div></th>
</tr>
</table><div align="right"></div>
</td>
</tr>
</table><br>
<TABLE border=0 width=100%>
<TR>
<TD align="left">
<span class="Normalfont">
[<a href="MIL001.php">新着メールの確認</a>]
[<a href="MIL010.php?from=&to=<?php echo $strMailAdd ?>&strSubject=&strBody=">新規作成</a>]
[<a href="MIL020.php">受信ボックス(未読<?php echo pg_numrows($objRecmi) ?>件)</a>]
[<a href="MIL030.php">送信ボックス</a>]
[<a href="MIL040.php">個人アドレス帳</a>]
</span>
</TD>
<TD align="right">
<span class="Normalfont">
[<a href="MIL050.php">署名設定</a>]
[<a href="MIL002.php">アカウント設定</a>]
</span>
</TD>
</TR>
</TABLE>
<TABLE border=0 width=100%>
<TR>
<TD align="left">
<img src="image/folder.gif" border="0"><strong><span class="Normalfont">受信ボックス(<?php echo $total_num."件,".$str_totalsize ?>)</span></strong><BR>
<?php echo $strMsg; ?>
</TD>
<TD align="right">
<input type="button" value="全受信メール一括削除" style="FONT-WEIGHT: bold;COLOR: #FF0000;" onclick="Delete_AllMail();">
</TD>
</TR>
</TABLE>
<?php if ($total_num > 0) { ?>
<TABLE border=0 width=100%>
<TR>
<TD align="right"><span class="Normalfont"><?php echo $strButton; ?></span></TD>
</TR>
</TABLE>
<TABLE cellSpacing=1 cellPadding=1 width=100% class="mainColor" border=0>
<TR>
<TD>
<TABLE cellSpacing=1 cellPadding=1 width=100% align=center class="mainColor" border=0>
<TR class="toneDown">
<TD height="25" width="50%" align="center">
<a href="javascript:Sort_Data('1','<?php echo $Sort_Val[1]; ?>');"><span class="Normalfont">件名<?php echo $Sort_Disp[1]; ?></span></a>
</TD>
<TD height="25" width="50" align="center"><span class="Normalfont">添付</span></TD>
<TD height="25" width="200" align="center">
<a href="javascript:Sort_Data('2','<?php echo $Sort_Val[2]; ?>');"><span class="Normalfont">送信者<?php echo $Sort_Disp[2]; ?></span></a>
</TD>
<TD height="25" width="200" align="center">
<a href="javascript:Sort_Data('3','<?php echo $Sort_Val[3]; ?>');"><span class="Normalfont">受信日付<?php echo $Sort_Disp[3]; ?></span></a>
</TD>
<TD height="25" width="70" align="center">
<a href="javascript:Sort_Data('4','<?php echo $Sort_Val[4]; ?>');"><span class="Normalfont">サイズ<?php echo $Sort_Disp[4]; ?></span></a>
</TD>
<TD height="25" width="50" align="center"><span class="Normalfont"><INPUT type="button" onclick="All_chk();" value="チェック"><input type="button" value="削除" onclick="Delete_Mail();"></TD>
</TR>
<?php
//曜日配列
$youbi=array("日","月","火","水","木","金","土");
for ($num = $init_num; $num > 0; --$num) {
if ($init_num - $list_num >= $num) break;
$objData = pg_fetch_object($objRecall, ($num-1));
//送信者
$str_From = $objData->from_name;
$str_Addr = $objData->from_addr;
//送信者が空の場合は、解析&UPDATE
if(trim($str_From) == ""){
$header_list = parse_header($objData->header);
//ヘッダー取得
if (isset($header_list['from'])) {
$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);
}
} else {
$str_From = '(Unknown)';
$str_Addr = '';
}
$strSqlTemp = "update mail_get_tbl set from_name = '".$str_From."', from_addr = '".$str_Addr."' where mail_id = '".addslashes($objData->mail_id)."' and get_date = '".$objData->get_date."' and syain_cd='".$PHP_SYAIN_CD."'";
$objRecTemp = pg_exec($strSqlTemp);
if($objRecTemp==false){
echo("SQL実行に失敗しました(UPDATE)");
exit;
}
}
$str_From = htmlspecialchars($str_From);
//日付編集
$str_year=substr($objData->get_date,0,4);
$str_mon=substr($objData->get_date,4,2);
$str_day=substr($objData->get_date,6,2);
$str_hour=substr($objData->get_date,8,2);
$str_min=substr($objData->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;
//サイズ
$strsize=format_size($objData->mail_size);
//長文ファイルチェック
$strName=htmlspecialchars(LINE_DEL($objData->subject,50));
?>
<?php if ($objData->kind_flg==0){ ?>
<TR bgcolor="#E5E5E5">
<TD height="25" width="50%" align="left"> <strong><span class="Normalfont">
<a href='MIL021.php?view_uid=<?php echo subRepURI($objData->mail_id) ?>'><?php if(trim($strName=="")){echo "(no subject)";}else{echo $strName;} ?></span></strong>
</TD>
<TD height="25" width="50" align="center">
<?php if ($objData->temp_flg==1){ ?>
<span class="Normalfont">◎</span>
<?php } ?>
</TD>
<TD height="25" width="200" align="left"><strong><span class="Normalfont"> <a href=# Onclick="return address_get(<?php echo "'".$str_From."','".$str_Addr."'"; ?>);"><?php echo $str_From; ?></a></span></strong></TD>
<TD height="25" width="200" align="left"><strong><span class="Normalfont"> <?php echo $strDate ?></span></strong></TD>
<TD height="25" width="70" align="center"><strong><span class="Normalfont"> <?php echo $strsize ?></span></strong></TD>
<TD height="25" width="50" align="center"><span class="Normalfont"><INPUT type="checkbox" name="del_seq" value='<?php echo subRepURI($objData->mail_id) ?>'></span></TD>
</TR>
<?php }else{ ?>
<TR bgcolor="#FFFFFF">
<TD height="25" width="50%" align="left"> <span class="Normalfont">
<a href='MIL021.php?view_uid=<?php echo subRepURI($objData->mail_id) ?>'><?php if(trim($strName=="")){echo "(no subject)";}else{echo $strName;} ?></span>
</TD>
<TD height="25" width="50" align="center">
<?php if ($objData->temp_flg==1){ ?>
<span class="Normalfont">◎</span>
<?php } ?>
</TD>
<TD height="25" width="200" align="left"><span class="Normalfont"> <a href=# Onclick="return address_get(<?php echo "'".$str_From."','".$str_Addr."'"; ?>);"><?php echo $str_From; ?></a></span></TD>
<TD height="25" width="200" align="left"><span class="Normalfont"> <?php echo $strDate ?></span></TD>
<TD height="25" width="70" align="center"><span class="Normalfont"> <?php echo $strsize ?></span></TD>
<TD height="25" width="50" align="center"><span class="Normalfont"><INPUT type="checkbox" name="del_seq" value='<?php echo subRepURI($objData->mail_id) ?>'></span></TD>
</TR>
<?php } ?>
<?php } ?>
<TR class="toneDown">
<TD height="25" width="50%" align="center"><span class="Normalfont">件名</span></TD>
<TD height="25" width="50" align="center"><span class="Normalfont">添付</span></TD>
<TD height="25" width="200" align="center"><span class="Normalfont">送信者</span></TD>
<TD height="25" width="200" align="center"><span class="Normalfont">受信日付</span></TD>
<TD height="25" width="70" align="center"><span class="Normalfont">サイズ</span></TD>
<TD height="25" width="50" align="center"><span class="Normalfont"><INPUT type="button" onclick="All_chk();" value="チェック"><input type="button" value="削除" onclick="Delete_Mail();"></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<TABLE border=0 width=100%>
<TR>
<TD align="right"><span class="Normalfont"><?php echo $strButton; ?></span></TD>
</TR>
</TABLE>
<input name="dele_uid" type="hidden" value=''>
<input name="start_from" type="hidden" value='<?php echo $init_num ?>'>
<input name="strChkDat" type="hidden" value='<?php echo $strChkDat; ?>'>
<input name="strName" type="hidden" value=''>
<input name="intGmSts" type="hidden" value=''>
<input name="strAddress" type="hidden" value=''>
<input name="Sort_Ptn" type="hidden" value='<?php echo $Sort_Ptn; ?>'>
<input name="Sort_Mode" type="hidden" value='<?php echo $Sort_Mode; ?>'>
<?php
}else{
?>
<BR><BR><span class="Normalfont"> 受信ボックスにはメールはありません</span>
</form>
<?php
}
//コピーライト
include("include/copyright.inc");
?>