그누보드 최신버전 (5.1.0) 살펴보기 - common.php (7)
common.php 그누보드에서 가장 기본이 되는 파일이라고 볼수 있습니다.
모든 파일에 기본적으로 인클루드 되어서 사용됩니다.
에러출력 설정, 보안적인 처리, 기본적인 경로 설정, 디비연결, 세션 설정및 시작, 공용변수의 초기화 및 재설정, 기타 확장 등의 내용으로 이루어져 있습니다.
337라인부터 461라인까지는 별다른 설명이 필요없어서 생략합니다.
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true)
$config['cf_theme'] = trim($_GET['theme']);
_THEME_PREVIEW_ 이 상수는 config.php 에 정의되어 있지 않습니다.
테마 미리 보기를 사용 할경우
config.php 이 상수를 true 로 정의 하면 됩니다.
$config['cf_theme'] = trim($_GET['theme']);
이 부부은 넘어온 theme 변수가 있으면 기본 테마를 그 변수값으로 설정하겠다는 것인데
if (isset($GET['theme']) && strlen(preg_replace("`\s`", '', $GET['theme'])) > 0)
$config['cf_theme'] = preg_replace("`\s`", '', $_GET['theme']);
이렇게 하는 것이 더 좋아보입니다.
if(isset($config['cf_theme']) && trim($config['cf_theme'])) {
$theme_path = G5_PATH.'/'.G5_THEME_DIR.'/'.$config['cf_theme'];
if(is_dir($theme_path)) {
define('G5_THEME_PATH', $theme_path);
define('G5_THEME_URL', G5_URL.'/'.G5_THEME_DIR.'/'.$config['cf_theme']);
define('G5_THEME_MOBILE_PATH', $theme_path.'/'.G5_MOBILE_DIR);
define('G5_THEME_LIB_PATH', $theme_path.'/'.G5_LIB_DIR);
define('G5_THEME_CSS_URL', G5_THEME_URL.'/'.G5_CSS_DIR);
define('G5_THEME_IMG_URL', G5_THEME_URL.'/'.G5_IMG_DIR);
define('G5_THEME_JS_URL', G5_THEME_URL.'/'.G5_JS_DIR);
}
unset($theme_path);
}
if(isset($config['cf_theme']) && trim($config['cf_theme'])) {
이것은 $config['cf_theme'] 가 정의 되어잇고 값이 있을때 실행하겟다는 내용인데
$config['cf_theme'] 에 0 이 들어가 있으면 실행안될수 있을것 같습니다.
물론 테마이름에 0을 설정하긴 드물겟지만.......
if (isset($config['cf_theme'])) {
$config['cf_theme'] = preg_replace("`\s`", '', $_GET['theme']);
if(strlen($config['cf_theme']) > 0) {
이렇게 하는 것이 더 좋아보입니다.
// 테마 설정 로드
if(is_file(G5_THEME_PATH.'/theme.config.php'))
include_once(G5_THEME_PATH.'/theme.config.php');
테마의 환경설정 파일을 인클루드 합니다.
해당파일에는 테마가 지원하는 장치 설정 및 사용될 스킨과 몇몇 환경설정값이 $theme_config 에 정의 됩니다.
$is_mobile = false;
$set_device = true;
if(defined('G5_THEME_DEVICE') && G5_THEME_DEVICE != '') {
switch(G5_THEME_DEVICE) {
case 'pc':
$is_mobile = false;
$set_device = false;
break;
case 'mobile':
$is_mobile = true;
$set_device = false;
break;
default:
break;
}
}
현재 출력될 페이지를 pc용으로 출력할것인지 mobile 용으로 출력할것인지 체크하는 부분입니다.
테마 환경설정에서 G5_THEME_DEVICE 빈값이 아닌 pc, mobile 로 설정하였다면 그 설정에 따릅니다.
그리고 $set_device = false; 를 통해 pc와 모바일 전환이 불가능하도록 합니다.
if(defined('G5_SET_DEVICE') && $set_device) {
switch(G5_SET_DEVICE) {
case 'pc':
$is_mobile = false;
$set_device = false;
break;
case 'mobile':
$is_mobile = true;
$set_device = false;
break;
default:
break;
}
}
G5_THEME_DEVICE 이 빈값일 경우 G5_SET_DEVICE 에 설정된 값에 따라 pc용인지 모바일용인지 체크합니다.
config.php 에서는
define('G5_SET_DEVICE', 'both'); 와 같이 설정되어있는데
both 라는 값은 무의미 해보입니다.
pc 또는 mobile 또는 빈값으로 설정가능합니다.
역시 마찬가지로 빈값이 아닐경우에는 $set_device = false; 를 통해 pc와 모바일 전환이 불가능하도록 합니다.
if (G5_USE_MOBILE && $set_device) {
if ($_REQUEST['device']=='pc')
$is_mobile = false;
else if ($_REQUEST['device']=='mobile')
$is_mobile = true;
else if (isset($_SESSION['ss_is_mobile']))
$is_mobile = $_SESSION['ss_is_mobile'];
else if (is_mobile())
$is_mobile = true;
} else {
$set_device = false;
}
config.php 에서 정의 된 G5_USE_MOBILE 을 사용합니다.
define('G5_USE_MOBILE', true); // 모바일 홈페이지를 사용하지 않을 경우 false 로 설정
이렇게 설명되어져 있습니다
G5_THEME_DEVICE 와 G5_SET_DEVICE 가 둘다 빈값일 때만 모바일 사용유무를 결정할수 있습니다.
if ($_REQUEST['device']=='pc')
$is_mobile = false;
else if ($_REQUEST['device']=='mobile')
$is_mobile = true;
조건절내에 isset($_REQUEST['device']) && 가 들어가는 것이 좋아 보입니다.
아무튼 $_REQUEST['device'] 가 존재하고 그 값이 pc나 모바일이면 그걸 우선으로 결정하고
그다음 세션, 세션도 없다면 이 접속환경이 모바일인지 체크하여 결정합니다.
$_SESSION['ss_is_mobile'] = $is_mobile;
결정된 출력환경을 세션에 저장합니다.
define('G5_IS_MOBILE', $is_mobile);
결정된 출력 환경을 상수에도 정의합니다.
define('G5_DEVICE_BUTTON_DISPLAY', $set_device);
pc 모바일 전환 가능 여부를 상수에 정의합니다.
if (G5_IS_MOBILE) {
$g5['mobile_path'] = G5_PATH.'/'.$g5['mobile_dir'];
}
모바일이라면 기본 모바일 경로를 설정합니다.
if (G5_IS_MOBILE) {
$board_skin_path = get_skin_path('board', $board['bo_mobile_skin']);
$board_skin_url = get_skin_url('board', $board['bo_mobile_skin']);
$member_skin_path = get_skin_path('member', $config['cf_mobile_member_skin']);
$member_skin_url = get_skin_url('member', $config['cf_mobile_member_skin']);
$new_skin_path = get_skin_path('new', $config['cf_mobile_new_skin']);
$new_skin_url = get_skin_url('new', $config['cf_mobile_new_skin']);
$search_skin_path = get_skin_path('search', $config['cf_mobile_search_skin']);
$search_skin_url = get_skin_url('search', $config['cf_mobile_search_skin']);
$connect_skin_path = get_skin_path('connect', $config['cf_mobile_connect_skin']);
$connect_skin_url = get_skin_url('connect', $config['cf_mobile_connect_skin']);
$faq_skin_path = get_skin_path('faq', $config['cf_mobile_faq_skin']);
$faq_skin_url = get_skin_url('faq', $config['cf_mobile_faq_skin']);
} else {
$board_skin_path = get_skin_path('board', $board['bo_skin']);
$board_skin_url = get_skin_url('board', $board['bo_skin']);
$member_skin_path = get_skin_path('member', $config['cf_member_skin']);
$member_skin_url = get_skin_url('member', $config['cf_member_skin']);
$new_skin_path = get_skin_path('new', $config['cf_new_skin']);
$new_skin_url = get_skin_url('new', $config['cf_new_skin']);
$search_skin_path = get_skin_path('search', $config['cf_search_skin']);
$search_skin_url = get_skin_url('search', $config['cf_search_skin']);
$connect_skin_path = get_skin_path('connect', $config['cf_connect_skin']);
$connect_skin_url = get_skin_url('connect', $config['cf_connect_skin']);
$faq_skin_path = get_skin_path('faq', $config['cf_faq_skin']);
$faq_skin_url = get_skin_url('faq', $config['cf_faq_skin']);
}
출력환경에 따른 기본 스킨 경로를 설정합니다.
$extend_file = array();
$tmp = dir(G5_EXTEND_PATH);
while ($entry = $tmp->read()) {
// php 파일만 include 함
if (preg_match("/(\.php)$/i", $entry))
$extend_file[] = $entry;
}
if(!empty($extend_file) && is_array($extend_file)) {
natsort($extend_file);
foreach($extend_file as $file) {
include_once(G5_EXTEND_PATH.'/'.$file);
}
}
unset($extend_file);
extend 하위에 확장자가 php 인 파일들을 넣어서 common.php를 직접 수정하는 경우가 없도록 하는 경우입니다.
일종의 hook 개념으로 볼수 있습니다.
natsort 은 자연정렬을 의미합니다.
일반적인 sort 는 문자열로 취급하여 정렬시키나 natsort 는 숫자도 따져서 정렬합니다.
본래의 의도와는 다르게 인클루드 순서가 꼬이는 것을 방지하기 위한 조치라고 볼수 있습니다.
ob_start();
출력버퍼를 켭니다.
즉, 지금 부터 출력되는 헤더를 제외한 모든것을 메모리에 담아두고 실제로는 아무 전송을 하지 않는다는 의미입니다.
header('Content-Type: text/html; charset=utf-8');
$gmnow = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: 0'); // rfc2616 - Section 14.21
header('Last-Modified: ' . $gmnow);
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
헤더 출력을 합니다.
윗 부분
session_cache_limiter("no-cache, must-revalidate");
에서
nocache 로 제대로 설정하였다면
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
이 부분은 필요없을것 같습니다.
$html_process = new html_process();
이 클래스에 대해서는 나중에 설명하도록 하겠습니다.
대략적으로 css 나 js 의 위치를 출력때 바로 잡아주기 위한 정도로 일단 생각하면 될것같습니다.
댓글 8개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 68 | ||
| 8229 | 9년 전 | 68 | ||
| 8228 |
커네드커네드
|
9년 전 | 112 | |
| 8227 | 9년 전 | 122 | ||
| 8226 | 9년 전 | 159 | ||
| 8225 | 9년 전 | 148 | ||
| 8224 | 9년 전 | 144 | ||
| 8223 | 9년 전 | 113 | ||
| 8222 |
|
9년 전 | 183 | |
| 8221 | 9년 전 | 88 | ||
| 8220 | 9년 전 | 101 | ||
| 8219 | 9년 전 | 97 | ||
| 8218 | 9년 전 | 138 | ||
| 8217 |
star3840
|
9년 전 | 112 | |
| 8216 | 9년 전 | 159 | ||
| 8215 | 9년 전 | 110 | ||
| 8214 | 9년 전 | 221 | ||
| 8213 | 9년 전 | 156 | ||
| 8212 | 9년 전 | 82 | ||
| 8211 | 9년 전 | 241 | ||
| 8210 | 9년 전 | 242 | ||
| 8209 | 9년 전 | 333 | ||
| 8208 | 9년 전 | 215 | ||
| 8207 | 9년 전 | 224 | ||
| 8206 |
|
9년 전 | 185 | |
| 8205 | 9년 전 | 168 | ||
| 8204 | 9년 전 | 130 | ||
| 8203 | 9년 전 | 231 | ||
| 8202 | 9년 전 | 138 | ||
| 8201 | 9년 전 | 179 | ||
| 8200 | 9년 전 | 160 | ||
| 8199 | 9년 전 | 212 | ||
| 8198 | 9년 전 | 173 | ||
| 8197 | 9년 전 | 164 | ||
| 8196 | 9년 전 | 551 | ||
| 8195 | 9년 전 | 154 | ||
| 8194 | 9년 전 | 280 | ||
| 8193 | 9년 전 | 153 | ||
| 8192 | 9년 전 | 183 | ||
| 8191 | 9년 전 | 138 | ||
| 8190 | 9년 전 | 126 | ||
| 8189 | 9년 전 | 188 | ||
| 8188 | 9년 전 | 127 | ||
| 8187 | 9년 전 | 140 | ||
| 8186 | 9년 전 | 139 | ||
| 8185 | 9년 전 | 308 | ||
| 8184 | 9년 전 | 106 | ||
| 8183 | 9년 전 | 323 | ||
| 8182 | 9년 전 | 165 | ||
| 8181 | 9년 전 | 128 | ||
| 8180 | 9년 전 | 692 | ||
| 8179 | 9년 전 | 483 | ||
| 8178 | 9년 전 | 309 | ||
| 8177 |
kiplayer
|
9년 전 | 314 | |
| 8176 | 9년 전 | 347 | ||
| 8175 | 9년 전 | 219 | ||
| 8174 | 9년 전 | 242 | ||
| 8173 | 9년 전 | 341 | ||
| 8172 | 9년 전 | 194 | ||
| 8171 | 9년 전 | 182 | ||
| 8170 | 9년 전 | 295 | ||
| 8169 |
커네드커네드
|
9년 전 | 257 | |
| 8168 | 9년 전 | 316 | ||
| 8167 | 9년 전 | 319 | ||
| 8166 | 9년 전 | 234 | ||
| 8165 | 9년 전 | 163 | ||
| 8164 | 9년 전 | 300 | ||
| 8163 | 9년 전 | 280 | ||
| 8162 | 9년 전 | 296 | ||
| 8161 | 9년 전 | 294 | ||
| 8160 |
|
9년 전 | 487 | |
| 8159 | 9년 전 | 426 | ||
| 8158 | 9년 전 | 247 | ||
| 8157 | 9년 전 | 371 | ||
| 8156 | 9년 전 | 274 | ||
| 8155 | 9년 전 | 249 | ||
| 8154 |
00년생용띠
|
9년 전 | 598 | |
| 8153 | 9년 전 | 227 | ||
| 8152 |
|
9년 전 | 403 | |
| 8151 | 9년 전 | 405 | ||
| 8150 | 9년 전 | 498 | ||
| 8149 |
Jangfolk
|
9년 전 | 348 | |
| 8148 | 9년 전 | 164 | ||
| 8147 | 9년 전 | 372 | ||
| 8146 | 9년 전 | 433 | ||
| 8145 | 9년 전 | 378 | ||
| 8144 | 9년 전 | 345 | ||
| 8143 | 9년 전 | 190 | ||
| 8142 | 9년 전 | 425 | ||
| 8141 | 9년 전 | 380 | ||
| 8140 | 9년 전 | 927 | ||
| 8139 | 9년 전 | 256 | ||
| 8138 |
전갈자리남자
|
9년 전 | 385 | |
| 8137 | 9년 전 | 393 | ||
| 8136 | 9년 전 | 743 | ||
| 8135 |
|
9년 전 | 793 | |
| 8134 |
PlayPixel
|
9년 전 | 510 | |
| 8133 |
|
9년 전 | 432 | |
| 8132 | 9년 전 | 444 | ||
| 8131 | 9년 전 | 809 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기