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
|
<?php header('Access-Control-Allow-Origin:*'); include_once("./_common2.php"); ?> <?php include("../../manage/category/common.php");
$DB_HOST = "localhost"; $DB_USER = "WebHostUser"; $DB_PWD = "WebHost5263"; $DB_NAME = "webhost"; $sqli_dbcon = mysqli_connect($DB_HOST, $DB_USER, $DB_PWD, $DB_NAME);
function filter_SQL($content){ $content = str_replace("&", "&", $content); $content = str_replace("<", "<", $content); $content = str_replace(">", ">", $content); $content = str_replace("'", "'", $content); $content = str_replace("\"", """, $content); $content = str_replace("\r", "", $content); $content = str_replace("'", "", $content); $content = str_replace('"', "", $content); $content = str_replace("--", "", $content); $content = str_replace(";", "", $content); $content = str_replace("%", "", $content); //$content = str_replace("+", "", $content); // 상담분야 선택에서 +가 들어가기때문에 코멘트 $content = str_replace("script", "", $content); $content = str_replace("alert", "", $content); $content = str_replace("cookie", "", $content); $content = SQL_Injection($content);
return $content; }
function SQL_Injection($get_Str) { $Str = preg_replace("/(select|union|insert|update|delete|drop|\"|\'|#|\/\*|\*\/|\\\|\;)/i","", $get_Str); return $Str; }
foreach($_POST as $key=>$val){ $_POST[$key] = filter_SQL($_POST[$key]); }
$sql = "select * from holidays where y = '' or y = '".date("Y")."' "; $res = mysql_query($sql); while($info = mysql_fetch_array($res)){ if($info['y']==''){ $holi[date("Y")."-".$info['m-d']] = "Y"; } else { $holi[$info['y']."-".$info['m-d']] = "Y"; } }
function not_holy_rtn($date){ Global $holi; $time = strtotime($date); $w = date("w",$time); if($w=='0' || $w=='6'){ //_pr("{$date} 휴일"); $date = date("Y-m-d",$time-(60*60*24)); return 1; } else { if($holi[$date]=='Y'){ //_pr("{$date} 휴일"); $date = date("Y-m-d",$time-(60*60*24)); return 1; } } return 0; }
$mode_ok = "Y";
@extract($_POST); $smname = iconv("utf-8","euckr",$smname); $telname = iconv("utf-8","euckr",$telname); $smtel = iconv("utf-8","euckr",$smtel); $s_email = iconv("utf-8","euckr",$s_email);
if($iw == 'mail_way'){ $smdetail = "(M)".$smdetail; }
if($ismobile=='1'){ $smtel = $smtel1."-".$smtel2."-".$smtel3; $smdetail = "고객요청 : ".$smdetail; $smdetail = iconv("utf-8","euckr",$smdetail); $smdetail = "*".$smdetail; }
if($ismobile=='2'){ $smtel = $smtel1."-".$smtel2."-".$smtel3; $smdetail = "고객요청 : ".$smdetail; $smdetail = iconv("utf-8","euckr",$smdetail); }
if($ismode=='1'){ $smdetail = "*".$smdetail; }
if($smdetail == "") { $smdetail = ""; }
$param = date("Y-m-d H:i",time())."%";
$stmt = mysqli_prepare($sqli_dbcon, "select count(*) as cnt from mBoard_install_req where ipadd = ? and reg_date like ?"); // 파라미터를 바인딩 (데이터 타입에 따라 'i'는 정수, 'd'는 실수, 's'는 문자열) $bind = mysqli_stmt_bind_param($stmt, "ss", $_SERVER['REMOTE_ADDR'], $param);
// 쿼리 실행 $exec = mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($result) {
$info = mysqli_fetch_assoc($result); if($info['cnt']>0){ $mode_ok = "N"; $msg = "너무 빠른시간안에 중복으로 요청하셨습니다."; }
// 결과 해제 mysqli_free_result($result); // statement 해제 mysqli_stmt_close($stmt); } else { echo "Error : " . mysqli_error($db_conn); exit; }
// 쿼리 실행 후 정리 mysqli_stmt_close($stmt);
/* $sql = "select count(*) as cnt from mBoard_install_req where ipadd = '".$_SERVER['REMOTE_ADDR']."' and reg_date like '".date("Y-m-d H:i",time())."%' "; $res = mysql_query($sql); $info = mysql_fetch_array($res); if($info['cnt']>0){ $mode_ok = "N"; $msg = "너무 빠른시간안에 중복으로 요청하셨습니다."; } */
$add_insert = ""; if($mode_ok=='Y'){ if($contact_time=='1'){ $date = date("Y-m-d"); $time = date("H:i:s"); $not_work_time = not_holy_rtn($date); if($not_work_time==0){ if(!($time>"08:50:00" && $time<"17:50:00")){ $not_work_time = 1; } } if($not_work_time==1){ $ct_time = "근무시간내에 최대한 빠르게 연락"; } else { $ct_time = "30분이내 연락"; } } else { $ct_time = "{$ct_date} {$ct_hour}시 {$ct_minute}분에 연락"; } $ct = $ct_time; $ct_time = iconv("utf-8","euckr",$ct_time); if("{$ct_date} {$ct_hour}:{$ct_minute}:00"<=date("Y-m-d H:i:s",time()) && $contact_time=='0'){ $mode_ok = "N"; $msg = "금일시분 이후로 선택하시기 바랍니다."; } else { if($smtitle=='PC' || $smtitle=='mobile' || $smtitle=='shopping-pc'){ if($edc_tel=='1' && $edc_email=='1'){ $s_contact = 2; } else if($edc_tel=='1'){ $s_contact = 0; } else if($edc_email=='1'){ $s_contact = 1; }
$add_insert = ", s_email = '{$s_email}', s_contact = '{$s_contact}' "; } if($st_type=='mail_cs'){ $smtitle = "mail-cs"; } if($come_from=='www.easytax.kr' || $come_from=='www.easytax.kr(m)'){ $smtitle = "tax"; } if($come_from=='www.ebizmall.co.kr' || $come_from=='www.ebizmall.co.kr(m)'){ $smtitle = "biz"; } if($come_from==''){ $come_from = 'mjsoft.co'; } $select_content2 = iconv("utf-8","euckr",$select_content2); $select_content2 = str_replace("^","*",$select_content2);
if($inflow_txt != "") { // 유입경로 선택이 있다면 $inflow = iconv("utf-8","euc-kr",$inflow_txt); } else { $inflow = iconv("utf-8","euc-kr","요청게시판 접수"); } if($flow == "c") { $inflow = $inflow."(C)"; }
if($telname == "") { $telname = ""; }
if(trim($smname)!='' && trim($smtel)!='' && trim($smtitle)!=''){ // 인젝션 방지
if($add_insert != "") { $stmt = mysqli_prepare($sqli_dbcon, "insert into mBoard_install_req set smname = ?, smtel = ?, smtitle = ?, telname = ?, smdetail = ?, contact_time = ?, ipadd = ?, reg_date = ?, prog_select = ?, come_from = ?, ismode = ?, s_email = ?, s_contact = ?, inflow = ?"); // 파라미터를 바인딩 (데이터 타입에 따라 'i'는 정수, 'd'는 실수, 's'는 문자열) mysqli_stmt_bind_param($stmt, "ssssssssssssss", $smname, $smtel, $smtitle, $telname, $smdetail, $ct_time, $_SERVER['REMOTE_ADDR'], date("Y-m-d H:i:s",time()), $select_content2, $come_from, $ismode, $s_email, $s_contact, $inflow); } else { $stmt = mysqli_prepare($sqli_dbcon, "insert into mBoard_install_req set smname = ?, smtel = ?, smtitle = ?, telname = ?, smdetail = ?, contact_time = ?, ipadd = ?, reg_date = ?, prog_select = ?, come_from = ?, ismode = ?, inflow = ?"); // 파라미터를 바인딩 (데이터 타입에 따라 'i'는 정수, 'd'는 실수, 's'는 문자열) mysqli_stmt_bind_param($stmt, "ssssssssssss", $smname, $smtel, $smtitle, $telname, $smdetail, $ct_time, $_SERVER['REMOTE_ADDR'], date("Y-m-d H:i:s",time()), $select_content2, $come_from, $ismode, $inflow); }
// 쿼리 실행 if (!mysqli_stmt_execute($stmt)) { mysqli_close($sqli_dbcon); die("ERROR"); }
// 쿼리 실행 후 정리 mysqli_stmt_close($stmt);
/* $sql = "insert into mBoard_install_req set smname = '{$smname}', smtel = '{$smtel}', smtitle = '{$smtitle}', telname = '{$telname}', smdetail = '{$smdetail}', contact_time = '{$ct_time}', ipadd = '".$_SERVER['REMOTE_ADDR']."', reg_date = '".date("Y-m-d H:i:s",time())."', prog_select = '{$select_content2}', come_from = '{$come_from}', ismode = '{$ismode}' {$add_insert} "; $res = mysql_query($sql); */ $mode_ok = "Y"; } else { //print_r($_POST); $mode_ok = "N"; } } }
mysqli_close($sqli_dbcon);
echo "<?php xml version='1.0' encoding='utf-8'?><output>"; echo "<mode>".$mode."</mode>"; echo "<mode_ok>".$mode_ok."</mode_ok>"; echo "<rtn_url>".$rtn_url."</rtn_url>"; echo "<msg>".$msg."</msg>"; echo "<contact_time>".$ct."</contact_time>"; echo "</output>"; ?>
|