분류를 선택하세요.'; } } else { $ca_name = ''; } //제목확인 $wr_subject = ''; if (isset($_POST['wr_subject'])) { $wr_subject = substr(trim($_POST['wr_subject']),0,255); $wr_subject = preg_replace("#[\\\]+$#", "", $wr_subject); } if ($wr_subject == '') { $msg[] = '제목을 입력하세요.'; } //내용확인 $wr_content = ''; if (isset($_POST['wr_content'])) { $wr_content = substr(trim($_POST['wr_content']),0,65536); $wr_content = preg_replace("#[\\\]+$#", "", $wr_content); } if ($wr_content == '') { $msg[] = '내용을 입력하세요.'; } //링크확인 $wr_link1 = ''; if (isset($_POST['wr_link1'])) { $wr_link1 = substr($_POST['wr_link1'],0,1000); $wr_link1 = trim(strip_tags($wr_link1)); $wr_link1 = preg_replace("#[\\\]+$#", "", $wr_link1); } $wr_link2 = ''; if (isset($_POST['wr_link2'])) { $wr_link2 = substr($_POST['wr_link2'],0,1000); $wr_link2 = trim(strip_tags($wr_link2)); $wr_link2 = preg_replace("#[\\\]+$#", "", $wr_link2); } //경고출력 $msg = implode('
', $msg); if ($msg) { alert($msg); } $upload_max_filesize = ini_get('upload_max_filesize'); if (empty($_POST)) { alert("파일 또는 글내용의 크기가 서버에서 설정한 값을 넘어 오류가 발생하였습니다.\\npost_max_size=".ini_get('post_max_size')." , upload_max_filesize=".$upload_max_filesize."\\n서버관리자에게 문의 바랍니다."); } $notice_array = explode(",", $board['bo_notice']); $wr_password = isset($_POST['wr_password']) ? $_POST['wr_password'] : ''; $bf_content = isset($_POST['bf_content']) ? (array) $_POST['bf_content'] : array(); $_POST['html'] = isset($_POST['html']) ? clean_xss_tags($_POST['html'], 1, 1) : ''; $_POST['secret'] = isset($_POST['secret']) ? clean_xss_tags($_POST['secret'], 1, 1) : ''; $_POST['mail'] = isset($_POST['mail']) ? clean_xss_tags($_POST['mail'], 1, 1) : ''; if ($w == 'u') { $wr = get_write($write_table, $wr_id); if (!$wr['wr_id']) { alert("해당 게시물이 존재하지 않습니다."); } } //비밀글 체크 $secret = ''; if (isset($_POST['secret']) && $_POST['secret']) { if(preg_match('#secret#', strtolower($_POST['secret']), $matches)) $secret = $matches[0]; } //html 체크 $html = ''; if (isset($_POST['html']) && $_POST['html']) { if(preg_match('#html(1|2)#', strtolower($_POST['html']), $matches)) $html = $matches[0]; } //메일발송 체크 $mail = ''; if (isset($_POST['mail']) && $_POST['mail']) { if(preg_match('#mail#', strtolower($_POST['mail']), $matches)) $mail = $matches[0]; } //공지체크 $notice = ''; if (isset($_POST['notice']) && $_POST['notice']) { $notice = $_POST['notice']; } //여분필드 체크 for ($i=1; $i<=10; $i++) { $var = "wr_$i"; $$var = ""; if (isset($_POST['wr_'.$i]) && settype($_POST['wr_'.$i], 'string')) { $$var = trim($_POST['wr_'.$i]); } } //옵션 $options = array($html,$secret,$mail); $wr_option = implode(',', array_filter(array_map('trim', $options))); if ($w == ""){ if ($member['mb_id']) { $mb_id = $member['mb_id']; $wr_name = addslashes(clean_xss_tags($board['bo_use_name'] ? $member['mb_name'] : $member['mb_nick'])); $wr_password = ''; $wr_email = addslashes($member['mb_email']); $wr_homepage = addslashes(clean_xss_tags($member['mb_homepage'])); } else { $mb_id = ''; // 비회원의 경우 이름이 누락되는 경우가 있음 $wr_name = clean_xss_tags(trim($_POST['wr_name'])); if (!$wr_name) alert('이름은 필히 입력하셔야 합니다.'); $wr_password = get_encrypt_string($wr_password); $wr_email = get_email_address(trim($_POST['wr_email'])); $wr_homepage = clean_xss_tags($wr_homepage); } } $wr_seo_title = exist_seo_title_recursive('bbs', generate_seo_title($wr_subject), $write_table, $wr_id); $wr_num = get_next_num($write_table); $wr_reply = ''; if ($w == "") { $sql = " insert into $write_table set wr_num = '$wr_num', wr_reply = '$wr_reply', wr_comment = 0, ca_name = '$ca_name', wr_option = '$wr_option', wr_subject = '$wr_subject', wr_content = '$wr_content', wr_seo_title = '$wr_seo_title', wr_link1 = '$wr_link1', wr_link2 = '$wr_link2', wr_link1_hit = 0, wr_link2_hit = 0, wr_hit = 0, wr_good = 0, wr_nogood = 0, mb_id = '{$member['mb_id']}', wr_password = '$wr_password', wr_name = '$wr_name', wr_email = '$wr_email', wr_homepage = '$wr_homepage', wr_datetime = '".G5_TIME_YMDHIS."', wr_last = '".G5_TIME_YMDHIS."', wr_ip = '{$_SERVER['REMOTE_ADDR']}' "; sql_query($sql); $wr_id = sql_insert_id(); // 부모 아이디에 UPDATE sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' "); // 새글 INSERT sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) "); // 게시글 1 증가 sql_query("update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}'"); // 공지처리 if ($w == '') { if ($notice) { $bo_notice = $wr_id.($board['bo_notice'] ? ",".$board['bo_notice'] : ''); sql_query(" update {$g5['board_table']} set bo_notice = '{$bo_notice}' where bo_table = '{$bo_table}' "); } } else { } } else if($w == "u") { if ($member['mb_id']) { // 자신의 글이라면 if ($member['mb_id'] === $wr['mb_id']) { $mb_id = $member['mb_id']; $wr_name = addslashes(clean_xss_tags($board['bo_use_name'] ? $member['mb_name'] : $member['mb_nick'])); $wr_email = addslashes($member['mb_email']); $wr_homepage = addslashes(clean_xss_tags($member['mb_homepage'])); } else { $mb_id = $wr['mb_id']; if(isset($_POST['wr_name']) && $_POST['wr_name']) $wr_name = clean_xss_tags(trim($_POST['wr_name'])); else $wr_name = addslashes(clean_xss_tags($wr['wr_name'])); if(isset($_POST['wr_email']) && $_POST['wr_email']) $wr_email = get_email_address(trim($_POST['wr_email'])); else $wr_email = addslashes($wr['wr_email']); if(isset($_POST['wr_homepage']) && $_POST['wr_homepage']) $wr_homepage = addslashes(clean_xss_tags($_POST['wr_homepage'])); else $wr_homepage = addslashes(clean_xss_tags($wr['wr_homepage'])); } } else { $mb_id = ""; // 비회원의 경우 이름이 누락되는 경우가 있음 if (!trim($wr_name)) alert("이름은 필히 입력하셔야 합니다."); $wr_name = clean_xss_tags(trim($_POST['wr_name'])); $wr_email = get_email_address(trim($_POST['wr_email'])); } $sql_password = $wr_password ? " , wr_password = '".get_encrypt_string($wr_password)."' " : ""; $sql_ip = ''; if (!$is_admin) $sql_ip = " , wr_ip = '{$_SERVER['REMOTE_ADDR']}' "; $sql = " update {$write_table} set ca_name = '{$ca_name}', wr_option = '{$wr_option}', wr_subject = '{$wr_subject}', wr_content = '{$wr_content}', wr_seo_title = '$wr_seo_title', wr_link1 = '{$wr_link1}', wr_link2 = '{$wr_link2}', mb_id = '{$mb_id}', wr_name = '{$wr_name}', wr_email = '{$wr_email}', wr_homepage = '{$wr_homepage}' {$sql_ip} {$sql_password} where wr_id = '{$wr['wr_id']}' "; sql_query($sql); // 분류가 수정되는 경우 해당되는 코멘트의 분류명도 모두 수정함 // 코멘트의 분류를 수정하지 않으면 검색이 제대로 되지 않음 $sql = " update {$write_table} set ca_name = '{$ca_name}' where wr_parent = '{$wr['wr_id']}' "; sql_query($sql); $bo_notice = board_notice($board['bo_notice'], $wr_id, $notice); sql_query(" update {$g5['board_table']} set bo_notice = '{$bo_notice}' where bo_table = '{$bo_table}' "); // 글을 수정한 경우에는 제목이 달라질수도 있으니 static variable 를 새로고침합니다. $write = get_write( $write_table, $wr['wr_id'], false); } // 파일개수 체크 $file_count = 0; $upload_count = (isset($_FILES['bf_file']['name']) && is_array($_FILES['bf_file']['name'])) ? count($_FILES['bf_file']['name']) : 0; for ($i=0; $i<$upload_count; $i++) { if($_FILES['bf_file']['name'][$i] && is_uploaded_file($_FILES['bf_file']['tmp_name'][$i])) $file_count++; } if($w == 'u') { $file = get_file($bo_table, $wr_id); if($file_count && (int)$file['count'] > $board['bo_upload_count']) alert('기존 파일을 삭제하신 후 첨부파일을 '.number_format($board['bo_upload_count']).'개 이하로 업로드 해주십시오.'); } else { if($file_count > $board['bo_upload_count']) alert('첨부파일을 '.number_format($board['bo_upload_count']).'개 이하로 업로드 해주십시오.'); } // 디렉토리가 없다면 생성합니다. (퍼미션도 변경하구요.) @mkdir(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); @chmod(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); $chars_array = array_merge(range(0,9), range('a','z'), range('A','Z')); // 가변 파일 업로드 $file_upload_msg = ''; $upload = array(); if(isset($_FILES['bf_file']['name']) && is_array($_FILES['bf_file']['name'])) { for ($i=0; $i $board['bo_upload_size']) { $file_upload_msg .= '\"'.$filename.'\" 파일의 용량('.number_format($filesize).' 바이트)이 게시판에 설정('.number_format($board['bo_upload_size']).' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n'; continue; } //=================================================================\ // 090714 // 이미지나 플래시 파일에 악성코드를 심어 업로드 하는 경우를 방지 // 에러메세지는 출력하지 않는다. //----------------------------------------------------------------- $timg = @getimagesize($tmp_file); // image type if ( preg_match("/\.({$config['cf_image_extension']})$/i", $filename) || preg_match("/\.({$config['cf_flash_extension']})$/i", $filename) ) { if ($timg['2'] < 1 || $timg['2'] > 18) continue; } //================================================================= $upload[$i]['image'] = $timg; // 4.00.11 - 글답변에서 파일 업로드시 원글의 파일이 삭제되는 오류를 수정 if ($w == 'u') { // 존재하는 파일이 있다면 삭제합니다. $row = sql_fetch(" select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i' "); if(isset($row['bf_file']) && $row['bf_file']){ $delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row['bf_file']), $row); if( file_exists($delete_file) ){ @unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']); } // 이미지파일이면 썸네일삭제 if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) { delete_board_thumbnail($bo_table, $row['bf_file']); } } } // 프로그램 원래 파일명 $upload[$i]['source'] = $filename; $upload[$i]['filesize'] = $filesize; // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함 $filename = preg_replace("/\.(php|pht|phtm|htm|cgi|pl|exe|jsp|asp|inc|phar)/i", "$0-x", $filename); shuffle($chars_array); $shuffle = implode('', $chars_array); // 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925) $upload[$i]['file'] = md5(sha1($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.replace_filename($filename); $dest_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$upload[$i]['file']; // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다. $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]); // 올라간 파일의 퍼미션을 변경합니다. chmod($dest_file, G5_FILE_PERMISSION); $dest_file = run_replace('write_update_upload_file', $dest_file, $board, $wr_id, $w); $upload[$i] = run_replace('write_update_upload_array', $upload[$i], $dest_file, $board, $wr_id, $w); } } // end for } // end if // 나중에 테이블에 저장하는 이유는 $wr_id 값을 저장해야 하기 때문입니다. for ($i=0; $i=0; $i--) { $row2 = sql_fetch(" select bf_file from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "); // 정보가 있다면 빠집니다. if (isset($row2['bf_file']) && $row2['bf_file']) break; // 그렇지 않다면 정보를 삭제합니다. sql_query(" delete from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "); } // 파일의 개수를 게시물에 업데이트 한다. $row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' "); sql_query(" update {$write_table} set wr_file = '{$row['cnt']}' where wr_id = '{$wr_id}' "); // 자동저장된 레코드를 삭제한다. sql_query(" delete from {$g5['autosave_table']} where as_uid = '{$uid}' "); //------------------------------------------------------------------------------ delete_cache_latest($bo_table); if ($file_upload_msg) { alert($file_upload_msg); } if($w == "u") { goto_url("./bbs_form.php?w=u&wr_id=$wr_id&sca=$sca&$qstr&bo_table=$bo_table"); } else if ($w == "") { goto_url("./bbs_list.php?$qstr&bo_table=$bo_table"); }