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
|
<?php include("./category/common.php");
$uid = $_REQUEST['uid']; $r_id = $_REQUEST['r_id'];
//$uid = "32875"; //$r_id = "ryunen";
function mail_log_write($post, $mail){ // post, mail 로그 Global $r_id; if($post!=''){ ob_start(); print_r($post); $res = ob_get_contents(); ob_end_clean(); //$res = iconv("euckr","utf-8",$res); } if($mail!=""){ ob_start(); print_r($mail); echo chr(10).chr(13); $res = ob_get_contents(); ob_end_clean(); }
$datetime = date("[Y-m-d H:i:s]",time()); $date_dir = date("Y-m-d",time()); $month_dir = date("Y-m",time()); $file_name = "M_{$r_id}-{$date_dir}";
@mkdir($_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/{$month_dir}"); @chmod($_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/{$month_dir}",0707);
$fp = fopen($_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/{$month_dir}/{$file_name}",'a'); fwrite($fp,$datetime.chr(10).$res); fclose($fp);
@chmod($_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/{$month_dir}/{$file_name}",0707);
if($handle = opendir($_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/")) { while(false !== ($entry = readdir($handle))) { if($entry == '.' || $entry == '..') continue;
$path = $_SERVER['DOCUMENT_ROOT']."/sql_log/rep_mail_log/".$entry;
if(is_dir($path)) $directory[] = $path; } }
flush();
$m6 = strtotime("-6 month $day"); // 6개월 이전껀 삭제 $key_date = date("Y-m",$m6);
foreach($directory as $dir){ $v = explode("/",$dir); $vv = $v[count($v)-1]; if($vv<$key_date){ if($dir!=''){ exec("rm -rf {$dir}"); } } }
}
mail_log_write($_POST, '');
$sql = "set names utf8"; $res = mysql_query($sql);
$sql = "select a.*, b.name as reply_name, b.content as reply_content, b.uid as rep_uid, c.programName from mBoard_as a left join mBoard_as b on a.fid = b.fid and b.thread = 'AA' left join cate3_info c on a.Msw1 = c.category_code where a.uid = '{$uid}' "; $res = mysql_query($sql); $as_info = mysql_fetch_array($res);
mail_log_write('', $sql.chr(10).chr(13));
if($as_info['mail_send_ok']=='1'){ mail_log_write('', "FAIL 이미 보낸 메일"); echo "FAIL 이미 보낸 메일"; } else if($as_info['mail_reply_yn']=='Y' && $as_info['email']!='' && strpos($as_info['email'],"@")>0){
$loginUrl = "http://mjsoft.co/html/millennium/customeras_mail.php";
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch);
$as_info['content'] = nl2br($as_info['content']); $as_info['reply_content'] = nl2br($as_info['reply_content']);
$result = str_replace("#아이디#",$as_info['id'],$result); $result = str_replace("#질문날짜#",date("Y년 m월 d일",$as_info['reg_date']),$result); $result = str_replace("#상담제목#","[질문과 답변] ".$as_info['subject'],$result); $result = str_replace("#프로그램#",$as_info['programName'],$result); $result = str_replace("#답변자#",$as_info['reply_name'],$result); $result = str_replace("#문의내용#",$as_info['content'],$result); $result = str_replace("#답변내용#",$as_info['reply_content'],$result);
include($_SERVER['DOCUMENT_ROOT']."/emillennium/lib/PHPMailer5/PHPMailerAutoload.php"); // phpmailer 5 모듈 그누보드 2.0 모듈하고 몇몇 명령어나 대소문자나 기타 틀림
$smtp_use = "smtp.naver.com"; $smtp_port = "465"; $smtp_mail_id = "1000y3"; //$smtp_mail_pw = "mjsoft8680!"; $smtp_mail_pw = "mj15668680!";
$send_email = "1000y3@naver.com"; $send_name = "엠제이소프트"; $recv_email = $as_info['email']; $email_subject = "문의하신 내용에 대한 답변이 처리되었습니다.";
$email_content = $result;
if($as_info['email']=='ryunen@naver.com'){ $sql = "select password(concat(uid,id)) as keycode from mBoard_as where uid = '{$as_info['rep_uid']}' "; $res = mysql_query($sql); $kc_info = mysql_fetch_array($res); $email_content .= "<img src='http://mjsoft.co/manage/reply_mail_ck_view.php?keycode={$kc_info['keycode']}' style='display:none;'>"; $email_content .= "<iframe src='http://mjsoft.co/manage/reply_mail_ck_view.php?keycode={$kc_info['keycode']}' style='width:100px;height:1px;'></iframe>"; }
$mail = new PHPMailer; $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = $smtp_use; $mail->SMTPAuth = true; $mail->Port = $smtp_port; $mail->SMTPSecure = "ssl"; // SSL을 사용함 $mail->Username = $smtp_mail_id; $mail->Password = $smtp_mail_pw;
$mail->setFrom($send_email, $send_name); $mail->addAddress($recv_email); $mail->Subject = $email_subject; $mail->isHTML(true); $mail->Body = "{$email_content}<br>";
$mail_log[] = $mail_site; $mail_log[] = $r_id; $mail_log[] = $send_email; $mail_log[] = $send_name; $mail_log[] = $recv_email; $mail_log[] = $email_subject; $mail_log[] = $email_content; mail_log_write('', $mail_log);
if (!$mail->send()) { echo "FAIL"; } else { echo "OK"; $mail->ErrorInfo = "OK";
$sql = "update mBoard_as set mail_send_ok = '1' where uid = '{$uid}' "; mysql_query($sql); } mail_log_write('', $mail->ErrorInfo);
} else { mail_log_write('', "FAIL 이메일 없거나 비수신인 사용자"); echo "FAIL 이메일 없거나 비수신인 사용자"; }
?>
|