From 16907801b7b4b168d841542e5255a81cb08c5631 Mon Sep 17 00:00:00 2001 From: thisgun Date: Thu, 13 Sep 2018 10:42:56 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=A7=EC=9D=80=20=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/_rewrite_config_form.php | 83 +++++ adm/admin.head.php | 2 +- adm/admin.lib.php | 2 +- adm/browscap.php | 2 +- adm/browscap_convert.php | 2 +- adm/config_form.php | 10 + adm/config_form_update.php | 7 + bbs/board.php | 2 +- bbs/write_update.php | 4 + common.php | 17 +- config.php | 3 + extend/debugbar.extend.php | 21 ++ head.php | 8 +- lib/URI/obj.class.php | 62 ++++ lib/URI/uri.class.php | 12 + lib/cache.lib.php | 16 + lib/common.lib.php | 121 +++++++- lib/get_data.lib.php | 287 ++++++++++++++++++ lib/hook.lib.php | 2 +- lib/uri.lib.php | 54 ++-- .../skin/outlogin/basic/outlogin.skin.2.php | 2 +- plugin/debugbar/debugbar.php | 254 ++++++++++++++++ plugin/debugbar/index.php | 0 plugin/debugbar/style.css | 51 ++++ skin/outlogin/basic/outlogin.skin.2.php | 2 +- tail.sub.php | 2 + theme/basic/head.php | 2 +- .../skin/outlogin/basic/outlogin.skin.2.php | 2 +- theme/basic/tail.sub.php | 2 + 29 files changed, 984 insertions(+), 50 deletions(-) create mode 100644 adm/_rewrite_config_form.php create mode 100644 extend/debugbar.extend.php create mode 100644 lib/URI/obj.class.php create mode 100644 lib/cache.lib.php create mode 100644 lib/get_data.lib.php create mode 100644 plugin/debugbar/debugbar.php create mode 100644 plugin/debugbar/index.php create mode 100644 plugin/debugbar/style.css diff --git a/adm/_rewrite_config_form.php b/adm/_rewrite_config_form.php new file mode 100644 index 000000000..f67e99deb --- /dev/null +++ b/adm/_rewrite_config_form.php @@ -0,0 +1,83 @@ + +
+

짧은 주소 설정

+ +
+

+ 게시판과 컨텐츠 페이지에 짧은 URL 을 사용합니다. +

+
+ +
+ + + + + + + + array('label'=>'사용안함', 'url'=>G5_URL.'/board.php?bo_table=free&wr_id=123'), + '1'=>array('label'=>'숫자', 'url'=>G5_URL.'/free/123'), + '2'=>array('label'=>'글 이름', 'url'=>G5_URL.'/free/안녕하세요/'), + ); + foreach($short_url_arrs as $k=>$v){ + $checked = ((int) $config['cf_bbs_rewrite'] === (int) $k) ? 'checked' : ''; + ?> + + + + + + +
짧은주소 설정
>
+
+ +
+
+
+                # nginx configuration
+
+                location /g54/ {
+                  if (!-e $request_filename){
+                    rewrite ^/g54/rss/([0-9a-zA-Z_]+)$ /g54/bbs/rss.php?bo_table=$1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)$ /g54/bbs/board.php?bo_table=$1&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/([^/]+)/$ /g54/bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/write$ /g54/bbs/write.php?bo_table=$1&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/p([0-9]+)$ /g54/bbs/board.php?bo_table=$1&page=$2 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/([0-9]+)$ /g54/bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 break;
+                  }
+                }
+            
+
+ +
+ +
+                # nginx configuration
+
+                location /g54/ {
+                  if (!-e $request_filename){
+                    rewrite ^/g54/rss/([0-9a-zA-Z_]+)$ /g54/bbs/rss.php?bo_table=$1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)$ /g54/bbs/board.php?bo_table=$1&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/([^/]+)/$ /g54/bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/write$ /g54/bbs/write.php?bo_table=$1&rewrite=1 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/p([0-9]+)$ /g54/bbs/board.php?bo_table=$1&page=$2 break;
+                    rewrite ^/g54/([0-9a-zA-Z_]+)/([0-9]+)$ /g54/bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1 break;
+                  }
+                }
+            
+
+ +
+
\ No newline at end of file diff --git a/adm/admin.head.php b/adm/admin.head.php index 9c35b557c..12934fc14 100644 --- a/adm/admin.head.php +++ b/adm/admin.head.php @@ -101,7 +101,7 @@ function imageview(id, w, h)

