Merge branch 'g54' of github.com:gnuboard/g5 into g54
This commit is contained in:
@@ -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('<link rel="stylesheet" href="'.G5_JS_URL.'/remodal/remodal.css">', 11);
|
||||
add_stylesheet('<link rel="stylesheet" href="'.G5_JS_URL.'/remodal/remodal-default-theme.css">', 12);
|
||||
add_javascript('<script src="'.G5_JS_URL.'/remodal/remodal.js"></script>', 10);
|
||||
?>
|
||||
<section id="anc_cf_url">
|
||||
<h2 class="h2_frm">짧은 주소 설정</h2>
|
||||
@@ -20,6 +33,14 @@ $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/';
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<?php if ( $is_apache && !$is_write_file ){ ?>
|
||||
<button type="button" data-remodal-target="modal_apache">Apache 설정 보기</button>
|
||||
<?php } else if ( $is_nginx ) { ?>
|
||||
<button type="button" data-remodal-target="modal_nginx">Nginx 설정 보기</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="tbl_frm01 tbl_wrap">
|
||||
<table>
|
||||
<caption>짧은주소 설정</caption>
|
||||
@@ -47,41 +68,34 @@ $base_path = isset($get_path_url['path']) ? $get_path_url['path'].'/' : '/';
|
||||
</div>
|
||||
|
||||
<div class="server_rewrite_info">
|
||||
<div class="is_apache">
|
||||
<div class="is_rewrite remodal" data-remodal-id="modal_apache" role="dialog" aria-labelledby="modalApache" aria-describedby="modal1Desc">
|
||||
|
||||
# apache configuration
|
||||
<pre>
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase <?php echo $base_path; ?>
|
||||
<button type="button" class="connect-close" data-remodal-action="close">
|
||||
<i class="fa fa-close"></i>
|
||||
<span class="txt">닫기</span>
|
||||
</button>
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
RewriteRule ^rss/([0-9a-zA-Z_]+)$ bbs/rss.php?bo_table=$1 [L]
|
||||
RewriteRule ^([0-9a-zA-Z_]+)$ bbs/board.php?bo_table=$1&rewrite=1 [QSA,L]
|
||||
RewriteRule ^([0-9a-zA-Z_]+)/([^/]+)/$ bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 [QSA,L]
|
||||
RewriteRule ^([0-9a-zA-Z_]+)/write$ bbs/write.php?bo_table=$1&rewrite=1 [QSA,L]
|
||||
RewriteRule ^([0-9a-zA-Z_]+)/p([0-9]+)$ bbs/board.php?bo_table=$1&page=$2 [QSA,L]
|
||||
RewriteRule ^([0-9a-zA-Z_]+)/([0-9]+)$ bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 [QSA,L]
|
||||
</IfModule>
|
||||
</pre>
|
||||
<h4 class="copy_title">아래 코드를 복사하여 .htaccess 파일에 붙여넣기 하여 주세요.</h4>
|
||||
<textarea readonly="readonly" rows="10">
|
||||
<?php echo get_mod_rewrite_rules(true); ?>
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
<div class="is_nginx">
|
||||
|
||||
# nginx configuration
|
||||
<pre>
|
||||
<div class="is_rewrite remodal" data-remodal-id="modal_nginx" role="dialog" aria-labelledby="modalNginx" aria-describedby="modal2Desc">
|
||||
|
||||
<h4 class="copy_title">아래 코드를 복사하여 nginx 설정 파일에 적용해 주세요.</h4>
|
||||
<textarea readonly="readonly" rows="10">
|
||||
if (!-e $request_filename){
|
||||
rewrite ^<?php echo $base_path; ?>rss/([0-9a-zA-Z_]+)$ /g54/bbs/rss.php?bo_table=$1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)$ /g54/bbs/board.php?bo_table=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/([^/]+)/$ /g54/bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/write$ /g54/bbs/write.php?bo_table=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/p([0-9]+)$ /g54/bbs/board.php?bo_table=$1&page=$2 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/([0-9]+)$ /g54/bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>content/([0-9a-zA-Z_]+)$ <?php echo $base_path; ?>bbs/content.php?co_id=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>content/([^/]+)/$ <?php echo $base_path; ?>bbs/content.php?co_seo_title=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>rss/([0-9a-zA-Z_]+)$ <?php echo $base_path; ?>bbs/rss.php?bo_table=$1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)$ <?php echo $base_path; ?>bbs/board.php?bo_table=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/([^/]+)/$ <?php echo $base_path; ?>bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/write$ <?php echo $base_path; ?>bbs/write.php?bo_table=$1&rewrite=1 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/p([0-9]+)$ <?php echo $base_path; ?>bbs/board.php?bo_table=$1&page=$2 break;
|
||||
rewrite ^<?php echo $base_path; ?>([0-9a-zA-Z_]+)/([0-9]+)$ <?php echo $base_path; ?>bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 break;
|
||||
}
|
||||
</pre>
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
?>
|
||||
+8
-1
@@ -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}
|
||||
|
||||
/* 메일 테스트 */
|
||||
|
||||
|
||||
@@ -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[] = '<IfModule mod_rewrite.c>';
|
||||
$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[] = '</IfModule>';
|
||||
$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;
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user