짧은 URL 적용 수정중
This commit is contained in:
1 parent
f66300a394
commit
58b86e556a
33 files changed
+241
-83
No files matched your search
@@ -2,6 +2,147 @@
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
class G5_URI {
|
||||
public $basename;
|
||||
public $parts;
|
||||
public $slashes;
|
||||
|
||||
public static function getInstance()
|
||||
{ //싱글톤
|
||||
static $instance = null;
|
||||
if (null === $instance) {
|
||||
$instance = new self();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function parseURL() {
|
||||
/* grab URL query string and script name */
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
$script = $_SERVER['SCRIPT_NAME'];
|
||||
/* get extension */
|
||||
$ext = end( explode(".",$script) );
|
||||
|
||||
/* if extension is found in URL, eliminate it */
|
||||
if(strstr($uri,".")) {
|
||||
$arr_uri = explode('.', $uri);
|
||||
/* get last part */
|
||||
$last = end($arr_uri);
|
||||
|
||||
if($last == $ext){
|
||||
array_pop($arr_uri);
|
||||
$uri = implode('.', $arr_uri);
|
||||
}
|
||||
}
|
||||
|
||||
/* pick the name without extension */
|
||||
$basename = basename ($script, '.'.$ext);
|
||||
/* slicing query string */
|
||||
$temp = explode('/',$uri);
|
||||
$key = array_search($basename,$temp);
|
||||
$parts = array_slice ($temp, $key+1);
|
||||
$this->basename = $basename;
|
||||
$this->parts = $parts;
|
||||
|
||||
}
|
||||
|
||||
public function setRelative($relativevar) {
|
||||
/* count the number of slash
|
||||
to define relative path */
|
||||
$numslash = count($this->parts);
|
||||
$slashes="";
|
||||
for($i=0;$i<$numslash;$i++){
|
||||
$slashes .= "../";
|
||||
}
|
||||
$this->slashes = $slashes;
|
||||
/* make relative path variable available for webpage */
|
||||
//eval("\$GLOBALS['$relativevar'] = '$slashes';");
|
||||
|
||||
$links = array();
|
||||
$links[$relativevar] = $slashes;
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
public function getParts() {
|
||||
/* return array of sliced query string */
|
||||
return $this->parts;
|
||||
}
|
||||
|
||||
public function setParts() {
|
||||
/* pair off query string variable and query string value */
|
||||
$numargs = func_num_args();
|
||||
$arg_list = func_get_args();
|
||||
$urlparts = $this->getParts();
|
||||
$links = array();
|
||||
for ($i = 0; $i < $numargs; $i++) {
|
||||
/* make them available for webpage */
|
||||
//eval ("\$GLOBALS['".$arg_list[$i] ."']= '$urlparts[$i]';");
|
||||
$links[$arg_list[$i]] = $urlparts[$i];
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
public function makeClean($stringurl) {
|
||||
/* convert normal URL query string to clean URL */
|
||||
$url=parse_url($stringurl);
|
||||
$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='') {
|
||||
$stringurl = str_replace('&', '&', $stringurl);
|
||||
$url=parse_url($stringurl);
|
||||
$strurl = basename($url['path'],".php");
|
||||
|
||||
if( ! in_array($strurl, array('board', 'view_comment.page')) ){ //게시판이 아니면 리턴
|
||||
return $stringurl;
|
||||
}
|
||||
|
||||
$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)) $strurl .= "/".$v;
|
||||
|
||||
$tmp = array('bo_table'=>'', 'wr_id'=>'');
|
||||
$s = array();
|
||||
|
||||
foreach( $tmp as $key=>$v ){
|
||||
if( !isset($vars[$key]) || empty($vars[$key]) ) continue;
|
||||
$add = '';
|
||||
$s[$key] = $vars[$key];
|
||||
}
|
||||
|
||||
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';
|
||||
|
||||
$host = G5_URL;
|
||||
|
||||
if( isset($url['host']) ){
|
||||
$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);
|
||||
}
|
||||
|
||||
$add_param = '';
|
||||
|
||||
if( $result = array_diff_key($vars, $tmp ) ){
|
||||
$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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
+3
-3
@@ -1257,7 +1257,7 @@ function get_sideview($mb_id, $name='', $email='', $homepage='')
|
||||
if(!$bo_table)
|
||||
return $name;
|
||||
|
||||
$tmp_name = '<a href="'.G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&sca='.$sca.'&sfl=wr_name,1&stx='.$name.'" title="'.$name.' 이름으로 검색" class="sv_guest" rel="nofollow" onclick="return false;">'.$name.'</a>';
|
||||
$tmp_name = '<a href="'.get_pretty_url($bo_table, '', 'sca='.$sca.'&sfl=wr_name,1&stx='.$name).'" title="'.$name.' 이름으로 검색" class="sv_guest" rel="nofollow" onclick="return false;">'.$name.'</a>';
|
||||
$title_mb_id = '[비회원]';
|
||||
}
|
||||
|
||||
@@ -1275,9 +1275,9 @@ function get_sideview($mb_id, $name='', $email='', $homepage='')
|
||||
$str2 .= "<a href=\"".G5_BBS_URL."/profile.php?mb_id=".$mb_id."\" onclick=\"win_profile(this.href); return false;\">자기소개</a>\n";
|
||||
if($bo_table) {
|
||||
if($mb_id)
|
||||
$str2 .= "<a href=\"".G5_BBS_URL."/board.php?bo_table=".$bo_table."&sca=".$sca."&sfl=mb_id,1&stx=".$mb_id."\">아이디로 검색</a>\n";
|
||||
$str2 .= "<a href=\"".get_pretty_url($bo_table, '', "sca=".$sca."&sfl=mb_id,1&stx=".$mb_id)."\">아이디로 검색</a>\n";
|
||||
else
|
||||
$str2 .= "<a href=\"".G5_BBS_URL."/board.php?bo_table=".$bo_table."&sca=".$sca."&sfl=wr_name,1&stx=".$name."\">이름으로 검색</a>\n";
|
||||
$str2 .= "<a href=\"".get_pretty_url($bo_table, '', "sca=".$sca."&sfl=wr_name,1&stx=".$name)."\">이름으로 검색</a>\n";
|
||||
}
|
||||
if($mb_id)
|
||||
$str2 .= "<a href=\"".G5_BBS_URL."/new.php?mb_id=".$mb_id."\" class=\"link_new_page\" onclick=\"check_goto_new(this.href, event);\">전체게시물</a>\n";
|
||||
|
||||
+9
-2
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
include_once(dirname(__FILE__) .'/URI/uri.class.php');
|
||||
|
||||
// 짧은 주소 형식으로 만들어서 가져온다.
|
||||
function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
{
|
||||
global $g5, $config;
|
||||
|
||||
$config['cf_bbs_rewrite'] = 1;
|
||||
|
||||
static $boards = array();
|
||||
|
||||
if( ! $boards ){
|
||||
@@ -68,4 +68,11 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
return $url;
|
||||
}
|
||||
|
||||
function short_url_clean($url, $add_qry=''){
|
||||
if( class_exists('G5_URI') ){
|
||||
return G5_URI::getInstance()->url_clean($url, $add_qry);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user