- +
    diff --git a/adm/admin.lib.php b/adm/admin.lib.php index 48baae0fd..9509f3a8d 100644 --- a/adm/admin.lib.php +++ b/adm/admin.lib.php @@ -429,7 +429,7 @@ function admin_referer_check($return=false) // 접근 권한 검사 if (!$member['mb_id']) { - alert('로그인 하십시오.', G5_BBS_URL.'/login.php?url=' . urlencode(G5_ADMIN_URL)); + alert('로그인 하십시오.', G5_BBS_URL.'/login.php?url=' . urlencode(correct_goto_url(G5_ADMIN_URL))); } else if ($is_admin != 'super') { diff --git a/adm/browscap.php b/adm/browscap.php index 25f2f511d..0c287c14e 100644 --- a/adm/browscap.php +++ b/adm/browscap.php @@ -3,7 +3,7 @@ $sub_menu = "100510"; include_once('./_common.php'); if(!(version_compare(phpversion(), '5.3.0', '>=') && defined('G5_BROWSCAP_USE') && G5_BROWSCAP_USE)) - alert('사용할 수 없는 기능입니다.', G5_ADMIN_URL); + alert('사용할 수 없는 기능입니다.', correct_goto_url(G5_ADMIN_URL)); if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); diff --git a/adm/browscap_convert.php b/adm/browscap_convert.php index edf3b0d39..7c0dfc880 100644 --- a/adm/browscap_convert.php +++ b/adm/browscap_convert.php @@ -3,7 +3,7 @@ $sub_menu = "100520"; include_once('./_common.php'); if(!(version_compare(phpversion(), '5.3.0', '>=') && defined('G5_BROWSCAP_USE') && G5_BROWSCAP_USE)) - alert('사용할 수 없는 기능입니다.', G5_ADMIN_URL); + alert('사용할 수 없는 기능입니다.', correct_goto_url(G5_ADMIN_URL)); if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); diff --git a/adm/config_form.php b/adm/config_form.php index 00915fe7d..8d17a818c 100644 --- a/adm/config_form.php +++ b/adm/config_form.php @@ -253,6 +253,12 @@ if(!sql_query(" DESC {$g5['social_profile_table']} ", false)) { ) ", true); } +// 짧은 URL 주소를 사용 여부 필드 추가 +if (!isset($config['cf_bbs_rewrite'])) { + sql_query(" ALTER TABLE `{$g5['config_table']}` + ADD `cf_bbs_rewrite` tinyint(4) NOT NULL DEFAULT '0' AFTER `cf_link_target` ", true); +} + if(!$config['cf_faq_skin']) $config['cf_faq_skin'] = "basic"; if(!$config['cf_mobile_faq_skin']) $config['cf_mobile_faq_skin'] = "basic"; @@ -264,6 +270,7 @@ $pg_anchor = '
+

기본 메일 환경 설정

