'{$write['wr_reply']}' {$sql_search} order by wr_num, wr_reply limit 1 "; $next = sql_fetch($sql); // 위의 쿼리문으로 값을 얻지 못했다면 if (!$next['wr_id']) { $sql = " select wr_id, wr_subject, wr_comment, wr_datetime from {$write_table} where wr_is_comment = 0 and wr_num > '{$write['wr_num']}' {$sql_search} order by wr_num, wr_reply limit 1 "; $next = sql_fetch($sql); } } // 이전글 링크 $prev_href = ''; if (isset($prev['wr_id']) && $prev['wr_id']) { $prev_wr_subject = get_text(cut_str($prev['wr_subject'], 255)); $prev_wr_comment = $prev['wr_comment']; $prev_wr_date = $prev['wr_datetime']; $prev_href = './board.php?bo_table='.$bo_table.'&wr_id='.$prev['wr_id'].$qstr; } // 다음글 링크 $next_href = ''; if (isset($next['wr_id']) && $next['wr_id']) { $next_wr_subject = get_text(cut_str($next['wr_subject'], 255)); $next_wr_comment = $next['wr_comment']; $next_wr_date = $next['wr_datetime']; $next_href = './board.php?bo_table='.$bo_table.'&wr_id='.$next['wr_id'].$qstr; } // 쓰기 링크 $write_href = ''; if ($member['mb_level'] >= $board['bo_write_level']) $write_href = './write.php?bo_table='.$bo_table; // 답변 링크 $reply_href = ''; if ($member['mb_level'] >= $board['bo_reply_level']) $reply_href = './write.php?w=r&bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr; // 수정, 삭제 링크 $update_href = $delete_href = ''; // 로그인중이고 자신의 글이라면 또는 관리자라면 비밀번호를 묻지 않고 바로 수정, 삭제 가능 if (($member['mb_id'] && ($member['mb_id'] === $write['mb_id'])) || $is_admin) { $update_href = './write.php?w=u&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr; set_session('ss_delete_token', $token = uniqid(time())); $delete_href ='./delete.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&token='.$token.'&page='.$page.urldecode($qstr); } else if (!$write['mb_id']) { // 회원이 쓴 글이 아니라면 $update_href = './password.php?w=u&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr; $delete_href = './password.php?w=d&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr; } // 최고, 그룹관리자라면 글 복사, 이동 가능 $copy_href = $move_href = ''; if ($write['wr_reply'] == '' && ($is_admin == 'super' || $is_admin == 'group')) { $copy_href = './move.php?sw=copy&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr; $move_href = './move.php?sw=move&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr; } //$scrap_href = ''; $good_href = ''; $nogood_href = ''; //if ($is_member) { // 스크랩 링크 $scrap_href = ($is_member) ? './scrap_popin.php?bo_table='.$bo_table.'&wr_id='.$wr_id : ''; // 추천 링크 if ($board['bo_use_good']) $good_href = './good.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&good=good'; // 비추천 링크 if ($board['bo_use_nogood']) $nogood_href = './good.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&good=nogood'; //} $view = get_view($write, $board, $board_skin_path); if (strstr($sfl, 'subject')) $view['subject'] = search_font($stx, $view['subject']); $html = 0; if (strstr($view['wr_option'], 'html1')) $html = 1; else if (strstr($view['wr_option'], 'html2')) $html = 2; $is_torrent = false; $is_view_shingo = false; $shingo_txt = ''; if($view['as_shingo'] < 0) { $shingo_txt = '

'.$aslang['wr_lock'].'

