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='') { global $config, $g5; $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]; } if( $config['cf_bbs_rewrite'] > 1 && (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']) ){ $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; } } ?>