0; $i--) {
$parent_code = implode('-', array_slice($parts, 0, $i));
$sql = "SELECT COUNT(*) as cnt FROM rb_topvisual
WHERE v_code = '{$parent_code}' AND co_topvisual_all = 1";
$row = sql_fetch($sql);
if (isset($row['cnt']) && $row['cnt'] > 0) {
return true;
}
}
return false;
}
// 노드가 등록되지않은 경우 인서트 (접속 기준 상위 노드를 찾는다)
function rb_auto_insert_node_if_inherited($v_code, $table = 'rb_topvisual') {
// 1. 현재 노드가 DB에 존재하는지 확인
$chk_sql = "SELECT COUNT(*) as cnt FROM {$table} WHERE v_code = '{$v_code}'";
$chk = sql_fetch($chk_sql);
if (isset($chk['cnt']) && $chk['cnt'] > 0) {
return; // 이미 존재 → 등록 안함
}
$rb_page_url = $_SERVER['REQUEST_URI'];
// 2. 상위 노드 중 co_topvisual_all = 1 인 노드 찾기
$parts = explode('-', $v_code);
for ($i = count($parts) - 1; $i > 0; $i--) {
$parent_code = implode('-', array_slice($parts, 0, $i));
$parent_sql = "SELECT * FROM {$table}
WHERE v_code = '{$parent_code}'
AND co_topvisual_all = 1
LIMIT 1";
$parent = sql_fetch($parent_sql);
if ($parent) {
$v_url = $rb_page_url;
$v_use = 1;
$v_time = G5_TIME_YMDHIS;
// 기본 필드
$columns = ['v_code', 'v_name', 'v_url', 'v_use', 'co_topvisual_all', 'v_time'];
$values = ["'{$v_code}'", "''", "'{$v_url}'", "'{$v_use}'", "'0'", "'{$v_time}'"];
// 스타일도 상속할 경우
if (isset($parent['co_topvisual_style_all']) && intval($parent['co_topvisual_style_all']) === 1) {
$style_fields = [
'co_topvisual_height',
'co_topvisual_width',
'co_topvisual_bl',
'co_topvisual_border',
'co_topvisual_radius',
'co_topvisual_m_color',
'co_topvisual_m_size',
'co_topvisual_m_font',
'co_topvisual_m_align',
'co_topvisual_s_color',
'co_topvisual_s_size',
'co_topvisual_s_font',
'co_topvisual_s_align',
'co_topvisual_bg_color',
'co_topvisual_main'
];
foreach ($style_fields as $field) {
$columns[] = $field;
$values[] = "'" . addslashes($parent[$field] ?? '') . "'";
}
}
// INSERT 쿼리 실행
$insert_sql = "INSERT INTO {$table} (" . implode(', ', $columns) . ")
VALUES (" . implode(', ', $values) . ")";
sql_query($insert_sql);
// 파일 복사: /data/topvisual/{parent_code}.txt / .jpg → {v_code}.txt / .jpg
$topvisual_path = G5_DATA_PATH . '/topvisual';
$exts = ['txt', 'jpg'];
foreach ($exts as $ext) {
$source = "{$topvisual_path}/{$parent_code}.{$ext}";
$target = "{$topvisual_path}/{$v_code}.{$ext}";
if (file_exists($source)) {
@copy($source, $target);
}
}
break;
}
}
}
// 상위노드명 출력
function rb_get_inherited_topvisual_node($v_code, $table = 'rb_topvisual') {
$parts = explode('-', $v_code);
for ($i = count($parts) - 1; $i > 0; $i--) {
$parent_code = implode('-', array_slice($parts, 0, $i));
$sql = "SELECT v_code, v_name, v_url FROM {$table}
WHERE v_code = '{$parent_code}' AND co_topvisual_all = 1 LIMIT 1";
$row = sql_fetch($sql);
if ($row) {
return $row; // 전체 정보 반환
}
}
return null;
}
// 기본 조건: 현재 노드가 사용 또는 전체사용일 때
if (isset($rb_v_info['v_use']) && in_array(intval($rb_v_info['v_use']), [1, 2])) {
$should_show_visual = true;
}
// 추가 조건: 상위 노드 중 co_topvisual_all = 1이 있는 경우
elseif (rb_has_topvisual_all($rb_page_urls)) {
$should_show_visual = true;
}
$rb_v_info['topvisual_height'] = !empty($rb_v_info['co_topvisual_height']) ? $rb_v_info['co_topvisual_height'] : '200'; // 상단영역 세로크기
$rb_v_info['topvisual_width'] = !empty($rb_v_info['co_topvisual_width']) ? $rb_v_info['co_topvisual_width'] : ''; // 상단영역 가로크기
$rb_v_info['topvisual_bl'] = isset($rb_v_info['co_topvisual_bl']) ? $rb_v_info['co_topvisual_bl'] : '10'; // 상단영역 블라인드
$rb_v_info['topvisual_border'] = isset($rb_v_info['co_topvisual_border']) ? $rb_v_info['co_topvisual_border'] : '0'; // 상단영역 테두리
$rb_v_info['topvisual_radius'] = isset($rb_v_info['co_topvisual_radius']) ? $rb_v_info['co_topvisual_radius'] : '10'; // 상단영역 라운드
$rb_v_info['topvisual_m_color'] = !empty($rb_v_info['co_topvisual_m_color']) ? $rb_v_info['co_topvisual_m_color'] : '#ffffff'; // 상단영역 메인워딩 컬러
$rb_v_info['topvisual_m_size'] = !empty($rb_v_info['co_topvisual_m_size']) ? $rb_v_info['co_topvisual_m_size'] : '20'; // 상단영역 메인워딩 사이즈
$rb_v_info['topvisual_m_font'] = !empty($rb_v_info['co_topvisual_m_font']) ? $rb_v_info['co_topvisual_m_font'] : 'font-B'; // 상단영역 메인워딩 두께
$rb_v_info['topvisual_m_align'] = !empty($rb_v_info['co_topvisual_m_align']) ? $rb_v_info['co_topvisual_m_align'] : 'left'; // 상단영역 메인워딩 정렬
$rb_v_info['topvisual_s_color'] = !empty($rb_v_info['co_topvisual_s_color']) ? $rb_v_info['co_topvisual_s_color'] : '#ffffff'; // 상단영역 서브워딩 컬러
$rb_v_info['topvisual_s_size'] = !empty($rb_v_info['co_topvisual_s_size']) ? $rb_v_info['co_topvisual_s_size'] : '16'; // 상단영역 서브워딩 사이즈
$rb_v_info['topvisual_s_font'] = !empty($rb_v_info['co_topvisual_s_font']) ? $rb_v_info['co_topvisual_s_font'] : 'font-R'; // 상단영역 서브워딩 두께
$rb_v_info['topvisual_s_align'] = !empty($rb_v_info['co_topvisual_s_align']) ? $rb_v_info['co_topvisual_s_align'] : 'left'; // 상단영역 서브워딩 정렬
$rb_v_info['topvisual_bg_color'] = !empty($rb_v_info['co_topvisual_bg_color']) ? $rb_v_info['co_topvisual_bg_color'] : '#f9f9f9';
$rb_v_info['topvisual_style_all'] = !empty($rb_v_info['co_topvisual_style_all']) ? $rb_v_info['co_topvisual_style_all'] : '0';
/* } */
//영카트 사용여부
$rb_core['layout_shop'] = !empty($rb_config['co_layout_shop']) ? $rb_config['co_layout_shop'] : ''; // 레이아웃(메인)
$rb_core['layout_hd_shop'] = !empty($rb_config['co_layout_hd_shop']) ? $rb_config['co_layout_hd_shop'] : ''; // 레이아웃(헤더)
$rb_core['layout_ft_shop'] = !empty($rb_config['co_layout_ft_shop']) ? $rb_config['co_layout_ft_shop'] : ''; // 레이아웃(푸터)
$rb_core['padding_top_shop'] = !empty($rb_config['co_main_padding_top_shop']) ? $rb_config['co_main_padding_top_shop'] : "0"; // 상단, 하단 가로사이즈
$rb_core['color'] = str_replace('#', '', $rb_core['color']); // # 제거 2.1.4
$rb_core['header'] = str_replace('#', '', $rb_core['header']); // # 제거 2.1.4
if(isset($rb_core['tb_width']) && $rb_core['tb_width'] == "100") {
$tb_width_inner = "100%";
$tb_width_padding = "padding:0px 40px";
} else {
$tb_width_inner = $rb_core['tb_width']."px";
$tb_width_padding = "";
}
if(isset($rb_core['main_width']) && $rb_core['main_width'] == "100") {
$rb_main_wide = "rb_main_wide";
} else {
$rb_sub_wide = "";
}
if(isset($rb_core['sub_width']) && $rb_core['sub_width'] == "100") {
$rb_sub_wide = "rb_sub_wide";
} else {
$rb_sub_wide = "";
}
// SEO설정
$sql_seo = " select * from rb_seo limit 1";
$seo = sql_fetch($sql_seo);
/*********************************************/
// SIR @트리플님 코드적용 // 출처 : https://sir.kr/g5_tip/21657
add_event('tail_sub', 'prism_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
add_replace('html_purifier_result', 'prism_html_purifier_result', 10, 3);
function prism_script(){
add_stylesheet('', -2);
$sh = ''.PHP_EOL;
$sh .= '';
add_javascript($sh, 0);
}
function prism_tail_sub(){
global $wr_id;
if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' || !$wr_id) return;
prism_script();
}
function PrismJS($m) {
$str = isset($m[3]) ? $m[3] : '';
if(!$str)
return;
$str = stripslashes($str);
$str = preg_replace("/(
|
|
|
)/i", "\n", $str);
$str = preg_replace("/(
|<\/div>|<\/p>)/i", "", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace("/", "<", $str);
$str = str_replace("/[/", "[", $str);
$str = str_replace("/{/", "{", $str);
if(!$str)
return;
//$brush = isset($m[2]) ? strtolower(trim($m[2])) : 'html';
$brush = 'php';
//prism_script();
return '
'.PHP_EOL;
}
function prism_html_purifier_result($str){
$content = preg_replace_callback("/(\[code\]|\[code=(.*)\])(.*)\[\/code\]/iUs", "PrismJS", $str); // PrismJS
return $content;
}
// 문자 발송 함수 @SIR 플래토님 코드사용 출처 : https://sir.kr/g5_tip/8262
function smsSend($sHp, $rHp, $msg) {
global $g5, $config;
$rtn = "";
try {
$send_hp = str_replace("-","",$sHp); // - 제거
$recv_hp = str_replace("-","",$rHp); // - 제거
$SMS = new SMS; // SMS 객체 생성
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
$SMS->Add($recv_hp, $send_hp, $config['cf_icode_id'], iconv("utf-8", "euc-kr", stripslashes($msg)), "");
$SMS->Send();
$rtn = true;
}
catch(Exception $e) {
alert("처리중 문제가 발생했습니다.".$e->getMessage());
$rtn = false;
}
return $rtn;
}
// 새글에 NEW 아이콘
function get_new_ico($bo_table, $ca_name) {
global $g5;
$new_icon = '';
$bbs = sql_fetch("select * from {$g5['board_table']} where bo_table = '{$bo_table}'");
if($bbs && isset($bbs['bo_table'])) {
$write_table = $g5['write_prefix'].$bbs['bo_table'];
if(isset($ca_name) && !empty($ca_name)) {
$time = sql_fetch("select * from {$write_table} where wr_is_comment = 0 and ca_name = '{$ca_name}' order by wr_id desc limit 1");
} else {
$time = sql_fetch("select * from {$write_table} where wr_is_comment = 0 order by wr_id desc limit 1");
}
}
if (isset($bbs['bo_new']) && isset($time['wr_datetime']) && $time['wr_datetime'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - ($bbs['bo_new'] * 3600))) {
$new_icon = '
n';
}
return $new_icon;
}
// 전체 URL (SEO)
function getCurrentUrl() {
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$host = $_SERVER['HTTP_HOST'];
$requestUri = $_SERVER['REQUEST_URI'];
return $protocol . $host . $requestUri;
}
// 안읽은 쪽지
if ($is_member) {
if( isset($member['mb_memo_cnt']) ){
$memo_not_read = $member['mb_memo_cnt'];
} else {
$memo_not_read = get_memo_not_read($member['mb_id']);
}
}
// 날자계산
function passing_time($datetime) {
$time_lag = time() - strtotime($datetime);
if($time_lag < 60) {
$posting_time = "방금";
} else if($time_lag >= 60 and $time_lag < 3600) {
$posting_time = floor($time_lag/60)."분 전";
} else if($time_lag >= 3600 and $time_lag < 86400) {
$posting_time = floor($time_lag/3600)."시간 전";
} else if($time_lag >= 86400 and $time_lag < 2419200) {
$posting_time = floor($time_lag/86400)."일 전";
} else {
$posting_time = date("Y.m.d", strtotime($datetime));
}
return $posting_time;
}
// 날자계산2
function passing_time2($datetime) {
$time_lag = time() - strtotime($datetime);
if($time_lag < 60) {
$posting_time = "방금
".date("Y.m.d", strtotime($datetime));
} else if($time_lag >= 60 and $time_lag < 3600) {
$posting_time = floor($time_lag/60)."분 전
".date("Y.m.d", strtotime($datetime));
} else if($time_lag >= 3600 and $time_lag < 86400) {
$posting_time = floor($time_lag/3600)."시간 전
".date("Y.m.d", strtotime($datetime));
} else if($time_lag >= 86400 and $time_lag < 2419200) {
$posting_time = floor($time_lag/86400)."일 전
".date("Y.m.d", strtotime($datetime));
} else {
$posting_time = "오래 전
".date("Y.m.d", strtotime($datetime));
}
return $posting_time;
}
// 날자계산3
function passing_time3($datetime) {
$time_lag = time() - strtotime($datetime);
if($time_lag < 60) {
$posting_time = "방금";
} else if($time_lag >= 60 and $time_lag < 3600) {
$posting_time = floor($time_lag/60)."분 전";
} else if($time_lag >= 3600 and $time_lag < 86400) {
$posting_time = floor($time_lag/3600)."시간 전";
} else if($time_lag >= 86400 and $time_lag < 2419200) {
$posting_time = floor($time_lag/86400)."일 전";
} else {
$posting_time = "오래 전";
}
return $posting_time;
}
// 회원 게시물 갯수
function wr_cnt($mb_id, $type){
global $g5;
$wr_sum = 0;
$sql = sql_query(" select bo_table from {$g5['board_table']} ");
while($row = sql_fetch_array($sql)) {
$write_table = $g5['write_prefix'] . $row['bo_table'];
if($type == "w") {
$sql2 = " select count(*) as cnt from {$write_table} where mb_id = '{$mb_id}' and wr_is_comment = 0 ";
} else if ($type == "c") {
$sql2 = " select count(*) as cnt from {$write_table} where mb_id = '{$mb_id}' and wr_is_comment = 1 ";
}
$wr = sql_fetch($sql2);
$wr_sum += $wr['cnt'];
}
return $wr_sum;
}
// 생성된 게시판 목록조회
function rb_board_list($bo_tables) {
global $g5;
$str = ""; // 초기화
$sql = " select bo_table, bo_subject from {$g5['board_table']} group by bo_table order by bo_table asc";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
if($bo_tables == $row['bo_table']) {
$str .= "