'; //블라인더 처리된 글입니다. if($is_admin || ($view['mb_id'] && $view['mb_id'] == $member['mb_id'])) { ; // 관리자 또는 글쓴이는 통과 } else { $is_view_shingo = true; $view['content'] = $view['wr_content'] = ''; // 글내용 지움 } } if(!$is_view_shingo) { $view['content'] = conv_content($view['wr_content'], $html, $board['as_purifier'] ? false : true); if (strstr($sfl, 'content')) $view['content'] = search_font($stx, $view['content']); // APMS 글내용 컨버터 $exceptfile = array(); $autoplay = ''; if($board['as_autoplay'] && $view['file']['count']) { //첨부동영상 오디오 자동실행 // $autoplay_ext = array("mp4", "m4v", "f4v", "mov", "flv", "webm", "acc", "m4a", "f4a", "mp3", "ogg", "oga", "rss"); $autoplay_ext = array("mp4", "webm"); for ($i=0; $i'; $autoplay .= '이 문장이 보이면 video 태그를 지원 하지 않는 브라우저 입니다.'; $autoplay .= ''; $autoplay .= ''; // $autoplay .= apms_jwplayer($view['file'][$i]['path'].'/'.$view['file'][$i]['file'], $screen, $caption, $jw_title); if(count($exceptnum) > 0) $exceptfile = array_merge($exceptfile, $exceptnum); } } //2022-03-06 gif to mp4 변환 if($file['ext'] == "gif"){ list($screen, $caption, $exceptnum) = apms_get_caption($view['file'], $file['name'], $i); // $jw_title = ($view['file'][$i]['content']) ? $view['file'][$i]['content'] : $view['file'][$i]['source']; $mp4_name = str_replace(".gif", ".mp4" ,$view['file'][$i]['file']); $autoplay .= '
'; $autoplay .= ''; $autoplay .= '
'; // $autoplay .= apms_jwplayer($view['file'][$i]['path'].'/mp4/'.$mp4_name, $screen, $caption, $jw_title); if(count($exceptnum) > 0) $exceptfile = array_merge($exceptfile, $exceptnum); } } if(count($exceptfile)) { // 동영상 이미지는 출력이미지에서 제외 $refile = array(); $j = 0; for ($i=0; $i 0) { $view['file'] = $refile['file']; $view['file']['count'] = $j; } } } if(G5_IS_MOBILE) { // 2022-05-07 모바일, pc 가로 크기 따로 $image_width = $board['bo_mobile_image_width']; $origin_image_width = $board['bo_mobile_image_width']; } else { $image_width = $board['bo_image_width']; } // 첨부동영상 function conv_rich_video_content($matches){ global $view; $num = $matches[2]; if(isset($view['file'][$num]['file']) && $view['file'][$num]['file']) $num = $view['file'][$num]['path'].'/'.$view['file'][$num]['file']; $str = ($matches[3]) ? $num.':'.$matches[3] : $num; return '{동영상:'.$str.'}'; } $view['content'] = preg_replace_callback("/{(동영상|video)\:([0-9]+)[:]?([^}]*)}/i", "conv_rich_video_content", $view['content']); $view['content'] = apms_content($view['content']); if($is_link_video) { $view['content'] = $autoplay.apms_link_video($view['link'], '', $seometa['img']['src']).$view['content']; } else { $view['content'] = $autoplay.$view['content']; } //$view['rich_content'] = preg_replace("/{이미지\:([0-9]+)[:]?([^}]*)}/ie", "view_image(\$view, '\\1', '\\2')", $view['content']); if($view['as_img'] == "2") { // 본문삽입 function conv_rich_content($matches){ global $view; return view_image($view, $matches[2], $matches[3]); } $view['content'] = preg_replace_callback("/{(이미지|img)\:([0-9]+)[:]?([^}]*)}/i", "conv_rich_content", $view['content']); } // 토렌트 if($board['as_torrent'] && $view['file']['count']) { //첨부파일에서 토렌트 시드추출 $torrent = apms_get_torrent($view['file'], G5_DATA_PATH.'/file/'.$bo_table); if(count($torrent) > 0) $is_torrent = true; } } $view['content'] = $shingo_txt.$view['content']; //2022-00-00 파싱 게시글이고 동영상 파일이면 본글 안보임 if($view['wr_1'] == "parse" && ($autoplay || $view['wr_file'])) { $view['content'] = $shingo_txt.$autoplay; } // 글쓴이 $author = array(); $is_signature = false; $signature = ''; if($view['mb_id']) { $lvl = ($board['as_level']) ? 'yes' : 'no'; $author = apms_member($view['mb_id'], $lvl, $board['bo_use_name']); if($author['mb_id']) { if(!$author['mb_open']) { $author['mb_email'] = ''; $author['mb_homepage'] = ''; } if ($board['bo_use_signature']) { $is_signature = true; $signature = apms_content(conv_content($author['mb_signature'], 1)); } } } if($is_signature) { $view['photo'] = $author['photo']; } else { $view['photo'] = apms_photo_url($view['mb_id']); } // 신고 $is_shingo = ($board['as_shingo'] > 0) ? true : false; // Tag $is_tag = false; if($view['as_tag']) { $tag_list = apms_get_tag($view['as_tag']); if($tag_list) $is_tag = true; } // 이미지 위치 $is_img_head = ($view['as_img']) ? false : true; // 상단 $is_img_tail = ($view['as_img'] == "1") ? true : false; // 하단 // 페이지 댓글용 $is_view_comment = true; $is_list_page = $page; $page = ''; // 베스트 댓글 $cbest = array(); $cbid = array(); $is_best_cmt = false; if(isset($board['as_best_cmt']) && $board['as_best_cmt'] > 0) { $cbrows = (isset($board['as_rank_cmt']) && $board['as_rank_cmt'] > 0) ? $board['as_rank_cmt'] : 3; // 비밀글, 블라인드글은 제외 $result = sql_query(" select * from {$write_table} where wr_parent = '{$wr_id}' and wr_is_comment = 1 and wr_good >= '{$board['as_best_cmt']}' and as_shingo >= '0' and wr_option not like '%secret%' order by wr_good desc, wr_id desc limit 0, $cbrows ", false); for ($i=0; $row=sql_fetch_array($result); $i++) { $cbest[$i] = $row; $cbwrid = $row['wr_id']; $cbid[$cbwrid] = $i + 1; $tmp_name = get_text(cut_str($row['wr_name'], $config['cf_cut_name'])); // 설정된 자리수 만큼만 이름 출력 if ($board['bo_use_sideview']) { $lvl = ($board['as_level']) ? 'yes' : 'no'; $cbest[$i]['name'] = apms_sideview($row['mb_id'], $tmp_name, $row['wr_email'], $row['wr_homepage'], $row['as_level'], $lvl); // APMS 용으로 교체 } else { $cbest[$i]['name'] = ''.$tmp_name.''; } $cbest[$i]['reply_name'] = ($row['wr_comment_reply'] && $row['as_re_name']) ? $row['as_re_name'] : ''; $chtml = 0; if (strstr($row['wr_option'], 'html1')) $chtml = 1; else if (strstr($row['wr_option'], 'html2')) $chtml = 2; $cbest[$i]['content'] = conv_content($row['wr_content'], $chtml, 'wr_content'); //$cbest[$i]['content'] = preg_replace("/\[\]*\>[^\s]*\<\/a\>\]/i", "\"\"", $cbest[$i]['content']); $cbest[$i]['content'] = preg_replace("/\[\]*\>[^\s]*\<\/a\>\]/i", "\"\"", $cbest[$i]['content']); $cbest[$i]['content'] = apms_content(get_view_thumbnail($cbest[$i]['content'])); //럭키포인트 if($row['as_lucky']) { $best[$i]['content'] = $cbest[$i]['content'].''.str_replace("[point]", number_format($row['as_lucky']), $xp['lucky_msg']); } // 글정리 $cbest[$i]['date'] = strtotime($cbest[$i]['wr_datetime']); $cbest[$i]['datetime'] = substr($cbest['wr_datetime'],2,14); // 관리자가 아니라면 중간 IP 주소를 감춘후 보여줍니다. $cbest[$i]['ip'] = $cbest['wr_ip']; if (!$is_admin) $cbest[$i]['ip'] = preg_replace("/([0-9]+).([0-9]+).([0-9]+).([0-9]+)/", G5_IP_DISPLAY, $row['wr_ip']); } if($i) $is_best_cmt = true; } // 2022-11-16 인기글 체크 lgj // 2024-02-19 wr_num이 0인 글은 패스 lgj $bset_sql = " select wr_hit, wr_best from {$write_table} where wr_id = '{$wr_id}' and wr_num != '0' and wr_is_comment = '0' "; $bset_view = sql_fetch($bset_sql); //2022-03-20 인기글 이동 lgj if(($board['bo_best_count'] <= $bset_view['wr_hit'] && $board['bo_best_count'] != 0 && $bo_table != "best") && $board['bo_best_board'] && !$bset_view['wr_best']) { if (!isset($view['wr_best'])) { sql_query(" ALTER TABLE {$write_table} ADD wr_best TINYINT NOT NULL DEFAULT '0' AFTER wr_num ", false); } // 자료가 많을 경우 대비 설정변경 @ini_set('memory_limit', '-1'); // 원본 파일 디렉토리 $src_dir = G5_DATA_PATH.'/file/'.$bo_table; $save = array(); $ca_name = (isset($_POST['ca_name']) && $_POST['ca_name']) ? $_POST['ca_name'] : ''; $chars_array = array_merge(range(0,9), range('a','z'), range('A','Z')); $sql = " select distinct wr_num from $write_table where wr_id = '{$wr_id}' order by wr_id "; $result = sql_fetch($sql); $wr_num = $result['wr_num']; $move_bo_table = $board['bo_best_board']; // 취약점 18-0075 참고 $sql = "select * from {$g5['board_table']} where bo_table = '".sql_real_escape_string($move_bo_table)."' "; $move_board = sql_fetch($sql); // 존재하지 않다면 if(!$move_board['bo_table']) { return; } $move_write_table = $g5['write_prefix'] . $move_bo_table; $src_dir = G5_DATA_PATH.'/file/'.$bo_table; // 원본 디렉토리 $dst_dir = G5_DATA_PATH.'/file/'.$move_bo_table; // 복사본 디렉토리 $is_same_board = ($bo_table == $move_bo_table) ? true : false; $count_write = 0; $count_comment = 0; $next_wr_num = get_next_num($move_write_table); $sql2 = " select * from $write_table where wr_num = '$wr_num' order by wr_parent, wr_is_comment, wr_comment desc, wr_id "; $result2 = sql_query($sql2); while ($row2 = sql_fetch_array($result2)) { $nick = cut_str($member['mb_nick'], $config['cf_cut_name']); if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) { if(strstr($row2['wr_option'], 'html')) { $log_tag1 = '
'; $log_tag2 = '
'; } else { $log_tag1 = "\n"; $log_tag2 = ''; } } // 분류 $row2['ca_name'] = ($ca_name) ? $ca_name : $row2['ca_name']; // 신고 $as_shingo = ($sw == "move") ? $row2['as_shingo'] : 0; // 에디터 이미지 복사 $tmp_content = ($row2['wr_is_comment']) ? $row2['wr_content'] : apms_editor_image($row2['wr_content'], "copy"); $sql = " insert IGNORE into $move_write_table set wr_num = '$next_wr_num', wr_reply = '{$row2['wr_reply']}', wr_is_comment = '{$row2['wr_is_comment']}', wr_comment = '{$row2['wr_comment']}', wr_comment_reply = '{$row2['wr_comment_reply']}', ca_name = '".addslashes($row2['ca_name'])."', wr_option = '{$row2['wr_option']}', wr_subject = '".addslashes($row2['wr_subject'])."', wr_content = '".addslashes($tmp_content)."', wr_link1 = '".addslashes($row2['wr_link1'])."', wr_link2 = '".addslashes($row2['wr_link2'])."', wr_link1_hit = '{$row2['wr_link1_hit']}', wr_link2_hit = '{$row2['wr_link2_hit']}', wr_hit = '{$row2['wr_hit']}', wr_good = '{$row2['wr_good']}', wr_nogood = '{$row2['wr_nogood']}', mb_id = '{$row2['mb_id']}', wr_password = '{$row2['wr_password']}', wr_name = '".addslashes($row2['wr_name'])."', wr_email = '".addslashes($row2['wr_email'])."', wr_homepage = '".addslashes($row2['wr_homepage'])."', wr_datetime = '".G5_TIME_YMDHIS."', wr_file = '{$row2['wr_file']}', wr_last = '{$row2['wr_last']}', wr_ip = '{$_SERVER['REMOTE_ADDR']}', as_type = '{$row2['as_type']}', as_img = '{$row2['as_img']}', as_list = '{$row2['as_list']}', as_publish = '{$row2['as_publish']}', as_shingo = '{$as_shingo}', as_extra = '{$row2['as_extra']}', as_extend = '{$row2['as_extend']}', as_download = '{$row2['as_download']}', as_down = '{$row2['as_down']}', as_view = '{$row2['as_view']}', as_level = '{$row2['as_level']}', as_lucky = '{$row2['as_lucky']}', as_poll = '{$row2['as_poll']}', as_star_score = '{$row2['as_star_score']}', as_star_cnt = '{$row2['as_star_cnt']}', as_re_mb = '{$row2['as_re_mb']}', as_re_name = '{$row2['as_re_name']}', as_tag = '".addslashes($row2['as_tag'])."', as_map = '".addslashes($row2['as_map'])."', as_icon = '".addslashes($row2['as_icon'])."', as_video = '".addslashes($row2['as_video'])."', as_update = '{$row2['as_update']}', wr_1 = '".addslashes($row2['wr_1'])."', wr_2 = '".addslashes($row2['wr_2'])."', wr_3 = '".$bo_table."', wr_4 = '".$row2['wr_id']."', wr_5 = '".$row2['wr_datetime']."', wr_6 = '".$row2['wr_hit']."', wr_7 = '".$board['bo_best_count']."', wr_8 = '{$_SERVER['REQUEST_URI']}|{$_SERVER['HTTP_REFERER']}', wr_9 = '".addslashes($row2['wr_9'])."', wr_10 = '".addslashes($row2['wr_10'])."' "; sql_query($sql); $insert_id = sql_insert_id(); // 코멘트가 아니라면 if (!$row2['wr_is_comment']) { $save_parent = $insert_id; $sql3 = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row2['wr_id']}' order by bf_no "; $result3 = sql_query($sql3); for ($k=0; $row3 = sql_fetch_array($result3); $k++) { if ($row3['bf_file']) { // 원본파일을 복사하고 퍼미션을 변경 // 제이프로님 코드제안 적용 $copy_file_name = $row3['bf_file']; if($bo_table === $move_bo_table){ if(preg_match('/_copy(\d+)?_(\d+)_/', $copy_file_name, $match)){ $number = isset($match[1]) ? (int) $match[1] : 0; $replace_str = '_copy'.($number + 1).'_'.$insert_id.'_'; $copy_file_name = preg_replace('/_copy(\d+)?_(\d+)_/', $replace_str, $copy_file_name); } else { $copy_file_name = $row2['wr_id'].'_copy_'.$insert_id.'_'.$row3['bf_file']; } } $is_exist_file = is_file($src_dir.'/'.$row3['bf_file']) && file_exists($src_dir.'/'.$row3['bf_file']); if( $is_exist_file ){ @copy($src_dir.'/'.$row3['bf_file'], $dst_dir.'/'.$copy_file_name); @chmod($dst_dir.'/'.$copy_file_name, G5_FILE_PERMISSION); } } $sql = " insert into {$g5['board_file_table']} set bo_table = '$move_bo_table', wr_id = '$insert_id', bf_no = '{$row3['bf_no']}', bf_source = '".addslashes($row3['bf_source'])."', bf_file = '$copy_file_name', bf_download = '{$row3['bf_download']}', bf_content = '".addslashes($row3['bf_content'])."', bf_filesize = '{$row3['bf_filesize']}', bf_width = '{$row3['bf_width']}', bf_height = '{$row3['bf_height']}', bf_type = '{$row3['bf_type']}', bf_datetime = '{$row3['bf_datetime']}' "; sql_query($sql); } // 설문복사 if ($sw == 'copy') { $sql4 = " select * from {$g5['apms_poll']} where bo_table = '$bo_table' and wr_id = '{$row2['wr_id']}' order by po_id "; $result4 = sql_query($sql4); for ($k=0; $row4 = sql_fetch_array($result4); $k++) { $sql = " insert into {$g5['apms_poll']} set bo_table = '$move_bo_table', wr_id = '$insert_id', po_subject = '".addslashes($row4['po_subject'])."', po_poll1 = '".addslashes($row4['po_poll1'])."', po_poll2 = '".addslashes($row4['po_poll2'])."', po_poll3 = '".addslashes($row4['po_poll3'])."', po_poll4 = '".addslashes($row4['po_poll4'])."', po_poll5 = '".addslashes($row4['po_poll5'])."', po_poll6 = '".addslashes($row4['po_poll6'])."', po_poll7 = '".addslashes($row4['po_poll7'])."', po_poll8 = '".addslashes($row4['po_poll8'])."', po_poll9 = '".addslashes($row4['po_poll9'])."', po_score = '{$row4['po_score']}', po_cnt = '{$row4['po_cnt']}', po_cnt1 = '{$row4['po_cnt1']}', po_cnt2 = '{$row4['po_cnt2']}', po_cnt3 = '{$row4['po_cnt3']}', po_cnt4 = '{$row4['po_cnt4']}', po_cnt5 = '{$row4['po_cnt5']}', po_cnt6 = '{$row4['po_cnt6']}', po_cnt7 = '{$row4['po_cnt7']}', po_cnt8 = '{$row4['po_cnt8']}', po_cnt9 = '{$row4['po_cnt9']}', po_use = '{$row4['po_use']}', po_type = '{$row4['po_type']}', po_end = '{$row4['po_end']}', po_level = '{$row4['po_level']}', po_join = '{$row4['po_join']}', po_point = '{$row4['po_point']}', po_datetime = '{$row4['po_datetime']}', po_endtime = '{$row4['po_endtime']}', po_ips = '".addslashes($row4['po_ips'])."', mb_ids = '".addslashes($row4['mb_ids'])."', po_content = '".addslashes($row4['po_content'])."' "; sql_query($sql); } } $count_write++; } else { $count_comment++; } sql_query(" update $move_write_table set wr_parent = '$save_parent' where wr_id = '$insert_id' "); } sql_query(" update {$write_table} set wr_best = '1' where wr_id = '{$wr_id}' "); sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + '$count_write' where bo_table = '$move_bo_table' "); sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + '$count_comment' where bo_table = '$move_bo_table' "); delete_cache_latest($move_bo_table); delete_cache_latest($bo_table); } include_once($board_skin_path.'/view.skin.php'); @include_once($board_skin_path.'/view.tail.skin.php'); $page = $is_list_page; ?>