짧은 URL 적용중
This commit is contained in:
1 parent
58b86e556a
commit
7c1e1e6240
3 files changed
+81
-2
No files matched your search
@@ -74,6 +74,22 @@ if( isset($g5['social_profile_table']) && !sql_query(" DESC {$g5['social_profile
|
||||
$is_check = true;
|
||||
}
|
||||
|
||||
$sql = " select bo_table from {$g5['board_table']} ";
|
||||
$result = sql_query($sql);
|
||||
|
||||
while ($row = sql_fetch_array($result)) {
|
||||
$write_table = $g5['write_prefix'] . $row['bo_table']; // 게시판 테이블 전체이름
|
||||
|
||||
$row = sql_fetch("select * from {$write_table} limit 1");
|
||||
|
||||
if(! isset($row['wr_unique'])){
|
||||
sql_query("ALTER TABLE `{$write_table}`
|
||||
ADD `wr_seo_title` varchar(255) NOT NULL DEFAULT '' AFTER `wr_content`,
|
||||
ADD INDEX `wr_seo_title` (`wr_seo_title`);
|
||||
", true);
|
||||
}
|
||||
}
|
||||
|
||||
$db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.';
|
||||
?>
|
||||
|
||||
|
||||
+8
-2
@@ -409,9 +409,15 @@ if ($bo_table) {
|
||||
set_cookie("ck_bo_table", $board['bo_table'], 86400 * 1);
|
||||
$gr_id = $board['gr_id'];
|
||||
$write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
|
||||
//$comment_table = $g5['write_prefix'] . $bo_table . $g5['comment_suffix']; // 코멘트 테이블 전체이름
|
||||
if (isset($wr_id) && $wr_id)
|
||||
|
||||
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);
|
||||
if( isset($write['wr_id']) ){
|
||||
$wr_id = $write['wr_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,4 +75,61 @@ function short_url_clean($url, $add_qry=''){
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function generate_seo_url($string, $wordLimit = 0){
|
||||
$separator = '-';
|
||||
|
||||
if($wordLimit != 0){
|
||||
$wordArr = explode(' ', $string);
|
||||
$string = implode(' ', array_slice($wordArr, 0, $wordLimit));
|
||||
}
|
||||
|
||||
$quoteSeparator = preg_quote($separator, '#');
|
||||
|
||||
$trans = array(
|
||||
'&.+?;' => '',
|
||||
'[^\w\d _-]' => '',
|
||||
'\s+' => $separator,
|
||||
'('.$quoteSeparator.')+'=> $separator
|
||||
);
|
||||
|
||||
$string = strip_tags($string);
|
||||
foreach ($trans as $key => $val){
|
||||
$string = preg_replace('#'.$key.'#i'.(UTF8_ENABLED ? 'u' : ''), $val, $string);
|
||||
}
|
||||
|
||||
$string = strtolower($string);
|
||||
|
||||
return trim(trim($string, $separator));
|
||||
}
|
||||
|
||||
function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){
|
||||
global $g5;
|
||||
|
||||
if( $type === 'bbs' ){
|
||||
$sql = "select wr_seo_title FROM {$write_table} WHERE wr_seo_title = '$seo_title' AND wr_id != '$sql_id' limit 1";
|
||||
$row = sql_fetch($sql);
|
||||
} else {
|
||||
return $seo_title;
|
||||
}
|
||||
|
||||
if ($row['wr_seo_title'])
|
||||
return 'is_exists';
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if( ! exist_seo_url($seo_title, $write_table, $sql_id) ){
|
||||
return $seo_title_add;
|
||||
}
|
||||
|
||||
$count++;
|
||||
return exist_seo_url_recursive($mb_id);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user