diff --git a/adm/config_form_update.php b/adm/config_form_update.php index 03179c345..e10a4647d 100644 --- a/adm/config_form_update.php +++ b/adm/config_form_update.php @@ -59,6 +59,7 @@ $sql = " update {$g5['config_table']} cf_add_meta = '{$_POST['cf_add_meta']}', cf_syndi_token = '{$_POST['cf_syndi_token']}', cf_syndi_except = '{$_POST['cf_syndi_except']}', + cf_bbs_rewrite = '{$_POST['cf_bbs_rewrite']}', cf_member_skin = '{$_POST['cf_member_skin']}', cf_use_homepage = '{$_POST['cf_use_homepage']}', cf_req_homepage = '{$_POST['cf_req_homepage']}', @@ -177,5 +178,11 @@ sql_query($sql); //sql_query(" OPTIMIZE TABLE `$g5[config_table]` "); +if( isset($_POST['cf_bbs_rewrite']) ){ + g5_delete_all_cache(); +} + +start_event('admin_config_form_update'); + goto_url('./config_form.php', false); ?> \ No newline at end of file diff --git a/bbs/board.php b/bbs/board.php index 43e318d1c..5aa1836a8 100644 --- a/bbs/board.php +++ b/bbs/board.php @@ -189,7 +189,7 @@ $ip = ""; $is_ip_view = $board['bo_use_ip_view']; if ($is_admin) { $is_ip_view = true; - if (array_key_exists('wr_ip', $write)) { + if ($write && array_key_exists('wr_ip', $write)) { $ip = $write['wr_ip']; } } else { diff --git a/bbs/write_update.php b/bbs/write_update.php index 55ddde35b..e0d1d8ec8 100644 --- a/bbs/write_update.php +++ b/bbs/write_update.php @@ -211,6 +211,8 @@ if ($w == '' || $w == 'r') { if (!isset($_POST['wr_subject']) || !trim($_POST['wr_subject'])) alert('제목을 입력하여 주십시오.'); +$wr_seo_title = exist_seo_url_recursive('bbs', generate_seo_url($wr_subject), $write_table, $wr_id); + if ($w == '' || $w == 'r') { if ($member['mb_id']) { @@ -251,6 +253,7 @@ if ($w == '' || $w == 'r') { wr_option = '$html,$secret,$mail', wr_subject = '$wr_subject', wr_content = '$wr_content', + wr_seo_title = '$wr_seo_title', wr_link1 = '$wr_link1', wr_link2 = '$wr_link2', wr_link1_hit = 0, @@ -372,6 +375,7 @@ if ($w == '' || $w == 'r') { wr_option = '{$html},{$secret},{$mail}', wr_subject = '{$wr_subject}', wr_content = '{$wr_content}', + wr_seo_title = '$wr_seo_title', wr_link1 = '{$wr_link1}', wr_link2 = '{$wr_link2}', mb_id = '{$mb_id}', diff --git a/common.php b/common.php index a76dd5e6c..b63190a25 100644 --- a/common.php +++ b/common.php @@ -122,9 +122,14 @@ $member = array(); $board = array(); $group = array(); $g5 = array(); +$g5_debug = array('php'=>array(),'sql'=>array()); include_once(G5_LIB_PATH.'/hook.lib.php'); // hook 함수 파일 +include_once(G5_LIB_PATH.'/get_data.lib.php'); include_once(G5_LIB_PATH.'/uri.lib.php'); // URL 함수 파일 +include_once(G5_LIB_PATH.'/cache.lib.php'); + +$g5_object = new G5_object_store(); //============================================================================== // 공통 @@ -214,7 +219,7 @@ ini_set("session.cookie_domain", G5_COOKIE_DOMAIN); //------------------------------------------------------------------------------ // 기본환경설정 // 기본적으로 사용하는 필드만 얻은 후 상황에 따라 필드를 추가로 얻음 -$config = sql_fetch(" select * from {$g5['config_table']} "); +$config = get_config(); define('G5_HTTP_BBS_URL', https_url(G5_BBS_DIR, false)); define('G5_HTTPS_BBS_URL', https_url(G5_BBS_DIR, true)); @@ -404,16 +409,16 @@ if ($_SESSION['ss_mb_id']) { // 로그인중이라면 $write = array(); $write_table = ""; if ($bo_table) { - $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' "); + $board = get_board_db($bo_table); if ($board['bo_table']) { set_cookie("ck_bo_table", $board['bo_table'], 86400 * 1); $gr_id = $board['gr_id']; $write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름 if (isset($wr_id) && $wr_id) { - $write = sql_fetch(" select * from $write_table where wr_id = '$wr_id' "); - } else if (isset($wr_unique) && $wr_unique) { - $write = sql_fetch(" select * from $write_table where wr_unique = '$wr_unique' ", false); + $write = get_write($write_table, $wr_id); + } else if (isset($wr_seo_title) && $wr_seo_title) { + $write = get_write_by_field($write_table, 'wr_seo_title', $wr_seo_title); if( isset($write['wr_id']) ){ $wr_id = $write['wr_id']; } @@ -422,7 +427,7 @@ if ($bo_table) { } if ($gr_id) { - $group = sql_fetch(" select * from {$g5['group_table']} where gr_id = '$gr_id' "); + $group = get_group($gr_id); } diff --git a/config.php b/config.php index d165d9cb1..ebf9a38a5 100644 --- a/config.php +++ b/config.php @@ -29,6 +29,9 @@ if (PHP_VERSION >= '5.1.0') { define('G5_DOMAIN', ''); define('G5_HTTPS_DOMAIN', ''); +//디버깅 상수 +define('G5_DEBUG', true); + /* www.sir.kr 과 sir.kr 도메인은 서로 다른 도메인으로 인식합니다. 쿠키를 공유하려면 .sir.kr 과 같이 입력하세요. 이곳에 입력이 없다면 www 붙은 도메인과 그렇지 않은 도메인은 쿠키를 공유하지 않으므로 로그인이 풀릴 수 있습니다. diff --git a/extend/debugbar.extend.php b/extend/debugbar.extend.php new file mode 100644 index 000000000..d01d8051e --- /dev/null +++ b/extend/debugbar.extend.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/head.php b/head.php index 47bbaab67..4e9be6f4a 100644 --- a/head.php +++ b/head.php @@ -38,8 +38,8 @@ include_once(G5_LIB_PATH.'/popular.lib.php');
  • 정보수정
  • 로그아웃
  • -
  • 관리자
  • - +
  • 관리자
  • +
  • 회원가입
  • 로그인
  • @@ -165,7 +165,7 @@ include_once(G5_LIB_PATH.'/popular.lib.php'); } //end foreach $row if ($i == 0) { ?> -
  • 메뉴 준비 중입니다. 관리자모드 > 환경설정 > 메뉴설정에서 설정하실 수 있습니다.
  • +
  • 메뉴 준비 중입니다. 관리자모드 > 환경설정 > 메뉴설정에서 설정하실 수 있습니다.
  • @@ -198,7 +198,7 @@ include_once(G5_LIB_PATH.'/popular.lib.php'); } //end foreach $row if ($i == 0) { ?> -
  • 메뉴 준비 중입니다.
    관리자모드 > 환경설정 > 메뉴설정에서 설정하실 수 있습니다.
  • +
  • 메뉴 준비 중입니다.
    관리자모드 > 환경설정 > 메뉴설정에서 설정하실 수 있습니다.
  • diff --git a/lib/URI/obj.class.php b/lib/URI/obj.class.php new file mode 100644 index 000000000..d77c9ebb0 --- /dev/null +++ b/lib/URI/obj.class.php @@ -0,0 +1,62 @@ +exists('bbs', $key, $group) ){ + if ( is_object($this->writes[$group][$key]) ) + return clone $this->writes[$group][$key]; + else + return $this->writes[$group][$key]; + } + return false; + break; + } + + } + + function exists($type, $key, $group = 'default' ) { + + $return_data = ''; + + switch ($type) { + case 'bbs': + $datas = $this->writes; + break; + } + + return isset($datas[$group]) && ( isset($datas[$group][$key]) || array_key_exists($key, $datas[$group]) ); + } + + function set($type, $key, $data=array(), $group='default') { + if ( is_object( $data ) ) + $data = clone $data; + + switch ($type) { + case 'bbs': + $this->writes[$group][$key] = $data; + break; + } + + } + + function delete($key, $group='default') { + switch ($type) { + case 'bbs': + if ( ! $this->exists('bbs', $key, $group) ) + return false; + + unset( $this->writes[$group][$key] ); + return true; + break; + } + } + +} //end Class + +?> \ No newline at end of file diff --git a/lib/URI/uri.class.php b/lib/URI/uri.class.php index 17e25c16e..254c0e6af 100644 --- a/lib/URI/uri.class.php +++ b/lib/URI/uri.class.php @@ -94,6 +94,8 @@ class G5_URI { } public function url_clean($stringurl, $add_qry='') { + global $config, $g5; + $stringurl = str_replace('&', '&', $stringurl); $url=parse_url($stringurl); $strurl = basename($url['path'],".php"); @@ -117,6 +119,16 @@ class G5_URI { $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; diff --git a/lib/cache.lib.php b/lib/cache.lib.php new file mode 100644 index 000000000..ba0b43379 --- /dev/null +++ b/lib/cache.lib.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/lib/common.lib.php b/lib/common.lib.php index afd5e2433..38ec7325a 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -335,11 +335,13 @@ function get_dirsize($dir) // 게시물 정보($write_row)를 출력하기 위하여 $list로 가공된 정보를 복사 및 가공 function get_list($write_row, $board, $skin_url, $subject_len=40) { - global $g5, $config; + global $g5, $config, $g5_object; global $qstr, $page; //$t = get_microtime(); + $g5_object->set('bbs', $write_row['wr_id'], $write_row, $board['bo_table']); + // 배열전체를 복사 $list = $write_row; unset($write_row); @@ -682,13 +684,51 @@ function get_sql_search($search_ca_name, $search_field, $search_text, $search_op return $str; } - // 게시판 테이블에서 하나의 행을 읽음 -function get_write($write_table, $wr_id) +function get_write($write_table, $wr_id, $is_cache=false) { - return sql_fetch(" select * from $write_table where wr_id = '$wr_id' "); + global $g5, $g5_object; + + $wr_bo_table = preg_replace('/^'.preg_quote($g5['write_prefix']).'/i', '', $write_table); + + $write = $g5_object->get('bbs', $wr_id, $wr_bo_table); + + if( !$write ){ + $sql = " select * from {$write_table} where wr_id = '{$wr_id}' "; + $write = sql_fetch($sql); + + $g5_object->set('bbs', $wr_id, $write, $wr_bo_table); + } + + return $write; } +// 게시판 테이블에서 하나의 행을 읽음 +function get_write_by_field($write_table, $where_field='', $where_value='', $is_cache=false) +{ + global $g5, $g5_object; + + if( ! in_array($where_field, array('wr_id', 'wr_num', 'wr_reply', 'wr_parent', 'wr_is_comment', 'ca_name', 'wr_option', 'wr_subject', 'wr_content', 'wr_seo_title', 'wr_link1', 'wr_link2', 'wr_hit', 'wr_good', 'wr_nogood', 'mb_id', 'wr_name', 'wr_email', 'wr_homepage', 'wr_datetime', 'wr_ip', 'wr_1', 'wr_2', 'wr_3', 'wr_4', 'wr_5', 'wr_6', 'wr_7', 'wr_8', 'wr_9', 'wr_10')) ){ + return ''; + } + + $where_value = strip_tags($where_value); + $key = md5($write_table.'|'.$where_field.'|'.$where_value); + + if( $is_cache && isset($cache[$key]) ){ + return $cache[$key]; + } + + $sql = " select * from {$write_table} where $where_field = '".sql_real_escape_string($where_value)."' "; + + $cache[$key] = sql_fetch($sql); + + $wr_bo_table = preg_replace('/^'.preg_quote($g5['write_prefix']).'/i', '', $write_table); + + $g5_object->set('bbs', $cache[$key]['wr_id'], $cache[$key], $wr_bo_table); + + return $cache[$key]; +} // 게시판의 다음글 번호를 얻는다. function get_next_num($table) @@ -702,20 +742,45 @@ function get_next_num($table) // 그룹 설정 테이블에서 하나의 행을 읽음 -function get_group($gr_id) +function get_group($gr_id, $is_cache=false) { global $g5; - return sql_fetch(" select * from {$g5['group_table']} where gr_id = '$gr_id' "); + static $cache = array(); + + $gr_id = preg_replace('/[^a-z0-9_]/i', '', $gr_id); + $key = md5($gr_id); + + if( $is_cache && isset($cache[$key]) ){ + return $cache[$key]; + } + + $sql = " select * from {$g5['group_table']} where gr_id = '$gr_id' "; + + $cache[$key] = apply_replace('get_group', sql_fetch($sql), $gr_id, $is_cache); + + return $cache[$key]; } // 회원 정보를 얻는다. -function get_member($mb_id, $fields='*') +function get_member($mb_id, $fields='*', $is_cache=false) { global $g5; - return sql_fetch(" select $fields from {$g5['member_table']} where mb_id = TRIM('$mb_id') "); + static $cache = array(); + + $key = md5($fields); + + if( $is_cache && isset($cache[$mb_id]) && isset($cache[$mb_id][$key]) ){ + return $cache[$mb_id][$key]; + } + + $sql = " select $fields from {$g5['member_table']} where mb_id = TRIM('$mb_id') "; + + $cache[$mb_id][$key] = apply_replace('get_member', sql_fetch($sql), $mb_id, $fields, $is_cache); + + return $cache[$mb_id][$key]; } @@ -1482,7 +1547,7 @@ function sql_set_charset($charset, $link=null) // mysql connect resource 지정 - 명랑폐인님 제안 function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null) { - global $g5; + global $g5, $g5_debug; if(!$link) $link = $g5['connect_db']; @@ -1495,6 +1560,10 @@ function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null) // `information_schema` DB로의 접근을 허락하지 않습니다. $sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql); + $is_debug = get_permission_debug_show(); + + $start_time = $is_debug ? get_microtime() : 0; + if(function_exists('mysqli_query') && G5_MYSQLI_USE) { if ($error) { $result = @mysqli_query($link, $sql) or die("

    $sql

    " . mysqli_errno($link) . " : " . mysqli_error($link) . "

    error file : {$_SERVER['SCRIPT_NAME']}"); @@ -1509,6 +1578,15 @@ function sql_query($sql, $error=G5_DISPLAY_SQL_ERROR, $link=null) } } + if($result && $is_debug) { + // 여기에 실행한 sql문을 화면에 표시하는 로직 넣기 + $g5_debug['sql'][] = array( + 'sql' => $sql, + 'start_time' => $start_time, + 'end_time' => get_microtime(), + ); + } + return $result; } @@ -1994,6 +2072,16 @@ function is_utf8($str) // 출처 : https://www.google.co.kr/search?q=utf8_strcut&aq=f&oq=utf8_strcut&aqs=chrome.0.57j0l3.826j0&sourceid=chrome&ie=UTF-8 function utf8_strcut( $str, $size, $suffix='...' ) { + if( function_exists('mb_strlen') && function_exists('mb_substr') ){ + + if(mb_strlen($str)<=$size) { + return $str; + } else { + $str = mb_substr($str, 0, $size, 'utf-8'); + $str .= $suffix; + } + + } else { $substr = substr( $str, 0, $size * 2 ); $multi_size = preg_match_all( '/[\x80-\xff]/', $substr, $multi_chars ); @@ -2005,8 +2093,9 @@ function utf8_strcut( $str, $size, $suffix='...' ) $str = preg_replace( '/(([\x80-\xff]{3})*?)([\x80-\xff]{0,2})$/', '$1', $str ); $str .= $suffix; } + } - return $str; + return $str; } @@ -2670,10 +2759,16 @@ function get_qa_config($fld='*') { global $g5; - $sql = " select $fld from {$g5['qa_config_table']} "; - $row = sql_fetch($sql); + static $cache = array(); - return $row; + if( $is_cache && !empty($cache) ){ + return $cache; + } + + $sql = " select * from {$g5['qa_config_table']} "; + $cache = apply_replace('get_qa_config', sql_fetch($sql)); + + return $cache; } // get_sock 함수 대체 diff --git a/lib/get_data.lib.php b/lib/get_data.lib.php new file mode 100644 index 000000000..51f7f30e0 --- /dev/null +++ b/lib/get_data.lib.php @@ -0,0 +1,287 @@ + \ No newline at end of file diff --git a/lib/hook.lib.php b/lib/hook.lib.php index 3739fbcc3..77ca17253 100644 --- a/lib/hook.lib.php +++ b/lib/hook.lib.php @@ -15,7 +15,7 @@ function get_hook_class(){ return null; } -function put_event($tag, $func, $priority=GML_HOOK_DEFAULT_PRIORITY, $args=0){ +function put_event($tag, $func, $priority=G5_HOOK_DEFAULT_PRIORITY, $args=0){ global $gml; if( $hook = get_hook_class() ){ diff --git a/lib/uri.lib.php b/lib/uri.lib.php index 81cf63fdb..7da5ce1be 100644 --- a/lib/uri.lib.php +++ b/lib/uri.lib.php @@ -2,29 +2,36 @@ if (!defined('_GNUBOARD_')) exit; include_once(dirname(__FILE__) .'/URI/uri.class.php'); +include_once(dirname(__FILE__) .'/URI/obj.class.php'); // 짧은 주소 형식으로 만들어서 가져온다. function get_pretty_url($folder, $no='', $query_string='', $action='') { global $g5, $config; - static $boards = array(); - - if( ! $boards ){ - $sql = " select bo_table from {$g5['board_table']} "; - $result = sql_query($sql); - - while ($row = sql_fetch_array($result)) { - $boards[] = $row['bo_table']; - } - } + $boards = get_board_names(); // use shortten url if($config['cf_bbs_rewrite']) { if(in_array($folder, $boards)) { + $url = G5_URL. '/'. $folder; if($no) { - $url .= '/'. $no; + + if( $config['cf_bbs_rewrite'] > 1 ){ + + $get_write = get_write( $g5['write_prefix'].$folder, $no , true); + + if( $get_write['wr_seo_title'] ){ + $url .= '/'. urlencode($get_write['wr_seo_title']).'/'; + } else { + $url .= '/'. $no; + } + + } else { + $url .= '/'. $no; + } + } else if($action) { $url .= '/'. $action; } @@ -76,6 +83,10 @@ function short_url_clean($url, $add_qry=''){ return $url; } +function correct_goto_url($url){ + return $url.'/'; +} + function generate_seo_url($string, $wordLimit = 0){ $separator = '-'; @@ -95,7 +106,7 @@ function generate_seo_url($string, $wordLimit = 0){ $string = strip_tags($string); foreach ($trans as $key => $val){ - $string = preg_replace('#'.$key.'#i'.(UTF8_ENABLED ? 'u' : ''), $val, $string); + $string = preg_replace('#'.$key.'#iu', $val, $string); } $string = strtolower($string); @@ -106,14 +117,18 @@ function generate_seo_url($string, $wordLimit = 0){ function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){ global $g5; + $exists_title = ''; if( $type === 'bbs' ){ - $sql = "select wr_seo_title FROM {$write_table} WHERE wr_seo_title = '$seo_title' AND wr_id != '$sql_id' limit 1"; + $sql = "select wr_seo_title FROM {$write_table} WHERE wr_seo_title = '".sql_real_escape_string($seo_title)."' AND wr_id <> '$sql_id' limit 1"; $row = sql_fetch($sql); + + $exists_title = $row['wr_seo_title']; + } else { return $seo_title; } - if ($row['wr_seo_title']) + if ($exists_title) return 'is_exists'; else return ''; @@ -122,14 +137,19 @@ function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){ function exist_seo_url_recursive($type, $seo_title, $write_table, $sql_id=0){ static $count = 0; - $seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 255 - (strlen($count)+1)) )."-$count" : $seo_title; + $seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 255 - ($count+1), '')."-$count" : $seo_title; - if( ! exist_seo_url($seo_title, $write_table, $sql_id) ){ + if( ! exist_seo_url($type, $seo_title_add, $write_table, $sql_id) ){ return $seo_title_add; } $count++; - return exist_seo_url_recursive($mb_id); + + if( $count > 253 ){ + return $seo_title_add; + } + + return exist_seo_url_recursive($type, $seo_title, $write_table, $sql_id); } ?> \ No newline at end of file diff --git a/mobile/skin/outlogin/basic/outlogin.skin.2.php b/mobile/skin/outlogin/basic/outlogin.skin.2.php index 6b338c82a..1fc98eca7 100644 --- a/mobile/skin/outlogin/basic/outlogin.skin.2.php +++ b/mobile/skin/outlogin/basic/outlogin.skin.2.php @@ -18,7 +18,7 @@ add_stylesheet(''

    diff --git a/plugin/debugbar/debugbar.php b/plugin/debugbar/debugbar.php new file mode 100644 index 000000000..f93cf3be5 --- /dev/null +++ b/plugin/debugbar/debugbar.php @@ -0,0 +1,254 @@ +', 0); +?> + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + + +
    +

    + 총 쿼리수 : +

    + +
    + + + + + + + + + + + $query){ + + if( empty($query) ) continue; + + $executed_time = $query['end_time'] - $query['start_time']; + $show_excuted_time = number_format((float)$executed_time * 1000, 2, '.', ''); + ?> + + + + + + + + + +
    + 쿼리 목록 +
    실행순서쿼리문실행시간
    +
    +
    + +
    + +
    + +
    + + + + + + + + + + + + + $count){ + + if( $tag === 'count' ) continue; + if( empty($count) ) continue; + + $datas = array(); + if( isset($event_callbacks[$tag]) ){ + + $event_callbacks_tag = $event_callbacks[$tag]; + ksort($event_callbacks_tag); + + foreach((array) $event_callbacks_tag as $priority=>$event_args){ + if( empty($event_args) ) continue; + + foreach($event_args as $index=>$funcs){ + $datas[] = array( + 'priority' => $priority, + 'function' => $funcs['function'], + 'arguments' => $funcs['arguments'], + ); + } //end foreach + } //end foreach + + $rowspan = $datas ? ' rowspan='.count($datas) : ''; + + $is_print = $rowspan; + + foreach($datas as $data){ + ?> + + + + + + + + + + + + + + + + + + + +
    + HOOK 목록 +
    event_tag (갯수)event_function인수의 수우선 순위
    >('.$count.')'; ?> + +
    ('.$count.')'; ?>   
    +
    + +
    + + + + + + + + + + + + + $count){ + + if( $tag === 'count' ) continue; + if( empty($count) ) continue; + + $datas = array(); + if( isset($replace_callbacks[$tag]) ){ + + $replace_callbacks_tag = $replace_callbacks[$tag]; + ksort($replace_callbacks_tag); + + foreach((array) $replace_callbacks_tag as $priority=>$replace_args){ + if( empty($replace_args) ) continue; + + foreach($replace_args as $index=>$funcs){ + $datas[] = array( + 'priority' => $priority, + 'function' => $funcs['function'], + 'arguments' => $funcs['arguments'], + ); + } //end foreach + } //end foreach + + $rowspan = $datas ? ' rowspan='.count($datas) : ''; + + $is_print = $rowspan; + + foreach($datas as $data){ + ?> + + + + + + + + + + + + + + + + + + + +
    + HOOK 목록 +
    replace_tag (갯수)replace_function인수의 수우선 순위
    >('.$count.')'; ?> + +
    ('.$count.')'; ?>   
    +
    + +
    +
    + +
    +
    +
    + \ No newline at end of file diff --git a/plugin/debugbar/index.php b/plugin/debugbar/index.php new file mode 100644 index 000000000..e69de29bb diff --git a/plugin/debugbar/style.css b/plugin/debugbar/style.css new file mode 100644 index 000000000..e01415591 --- /dev/null +++ b/plugin/debugbar/style.css @@ -0,0 +1,51 @@ +.debug_bar_wrap{display:block;position:relative;z-index:80;height:32px;background-color:#1ABC9C} +.debug_bar_content{display:none;position:absolute;z-index:81;width:100%;top:32px;min-height:300px;overflow:hidden;background:#fff;overflow-y:scroll;box-sizing:content-box;border-top:thin solid gray} +.debug_bar_text_group{position:relative;padding:0 20px 0 120px;line-height:32px;} +.debug_bar_btn_group{position:absolute;top:0;left:1em;line-height:32px;text-align:left} +.debug_bar_text{line-height:32px;display:block;width:100%;color:#fff;text-align:right;font-size:1.2em;overflow:hidden;text-overflow: ellipsis;-o-text-overflow:ellipsis;white-space:nowrap;word-wrap:normal !important} +.sql_query_list li{padding:1em;line-height:1em} +.debug_bar_content .content_inner{position:relative;padding:1em} +.debug_bar_content .debug_table_wrap{margin:10px 0} +.debugbar_tab::after{display:block;visibility:hidden;clear:both;content:""} +.debugbar_tab li{float:left;margin-bottom:-1px;position:relative;display:block;position:relative;display:block;padding:10px 15px} +.debugbar_tab li.debug_tab{border-bottom:2px solid #DDD} +.debugbar_tab li.active a,.debugbar_tab li.active a:focus,.debugbar_tab li.active a:hover{border-width:0} +.debugbar_tab li a{border:none;color:#666} +.debugbar_tab li.active a,.debugbar_tab li a:hover{border:none;color:#4285F4!important;background:transparent} +.debugbar_tab li a::after{content:"";background:#4285F4;height:2px;position:absolute;width:100%;left:0;bottom:-1px;transition:all 250ms ease 0;transform:scale(0)} +.debugbar_tab li.active a::after,.debugbar_tab li:hover a::after{transform:scale(1)} +.debugbar_tab li a::after{background:#21527d none repeat scroll 0 0;color:#fff} +.inner_debug {display:none} +.inner_debug h3.query_top{padding:1em;font-size:1.3em} +#debug_executed_query{display:block} +.lang_domain_list td .num{margin-right:10px;color:#9b9ea5;font-size:9px} +.debugbar_close_btn_el{position:absolute;top:20px;right:20px} +.debug_table{border:1px solid #ccc;border-collapse:collapse;margin:0;padding:0;width:100%} +.debug_table caption{display:none} +.debug_table tr{background:#f8f8f8;border:1px solid #ddd;padding:.35em} +.debug_table th,.debug_table td{padding:.625em;text-align:center} +.debug_table tbody tr:hover td{background:#c7d4dd!important} +.debug_table tbody tr:nth-child(even){background-color:#fff} +.debug_table td.left{text-align:left} +.debug_table th{font-size:.85em;letter-spacing:.1em;text-transform:uppercase} +.debug_table td img{text-align:center} + +.debug_table.hook_table th, .debug_table.hook_table td {text-align:left;border:1px solid #ddd;} +.hook_table .hook_count{margin-left:3px;font-size:0.9em;color:#7cbc0a} + +.debug_bar_btn_group button.debug_button{margin-top:3px} +button.debug_button{background-color:#7fbf4d;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#7fbf4d),color-stop(100%,#63a62f));background-image:-webkit-linear-gradient(top,#7fbf4d,#63a62f);background-image:-moz-linear-gradient(top,#7fbf4d,#63a62f);background-image:-ms-linear-gradient(top,#7fbf4d,#63a62f);background-image:-o-linear-gradient(top,#7fbf4d,#63a62f);background-image:linear-gradient(top,#7fbf4d,#63a62f);border:1px solid #63a62f;border-bottom:1px solid #5b992b;border-radius:3px;-webkit-box-shadow:inset 0 1px 0 0 #96ca6d;box-shadow:inset 0 1px 0 0 #96ca6d;color:#fff;padding:3px 0 4px;text-align:center;text-shadow:0 -1px 0 #4c9021;width:100px;font-weight:700;font-size:14px;vertical-align:top} +button.debug_button:hover{background-color:#76b347;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#76b347),color-stop(100%,#5e9e2e));background-image:-webkit-linear-gradient(top,#76b347,#5e9e2e);background-image:-moz-linear-gradient(top,#76b347,#5e9e2e);background-image:-ms-linear-gradient(top,#76b347,#5e9e2e);background-image:-o-linear-gradient(top,#76b347,#5e9e2e);background-image:linear-gradient(top,#76b347,#5e9e2e);-webkit-box-shadow:inset 0 1px 0 0 #8dbf67;box-shadow:inset 0 1px 0 0 #8dbf67;cursor:pointer} +button.debug_button:active{border:1px solid #5b992b;border-bottom:1px solid #538c27;-webkit-box-shadow:inset 0 0 8px 4px #548c29,0 1px 0 0 #eee;box-shadow:inset 0 0 8px 4px #548c29,0 1px 0 0 #eee} + +@media screen and (max-width: 600px) { + .debug_table{border:0} + .debug_table caption{font-size:1.3em} + .debug_table thead{display:none} + .debug_table tr{border-bottom:3px solid #ddd;display:block;margin-bottom:.625em} + .debug_table td{border-bottom:1px solid #ddd;display:block;font-size:.8em;text-align:right} + .debug_table td.left{text-align:right} + .debug_table td:before{content:attr(data-label);float:left;font-weight:700;text-transform:uppercase} + .debug_table.hook_table th, .debug_table.hook_table td{border:0 none;border-bottom:1px solid #ddd;text-align:right} + .debug_table td:last-child{border-bottom:0 !important} +} \ No newline at end of file diff --git a/skin/outlogin/basic/outlogin.skin.2.php b/skin/outlogin/basic/outlogin.skin.2.php index 2341db4c8..d8e745e95 100644 --- a/skin/outlogin/basic/outlogin.skin.2.php +++ b/skin/outlogin/basic/outlogin.skin.2.php @@ -15,7 +15,7 @@ add_stylesheet('' 님 로그아웃 - 관리자 + 관리자
    • diff --git a/tail.sub.php b/tail.sub.php index a5d0a87b4..cf859d92f 100644 --- a/tail.sub.php +++ b/tail.sub.php @@ -25,6 +25,8 @@ $(function() { + + \ No newline at end of file diff --git a/theme/basic/head.php b/theme/basic/head.php index 61aaaef61..774c39de5 100644 --- a/theme/basic/head.php +++ b/theme/basic/head.php @@ -33,7 +33,7 @@ include_once(G5_LIB_PATH.'/popular.lib.php');
    • 정보수정
    • 로그아웃
    • -
    • 관리자
    • +
    • 관리자
    • 회원가입
    • diff --git a/theme/basic/skin/outlogin/basic/outlogin.skin.2.php b/theme/basic/skin/outlogin/basic/outlogin.skin.2.php index 2341db4c8..d8e745e95 100644 --- a/theme/basic/skin/outlogin/basic/outlogin.skin.2.php +++ b/theme/basic/skin/outlogin/basic/outlogin.skin.2.php @@ -15,7 +15,7 @@ add_stylesheet('' 님 로그아웃 - 관리자 + 관리자
      • diff --git a/theme/basic/tail.sub.php b/theme/basic/tail.sub.php index ec5920f63..6772a3772 100644 --- a/theme/basic/tail.sub.php +++ b/theme/basic/tail.sub.php @@ -20,6 +20,8 @@ $(function() { + + \ No newline at end of file