diff --git a/adm/_rewrite_config_form.php b/adm/_rewrite_config_form.php index e5986ad4c..e40c7db44 100644 --- a/adm/_rewrite_config_form.php +++ b/adm/_rewrite_config_form.php @@ -7,9 +7,22 @@ $is_nginx = (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false); $is_iis = !$is_apache && (stripos($_SERVER['SERVER_SOFTWARE'], 'microsoft-iis') !== false); +$is_write_file = false; + +if ( $is_nginx ){ + $is_write_file = false; +} else if ( $is_apache && ((!file_exists(G5_PATH.'/.htaccess') && is_writable($home_path)) || is_writable(G5_PATH.'/.htaccess')) ){ + $is_write_file = true; +} + $get_path_url = parse_url( G5_URL ); $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/'; + +// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 +add_stylesheet('', 11); +add_stylesheet('', 12); +add_javascript('', 10); ?>

짧은 주소 설정

@@ -20,6 +33,14 @@ $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/';

+
+ + + + + +
+
@@ -47,41 +68,34 @@ $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/';
-
+ -
- -# nginx configuration -
+        
 
     
diff --git a/adm/config_form_update.php b/adm/config_form_update.php index e10a4647d..86227e727 100644 --- a/adm/config_form_update.php +++ b/adm/config_form_update.php @@ -184,5 +184,7 @@ if( isset($_POST['cf_bbs_rewrite']) ){ start_event('admin_config_form_update'); +update_rewrite_rules(); + goto_url('./config_form.php', false); ?> \ No newline at end of file diff --git a/adm/css/admin.css b/adm/css/admin.css index 5b31afdc1..33d6d69d2 100644 --- a/adm/css/admin.css +++ b/adm/css/admin.css @@ -512,8 +512,15 @@ td.td_grpset {width:160px;border-left:1px solid #e9ecee;text-align:center} /* 환경설정 */ .cf_cert_hide {display:none} +.is_rewrite .connect-close {position:absolute;top:10px;right:10px;margin:0;padding:0;width:30px;height:30px;border:0;background:transparent;color:#383838;cursor:pointer;font-size:15px} +.is_rewrite .connect-close:hover {color:#ff5191} +.is_rewrite .connect-close .fa {margin:0 0 0 1px} +.is_rewrite .connect-close .txt {position:absolute;line-height:0;font-size:0;overflow:hidden} +.is_rewrite textarea{width:99%} +.is_rewrite .copy_title{margin-top:25px;margin-bottom:10px;font-weight:bold;text-align:left} + /* 관리권한설정 */ -#add_admin fieldset {margin-top:20px} +#add_admin fieldset {margin-top:20px;overflow:auto;padding:2px 6px;line-height:1.4;resize:vertical} /* 메일 테스트 */ diff --git a/lib/uri.lib.php b/lib/uri.lib.php index f926705fa..a1c56fb57 100644 --- a/lib/uri.lib.php +++ b/lib/uri.lib.php @@ -188,4 +188,73 @@ function exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id=0){ return exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id); } +function get_mod_rewrite_rules($return_string=false){ + + $get_path_url = parse_url( G5_URL ); + + $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/'; + + $rules = array(); + + $rules[] = '#### '.G5_VERSION.' rewrite BOF #####'; + $rules[] = ''; + $rules[] = 'RewriteEngine On'; + $rules[] = 'RewriteBase '.$base_path; + $rules[] = 'RewriteCond %{REQUEST_FILENAME} !-f'; + $rules[] = 'RewriteCond %{REQUEST_FILENAME} !-d'; + $rules[] = 'RewriteRule ^content/([0-9a-zA-Z_]+)$ '.G5_BBS_DIR.'/content.php?co_id=$1&rewrite=1 [L]'; + $rules[] = 'RewriteRule ^content/([^/]+)/$ '.G5_BBS_DIR.'/content.php?co_seo_title=$1&rewrite=1 [QSA,L]'; + $rules[] = 'RewriteRule ^rss/([0-9a-zA-Z_]+)$ '.G5_BBS_DIR.'/rss.php?bo_table=$1 [L]'; + $rules[] = 'RewriteRule ^([0-9a-zA-Z_]+)$ '.G5_BBS_DIR.'/board.php?bo_table=$1&rewrite=1 [QSA,L]'; + $rules[] = 'RewriteRule ^([0-9a-zA-Z_]+)/([^/]+)/$ '.G5_BBS_DIR.'/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 [QSA,L]'; + $rules[] = 'RewriteRule ^([0-9a-zA-Z_]+)/write$ '.G5_BBS_DIR.'/write.php?bo_table=$1&rewrite=1 [QSA,L]'; + $rules[] = 'RewriteRule ^([0-9a-zA-Z_]+)/p([0-9]+)$ '.G5_BBS_DIR.'/board.php?bo_table=$1&page=$2 [QSA,L]'; + $rules[] = 'RewriteRule ^([0-9a-zA-Z_]+)/([0-9]+)$ '.G5_BBS_DIR.'/board.php?bo_table=$1&wr_id=$2&rewrite=1 [QSA,L]'; + $rules[] = ''; + $rules[] = '#### '.G5_VERSION.' rewrite EOF #####'; + + return $return_string ? implode('\n', $rules) : $rules; +} + +function update_rewrite_rules(){ + + $is_apache = (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false); + + if($is_apache){ + $save_path = G5_PATH.'/.htaccess'; + + if( (!file_exists($save_path) && is_writable(G5_PATH)) || is_writable($save_path) ){ + + $rules = get_mod_rewrite_rules(); + + $bof_str = $rules[0]; + $eof_str = end($rules); + + if( file_exists($save_path) ){ + $code = file_get_contents($save_path); + + if( $code && strpos($code, $bof_str) !== false && strpos($code, $eof_str) !== false ){ + return true; + } + } + + $fp = fopen($save_path, "ab"); + flock( $fp, LOCK_EX ); + + $rewrite_str = implode("\n", $rules); + + fwrite( $fp, "\n" ); + fwrite( $fp, $rewrite_str ); + fwrite( $fp, "\n" ); + + flock( $fp, LOCK_UN ); + fclose($fp); + + return true; + } + } + + return false; + +} ?> \ No newline at end of file
짧은주소 설정