Merge branch 'g54' of github.com:gnuboard/g5 into g54
This commit is contained in:
+1
-1
@@ -231,7 +231,7 @@ if ($is_search_bbs) {
|
||||
|
||||
$write_href = '';
|
||||
if ($member['mb_level'] >= $board['bo_write_level']) {
|
||||
$write_href = get_pretty_url($bo_table, '', '', 'write');
|
||||
$write_href = short_url_clean(G5_BBS_URL.'/write.php?bo_table='.$bo_table);
|
||||
}
|
||||
|
||||
$nobr_begin = $nobr_end = "";
|
||||
|
||||
+3
-5
@@ -62,22 +62,20 @@ if (isset($next['wr_id']) && $next['wr_id']) {
|
||||
// 쓰기 링크
|
||||
$write_href = '';
|
||||
if ($member['mb_level'] >= $board['bo_write_level']) {
|
||||
$write_href = get_pretty_url($bo_table, '', '', 'write');
|
||||
$write_href = short_url_clean(G5_BBS_URL.'/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;
|
||||
$reply_href = get_pretty_url($bo_table, '', 'w=r&wr_id='.$wr_id.$qstr, 'write');
|
||||
$reply_href = short_url_clean(G5_BBS_URL.'/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 = G5_BBS_URL.'/write.php?w=u&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr;
|
||||
$update_href = get_pretty_url($bo_table, '', 'w=u&wr_id='.$wr_id.'&page='.$page.$qstr, 'write');
|
||||
$update_href = short_url_clean(G5_BBS_URL.'/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 = G5_BBS_URL.'/delete.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&token='.$token.'&page='.$page.urldecode($qstr);
|
||||
}
|
||||
|
||||
+29
-22
@@ -84,49 +84,56 @@ class G5_URI {
|
||||
return $links;
|
||||
}
|
||||
|
||||
public function makeClean($stringurl) {
|
||||
public function makeClean($string_url) {
|
||||
/* convert normal URL query string to clean URL */
|
||||
$url=parse_url($stringurl);
|
||||
$url=parse_url($string_url);
|
||||
$strurl = basename($url['path'],".php");
|
||||
$qstring = parse_str($url['query'],$vars);
|
||||
while(list($k,$v) = each($vars)) $strurl .= "/".$v;
|
||||
return $strurl;
|
||||
}
|
||||
|
||||
public function url_clean($stringurl, $add_qry='') {
|
||||
public function url_clean($string_url, $add_qry='') {
|
||||
global $config, $g5;
|
||||
|
||||
$stringurl = str_replace('&', '&', $stringurl);
|
||||
$url=parse_url($stringurl);
|
||||
$strurl = basename($url['path'],".php");
|
||||
$string_url = str_replace('&', '&', $string_url);
|
||||
$url=parse_url($string_url);
|
||||
$page_name = basename($url['path'],".php");
|
||||
|
||||
$array_page_names = apply_replace('url_clean_page_names', array('board', 'write'));
|
||||
|
||||
if( ! in_array($strurl, array('board', 'view_comment.page')) ){ //게시판이 아니면 리턴
|
||||
return $stringurl;
|
||||
if( strpos($string_url, G5_BBS_URL) === false || ! in_array($page_name, $array_page_names) ){ //게시판이 아니면 리턴
|
||||
return $string_url;
|
||||
}
|
||||
|
||||
$return_url = '';
|
||||
$qstring = parse_str($url['query'],$vars);
|
||||
$qstring = parse_str($url['query'], $vars);
|
||||
|
||||
// 예) Array ( [scheme] => http [host] => sir.kr [path] => /bbs/board.php [query] => wr_id=1110870&bo_table=cm_free&cpage=1 [fragment] => c_1110946 )
|
||||
//while(list($k,$v) = each($vars)) $strurl .= "/".$v;
|
||||
//while(list($k,$v) = each($vars)) $page_name .= "/".$v;
|
||||
|
||||
if( $page_name === 'write' ){
|
||||
$vars['action'] = 'write';
|
||||
$allow_param_keys = array('bo_table'=>'', 'action'=>'');
|
||||
} else {
|
||||
$allow_param_keys = array('bo_table'=>'', 'wr_id'=>'');
|
||||
}
|
||||
|
||||
$tmp = array('bo_table'=>'', 'wr_id'=>'');
|
||||
$s = array();
|
||||
|
||||
foreach( $tmp as $key=>$v ){
|
||||
foreach( $allow_param_keys as $key=>$v ){
|
||||
if( !isset($vars[$key]) || empty($vars[$key]) ) continue;
|
||||
$add = '';
|
||||
$s[$key] = $vars[$key];
|
||||
}
|
||||
|
||||
if( $config['cf_bbs_rewrite'] > 1 && (isset($s['wr_id']) && $s['wr_id']) && (isset($s['bo_table']) && $s['bo_table']) ){
|
||||
if( $config['cf_bbs_rewrite'] > 1 && $page_name === 'board' && (isset($s['wr_id']) && $s['wr_id']) && (isset($s['bo_table']) && $s['bo_table']) ){
|
||||
$get_write = get_write( get_write_table_name($s['bo_table']), $s['wr_id'], true);
|
||||
|
||||
if( $get_write['wr_seo_title'] ){
|
||||
unset($s['wr_id']);
|
||||
$s['wr_seo_title'] = $get_write['wr_seo_title'].'/';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
@@ -134,17 +141,17 @@ class G5_URI {
|
||||
$host = G5_URL;
|
||||
|
||||
if( isset($url['host']) ){
|
||||
|
||||
$array_file_paths = apply_replace('url_clean_page_paths', array('/'.G5_BBS_DIR.'/board.php', '/'.G5_BBS_DIR.'/write.php'));
|
||||
|
||||
$str_path = isset($url['path']) ? $url['path'] : '';
|
||||
$http = 'http://';
|
||||
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') {
|
||||
$http = 'https://';
|
||||
}
|
||||
$host = $http.$url['host'].str_replace('/'.G5_BBS_DIR.'/board.php', '', $str_path);
|
||||
$http = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 'https://' : 'http://';
|
||||
$host = $http.$url['host'].str_replace($array_file_paths, '', $str_path);
|
||||
}
|
||||
|
||||
$add_param = '';
|
||||
|
||||
if( $result = array_diff_key($vars, $tmp ) ){
|
||||
if( $result = array_diff_key($vars, $allow_param_keys ) ){
|
||||
$add_param = '?'.http_build_query($result,'','&');
|
||||
}
|
||||
|
||||
@@ -152,8 +159,8 @@ class G5_URI {
|
||||
$add_param .= $add_param ? '&'.$add_qry : '?'.$add_qry;
|
||||
}
|
||||
|
||||
while(list($k,$v) = each($s)) $return_url .= "/".$v;
|
||||
|
||||
while(list($k,$v) = each($s)) $return_url .= '/'.$v;
|
||||
|
||||
return $host.$return_url.$add_param.$fragment;
|
||||
}
|
||||
}
|
||||
|
||||
+73
-4
@@ -94,12 +94,81 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
return implode('/', $segments).$add_query;
|
||||
}
|
||||
|
||||
function short_url_clean($url, $add_qry=''){
|
||||
if( class_exists('G5_URI') ){
|
||||
return G5_URI::getInstance()->url_clean($url, $add_qry);
|
||||
function short_url_clean($string_url, $add_qry=''){
|
||||
|
||||
global $config, $g5;
|
||||
|
||||
if( isset($config['cf_bbs_rewrite']) && $config['cf_bbs_rewrite'] ){
|
||||
|
||||
$string_url = str_replace('&', '&', $string_url);
|
||||
$url=parse_url($string_url);
|
||||
$page_name = basename($url['path'],".php");
|
||||
|
||||
$array_page_names = apply_replace('url_clean_page_names', array('board', 'write'));
|
||||
|
||||
if( strpos($string_url, G5_BBS_URL) === false || ! in_array($page_name, $array_page_names) ){ //게시판이 아니면 리턴
|
||||
return $string_url;
|
||||
}
|
||||
|
||||
$return_url = '';
|
||||
$qstring = parse_str($url['query'], $vars);
|
||||
|
||||
// 예) Array ( [scheme] => http [host] => sir.kr [path] => /bbs/board.php [query] => wr_id=1110870&bo_table=cm_free&cpage=1 [fragment] => c_1110946 )
|
||||
//while(list($k,$v) = each($vars)) $page_name .= "/".$v;
|
||||
|
||||
if( $page_name === 'write' ){
|
||||
$vars['action'] = 'write';
|
||||
$allow_param_keys = array('bo_table'=>'', 'action'=>'');
|
||||
} else {
|
||||
$allow_param_keys = array('bo_table'=>'', 'wr_id'=>'');
|
||||
}
|
||||
|
||||
$s = array();
|
||||
|
||||
foreach( $allow_param_keys as $key=>$v ){
|
||||
if( !isset($vars[$key]) || empty($vars[$key]) ) continue;
|
||||
$add = '';
|
||||
$s[$key] = $vars[$key];
|
||||
}
|
||||
|
||||
if( $config['cf_bbs_rewrite'] > 1 && $page_name === 'board' && (isset($s['wr_id']) && $s['wr_id']) && (isset($s['bo_table']) && $s['bo_table']) ){
|
||||
$get_write = get_write( get_write_table_name($s['bo_table']), $s['wr_id'], true);
|
||||
|
||||
if( $get_write['wr_seo_title'] ){
|
||||
unset($s['wr_id']);
|
||||
$s['wr_seo_title'] = $get_write['wr_seo_title'].'/';
|
||||
}
|
||||
}
|
||||
|
||||
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
|
||||
$host = G5_URL;
|
||||
|
||||
if( isset($url['host']) ){
|
||||
|
||||
$array_file_paths = apply_replace('url_clean_page_paths', array('/'.G5_BBS_DIR.'/board.php', '/'.G5_BBS_DIR.'/write.php'));
|
||||
|
||||
$str_path = isset($url['path']) ? $url['path'] : '';
|
||||
$http = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 'https://' : 'http://';
|
||||
$host = $http.$url['host'].str_replace($array_file_paths, '', $str_path);
|
||||
}
|
||||
|
||||
$add_param = '';
|
||||
|
||||
if( $result = array_diff_key($vars, $allow_param_keys ) ){
|
||||
$add_param = '?'.http_build_query($result,'','&');
|
||||
}
|
||||
|
||||
if( $add_qry ){
|
||||
$add_param .= $add_param ? '&'.$add_qry : '?'.$add_qry;
|
||||
}
|
||||
|
||||
while(list($k,$v) = each($s)) $return_url .= '/'.$v;
|
||||
|
||||
return $host.$return_url.$add_param.$fragment;
|
||||
}
|
||||
|
||||
return $url;
|
||||
return $string_url;
|
||||
}
|
||||
|
||||
function correct_goto_url($url){
|
||||
|
||||
Reference in New Issue
Block a user