fix 8.3 redis error

This commit is contained in:
Amberstone 2025-11-15 12:55:53 +09:00
parent 031e6fb073
commit df8f0dd2e5
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
4 changed files with 555 additions and 856 deletions

View file

@ -2,25 +2,82 @@
if (!defined('_GNUBOARD_'))
exit;
$font_sql = "SELECT * FROM {$g5['font_table']} ORDER BY font_name ASC";
$font_result = sql_query($font_sql);
function getFontCSSWithCache()
{
global $g5;
$cache_key = 'font_css_cache';
$cache_duration = 300;
echo "<style id=\"extra_font\">";
while ($row = sql_fetch_array($font_result)) {
if (USE_REDIS && class_exists('Redis')) {
try {
$redis = new Redis();
$redis->connect('localhost', 6379);
$cached_css = $redis->get($cache_key);
if ($cached_css !== false) {
$redis->close();
return $cached_css;
}
$css_content = generateFontCSS($g5);
$redis->setex($cache_key, $cache_duration, $css_content);
$redis->close();
return $css_content;
} catch (Exception $e) {
error_log("Redis 연결 실패: " . $e->getMessage());
}
}
return getFontCSSWithFileCache($g5, $cache_duration);
}
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) {
echo "{$font_url}\n\n";
$css_content .= "{$font_url}\n\n";
} else {
echo "@font-face {\n";
echo " font-family: '{$font_family}';\n";
echo " src: {$font_url};\n";
echo " font-weight: {$font_weight};\n";
echo " font-style: {$font_style};\n";
echo "}\n\n";
$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 "</style>";
echo getFontCSSWithCache();

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,8 @@
<?php
/**
* @suppress PHP0419
* @suppress PHP6405
*/
/*******************************************************************************
** 공통 변수, 상수, 코드
*******************************************************************************/
@ -487,12 +491,15 @@ if (!defined('G5_IS_ADMIN')) {
@ini_set("session.use_trans_sid", 0); // PHPSESSID를 자동으로 넘기지 않음
@ini_set("url_rewriter.tags", ""); // 링크에 PHPSESSID가 따라다니는것을 무력화함 (해뜰녘님께서 알려주셨습니다.)
session_save_path(G5_SESSION_PATH);
if (isset($SESSION_CACHE_LIMITER))
if (USE_REDIS && extension_loaded('redis')) {
ini_set('session.save_path', 'tcp://localhost:6379');
} else {
session_save_path(G5_SESSION_PATH);
if (isset($SESSION_CACHE_LIMITER))
@session_cache_limiter($SESSION_CACHE_LIMITER);
else
else
@session_cache_limiter("no-cache, must-revalidate");
}
ini_set("session.cache_expire", 180); // 세션 캐쉬 보관시간 (분)
ini_set("session.gc_maxlifetime", 10800); // session data의 garbage collection 존재 기간을 지정 (초)

View file

@ -2,6 +2,15 @@
/**
* @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');
}
/********************
상수 선언
********************/