SEND2010.php
13.3 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
<?PHP
//*****************************************************************************
//*
//* プログラム名:配信処理画面
//* プログラムID:SEND1010.php
//* 機能 :配信処理
//*
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
include("./include/session_start.inc");
include("./include/SessionChk.inc");
//***************************
//* インクルードファイル
//***************************
include("./include/getWeekDay.inc");
include("./include/getDomain.inc");
include("./include/jcode.phps");
include("./include/dbcon.inc");
include("./include/mime.php");
include("./include/point.inc");
include("./include/logget.inc");
include("./include/mtcnews.inc");
$Comment_tel = jcodeconvert($Mail_Keitai, 1, 3);
$Comment_pc = jcodeconvert($Mail_PC, 1, 3);
//***************************
//* メイン処理
//表示項目名を取得
$strSQL = "SELECT disp_id, disp_name FROM mst_disp WHERE disp_id = '6'";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$objData = pg_fetch_object($objRecSet,0);
$strDisp_Name = JcodeConvert($objData->disp_name, 1, 1);
//件名
if($_REQUEST["tei"]=="on"){
$strKenmei = "(〒)".$strDisp_Name.":".$_REQUEST["kenmei"];
}else{
$strKenmei = "(〒)".$_REQUEST["kenmei"];
}
$strKenmei = JcodeConvert($strKenmei, 1, 1);
//本文
$strText = JcodeConvert($_REQUEST["text"], 1, 1);
//送信日時
$strSubmitTime = date("YmdHis");
if (strlen($strSubmitTime) == 12) {
$strSubmitTime = "20".$strSubmitTime;
}
//送信者アドレス,名前
$strSQL = "SELECT name_kj_sei, name_kj_mei, pc_mail_addr, mail_addr FROM syain_tbl ".
"WHERE syain_cd = ".$PHP_POST_SYAIN_CD." " .
"ORDER BY syain_cd";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
$objData = pg_fetch_object($objRecSet, 0);
$strSubmitAdd = $objData->pc_mail_addr;
if($strSubmitAdd == ""){//pcメルアドが無かったら
$objData = pg_fetch_object($objRecSet, 0);
$strSubmitAdd = $objData->mail_addr;
if($strSubmitAdd == ""){//どちらのメルアドも無かったら
$strSQL = "SELECT * FROM mst_dmain";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
$objData = pg_fetch_object($objRecSet, 0);
$strSubmitAdd = $objData->mail_addr;
}
}
$strSubmitName=$objData->name_kj_sei." ".$objData->name_kj_mei;
//ドメイン
$strDomeName=getDomain();
//メールID?
$strSQL = "SELECT Max(mail_id) as Max_id FROM mail_data";
$objRecSet = pg_exec($strSQL);
$Max_id = pg_result($objRecSet,0,"Max_id");
if($objRecSet==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
$Max_mail = ($Max_id + 1);
$Max_id = "'".($Max_id + 1)."'";
//乱数取得----------
$num = 1;
while ($num >= 1){
$strArray = array(0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z);
$angou = "";
for ($i = 0; $i < (10 - (int)$_REQUEST["view_flg"]); $i++){
$tmp_num = rand(0, 51);
$angou .= $strArray[$tmp_num];
}
$sql = "SELECT * FROM mail_data";
$sql .= " WHERE angou_id = '".$angou."'";
$rtn = pg_exec($sql);
if($rtn == false){
echo "SQLの実行に失敗しました。(#1)";
exit;
}
$num = pg_numrows($rtn);
}
//メールデータ作成
$strSQL = "INSERT INTO mail_data (" .
"mail_id, " .
"angou_id, " .
"message_date, " .
"message_time, " .
"subject_name, " .
"contents, " .
"admin_cd, " .
"send_date, " .
"send_type, " .
"send_alarm)" .
"VALUES (" .
$Max_id.", " .
"'".$angou."', " .
"'', " .
"'', " .
"'".addslashes($strKenmei)."'".", " .
"'".addslashes($strText)."'". ", " .
$PHP_POST_SYAIN_CD.", " .
$strSubmitTime.", " .
(int)$_REQUEST["SendType"].", " .
"0) ";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
$strSQL="UPDATE mail_data SET " .
"reserva_flg = 0," .
"reserva_date = ''," .
"reserva_time = '' " .
"WHERE mail_id = ".$Max_id;
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
//回答期限
$limit_date = $_REQUEST["limit_yyyy"].$_REQUEST["limit_mm"].$_REQUEST["limit_dd"].$_REQUEST["limit_time_hh"].$_REQUEST["limit_time_mm"];
if(is_numeric($limit_date) == true && strlen($limit_date) == 12){
$strSQL = "INSERT INTO res_time_tbl (" .
"mail_id, " .
"angou_id, " .
"date) " .
"VALUES (" .
$Max_id.", " .
"'".$angou."', " .
"'".$limit_date. "') ";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
//回答でーーた
$strSQL = "INSERT INTO answer_data ";
$strSQL .= " ( ";
$strSQL .= " mail_id, ";
$strSQL .= " select_nm, ";
for($i=1;$i<=$_REQUEST["kouho"];$i++){
$strSQL .= " name".$i."_id, ";
$strSQL .= " name".$i."_nm, ";
}
$strSQL .= " name50_nm ";
$strSQL .= " ) ";
$strSQL .= " VALUES( ";
$strSQL .= " ".$Max_id.", ";
$strSQL .= " ".((int)$_REQUEST["kouho"]).", ";
for($i=1;$i<=$_REQUEST["kouho"];$i++){
$strSQL .= " ".($i).", ";
$temp = str_pad($_REQUEST["kouhoS_yyyy".$i], 4, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoS_mm".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoS_dd".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoS_hh".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoS_ii".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoE_yyyy".$i], 4, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoE_mm".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoE_dd".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoE_hh".$i], 2, " ", STR_PAD_LEFT);
$temp .= str_pad($_REQUEST["kouhoE_ii".$i], 2, " ", STR_PAD_LEFT);
$strSQL .= " '".$temp."', ";
}
$strSQL .= " 'QU' ";
$strSQL .= " ) ";
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
if($_REQUEST["radSendPtn"] == "1"){
//個人配信
$strWhere="";
$strData=split(",", $_REQUEST["Send_User"]);
for ($intIdx = 0; $intIdx < count($strData) - 1; $intIdx++){
if ($strWhere == ""){
$strWhere = " syain_cd = '".$strData[$intIdx]."' ";
}else{
$strWhere .= " OR syain_cd = '".$strData[$intIdx]."' ";
}
}
$strSQL = "SELECT * FROM syain_tbl ";
$strSQL .= "WHERE ".$strWhere;
}elseif($_REQUEST["radSendPtn"] == "2"){
//グループ配信
$strWhere="";
$strData=split("/", $_REQUEST["group_id"]);
for ($intIdx = 1; $intIdx < count($strData) - 1; $intIdx++){
if ($strWhere==""){
$strWhere="AND (group_info.group_id='".$strData[$intIdx]."'";
}else{
$strWhere=$strWhere." or group_info.group_id='".$strData[$intIdx]."'";
}
}
$strWhere=$strWhere.")";
$strSQL = "SELECT syain_tbl.syain_cd, syain_tbl.angou_cd, syain_tbl.mail_addr, syain_tbl.pc_mail_addr, name_kj_sei, name_kj_mei " .
"FROM group_info , syain_tbl " .
"WHERE syain_tbl.syain_cd = group_info.syain_cd " .
$strWhere." group by syain_tbl.syain_cd, syain_tbl.angou_cd, syain_tbl.mail_addr, syain_tbl.pc_mail_addr,name_kj_sei, name_kj_mei " .
"ORDER BY syain_tbl.syain_cd";
}
$objRecSet = pg_exec($strSQL);
if($objRecSet==false){
echo("SQL実行に失敗しました(SELECT)");
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<META http-equiv="Content-Style-Type" content="text/css">
<link href="./style.css" rel="stylesheet" type="text/css">
<TITLE>送信中</TITLE>
<script language="javascript">
function pageJump(){
document.frm.action = "SEND2020.php";
document.frm.method="POST";
document.frm.submit();
}
</script>
</HEAD>
<BODY onload="pageJump();" bgcolor="White">
<br>
<br>
<br>
<center>
<B><FONT color=blue size=5>送信中です。しばらく待ちください。</FONT></B>
<br>
<form name="frm">
<table>
<tr>
<br>
<br>
<td><FONT size=5><div id="maxcount"></div></FONT></td>
<td><FONT size=5>件中</FONT></td>
<td><FONT size=5><div id="count"></div></FONT></td>
<td><FONT size=5>件送信しました。</FONT></td>
<tr>
</table>
<br>
<B><FONT color=red size=5>※この画面で何か操作しますと、処理が正常におこなわれません。</FONT></B>
<br>
</form>
<br>
</center>
<?PHP
if($tmp_flg==0){
$intRoop=1;
$Mail_Nasi=0;
$arrayToAdd = array();
$logFrom = array(); //log配列初期化
$logTo = array();
$logType = array();
$logDate = array();
$intCountLog=0;
for ($intCount = 0; $intCount<pg_numrows($objRecSet);){
$Header="";//ヘッダー部クリア
$objData = pg_fetch_object($objRecSet, $intCount);
$strTo = $objData->pc_mail_addr;
$strToMob= $objData->mail_addr;
$strSendName=$objData->name_kj_sei.$objData->name_kj_mei;
if($_REQUEST["SendType"] == "0"){
if($objData->pc_mail_addr=="" && $objData->mail_addr==""){
$Mail_Nasi=1; //PCか携帯メールアドレスが未登録の人
$SendRes = 3;
}elseif($objData->pc_mail_addr=="" && $objData->mail_addr!=""){
$SendRes = 1;
}elseif($objData->pc_mail_addr!="" && $objData->mail_addr==""){
$SendRes = 2;
}elseif($objData->pc_mail_addr!="" && $objData->mail_addr!=""){
$SendRes = 0;
}
}elseif($_REQUEST["SendType"] == "1"){
if($objData->mail_addr==""){
$Mail_Nasi=1; //携帯メールアドレスが未登録の人
$SendRes = 3;
}else{
$SendRes = 1;
}
}elseif($_REQUEST["SendType"] == "2"){
if($objData->pc_mail_addr==""){
$Mail_Nasi=1; //PCメールアドレスが未登録の人
$SendRes = 3;
}else{
$SendRes = 2;
}
}
$strSubject = "=?iso-2022-jp?B?".base64_encode(jcodeconvert(stripslashes($strKenmei), 0, 3))."?=";
$strComment = $PHP_POST_DB_USER_NAME."の皆様(".$strSendName."様)へ\n\n下記のアドレスからメール内容を確認してください。\n".
$PONV2_URL_HEAD."USER0000.php?m=".$angou .
"&s=" .$objData->angou_cd."&d=" .$PHP_POST_DB_ANGOU. "\n\n";
$strComment = jcodeconvert($strComment, 1, 3);
$Header="";//ヘッダー部クリア
$Header1 = "";
if($_REQUEST["NowSend"] != "on"){
if($_REQUEST["SendType"] == "0" || $_REQUEST["SendType"] == "1"){
if($strToMob!=""){
$intBool2 = mail($strToMob,$strSubject,$strComment.$Comment_tel.$koukokuTEL,$Header1,"-f ".$strSubmitAdd);//携帯に送信
$logFrom[$intCountLog] = $strSubmitAdd;
$logTo[$intCountLog] = $strToMob;
$logType[$intCountLog] = 1;
$logDate[$intCountLog] = date("YmdHi");
$intCountLog+=1;
}
$intBool2 = true;
}else{
$intBool2 = true;
}
}else{
$intBool2 = true;
}
$Header="";//ヘッダー部クリア
//PEARのmimeクラス設定
$mime = new Mail_mime("\r\n");
$mime->_build_params['text_charset'] = 'iso-2022-jp'; //本文テキストの文字コードをJISに設定する
//本文のテキストの指定
$mime->setTXTBody($strComment);
//添付ファイル
if ($f_attach) {
//添付ファイルの指定
//$mime->addAttachment($_FILES['f_attach']['tmp_name'], $_FILES['f_attach']['type'], mb_convert_encoding($_FILES['f_attach']['name'],"SJIS","EUC-JP"));
$mime->addAttachment($_FILES['f_attach']['tmp_name'], $_FILES['f_attach']['type'], jcodeconvert($_FILES['f_attach']['name'], 1, 3));
}
//メールボディの取得
$strComment = $mime->get();
//メールヘッダの取得
$Headers = $mime->headers($Headers);
//メールヘッダの配列を文字列に組み立てる
while (list($key,$val)=each($Headers)) {
$Header .= $key.": ".$val."\r\n";
}
if($_REQUEST["NowSend"] != "on"){
if($_REQUEST["SendType"] == "0" || $_REQUEST["SendType"] == "2"){
if($strTo!=""){
$intBool = mail($strTo, $strSubject, $strComment.$Comment_pc.$koukokuPC,$Header,"-f ".$strSubmitAdd);//PCに送信
$logFrom[$intCountLog] = $strSubmitAdd;
$logTo[$intCountLog] = $strToMob;
$logType[$intCountLog] = 0;
$logDate[$intCountLog] = date("YmdHi");
$intCountLog+=1;
}
$intBool = true;
}else{
$intBool = true;
}
}else{
$intBool = true;
}
if($intBool && $intBool2){
if($Mail_Nasi != 1){
$objData = pg_fetch_object($objRecSet, $intCount);
$strSQL = "INSERT INTO mail_info (".
"mail_id, " .
"syain_cd, " .
"check_flg) " .
"VALUES (" .
$Max_id.", " .
"'".$objData->syain_cd."', " .
"0)";
$objInsRet = pg_exec($strSQL);
if($objInsRet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}else{
$objData = pg_fetch_object($objRecSet, $intCount);
$strSQL = "INSERT INTO mail_info (".
"mail_id, " .
"syain_cd, " .
"check_flg) " .
"VALUES (" .
$Max_id.", " .
"'".$objData->syain_cd."', " .
"100)";
$objInsRet = pg_exec($strSQL);
if($objInsRet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
//送信機種保存
$strSQL = "INSERT INTO mail_send_tbl (" .
"mail_id, " .
"syain_cd, " .
"send_flg) " .
"VALUES (" .
$Max_id.", " .
"'".$objData->syain_cd."', " .
$SendRes.")";
$objInsRet = pg_exec($strSQL);
if($objInsRet==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
$intCount=$intCount+1; //何人に送ったか
$Mail_Nasi=0;//初期化
//echo $intCountLog." 通おくったぜ べいべ!<br>";
echo "<script language='javascript'>";
echo "document.getElementById('maxcount').innerHTML ='".pg_numrows($objRecSet)."';";
echo "document.getElementById('count').innerHTML ='".$intCount."';";
echo "</script>";
ob_flush();
flush();
}
if($PHP_POST_DB_FLG==6){
func_point_decrement($PHP_POST_SYAIN_ID,$intCount,0); //ポイント減算
func_LogInput($PHP_POST_SYAIN_ID,$logFrom,$logTo,$logType,$logDate,$intCountLog);
}
}
?>
</BODY>
</HTML>