영카트 5.4.3 버전으로 수정
This commit is contained in:
@ -33,9 +33,9 @@ class FileCache
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function get($id)
|
||||
public function get($id, $expired_time=0)
|
||||
{
|
||||
$data = $this->_get($id);
|
||||
$data = $this->_get($id, $expired_time);
|
||||
return is_array($data) ? $data['data'] : FALSE;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class FileCache
|
||||
|
||||
}
|
||||
|
||||
protected function _get($id)
|
||||
protected function _get($id, $expired_time=0)
|
||||
{
|
||||
$cache_file_path = $this->get_cache_file_path($id);
|
||||
|
||||
@ -68,20 +68,27 @@ class FileCache
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$server_time = defined('G5_SERVER_TIME') ? G5_SERVER_TIME : time();
|
||||
|
||||
try{
|
||||
$file_contents = file_get_contents($cache_file_path);
|
||||
$file_ex = explode("\n\n", $file_contents);
|
||||
$data = unserialize(base64_decode($file_ex[1]));
|
||||
} catch(Exception $e){
|
||||
$data = array('ttl'=>1, 'time'=>time() - 1000);
|
||||
$data = array('ttl'=>1, 'time'=> $server_time - 1000);
|
||||
}
|
||||
|
||||
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
|
||||
|
||||
if ($data['ttl'] > 0 && $server_time > $data['time'] + $data['ttl'])
|
||||
{
|
||||
unlink( $cache_file_path );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($data['time'] && $expired_time && $data['time'] < ($server_time - $expired_time)){
|
||||
unlink( $cache_file_path );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@ -52,10 +52,10 @@ function g5_set_cache($key, $save_data, $ttl = null){
|
||||
}
|
||||
}
|
||||
|
||||
function g5_get_cache($key){
|
||||
function g5_get_cache($key, $expired_time=0){
|
||||
|
||||
if( $cache = get_cachemanage_instance() ){
|
||||
return $cache->get($key);
|
||||
return $cache->get($key, $expired_time);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -754,6 +754,7 @@ function get_group($gr_id, $is_cache=false)
|
||||
static $cache = array();
|
||||
|
||||
$gr_id = preg_replace('/[^a-z0-9_]/i', '', $gr_id);
|
||||
$cache = run_replace('get_group_db_cache', $cache, $gr_id, $is_cache);
|
||||
$key = md5($gr_id);
|
||||
|
||||
if( $is_cache && isset($cache[$key]) ){
|
||||
@ -1605,15 +1606,19 @@ function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null)
|
||||
}
|
||||
}
|
||||
|
||||
$end_time = $is_debug ? get_microtime() : 0;
|
||||
|
||||
if($result && $is_debug) {
|
||||
// 여기에 실행한 sql문을 화면에 표시하는 로직 넣기
|
||||
$g5_debug['sql'][] = array(
|
||||
'sql' => $sql,
|
||||
'start_time' => $start_time,
|
||||
'end_time' => get_microtime(),
|
||||
'end_time' => $end_time,
|
||||
);
|
||||
}
|
||||
|
||||
run_event('sql_query_after', $result, $sql, $start_time, $end_time);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -70,11 +70,10 @@ function get_board_db($bo_table, $is_cache=false){
|
||||
|
||||
static $cache = array();
|
||||
|
||||
$bo_table = preg_replace('/[^a-z0-9_]/i', '', $bo_table);
|
||||
$cache = run_replace('get_board_db_cache', $cache, $bo_table, $is_cache);
|
||||
|
||||
$key = md5($bo_table);
|
||||
|
||||
$bo_table = preg_replace('/[^a-z0-9_]/i', '', $bo_table);
|
||||
if( $is_cache && isset($cache[$key]) ){
|
||||
return $cache[$key];
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
||||
global $g5;
|
||||
|
||||
if (!$skin_dir) $skin_dir = 'basic';
|
||||
|
||||
$time_unit = 3600; // 1시간으로 고정
|
||||
|
||||
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
|
||||
if (G5_IS_MOBILE) {
|
||||
@ -35,7 +37,7 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
||||
|
||||
if(G5_USE_CACHE) {
|
||||
$cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();
|
||||
$caches = g5_get_cache($cache_file_name);
|
||||
$caches = g5_get_cache($cache_file_name, $time_unit * $cache_time);
|
||||
$cache_list = isset($caches['list']) ? $caches['list'] : array();
|
||||
g5_latest_cache_data($bo_table, $cache_list);
|
||||
}
|
||||
@ -90,7 +92,7 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
||||
'bo_subject' => sql_escape_string($bo_subject),
|
||||
);
|
||||
|
||||
g5_set_cache($cache_file_name, $caches, 3600 * $cache_time);
|
||||
g5_set_cache($cache_file_name, $caches, $time_unit * $cache_time);
|
||||
}
|
||||
} else {
|
||||
$list = $cache_list;
|
||||
|
||||
@ -16,13 +16,13 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
return $url;
|
||||
}
|
||||
|
||||
// use shortten url
|
||||
if($config['cf_bbs_rewrite']) {
|
||||
|
||||
// use shortten url
|
||||
if($config['cf_bbs_rewrite']) {
|
||||
|
||||
$segments[0] = G5_URL;
|
||||
|
||||
if( $folder === 'content' && $no ){ // 내용관리
|
||||
|
||||
|
||||
$segments[1] = $folder;
|
||||
|
||||
if( $config['cf_bbs_rewrite'] > 1 ){
|
||||
@ -36,32 +36,32 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
|
||||
} else if(in_array($folder, $boards)) { // 게시판
|
||||
|
||||
$segments[1] = $folder;
|
||||
$segments[1] = $folder;
|
||||
|
||||
if($no) {
|
||||
if($no) {
|
||||
|
||||
if( $config['cf_bbs_rewrite'] > 1 ){
|
||||
|
||||
$get_write = get_write( $g5['write_prefix'].$folder, $no , true);
|
||||
|
||||
$segments[2] = $get_write['wr_seo_title'] ? urlencode($get_write['wr_seo_title']).'/' : urlencode($no);
|
||||
$get_write = get_write( $g5['write_prefix'].$folder, $no , true);
|
||||
|
||||
$segments[2] = $get_write['wr_seo_title'] ? urlencode($get_write['wr_seo_title']).'/' : urlencode($no);
|
||||
|
||||
} else {
|
||||
$segments[2] = urlencode($no);
|
||||
}
|
||||
|
||||
} else if($action) {
|
||||
} else if($action) {
|
||||
$segments[2] = urlencode($action);
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
$segments[1] = $folder;
|
||||
if($no) {
|
||||
$no_array = explode("=", $no);
|
||||
$no_value = end($no_array);
|
||||
if($no) {
|
||||
$no_array = explode("=", $no);
|
||||
$no_value = end($no_array);
|
||||
$segments[2] = urlencode($no_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($query_string) {
|
||||
// If the first character of the query string is '&', replace it with '?'.
|
||||
@ -72,33 +72,33 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
||||
}
|
||||
}
|
||||
|
||||
} else { // don't use shortten url
|
||||
if(in_array($folder, $boards)) {
|
||||
$url = G5_BBS_URL. '/board.php?bo_table='. $folder;
|
||||
if($no) {
|
||||
$url .= '&wr_id='. $no;
|
||||
}
|
||||
if($query_string) {
|
||||
} else { // don't use shortten url
|
||||
if(in_array($folder, $boards)) {
|
||||
$url = G5_BBS_URL. '/board.php?bo_table='. $folder;
|
||||
if($no) {
|
||||
$url .= '&wr_id='. $no;
|
||||
}
|
||||
if($query_string) {
|
||||
if(substr($query_string, 0, 1) !== '&') {
|
||||
$url .= '&';
|
||||
}
|
||||
|
||||
$url .= $query_string;
|
||||
}
|
||||
} else {
|
||||
$url = G5_BBS_URL. '/'.$folder.'.php';
|
||||
$url .= $query_string;
|
||||
}
|
||||
} else {
|
||||
$url = G5_BBS_URL. '/'.$folder.'.php';
|
||||
if($no) {
|
||||
$url .= ($folder === 'content') ? '?co_id='. $no : '?'. $no;
|
||||
}
|
||||
$url .= ($folder === 'content') ? '?co_id='. $no : '?'. $no;
|
||||
}
|
||||
if($query_string) {
|
||||
$url .= ($no ? '?' : '&'). $query_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$segments[0] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $segments).$add_query;
|
||||
return implode('/', $segments).$add_query;
|
||||
}
|
||||
|
||||
function short_url_clean($string_url, $add_qry=''){
|
||||
@ -110,7 +110,7 @@ function short_url_clean($string_url, $add_qry=''){
|
||||
$string_url = str_replace('&', '&', $string_url);
|
||||
$url=parse_url($string_url);
|
||||
$page_name = basename($url['path'],".php");
|
||||
|
||||
|
||||
$array_page_names = run_replace('url_clean_page_names', array('board', 'write', 'content'));
|
||||
|
||||
if( stripos(preg_replace('/^https?:/i', '', $string_url), preg_replace('/^https?:/i', '', G5_BBS_URL)) === false || ! in_array($page_name, $array_page_names) ){ //게시판이 아니면 리턴
|
||||
@ -119,19 +119,19 @@ function short_url_clean($string_url, $add_qry=''){
|
||||
|
||||
$return_url = '';
|
||||
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 )
|
||||
foreach($vars as $k => $v) { $page_name .= "/".$v; }
|
||||
*/
|
||||
|
||||
foreach($vars as $k => $v) { $page_name .= "/".$v; }
|
||||
*/
|
||||
|
||||
if( $page_name === 'write' ){
|
||||
$vars['action'] = 'write';
|
||||
$allow_param_keys = array('bo_table'=>'', 'action'=>'');
|
||||
} else if( $page_name === 'content' ){
|
||||
$vars['action'] = 'content';
|
||||
$allow_param_keys = array('action'=>'', 'co_id'=>'');
|
||||
} else {
|
||||
$vars['action'] = 'content';
|
||||
$allow_param_keys = array('action'=>'', 'co_id'=>'');
|
||||
} else {
|
||||
$allow_param_keys = array('bo_table'=>'', 'wr_id'=>'');
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ function short_url_clean($string_url, $add_qry=''){
|
||||
|
||||
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'] = urlencode($get_write['wr_seo_title']).'/';
|
||||
@ -175,8 +175,8 @@ function short_url_clean($string_url, $add_qry=''){
|
||||
if( $add_qry ){
|
||||
$add_param .= $add_param ? '&'.$add_qry : '?'.$add_qry;
|
||||
}
|
||||
|
||||
foreach($s as $k => $v) { $return_url .= '/'.$v; }
|
||||
|
||||
foreach($s as $k => $v) { $return_url .= '/'.$v; }
|
||||
|
||||
return $host.$return_url.$add_param.$fragment;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user