fix 8.3 redis error
This commit is contained in:
parent
031e6fb073
commit
df8f0dd2e5
4 changed files with 555 additions and 856 deletions
|
|
@ -2,25 +2,82 @@
|
||||||
if (!defined('_GNUBOARD_'))
|
if (!defined('_GNUBOARD_'))
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
$font_sql = "SELECT * FROM {$g5['font_table']} ORDER BY font_name ASC";
|
function getFontCSSWithCache()
|
||||||
$font_result = sql_query($font_sql);
|
{
|
||||||
|
global $g5;
|
||||||
|
$cache_key = 'font_css_cache';
|
||||||
|
$cache_duration = 300;
|
||||||
|
|
||||||
echo "<style id=\"extra_font\">";
|
if (USE_REDIS && class_exists('Redis')) {
|
||||||
while ($row = sql_fetch_array($font_result)) {
|
try {
|
||||||
$font_family = $row['font_family'];
|
$redis = new Redis();
|
||||||
$font_url = stripslashes($row['font_url']);
|
$redis->connect('localhost', 6379);
|
||||||
$font_weight = $row['font_weight'];
|
|
||||||
$font_style = $row['font_style'];
|
|
||||||
|
|
||||||
if (strpos($font_url, '@import') !== false) {
|
$cached_css = $redis->get($cache_key);
|
||||||
echo "{$font_url}\n\n";
|
if ($cached_css !== false) {
|
||||||
} else {
|
$redis->close();
|
||||||
echo "@font-face {\n";
|
return $cached_css;
|
||||||
echo " font-family: '{$font_family}';\n";
|
}
|
||||||
echo " src: {$font_url};\n";
|
|
||||||
echo " font-weight: {$font_weight};\n";
|
$css_content = generateFontCSS($g5);
|
||||||
echo " font-style: {$font_style};\n";
|
$redis->setex($cache_key, $cache_duration, $css_content);
|
||||||
echo "}\n\n";
|
$redis->close();
|
||||||
|
|
||||||
|
return $css_content;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Redis 연결 실패: " . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return getFontCSSWithFileCache($g5, $cache_duration);
|
||||||
}
|
}
|
||||||
echo "</style>";
|
|
||||||
|
function getFontCSSWithFileCache($g5, $cache_duration)
|
||||||
|
{
|
||||||
|
$cache_file = G5_DATA_PATH . '/cache/font_css_cache.txt';
|
||||||
|
$cache_dir = dirname($cache_file);
|
||||||
|
|
||||||
|
if (!is_dir($cache_dir)) {
|
||||||
|
@mkdir($cache_dir, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($cache_file) && (time() - filemtime($cache_file)) < $cache_duration) {
|
||||||
|
return file_get_contents($cache_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$css_content = generateFontCSS($g5);
|
||||||
|
|
||||||
|
@file_put_contents($cache_file, $css_content, LOCK_EX);
|
||||||
|
|
||||||
|
return $css_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateFontCSS($g5)
|
||||||
|
{
|
||||||
|
$font_sql = "SELECT * FROM {$g5['font_table']} ORDER BY font_name ASC";
|
||||||
|
$font_result = sql_query($font_sql);
|
||||||
|
$css_content = "<style id=\"extra_font\">";
|
||||||
|
|
||||||
|
while ($row = sql_fetch_array($font_result)) {
|
||||||
|
$font_family = $row['font_family'];
|
||||||
|
$font_url = stripslashes($row['font_url']);
|
||||||
|
$font_weight = $row['font_weight'];
|
||||||
|
$font_style = $row['font_style'];
|
||||||
|
|
||||||
|
if (strpos($font_url, '@import') !== false) {
|
||||||
|
$css_content .= "{$font_url}\n\n";
|
||||||
|
} else {
|
||||||
|
$css_content .= "@font-face {\n";
|
||||||
|
$css_content .= " font-family: '{$font_family}';\n";
|
||||||
|
$css_content .= " src: {$font_url};\n";
|
||||||
|
$css_content .= " font-weight: {$font_weight};\n";
|
||||||
|
$css_content .= " font-style: {$font_style};\n";
|
||||||
|
$css_content .= "}\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$css_content .= "</style>";
|
||||||
|
return $css_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo getFontCSSWithCache();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @suppress PHP0419
|
||||||
|
* @suppress PHP6405
|
||||||
|
*/
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** 공통 변수, 상수, 코드
|
** 공통 변수, 상수, 코드
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
@ -487,12 +491,15 @@ if (!defined('G5_IS_ADMIN')) {
|
||||||
@ini_set("session.use_trans_sid", 0); // PHPSESSID를 자동으로 넘기지 않음
|
@ini_set("session.use_trans_sid", 0); // PHPSESSID를 자동으로 넘기지 않음
|
||||||
@ini_set("url_rewriter.tags", ""); // 링크에 PHPSESSID가 따라다니는것을 무력화함 (해뜰녘님께서 알려주셨습니다.)
|
@ini_set("url_rewriter.tags", ""); // 링크에 PHPSESSID가 따라다니는것을 무력화함 (해뜰녘님께서 알려주셨습니다.)
|
||||||
|
|
||||||
session_save_path(G5_SESSION_PATH);
|
if (USE_REDIS && extension_loaded('redis')) {
|
||||||
|
ini_set('session.save_path', 'tcp://localhost:6379');
|
||||||
if (isset($SESSION_CACHE_LIMITER))
|
} else {
|
||||||
@session_cache_limiter($SESSION_CACHE_LIMITER);
|
session_save_path(G5_SESSION_PATH);
|
||||||
else
|
if (isset($SESSION_CACHE_LIMITER))
|
||||||
@session_cache_limiter("no-cache, must-revalidate");
|
@session_cache_limiter($SESSION_CACHE_LIMITER);
|
||||||
|
else
|
||||||
|
@session_cache_limiter("no-cache, must-revalidate");
|
||||||
|
}
|
||||||
|
|
||||||
ini_set("session.cache_expire", 180); // 세션 캐쉬 보관시간 (분)
|
ini_set("session.cache_expire", 180); // 세션 캐쉬 보관시간 (분)
|
||||||
ini_set("session.gc_maxlifetime", 10800); // session data의 garbage collection 존재 기간을 지정 (초)
|
ini_set("session.gc_maxlifetime", 10800); // session data의 garbage collection 존재 기간을 지정 (초)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,15 @@
|
||||||
/**
|
/**
|
||||||
* @suppress PHP0419
|
* @suppress PHP0419
|
||||||
*/
|
*/
|
||||||
|
// if you want use redis-session, enable it (change to true)
|
||||||
|
define('USE_REDIS', false);
|
||||||
|
|
||||||
|
if (USE_REDIS) {
|
||||||
|
ini_set('session.save_handler', 'redis');
|
||||||
|
} else {
|
||||||
|
ini_set('session.save_handler', 'files');
|
||||||
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
상수 선언
|
상수 선언
|
||||||
********************/
|
********************/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue