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
|
<?php $dir = "."; include_once($dir."/_common.php");
$ref = $_SERVER['HTTP_REFERER']; if(strpos($ref,"/shopm/")>0){ $is_mobile = 1; $j3_shop_url = $j3_shopm_url; $w_content = nl2br2($w_content); }
$begin_reply_char = 'A'; $end_reply_char = 'Z';
//_pr($_POST); exit;
$bbsinfo = bbs_info($b_table); // 게시판 정보 가져오기 //$cust_info = customer_info_get($id_ccode); // 회원 정보 가져오기 $cust_info = $cinfo;
function board_file($b_table, $idx, $files, $add_file_del){ Global $j3, $table_name, $_POST;
function delete_file($b_table, $idx, $key){ // 파일 정보 삭제 Global $j3; $sql = "select * from shop_bbs_file where b_table = '{$b_table}' and b_idx = '{$idx}' and b_no = '{$key}' "; $info = sql_fetch($sql,$j3['connect_j3']); if($info['b_idx']!=''){ unlink("{$j3['j3_data_path']}/bbs/{$b_table}/{$info['b_filename']}"); $sql = "delete from shop_bbs_file where b_table = '{$b_table}' and b_idx = '{$idx}' and b_no = '{$key}' "; mysql_query($sql,$j3['connect_j3']); } }
foreach($files['name'] as $key=>$val){ if($_POST['add_file_del_'.$key]=='1'){ // 삭제 체크시 delete_file($b_table, $idx, $key); } if($val!=''){ $val = preg_replace("/\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", $val);
delete_file($b_table, $idx, $key); // 파일이 바뀌면 깔끔하게 기존 정보 지운다. $save_name = "{$b_table}_{$idx}_{$key}_".time(); $dest = "{$j3['j3_data_path']}/bbs/{$b_table}/"; @mkdir($dest, G5_DIR_PERMISSION); @chmod($dest, G5_DIR_PERMISSION); $img_size = getimagesize($files['tmp_name'][$key]); move_uploaded_file($files['tmp_name'][$key],$dest.$save_name); @chmod($dest.$save_name, G5_FILE_PERMISSION); $sql = "insert into shop_bbs_file set b_table = '{$b_table}', b_idx = '{$idx}', b_no = '{$key}' , b_oriname = '{$val}', b_filename = '$save_name', b_download = 0, b_filesize = '{$files['size'][$key]}', b_width = '{$img_size[0]}', b_height = '{$img_size[1]}', b_regdate = '".G5_TIME_YMDHIS."' "; mysql_query($sql,$j3['connect_j3']); } }
$sql = "select ifnull(count(*),0) as cnt from shop_bbs_file where b_table = '{$b_table}' and b_idx = '{$idx}' "; $cnt_info = sql_fetch($sql,$j3['connect_j3']); $sql = "update $table_name set w_file = '{$cnt_info['cnt']}' where idx = '{$idx}' "; mysql_query($sql,$j3['connect_j3']); }
$mode_ok = "Y";
$all_sql = "";
$bbs_info = bbs_info($b_table); foreach($_FILES['add_file']['name'] as $key=>$val){ // 파일 허용용량 체크 if($val!=''){ if($_FILES['add_file']['size'][$key]>$bbs_info['b_file_size']){ alert("{$val} 파일의 용량이 초과되었습니다. {$_FILES['add_file']['size'][$key]} / {$bbs_info['b_file_size']}"); } } }
if($_GET['spam']=='Y'){ if($idx!=''){ $sql = "select * from {$table_name} where idx = '{$idx}' "; $pinfo = sql_fetch($sql,$connect_j3);
$enc_w_passwd = hash("sha256",$w_passwd); if($pinfo['w_passwd']!=$enc_w_passwd){ $mode_ok = "N"; $msg = "비밀번호가 틀렸습니다."; } } if($captcha_input!=$_SESSION['captcha_code']){ $mode_ok = "N"; $msg = "스팸방지 코드가 틀렸습니다.{$captcha_input}"; } } else if($c_mode=='dcom' && $mode_ok=='Y'){ // 대댓글 삭제
$sql = "select * from {$table_name} where idx = '{$pcode}' "; $pinfo = sql_fetch($sql,$connect_j3); //if($pinfo['w_ecode']==$id_code || $pinfo['w_ccode']==$id_ccode || $id!=''){ // 작성자이면 바로 삭제, 관리자이면 바로 삭제 if($pinfo['w_ecode']==$id_code || $pinfo['w_ccode']==$id_ccode){ // 작성자이면 바로 삭제 update_del_log($table_name, "idx", $pcode,"del"); // 삭제 로그 처리
$sql = "delete from {$table_name} where idx = '{$pcode}' "; mysql_query($sql,$connect_j3); } else if($w_passwd!=''){ // 비회원이면서 비밀번호 있으면 비교후 삭제 $w_passwd = hash("sha256",$w_passwd); if($pinfo['w_passwd']==$w_passwd){ update_del_log($table_name, "idx", $pcode,"del"); // 삭제 로그 처리
$sql = "delete from {$table_name} where idx = '{$pcode}' "; mysql_query($sql,$connect_j3); } else { $mode = "comment"; $mode_ok = "N"; $msg = "비밀번호가 틀렸습니다."; } } else { $mode = "comm_passwd"; $mode_ok = "N"; $msg = "비밀번호를 입력하세요."; } } else if($c_mode=='ecom' && $mode_ok=='Y'){ // 대댓글 수정 if($w_passwd!=''){ $sql = "select * from {$table_name} where idx = '{$pcode}' "; $pinfo = sql_fetch($sql,$connect_j3); $w_passwd = hash("sha256",$w_passwd); if($pinfo['w_passwd']!=$w_passwd){ $msg = "비밀번호가 틀렸습니다."; $mode_ok = "N"; } } if($mode_ok=='Y'){ $sql = "update {$table_name} set w_content ='{$w_content}', w_name ='{$w_name}', w_editdate ='".G5_TIME_YMDHIS."' where idx = '{$pcode}' "; $res = mysql_query($sql,$connect_j3);
update_del_log($table_name, "idx", $pcode,""); // 업데이트 로그 처리 } } else if($c_mode=='ccom' && $mode_ok=='Y'){ // 대댓글 추가 repeat_reg_exp();
if($bbsinfo['b_comt_lv']>$cust_info['mb_lv']){ $mode_ok = "N"; $msg = "댓글을 작성할 권한이 없습니다."; }
if($mode_ok=="Y"){ $sql = "select * from {$table_name} where idx = '{$pcode}' "; $pinfo = sql_fetch($sql,$connect_j3);
$sql = "select max(w_subject) as maxchar from {$table_name} where w_parent = '{$pinfo['w_parent']}' and w_comment > 0 and w_subject <> '' "; $maxinfo = sql_fetch($sql,$connect_j3);
$w_num = $pinfo['w_num']; $w_reply = ""; $w_parent = $pinfo['w_parent']; $w_comment = $pinfo['w_comment']; if($maxinfo['maxchar']==''){ $w_subject = $begin_reply_char; } else { $w_subject = chr(ord($maxinfo['maxchar']) + 1); } if($w_passwd!=''){ $w_passwd = hash("sha256",$w_passwd); }
$sql = "insert into {$table_name} set w_num ='{$w_num}', w_reply ='{$w_reply}', w_parent ='{$w_parent}', w_comment ='{$w_comment}', w_cate ='{$w_cate}', w_subject ='{$w_subject}', w_content ='{$w_content}', w_notice ='{$w_notice}', w_hit ='0', w_ecode ='{$w_ecode}', w_ccode ='{$id_ccode}', w_login_id ='{$id_cust}', w_passwd ='{$w_passwd}', w_name ='{$w_name}', w_email ='{$w_email}', w_regdate ='".G5_TIME_YMDHIS."', w_ip ='{$_SERVER['REMOTE_ADDR']}' "; $res = mysql_query($sql,$connect_j3); $idx = mysql_insert_id($connect_j3); $_SESSION['bbs_time'] = time(); } } else if($mode=='comment' && $mode_ok=='Y'){ // 댓글 추가 repeat_reg_exp();
if($bbsinfo['b_comt_lv']>$cust_info['mb_lv']){ $mode_ok = "N"; $msg = "댓글을 작성할 권한이 없습니다."; }
if($mode_ok=="Y"){ $sql = "select * from {$table_name} where idx = '{$pcode}' "; $pinfo = sql_fetch($sql,$connect_j3);
$sql = "select ifnull(max(w_comment),0) as cnt from {$table_name} where w_parent = '{$pcode}' and w_comment > 0 and w_subject = '' "; $maxinfo = sql_fetch($sql,$connect_j3);
$w_num = $pinfo['w_num']; $w_reply = ""; $w_parent = $pcode; $w_comment = $maxinfo['cnt']+1; if($w_passwd!=''){ $w_passwd = hash("sha256",$w_passwd); }
$sql = "insert into {$table_name} set w_num ='{$w_num}', w_reply ='{$w_reply}', w_parent ='{$w_parent}', w_comment ='{$w_comment}', w_cate ='{$w_cate}', w_subject ='{$w_subject}', w_content ='{$w_content}', w_notice ='{$w_notice}', w_hit ='0', w_ecode ='{$w_ecode}', w_ccode ='{$id_ccode}', w_login_id ='{$id_cust}', w_passwd ='{$w_passwd}', w_name ='{$w_name}', w_email ='{$w_email}', w_regdate ='".G5_TIME_YMDHIS."', w_ip ='{$_SERVER['REMOTE_ADDR']}' "; $res = mysql_query($sql,$connect_j3); $idx = mysql_insert_id($connect_j3); $_SESSION['bbs_time'] = time(); }
} else if($sel_del=='Y' && $mode_ok=='Y'){ // 삭제 $mode = "delete";
$code_list = ""; foreach($code_idx as $key=>$val){ $code_list .= "{$codes[$val]},"; } if($mode_ok=='Y'){
$code_list = substr($code_list,0,strlen($code_list)-1);
$sql = "select * from {$table_name} where idx = '{$code_list}' "; $pinfo = sql_fetch($sql,$connect_j3);
if($pinfo['w_login_id']=='' && $w_passwd==''){ $mode_ok = "D"; $pwd_idx = $pinfo['idx']; $msg = "비회원 게시물입니다. 비밀번호를 입력하세요."; } else if($pinfo['w_login_id']==''){ $enc_w_passwd = hash("sha256",$w_passwd); if($enc_w_passwd!=$pinfo['w_passwd']){ $mode_ok = "N"; $msg = "비밀번호가 틀렸습니다."; } }
if($mode_ok=='Y'){ $idx_list = ""; $sql = "select b.idx from {$table_name} a left join {$table_name} b on a.idx = b.w_parent where a.idx in ($code_list) "; $res = mysql_query($sql,$connect_j3); while($info=mysql_fetch_array($res)){ $idx_list .= "{$info['idx']},"; } $idx_list = substr($idx_list,0,strlen($idx_list)-1);
update_del_log($table_name, "idx", $idx_list,"del"); // 삭제 로그 처리 $sql = "delete from {$table_name} where idx in ({$idx_list}) and w_ccode = '{$id_ccode}' "; $res = mysql_query($sql,$connect_j3); $all_sql .= $sql; } } } else if($idx!='' && $mode_ok=='Y'){ // 수정 $mode = "update";
$sql = "select * from {$table_name} where idx = '{$idx}' "; $pinfo = sql_fetch($sql,$connect_j3);
if($pinfo['w_login_id']==''){ if($captcha_input!=$_SESSION['captcha_code']){ alert("스팸방지 코드가 틀렸습니다.{$captcha_input}"); exit; } if($w_passwd==''){ alert("비밀번호를 입력하세요."); exit; } $enc_w_passwd = hash("sha256",$w_passwd); if($enc_w_passwd!=$pinfo['w_passwd']){ alert("비밀번호가 틀렸습니다."); exit; } }
$sql = "update {$table_name} set w_cate ='{$w_cate}', w_subject ='{$w_subject}', w_content ='{$w_content}', w_notice ='{$w_notice}', w_name ='{$w_name}', w_email ='{$w_email}', w_editdate ='".G5_TIME_YMDHIS."' where idx = '{$idx}' "; $res = mysql_query($sql,$connect_j3);
update_del_log($table_name, "idx", $idx,""); // 업데이트 로그 처리
board_file($b_table, $idx,$_FILES['add_file'], $add_file_del); //exit; } else if($idx=='' && $pcode!=''){ // 답변글 추가 $mode = "reply"; repeat_reg_exp();
$sql = "select * from {$table_name} where idx = '{$pcode}' "; $pinfo = sql_fetch($sql,$connect_j3);
if($pinfo['idx']!=''){ if (strlen($pinfo['w_reply']) == 10) { alert("더 이상 답변하실 수 없습니다.\\n답변은 10단계 까지만 가능합니다."); } $reply_len = strlen($pinfo['w_reply']) + 1;
$sql = "select max(substring(w_reply,{$reply_len},1)) as reply from {$table_name} where w_num = {$pinfo['w_num']} and substring(w_reply,{$reply_len},1) <> '' "; $replay_get = sql_fetch($sql,$connect_j3); $rep_char = chr(ord($replay_get['reply']) + 1); $w_num = $pinfo['w_num']; if($replay_get['reply']==''){ $w_rep = $begin_reply_char; } else if($replay_get['reply']==$end_reply_char){ alert('더 이상 답변하실 수 없습니다.\\n답변은 26개 까지만 가능합니다.'); } else { $w_rep = $rep_char; } $w_reply = $pinfo['w_reply'].$w_rep; $w_parent = ""; $w_comment = 0; if($w_passwd!=''){ $w_passwd = hash("sha256",$w_passwd); }
$sql = "insert into {$table_name} set w_num ='{$w_num}', w_reply ='{$w_reply}', w_parent ='{$w_parent}', w_comment ='{$w_comment}', w_cate ='{$w_cate}', w_subject ='{$w_subject}', w_content ='{$w_content}', w_notice ='{$w_notice}', w_hit ='0', w_ecode ='{$w_ecode}', w_ccode ='{$id_ccode}', w_login_id ='{$id_cust}', w_passwd ='{$w_passwd}', w_name ='{$w_name}', w_email ='{$w_email}', w_regdate ='".G5_TIME_YMDHIS."', w_ip ='{$_SERVER['REMOTE_ADDR']}' "; $res = mysql_query($sql,$connect_j3); $idx = mysql_insert_id($connect_j3); $sql = "update {$table_name} set w_parent = '{$idx}' where idx = '{$idx}' "; mysql_query($sql,$connect_j3);
board_file($b_table, $idx,$_FILES['add_file'], $add_file_del);
$_SESSION['bbs_time'] = time(); } else { alert('답변 부모 게시물이 없습니다.'); }
} else { // 신규시 $mode = "new";
if($bbsinfo['b_list_lv']>$cust_info['mb_lv']){ alert("게시판리스트를 볼 권한이 없습니다."); exit; }
if($id_ccode==''){ if($captcha_input!=$_SESSION['captcha_code']){ alert("스팸방지 코드가 틀렸습니다.{$captcha_input}"); exit; } }
repeat_reg_exp();
$w_num = board_last_w_num($table_name); $w_reply = ""; $w_parent = ""; $w_comment = 0; if($w_passwd!=''){ $w_passwd = hash("sha256",$w_passwd); }
$sql = "insert into {$table_name} set w_num ='{$w_num}', w_reply ='{$w_reply}', w_parent ='{$w_parent}', w_comment ='{$w_comment}', w_cate ='{$w_cate}', w_subject ='{$w_subject}', w_content ='{$w_content}', w_notice ='{$w_notice}', w_hit ='0', w_ecode ='{$w_ecode}', w_ccode ='{$id_ccode}', w_login_id ='{$id_cust}', w_passwd ='{$w_passwd}', w_name ='{$w_name}', w_email ='{$w_email}', w_regdate ='".G5_TIME_YMDHIS."', w_ip ='{$_SERVER['REMOTE_ADDR']}' "; $res = mysql_query($sql,$connect_j3); $idx = mysql_insert_id($connect_j3); $sql = "update {$table_name} set w_parent = '{$idx}' where idx = '{$idx}' "; mysql_query($sql,$connect_j3);
board_file($b_table, $idx,$_FILES['add_file'], $add_file_del);
$_SESSION['bbs_time'] = time();
if($config['mail_bbs_admin']=='1' || $config['mail_bbs_writer']=='1'){ // 기본환경설정 게시판작성시 관리자나 회원에게 통보 ob_start(); include_once ("{$j3_shop_path}/mail/board_mail.php"); $ma_content = ob_get_contents(); ob_end_clean();
$ma_subject = "[{$config['shop_title']}] {$bbsinfo['b_title']} 게시판에 {$w_name}님 께서 글을 올렸습니다.";
if($config['mail_bbs_admin']=='1'){ // 게시판 작성시 -> 관리자에게 통보 $snd_email = $config['admin_email']; $rcv_email = $config['admin_email']; $mail = new PHPMailer; $rtn = email_send($mail, $ma_subject, $ma_content, $snd_email, $rcv_email); } if($config['mail_bbs_writer']=='1'){ // 게시판 작성시 -> 작성자에게 통보 $snd_email = $config['admin_email']; $rcv_email = $w_email; $mail = new PHPMailer; $rtn = email_send($mail, $ma_subject, $ma_content, $snd_email, $rcv_email); } } }
//_pr($_POST); exit; if($mode=='reply'){ $qstr = qstr_except($qstr,'idx'); } // 답변작성후 리스트로 돌아가기 위해서
if($mode=='comment' || $mode=='comm_passwd' || $mode=='delete' || $_GET['spam']=='Y'){ 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 "<pwd_idx>".$pwd_idx."</pwd_idx>"; //echo "<sql>".$all_sql."</sql>"; echo "</output>"; } else { ?> <script> document.location.href='<?php echo $j3_shop_url;?>/board.php?<?php echo $qstr;?>'; </script> <?php } ?>
|