짧은 주소 url 수정
This commit is contained in:
1 parent
7547b6e0ab
commit
cbeef0e453
22 files changed
+541
-143
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('_GNUBOARD_')) exit;
|
if (!defined('_GNUBOARD_')) exit;
|
||||||
|
|
||||||
$begin_time = get_microtime();
|
$g5_debug['php']['begin_time'] = $begin_time = get_microtime();
|
||||||
|
|
||||||
$files = glob(G5_ADMIN_PATH.'/css/admin_extend_*');
|
$files = glob(G5_ADMIN_PATH.'/css/admin_extend_*');
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ if( $co_include_tail && ! is_include_path_check($co_include_tail) ){
|
|||||||
$error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 하단 파일 경로에 포함시킬수 없습니다.';
|
$error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 하단 파일 경로에 포함시킬수 없습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$co_seo_title = exist_seo_title_recursive('content', generate_seo_title($co_subject), $g5['content_table'], $co_id);
|
||||||
|
|
||||||
$sql_common = " co_include_head = '$co_include_head',
|
$sql_common = " co_include_head = '$co_include_head',
|
||||||
co_include_tail = '$co_include_tail',
|
co_include_tail = '$co_include_tail',
|
||||||
co_html = '$co_html',
|
co_html = '$co_html',
|
||||||
@@ -76,6 +78,7 @@ $sql_common = " co_include_head = '$co_include_head',
|
|||||||
co_subject = '$co_subject',
|
co_subject = '$co_subject',
|
||||||
co_content = '$co_content',
|
co_content = '$co_content',
|
||||||
co_mobile_content = '$co_mobile_content',
|
co_mobile_content = '$co_mobile_content',
|
||||||
|
co_seo_title = '$co_seo_title',
|
||||||
co_skin = '$co_skin',
|
co_skin = '$co_skin',
|
||||||
co_mobile_skin = '$co_mobile_skin' ";
|
co_mobile_skin = '$co_mobile_skin' ";
|
||||||
|
|
||||||
@@ -109,6 +112,8 @@ else if ($w == "d")
|
|||||||
if(function_exists('get_admin_captcha_by'))
|
if(function_exists('get_admin_captcha_by'))
|
||||||
get_admin_captcha_by('remove');
|
get_admin_captcha_by('remove');
|
||||||
|
|
||||||
|
g5_delete_cache_by_prefix('content-'.$co_id.'-');
|
||||||
|
|
||||||
if ($w == "" || $w == "u")
|
if ($w == "" || $w == "u")
|
||||||
{
|
{
|
||||||
if ($_FILES['co_himg']['name'])
|
if ($_FILES['co_himg']['name'])
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ if( isset($g5['social_profile_table']) && !sql_query(" DESC {$g5['social_profile
|
|||||||
$is_check = true;
|
$is_check = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 게시판 짧은 주소
|
||||||
$sql = " select bo_table from {$g5['board_table']} ";
|
$sql = " select bo_table from {$g5['board_table']} ";
|
||||||
$result = sql_query($sql);
|
$result = sql_query($sql);
|
||||||
|
|
||||||
@@ -93,6 +94,37 @@ while ($row = sql_fetch_array($result)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 내용 관리 짧은 주소
|
||||||
|
$sql = " SHOW COLUMNS FROM `{$g5['content_table']}` LIKE 'co_seo_title' ";
|
||||||
|
$row = sql_fetch($sql);
|
||||||
|
|
||||||
|
if( !$row ){
|
||||||
|
sql_query("ALTER TABLE `{$g5['content_table']}`
|
||||||
|
ADD `co_seo_title` varchar(255) NOT NULL DEFAULT '' AFTER `co_content`,
|
||||||
|
ADD INDEX `co_seo_title` (`co_seo_title`);
|
||||||
|
", false);
|
||||||
|
|
||||||
|
$is_check = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "select * from {$g5['content_table']} limit 100 ";
|
||||||
|
$result = sql_query($sql);
|
||||||
|
|
||||||
|
while ($row = sql_fetch_array($result)) {
|
||||||
|
|
||||||
|
if( ! $row['co_seo_title']){
|
||||||
|
|
||||||
|
$co_seo_title = exist_seo_title_recursive('content', generate_seo_title($row['co_subject']), $g5['content_table'], $row['co_id']);
|
||||||
|
|
||||||
|
$sql = " update {$g5['content_table']}
|
||||||
|
set co_seo_title = '$co_seo_title'
|
||||||
|
where co_id = '{$row['co_id']}' ";
|
||||||
|
sql_query($sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.';
|
$db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ CREATE TABLE `__TABLE_NAME__` (
|
|||||||
`wr_option` set('html1','html2','secret','mail') NOT NULL,
|
`wr_option` set('html1','html2','secret','mail') NOT NULL,
|
||||||
`wr_subject` varchar(255) NOT NULL,
|
`wr_subject` varchar(255) NOT NULL,
|
||||||
`wr_content` text NOT NULL,
|
`wr_content` text NOT NULL,
|
||||||
|
`wr_seo_title` varchar(255) NOT NULL DEFAULT ''
|
||||||
`wr_link1` text NOT NULL,
|
`wr_link1` text NOT NULL,
|
||||||
`wr_link2` text NOT NULL,
|
`wr_link2` text NOT NULL,
|
||||||
`wr_link1_hit` int(11) NOT NULL DEFAULT '0',
|
`wr_link1_hit` int(11) NOT NULL DEFAULT '0',
|
||||||
@@ -39,6 +40,7 @@ CREATE TABLE `__TABLE_NAME__` (
|
|||||||
`wr_9` varchar(255) NOT NULL,
|
`wr_9` varchar(255) NOT NULL,
|
||||||
`wr_10` varchar(255) NOT NULL,
|
`wr_10` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`wr_id`),
|
PRIMARY KEY (`wr_id`),
|
||||||
|
KEY `wr_seo_title` (`wr_seo_title`),
|
||||||
KEY `wr_num_reply_parent` (`wr_num`,`wr_reply`,`wr_parent`),
|
KEY `wr_num_reply_parent` (`wr_num`,`wr_reply`,`wr_parent`),
|
||||||
KEY `wr_is_comment` (`wr_is_comment`,`wr_id`)
|
KEY `wr_is_comment` (`wr_is_comment`,`wr_id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
+7
-3
@@ -6,14 +6,18 @@ if( !isset($g5['content_table']) ){
|
|||||||
die('<meta charset="utf-8">관리자 모드에서 게시판관리->내용 관리를 먼저 확인해 주세요.');
|
die('<meta charset="utf-8">관리자 모드에서 게시판관리->내용 관리를 먼저 확인해 주세요.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 내용
|
||||||
|
if($co_seo_title){
|
||||||
|
$co = get_content_by_field($g5['content_table'], 'content', 'co_seo_title', $co_seo_title);
|
||||||
|
} else {
|
||||||
|
$co = get_content_db($co_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (G5_IS_MOBILE) {
|
if (G5_IS_MOBILE) {
|
||||||
include_once(G5_MOBILE_PATH.'/content.php');
|
include_once(G5_MOBILE_PATH.'/content.php');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 내용
|
|
||||||
$sql = " select * from {$g5['content_table']} where co_id = '$co_id' ";
|
|
||||||
$co = sql_fetch($sql);
|
|
||||||
if (!$co['co_id'])
|
if (!$co['co_id'])
|
||||||
alert('등록된 내용이 없습니다.');
|
alert('등록된 내용이 없습니다.');
|
||||||
|
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ if($page_rows > 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g5_latest_cache_data($board['bo_table'], $list);
|
||||||
|
|
||||||
$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, get_pretty_url($bo_table, '', $qstr.'&page='));
|
$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, get_pretty_url($bo_table, '', $qstr.'&page='));
|
||||||
|
|
||||||
$list_href = '';
|
$list_href = '';
|
||||||
|
|||||||
+3
-2
@@ -69,14 +69,15 @@ if ($member['mb_level'] >= $board['bo_write_level']) {
|
|||||||
$reply_href = '';
|
$reply_href = '';
|
||||||
if ($member['mb_level'] >= $board['bo_reply_level']) {
|
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 = './write.php?w=r&bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr;
|
||||||
$reply_href = get_pretty_url($bo_table, '', 'wr_id='.$wr_id.$qstr, 'write');
|
$reply_href = get_pretty_url($bo_table, '', 'w=r&wr_id='.$wr_id.$qstr, 'write');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 수정, 삭제 링크
|
// 수정, 삭제 링크
|
||||||
$update_href = $delete_href = '';
|
$update_href = $delete_href = '';
|
||||||
// 로그인중이고 자신의 글이라면 또는 관리자라면 비밀번호를 묻지 않고 바로 수정, 삭제 가능
|
// 로그인중이고 자신의 글이라면 또는 관리자라면 비밀번호를 묻지 않고 바로 수정, 삭제 가능
|
||||||
if (($member['mb_id'] && ($member['mb_id'] === $write['mb_id'])) || $is_admin) {
|
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 = 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');
|
||||||
set_session('ss_delete_token', $token = uniqid(time()));
|
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);
|
$delete_href = G5_BBS_URL.'/delete.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&token='.$token.'&page='.$page.urldecode($qstr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ if ($w == '' || $w == 'r') {
|
|||||||
if (!isset($_POST['wr_subject']) || !trim($_POST['wr_subject']))
|
if (!isset($_POST['wr_subject']) || !trim($_POST['wr_subject']))
|
||||||
alert('제목을 입력하여 주십시오.');
|
alert('제목을 입력하여 주십시오.');
|
||||||
|
|
||||||
$wr_seo_title = exist_seo_url_recursive('bbs', generate_seo_url($wr_subject), $write_table, $wr_id);
|
$wr_seo_title = exist_seo_title_recursive('bbs', generate_seo_title($wr_subject), $write_table, $wr_id);
|
||||||
|
|
||||||
if ($w == '' || $w == 'r') {
|
if ($w == '' || $w == 'r') {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -418,7 +418,7 @@ if ($bo_table) {
|
|||||||
if (isset($wr_id) && $wr_id) {
|
if (isset($wr_id) && $wr_id) {
|
||||||
$write = get_write($write_table, $wr_id);
|
$write = get_write($write_table, $wr_id);
|
||||||
} else if (isset($wr_seo_title) && $wr_seo_title) {
|
} else if (isset($wr_seo_title) && $wr_seo_title) {
|
||||||
$write = get_write_by_field($write_table, 'wr_seo_title', $wr_seo_title);
|
$write = get_content_by_field($write_table, 'bbs', 'wr_seo_title', $wr_seo_title);
|
||||||
if( isset($write['wr_id']) ){
|
if( isset($write['wr_id']) ){
|
||||||
$wr_id = $write['wr_id'];
|
$wr_id = $write['wr_id'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,9 @@ define('G5_HANGUL', 16); // 한글
|
|||||||
define('G5_SPACE', 32); // 공백
|
define('G5_SPACE', 32); // 공백
|
||||||
define('G5_SPECIAL', 64); // 특수문자
|
define('G5_SPECIAL', 64); // 특수문자
|
||||||
|
|
||||||
|
// SEO TITLE 문단 길이
|
||||||
|
define('G5_SEO_TITEL_WORD_CUT', 8); // SEO TITLE 문단 길이
|
||||||
|
|
||||||
// 퍼미션
|
// 퍼미션
|
||||||
define('G5_DIR_PERMISSION', 0755); // 디렉토리 생성시 퍼미션
|
define('G5_DIR_PERMISSION', 0755); // 디렉토리 생성시 퍼미션
|
||||||
define('G5_FILE_PERMISSION', 0644); // 파일 생성시 퍼미션
|
define('G5_FILE_PERMISSION', 0644); // 파일 생성시 퍼미션
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function show_debug_bar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$memory_usage = function_exists( 'memory_get_peak_usage' ) ? memory_get_peak_usage() : memory_get_usage();
|
$memory_usage = function_exists( 'memory_get_peak_usage' ) ? memory_get_peak_usage() : memory_get_usage();
|
||||||
$php_run_time = get_microtime()-$gml_debug['begin_time'];
|
$php_run_time = get_microtime()-$g5_debug['php']['begin_time'];
|
||||||
|
|
||||||
include_once( G5_PLUGIN_PATH.'/debugbar/debugbar.php' );
|
include_once( G5_PLUGIN_PATH.'/debugbar/debugbar.php' );
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ if(!defined('G5_IS_ADMIN') && defined('G5_THEME_PATH') && is_file(G5_THEME_PATH.
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$begin_time = get_microtime();
|
$g5_debug['php']['begin_time'] = $begin_time = get_microtime();
|
||||||
|
|
||||||
if (!isset($g5['title'])) {
|
if (!isset($g5['title'])) {
|
||||||
$g5['title'] = $config['cf_title'];
|
$g5['title'] = $config['cf_title'];
|
||||||
|
|||||||
@@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
if (!defined('_GNUBOARD_')) exit;
|
||||||
|
|
||||||
|
class FileCache
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root cache directory.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_cache_path = '/tmp/cache';
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $file_extension = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a FileCache object
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct($options = array())
|
||||||
|
{
|
||||||
|
$available_options = array('_cache_path', 'file_extension');
|
||||||
|
foreach ($available_options as $name) {
|
||||||
|
if (isset($options[$name])) {
|
||||||
|
$this->$name = $options[$name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches an entry from the cache.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
*/
|
||||||
|
public function get($id)
|
||||||
|
{
|
||||||
|
$data = $this->_get($id);
|
||||||
|
return is_array($data) ? $data['data'] : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function get_cache_file_path($id){
|
||||||
|
|
||||||
|
$id = str_replace(DIRECTORY_SEPARATOR, '/', $id);
|
||||||
|
$add_separator = '';
|
||||||
|
$add_file_extension = '';
|
||||||
|
|
||||||
|
if( strpos('/', $id) !== 0 ){
|
||||||
|
$add_separator = '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ext = pathinfo($id, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if( !(isset($ext['extension']) && $ext['extension']) ){
|
||||||
|
$add_file_extension = $this->file_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_cache_path.$add_separator.$id.$add_file_extension;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function _get($id)
|
||||||
|
{
|
||||||
|
$cache_file_path = $this->get_cache_file_path($id);
|
||||||
|
|
||||||
|
if ( ! is_file($cache_file_path) )
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = unserialize(file_get_contents( $cache_file_path ));
|
||||||
|
|
||||||
|
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
|
||||||
|
{
|
||||||
|
unlink( $cache_file_path );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function write_file($path, $data, $mode = 'wb')
|
||||||
|
{
|
||||||
|
if ( ! $fp = @fopen($path, $mode))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
flock($fp, LOCK_EX);
|
||||||
|
|
||||||
|
for ($result = $written = 0, $length = strlen($data); $written < $length; $written += $result)
|
||||||
|
{
|
||||||
|
if (($result = fwrite($fp, substr($data, $written))) === FALSE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flock($fp, LOCK_UN);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
return is_int($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a cache entry.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$cache_file_path = $this->get_cache_file_path($id);
|
||||||
|
|
||||||
|
return file_exists($cache_file_path) ? unlink($cache_file_path) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts data into the cache.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param mixed $data
|
||||||
|
* @param int $lifetime
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function save($id, $data, $ttl = 60, $raw = FALSE)
|
||||||
|
{
|
||||||
|
$cache_file_path = $this->get_cache_file_path($id);
|
||||||
|
|
||||||
|
$contents = array(
|
||||||
|
'time' => time(),
|
||||||
|
'ttl' => $ttl,
|
||||||
|
'data' => $data
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->write_file($cache_file_path, serialize($contents)))
|
||||||
|
{
|
||||||
|
chmod($cache_file_path, G5_FILE_PERMISSION);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches a base directory to store the cache data
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getCacheDirectory()
|
||||||
|
{
|
||||||
|
return $this->_cache_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes some data to a string so it can be written to disk
|
||||||
|
*
|
||||||
|
* @param mixed $data
|
||||||
|
* @param int $ttl
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function encode($data, $ttl)
|
||||||
|
{
|
||||||
|
$expire = null;
|
||||||
|
if ($ttl !== null) {
|
||||||
|
$expire = time() + $ttl;
|
||||||
|
}
|
||||||
|
return serialize(array($data, $expire));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a string encoded by {@see encode()}
|
||||||
|
*
|
||||||
|
* Must returns a tuple (data, expire). Expire
|
||||||
|
* can be null to signal no expiration.
|
||||||
|
*
|
||||||
|
* @param string $data
|
||||||
|
* @return array (data, expire)
|
||||||
|
*/
|
||||||
|
public function decode($data)
|
||||||
|
{
|
||||||
|
return unserialize($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
+29
-12
@@ -3,21 +3,27 @@ if (!defined('_GNUBOARD_')) exit;
|
|||||||
|
|
||||||
Class G5_object_store {
|
Class G5_object_store {
|
||||||
public $writes = array();
|
public $writes = array();
|
||||||
|
public $contents = array();
|
||||||
|
|
||||||
function get($type, $key, $group ='default') {
|
function get($type, $key, $group ='default') {
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bbs':
|
case 'bbs':
|
||||||
if( $this->exists('bbs', $key, $group) ){
|
$datas = $this->writes;
|
||||||
if ( is_object($this->writes[$group][$key]) )
|
break;
|
||||||
return clone $this->writes[$group][$key];
|
case 'content' :
|
||||||
else
|
$datas = $this->contents;
|
||||||
return $this->writes[$group][$key];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $this->exists($type, $key, $group) ){
|
||||||
|
if ( is_object($datas[$group][$key]) )
|
||||||
|
return clone $datas[$group][$key];
|
||||||
|
else
|
||||||
|
return $datas[$group][$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists($type, $key, $group = 'default' ) {
|
function exists($type, $key, $group = 'default' ) {
|
||||||
@@ -28,6 +34,9 @@ Class G5_object_store {
|
|||||||
case 'bbs':
|
case 'bbs':
|
||||||
$datas = $this->writes;
|
$datas = $this->writes;
|
||||||
break;
|
break;
|
||||||
|
case 'content':
|
||||||
|
$datas = $this->contents;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isset($datas[$group]) && ( isset($datas[$group][$key]) || array_key_exists($key, $datas[$group]) );
|
return isset($datas[$group]) && ( isset($datas[$group][$key]) || array_key_exists($key, $datas[$group]) );
|
||||||
@@ -41,6 +50,9 @@ Class G5_object_store {
|
|||||||
case 'bbs':
|
case 'bbs':
|
||||||
$this->writes[$group][$key] = $data;
|
$this->writes[$group][$key] = $data;
|
||||||
break;
|
break;
|
||||||
|
case 'content':
|
||||||
|
$this->contents[$group][$key] = $data;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,13 +60,18 @@ Class G5_object_store {
|
|||||||
function delete($key, $group='default') {
|
function delete($key, $group='default') {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bbs':
|
case 'bbs':
|
||||||
if ( ! $this->exists('bbs', $key, $group) )
|
$datas = $this->writes;
|
||||||
return false;
|
break;
|
||||||
|
case 'content':
|
||||||
unset( $this->writes[$group][$key] );
|
$datas = $this->contents;
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $this->exists('bbs', $key, $group) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
unset( $datas[$group][$key] );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end Class
|
} //end Class
|
||||||
|
|||||||
@@ -1,6 +1,73 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('_GNUBOARD_')) exit;
|
if (!defined('_GNUBOARD_')) exit;
|
||||||
|
|
||||||
|
include_once(dirname(__FILE__) .'/Cache/FileCache.class.php');
|
||||||
|
|
||||||
|
function get_cachemanage_instance(){
|
||||||
|
static $instance = null;
|
||||||
|
|
||||||
|
if( ! (defined('G5_USE_CACHE') && G5_USE_CACHE) ) return $instance;
|
||||||
|
|
||||||
|
if( $instance === null ){
|
||||||
|
$options = array(
|
||||||
|
'_cache_path'=> G5_DATA_PATH.'/cache',
|
||||||
|
'file_extension'=>'.php',
|
||||||
|
);
|
||||||
|
$instance = new FileCache($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function g5_cache_secret_key(){
|
||||||
|
static $str = '';
|
||||||
|
|
||||||
|
if( $str ) return $str;
|
||||||
|
|
||||||
|
$str = substr(md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['DOCUMENT_ROOT']), 0, 6);
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function g5_latest_cache_data($bo_table, $cache_list=array(), $find_wr_id=0){
|
||||||
|
static $cache = array();
|
||||||
|
|
||||||
|
if( $bo_table && $cache_list && ! isset($cache[$bo_table]) ){
|
||||||
|
foreach( (array) $cache_list as $wr ){
|
||||||
|
if( empty($wr) || ! isset($wr['wr_id']) ) continue;
|
||||||
|
$cache[$bo_table][$wr['wr_id']] = $wr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $find_wr_id && isset($cache[$bo_table][$find_wr_id]) ){
|
||||||
|
return $cache[$bo_table][$find_wr_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function g5_set_cache($key, $save_data, $ttl = null){
|
||||||
|
|
||||||
|
if( $cache = get_cachemanage_instance() ){
|
||||||
|
$cache->save($key, $save_data, $ttl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function g5_get_cache($key){
|
||||||
|
|
||||||
|
if( $cache = get_cachemanage_instance() ){
|
||||||
|
return $cache->get($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function g5_delete_cache($key){
|
||||||
|
if( $cache = get_cachemanage_instance() ){
|
||||||
|
return $cache->delete($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function g5_delete_all_cache(){
|
function g5_delete_all_cache(){
|
||||||
|
|
||||||
$board_tables = get_board_names();
|
$board_tables = get_board_names();
|
||||||
@@ -13,4 +80,15 @@ function g5_delete_all_cache(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function g5_delete_cache_by_prefix($key){
|
||||||
|
$files = glob(G5_DATA_PATH.'/cache/'.$key.'*');
|
||||||
|
|
||||||
|
foreach( (array) $files as $filename){
|
||||||
|
if(empty($filename)) continue;
|
||||||
|
|
||||||
|
unlink($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($files) ? true : false;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
+35
-45
@@ -703,33 +703,6 @@ function get_write($write_table, $wr_id, $is_cache=false)
|
|||||||
return $write;
|
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)
|
function get_next_num($table)
|
||||||
{
|
{
|
||||||
@@ -2246,11 +2219,7 @@ function delete_cache_latest($bo_table)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = glob(G5_DATA_PATH.'/cache/latest-'.$bo_table.'-*');
|
g5_delete_cache_by_prefix('latest-'.$bo_table.'-');
|
||||||
if (is_array($files)) {
|
|
||||||
foreach ($files as $filename)
|
|
||||||
unlink($filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 게시판 첨부파일 썸네일 삭제
|
// 게시판 첨부파일 썸네일 삭제
|
||||||
@@ -2535,6 +2504,8 @@ class html_process {
|
|||||||
|
|
||||||
array_multisort($order, SORT_ASC, $index, SORT_ASC, $links);
|
array_multisort($order, SORT_ASC, $index, SORT_ASC, $links);
|
||||||
|
|
||||||
|
$links = apply_replace('html_process_css_files', $links);
|
||||||
|
|
||||||
foreach($links as $link) {
|
foreach($links as $link) {
|
||||||
if(!trim($link[1]))
|
if(!trim($link[1]))
|
||||||
continue;
|
continue;
|
||||||
@@ -2561,6 +2532,8 @@ class html_process {
|
|||||||
|
|
||||||
array_multisort($order, SORT_ASC, $index, SORT_ASC, $scripts);
|
array_multisort($order, SORT_ASC, $index, SORT_ASC, $scripts);
|
||||||
|
|
||||||
|
$scripts = apply_replace('html_process_script_files', $scripts);
|
||||||
|
|
||||||
foreach($scripts as $js) {
|
foreach($scripts as $js) {
|
||||||
if(!trim($js[1]))
|
if(!trim($js[1]))
|
||||||
continue;
|
continue;
|
||||||
@@ -2589,6 +2562,17 @@ class html_process {
|
|||||||
$nl = "\n";
|
$nl = "\n";
|
||||||
$buffer = preg_replace('#(</head>[^<]*<body[^>]*>)#', "$javascript{$nl}$1", $buffer);
|
$buffer = preg_replace('#(</head>[^<]*<body[^>]*>)#', "$javascript{$nl}$1", $buffer);
|
||||||
|
|
||||||
|
$meta_tag = apply_replace('html_process_add_meta', '');
|
||||||
|
|
||||||
|
if( $meta_tag ){
|
||||||
|
/*
|
||||||
|
</title>content<body>
|
||||||
|
전에 메타태그가 위치 하도록 하게 한다.
|
||||||
|
*/
|
||||||
|
$nl = "\n";
|
||||||
|
$buffer = preg_replace('#(<title[^>]*>.*?</title>)#', "$meta_tag{$nl}$1", $buffer);
|
||||||
|
}
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3269,22 +3253,19 @@ function clean_query_string($query, $amp=true)
|
|||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_device_change_url()
|
function get_params_merge_url($params){
|
||||||
{
|
|
||||||
$p = @parse_url(G5_URL);
|
$p = @parse_url(G5_URL);
|
||||||
$href = $p['scheme'].'://'.$p['host'];
|
$href = $p['scheme'].'://'.$p['host'];
|
||||||
if(isset($p['port']) && $p['port'])
|
if(isset($p['port']) && $p['port'])
|
||||||
$href .= ':'.$p['port'];
|
$href .= ':'.$p['port'];
|
||||||
$href .= $_SERVER['SCRIPT_NAME'];
|
|
||||||
|
|
||||||
|
if( $tmp = explode('?', $_SERVER['REQUEST_URI']) ){
|
||||||
|
if( isset($tmp[0]) && $tmp[0] )
|
||||||
|
$href .= $tmp[0];
|
||||||
|
}
|
||||||
$q = array();
|
$q = array();
|
||||||
$device = 'device='.(G5_IS_MOBILE ? 'pc' : 'mobile');
|
|
||||||
|
|
||||||
if($_SERVER['QUERY_STRING']) {
|
if($_SERVER['QUERY_STRING']) {
|
||||||
foreach($_GET as $key=>$val) {
|
foreach($_GET as $key=>$val) {
|
||||||
if($key == 'device')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$key = strip_tags($key);
|
$key = strip_tags($key);
|
||||||
$val = strip_tags($val);
|
$val = strip_tags($val);
|
||||||
|
|
||||||
@@ -3293,16 +3274,25 @@ function get_device_change_url()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($q)) {
|
if( is_array($params) ){
|
||||||
$query = http_build_query($q, '', '&');
|
$q = array_merge($q, $params);
|
||||||
$href .= '?'.$query.'&'.$device;
|
|
||||||
} else {
|
|
||||||
$href .= '?'.$device;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query = http_build_query($q, '', '&');
|
||||||
|
$href .= '?'.$query;
|
||||||
|
|
||||||
return $href;
|
return $href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_device_change_url()
|
||||||
|
{
|
||||||
|
$q = array();
|
||||||
|
$device = (G5_IS_MOBILE ? 'pc' : 'mobile');
|
||||||
|
$q['device'] = $device;
|
||||||
|
|
||||||
|
return get_params_merge_url($q);
|
||||||
|
}
|
||||||
|
|
||||||
// 스킨 path
|
// 스킨 path
|
||||||
function get_skin_path($dir, $skin)
|
function get_skin_path($dir, $skin)
|
||||||
{
|
{
|
||||||
|
|||||||
+60
-11
@@ -19,22 +19,31 @@ function get_config($is_cache=false){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_content_db($co_id, $is_cache=false){
|
function get_content_db($co_id, $is_cache=false){
|
||||||
global $g5;
|
global $g5, $g5_object;
|
||||||
|
|
||||||
static $cache = array();
|
static $cache = array();
|
||||||
|
|
||||||
$co_id = preg_replace('/[^a-z0-9_]/i', '', $co_id);
|
$type = 'content';
|
||||||
$key = md5($co_id);
|
|
||||||
|
|
||||||
if( $is_cache && isset($cache[$key]) ){
|
$co_id = preg_replace('/[^a-z0-9_]/i', '', $co_id);
|
||||||
return $cache[$key];
|
$co = $g5_object->get($type, $co_id, $type);
|
||||||
|
|
||||||
|
if( !$co ){
|
||||||
|
|
||||||
|
$cache_file_name = "{$type}-{$co_id}-".g5_cache_secret_key();
|
||||||
|
$co = g5_get_cache($cache_file_name, 10800);
|
||||||
|
|
||||||
|
if( $co === false ){
|
||||||
|
$sql = " select * from {$g5['content_table']} where co_id = '$co_id' ";
|
||||||
|
$co = sql_fetch($sql);
|
||||||
|
|
||||||
|
g5_set_cache($cache_file_name, $co, 10800);
|
||||||
|
}
|
||||||
|
|
||||||
|
$g5_object->set($type, $co_id, $co, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = " select * from {$g5['content_table']} where co_id = '$co_id' ";
|
return $co;
|
||||||
|
|
||||||
$cache[$key] = sql_fetch($sql);
|
|
||||||
|
|
||||||
return $cache[$key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_board_names(){
|
function get_board_names(){
|
||||||
@@ -79,6 +88,46 @@ function get_board_db($bo_table, $is_cache=false){
|
|||||||
return $cache[$key];
|
return $cache[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 게시판 테이블에서 하나의 행을 읽음
|
||||||
|
function get_content_by_field($write_table, $type='bbs', $where_field='', $where_value='', $is_cache=false)
|
||||||
|
{
|
||||||
|
global $g5, $g5_object;
|
||||||
|
|
||||||
|
if( $type === 'content' ){
|
||||||
|
$check_array = array('co_id', 'co_html', 'co_subject', 'co_content', 'co_seo_title', 'co_mobile_content', 'co_skin', 'co_mobile_skin', 'co_tag_filter_use', 'co_hit', 'co_include_head', 'co_include_tail');
|
||||||
|
} else {
|
||||||
|
$check_array = 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! in_array($where_field, $check_array) ){
|
||||||
|
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);
|
||||||
|
|
||||||
|
if( $type === 'content' ){
|
||||||
|
|
||||||
|
$g5_object->set($type, $cache[$key]['co_id'], $cache[$key], 'content');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$wr_bo_table = preg_replace('/^'.preg_quote($g5['write_prefix']).'/i', '', $write_table);
|
||||||
|
$g5_object->set($type, $cache[$key]['wr_id'], $cache[$key], $wr_bo_table);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cache[$key];
|
||||||
|
}
|
||||||
|
|
||||||
// 게시판 첨부파일 테이블에서 하나의 행을 읽음
|
// 게시판 첨부파일 테이블에서 하나의 행을 읽음
|
||||||
function get_board_file_db($bo_table, $wr_id, $fields='*', $add_where='', $is_cache=false)
|
function get_board_file_db($bo_table, $wr_id, $fields='*', $add_where='', $is_cache=false)
|
||||||
{
|
{
|
||||||
@@ -190,7 +239,7 @@ function get_thumbnail_find_cache($bo_table, $wr_id, $wr_key){
|
|||||||
|
|
||||||
if( $wr_key === 'content' ){
|
if( $wr_key === 'content' ){
|
||||||
$write_table = $g5['write_prefix'].$bo_table;
|
$write_table = $g5['write_prefix'].$bo_table;
|
||||||
return get_write_db($write_table, $wr_id, 'wr_content', true);
|
return get_write($write_table, $wr_id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_board_file_db($bo_table, $wr_id, 'bf_file, bf_content', "and bf_type between '1' and '3'", true);
|
return get_board_file_db($bo_table, $wr_id, 'bf_file, bf_content', "and bf_type between '1' and '3'", true);
|
||||||
|
|||||||
+38
-41
@@ -30,46 +30,27 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_fwrite = false;
|
$caches = null;
|
||||||
|
|
||||||
if(G5_USE_CACHE) {
|
if(G5_USE_CACHE) {
|
||||||
$cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-serial.php";
|
$cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();
|
||||||
|
$caches = g5_get_cache($cache_file_name);
|
||||||
if(!file_exists($cache_file)) {
|
$cache_list = isset($caches['list']) ? $caches['list'] : array();
|
||||||
$cache_fwrite = true;
|
g5_latest_cache_data($bo_table, $cache_list);
|
||||||
} else {
|
|
||||||
if($cache_time > 0) {
|
|
||||||
$filetime = filemtime($cache_file);
|
|
||||||
if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) {
|
|
||||||
@unlink($cache_file);
|
|
||||||
$cache_fwrite = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$cache_fwrite) {
|
|
||||||
try{
|
|
||||||
$file_contents = file_get_contents($cache_file);
|
|
||||||
$file_ex = explode("\n\n", $file_contents);
|
|
||||||
$caches = unserialize(base64_decode($file_ex[1]));
|
|
||||||
|
|
||||||
$list = (is_array($caches) && isset($caches['list'])) ? $caches['list'] : array();
|
|
||||||
$bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';
|
|
||||||
} catch(Exception $e){
|
|
||||||
$cache_fwrite = true;
|
|
||||||
$list = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!G5_USE_CACHE || $cache_fwrite) {
|
if( $caches === false ){
|
||||||
|
|
||||||
$list = array();
|
$list = array();
|
||||||
|
|
||||||
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
|
$board = get_board_db($bo_table, true);
|
||||||
$board = sql_fetch($sql);
|
|
||||||
$bo_subject = get_text($board['bo_subject']);
|
$bo_subject = get_text($board['bo_subject']);
|
||||||
|
$board['bo_use_sideview'] = 0; // not use sideview
|
||||||
|
|
||||||
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
|
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
|
||||||
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
|
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
|
||||||
|
|
||||||
$result = sql_query($sql);
|
$result = sql_query($sql);
|
||||||
for ($i=0; $row = sql_fetch_array($result); $i++) {
|
for ($i=0; $row = sql_fetch_array($result); $i++) {
|
||||||
try {
|
try {
|
||||||
@@ -82,22 +63,38 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
|||||||
$row['file'] = array('count'=>0);
|
$row['file'] = array('count'=>0);
|
||||||
}
|
}
|
||||||
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
|
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
|
||||||
}
|
|
||||||
|
|
||||||
if($cache_fwrite) {
|
$list[$i]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "and bf_type between '1' and '3'", true) : array('bf_file'=>'', 'bf_content'=>'');
|
||||||
$handle = fopen($cache_file, 'w');
|
$list[$i]['bo_table'] = $bo_table;
|
||||||
|
// 썸네일 추가
|
||||||
|
if($options) {
|
||||||
|
$options_arr = explode(',', $options);
|
||||||
|
$thumb_width = $options_arr[0];
|
||||||
|
$thumb_height = $options_arr[1];
|
||||||
|
$thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);
|
||||||
|
// 이미지 썸네일
|
||||||
|
if($thumb['src']) {
|
||||||
|
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
|
||||||
|
$list[$i]['img_thumbnail'] = '<a href="'.$list[$i]['href'].'" class="lt_img">'.$img_content.'</a>';
|
||||||
|
// } else {
|
||||||
|
// $img_content = '<img src="'. G5_IMG_URL.'/no_img.png'.'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="no_img">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g5_latest_cache_data($bo_table, $list);
|
||||||
|
|
||||||
|
if(G5_USE_CACHE) {
|
||||||
|
|
||||||
$caches = array(
|
$caches = array(
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
'bo_subject' => sql_escape_string($bo_subject),
|
'bo_subject' => sql_escape_string($bo_subject),
|
||||||
);
|
);
|
||||||
$cache_content = "<?php if (!defined('_GNUBOARD_')) exit; ?>\n\n";
|
|
||||||
$cache_content .= base64_encode(serialize($caches)); //serialize
|
|
||||||
|
|
||||||
fwrite($handle, $cache_content);
|
g5_set_cache($cache_file_name, $caches, 3600 * $cache_time);
|
||||||
fclose($handle);
|
|
||||||
|
|
||||||
@chmod($cache_file, 0640);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$list = $cache_list;
|
||||||
|
$bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
|
|||||||
$filename = $alt = "";
|
$filename = $alt = "";
|
||||||
$edt = false;
|
$edt = false;
|
||||||
|
|
||||||
$sql = " select bf_file, bf_content from {$g5['board_file_table']}
|
$row = get_thumbnail_find_cache($bo_table, $wr_id, 'file');
|
||||||
where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_type between '1' and '3' order by bf_no limit 0, 1 ";
|
|
||||||
$row = sql_fetch($sql);
|
|
||||||
|
|
||||||
if($row['bf_file']) {
|
if($row['bf_file']) {
|
||||||
$filename = $row['bf_file'];
|
$filename = $row['bf_file'];
|
||||||
|
|||||||
+53
-17
@@ -10,48 +10,65 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
|||||||
global $g5, $config;
|
global $g5, $config;
|
||||||
|
|
||||||
$boards = get_board_names();
|
$boards = get_board_names();
|
||||||
|
$segments = array();
|
||||||
|
$url = $add_query = '';
|
||||||
|
|
||||||
// use shortten url
|
// use shortten url
|
||||||
if($config['cf_bbs_rewrite']) {
|
if($config['cf_bbs_rewrite']) {
|
||||||
if(in_array($folder, $boards)) {
|
|
||||||
|
|
||||||
$url = G5_URL. '/'. $folder;
|
$segments[0] = G5_URL;
|
||||||
|
|
||||||
|
if( $folder === 'content' && $no ){ // 내용관리
|
||||||
|
|
||||||
|
$segments[1] = $folder;
|
||||||
|
|
||||||
|
if( $config['cf_bbs_rewrite'] > 1 ){
|
||||||
|
|
||||||
|
$get_content = get_content_db( $no , true);
|
||||||
|
$segments[2] = $get_content['co_seo_title'] ? urlencode($get_content['co_seo_title']).'/' : urlencode($no);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$segments[2] = urlencode($no);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(in_array($folder, $boards)) { // 게시판
|
||||||
|
|
||||||
|
$segments[1] = $folder;
|
||||||
|
|
||||||
if($no) {
|
if($no) {
|
||||||
|
|
||||||
if( $config['cf_bbs_rewrite'] > 1 ){
|
if( $config['cf_bbs_rewrite'] > 1 ){
|
||||||
|
|
||||||
$get_write = get_write( $g5['write_prefix'].$folder, $no , true);
|
$get_write = get_write( $g5['write_prefix'].$folder, $no , true);
|
||||||
|
|
||||||
if( $get_write['wr_seo_title'] ){
|
$segments[2] = $get_write['wr_seo_title'] ? urlencode($get_write['wr_seo_title']).'/' : urlencode($no);
|
||||||
$url .= '/'. urlencode($get_write['wr_seo_title']).'/';
|
|
||||||
} else {
|
|
||||||
$url .= '/'. $no;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$url .= '/'. $no;
|
$segments[2] = urlencode($no);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if($action) {
|
} else if($action) {
|
||||||
$url .= '/'. $action;
|
$segments[2] = urlencode($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$url = G5_URL. '/'.$folder;
|
$segments[1] = $folder;
|
||||||
if($no) {
|
if($no) {
|
||||||
$no_array = explode("=", $no);
|
$no_array = explode("=", $no);
|
||||||
$no_value = end($no_array);
|
$no_value = end($no_array);
|
||||||
$url .= '/'. $no_value;
|
$segments[2] = urlencode($no_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($query_string) {
|
if($query_string) {
|
||||||
// If the first character of the query string is '&', replace it with '?'.
|
// If the first character of the query string is '&', replace it with '?'.
|
||||||
if(substr($query_string, 0, 1) == '&') {
|
if(substr($query_string, 0, 1) == '&') {
|
||||||
$url .= preg_replace("/\&/", "?", $query_string, 1);
|
$add_query = preg_replace("/\&/", "?", $query_string, 1);
|
||||||
} else {
|
} else {
|
||||||
$url .= '?'. $query_string;
|
$add_query = '?'. $query_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // don't use shortten url
|
} else { // don't use shortten url
|
||||||
if(in_array($folder, $boards)) {
|
if(in_array($folder, $boards)) {
|
||||||
$url = G5_BBS_URL. '/board.php?bo_table='. $folder;
|
$url = G5_BBS_URL. '/board.php?bo_table='. $folder;
|
||||||
@@ -70,9 +87,11 @@ function get_pretty_url($folder, $no='', $query_string='', $action='')
|
|||||||
$url .= ($no ? '?' : '&'). $query_string;
|
$url .= ($no ? '?' : '&'). $query_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$segments[0] = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
return implode('/', $segments).$add_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function short_url_clean($url, $add_qry=''){
|
function short_url_clean($url, $add_qry=''){
|
||||||
@@ -87,7 +106,7 @@ function correct_goto_url($url){
|
|||||||
return $url.'/';
|
return $url.'/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_seo_url($string, $wordLimit = 0){
|
function generate_seo_title($string, $wordLimit=G5_SEO_TITEL_WORD_CUT){
|
||||||
$separator = '-';
|
$separator = '-';
|
||||||
|
|
||||||
if($wordLimit != 0){
|
if($wordLimit != 0){
|
||||||
@@ -105,6 +124,11 @@ function generate_seo_url($string, $wordLimit = 0){
|
|||||||
);
|
);
|
||||||
|
|
||||||
$string = strip_tags($string);
|
$string = strip_tags($string);
|
||||||
|
|
||||||
|
if( function_exists('mb_convert_encoding') ){
|
||||||
|
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($trans as $key => $val){
|
foreach ($trans as $key => $val){
|
||||||
$string = preg_replace('#'.$key.'#iu', $val, $string);
|
$string = preg_replace('#'.$key.'#iu', $val, $string);
|
||||||
}
|
}
|
||||||
@@ -118,12 +142,24 @@ function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){
|
|||||||
global $g5;
|
global $g5;
|
||||||
|
|
||||||
$exists_title = '';
|
$exists_title = '';
|
||||||
|
$sql_id = preg_replace('/[^a-z0-9_]/i', '', $sql_id);
|
||||||
|
|
||||||
if( $type === 'bbs' ){
|
if( $type === 'bbs' ){
|
||||||
$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";
|
$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);
|
$row = sql_fetch($sql);
|
||||||
|
|
||||||
|
echo $sql;
|
||||||
|
|
||||||
$exists_title = $row['wr_seo_title'];
|
$exists_title = $row['wr_seo_title'];
|
||||||
|
|
||||||
|
} else if ( $type === 'content' ){
|
||||||
|
|
||||||
|
$sql = "select co_seo_title FROM {$write_table} WHERE co_seo_title = '".sql_real_escape_string($seo_title)."' AND co_id <> '$sql_id' limit 1";
|
||||||
|
$row = sql_fetch($sql);
|
||||||
|
|
||||||
|
$exists_title = $row['co_seo_title'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return $seo_title;
|
return $seo_title;
|
||||||
}
|
}
|
||||||
@@ -134,7 +170,7 @@ function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function exist_seo_url_recursive($type, $seo_title, $write_table, $sql_id=0){
|
function exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id=0){
|
||||||
static $count = 0;
|
static $count = 0;
|
||||||
|
|
||||||
$seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 255 - ($count+1), '')."-$count" : $seo_title;
|
$seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 255 - ($count+1), '')."-$count" : $seo_title;
|
||||||
@@ -149,7 +185,7 @@ function exist_seo_url_recursive($type, $seo_title, $write_table, $sql_id=0){
|
|||||||
return $seo_title_add;
|
return $seo_title_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
return exist_seo_url_recursive($type, $seo_title, $write_table, $sql_id);
|
return exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once('./_common.php');
|
include_once('./_common.php');
|
||||||
|
|
||||||
// 내용
|
|
||||||
$sql = " select * from {$g5['content_table']} where co_id = '$co_id' ";
|
|
||||||
$co = sql_fetch($sql);
|
|
||||||
if (!$co['co_id'])
|
if (!$co['co_id'])
|
||||||
alert('등록된 내용이 없습니다.');
|
alert('등록된 내용이 없습니다.');
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// 이 파일은 새로운 파일 생성시 반드시 포함되어야 함
|
// 이 파일은 새로운 파일 생성시 반드시 포함되어야 함
|
||||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||||
|
|
||||||
$begin_time = get_microtime();
|
$g5_debug['php']['begin_time'] = $begin_time = get_microtime();
|
||||||
|
|
||||||
if (!isset($g5['title'])) {
|
if (!isset($g5['title'])) {
|
||||||
$g5['title'] = $config['cf_title'];
|
$g5['title'] = $config['cf_title'];
|
||||||
|
|||||||
Reference in new issue
Block a user