From da84fbbad1c9c7695f5987c082326dc36b7d20f7 Mon Sep 17 00:00:00 2001 From: Arcturus Date: Wed, 2 Oct 2024 09:08:18 +0900 Subject: [PATCH] move html_process --- .../classes/htmlprocess/htmlprocess.class.php | 117 +++++++++++++++ AvocadoEdition_Light/lib/common.lib.php | 140 ------------------ 2 files changed, 117 insertions(+), 140 deletions(-) create mode 100644 AvocadoEdition_Light/classes/htmlprocess/htmlprocess.class.php diff --git a/AvocadoEdition_Light/classes/htmlprocess/htmlprocess.class.php b/AvocadoEdition_Light/classes/htmlprocess/htmlprocess.class.php new file mode 100644 index 0000000..33f627d --- /dev/null +++ b/AvocadoEdition_Light/classes/htmlprocess/htmlprocess.class.php @@ -0,0 +1,117 @@ +css; + $is_merge = true; + + foreach ($links as $link) { + if ($link[1] == $stylesheet) { + $is_merge = false; + break; + } + } + + if ($is_merge) + $this->css[] = [$order, $stylesheet]; + } + + function merge_javascript($javascript, $order) + { + $scripts = $this->js; + $is_merge = true; + + foreach ($scripts as $script) { + if ($script[1] == $javascript) { + $is_merge = false; + break; + } + } + + if ($is_merge) + $this->js[] = [$order, $javascript]; + } + + function run() + { + global $config, $g5, $member; + + $tmp_sql = "SELECT count(*) as cnt FROM {$g5['login_table']} where lo_ip = '{$_SERVER['REMOTE_ADDR']}' "; + $tmp_row = sql_fetch($tmp_sql); + + if ($tmp_row['cnt']) { + $tmp_sql = "UPDATE {$g5['login_table']} SET mb_id = '{$member['mb_id']}', lo_datetime = '" . G5_TIME_YMDHIS . "', lo_location = '{$g5['lo_location']}', lo_url = '{$g5['lo_url']}' where lo_ip = '{$_SERVER['REMOTE_ADDR']}' "; + sql_query($tmp_sql, FALSE); + } else { + $tmp_sql = "INSERT INTO {$g5['login_table']} ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '{$_SERVER['REMOTE_ADDR']}', '{$member['mb_id']}', '" . G5_TIME_YMDHIS . "', '{$g5['lo_location']}', '{$g5['lo_url']}' ) "; + sql_query($tmp_sql, FALSE); + + sql_query(" delete from {$g5['login_table']} where lo_datetime < '" . date("Y-m-d H:i:s", G5_SERVER_TIME - (60 * $config['cf_login_minutes'])) . "' "); + + // 부담(overhead)이 있다면 테이블 최적화 + //$row = sql_fetch(" SHOW TABLE STATUS FROM `$mysql_db` LIKE '$g5['login_table']' "); + //if ($row['Data_free'] > 0) sql_query(" OPTIMIZE TABLE $g5['login_table'] "); + } + + $buffer = ob_get_contents(); + ob_end_clean(); + + $stylesheet = ''; + $links = $this->css; + + if (!empty($links)) { + foreach ($links as $key => $row) { + $order[$key] = $row[0]; + $index[$key] = $key; + $style[$key] = $row[1]; + } + + array_multisort($order, SORT_ASC, $index, SORT_ASC, $links); + + foreach ($links as $link) { + if (!trim($link[1])) + continue; + + $link[1] = preg_replace('#\.css([\'\"]?>)$#i', '.css?ver=' . G5_CSS_VER . '$1', $link[1]); + + $stylesheet .= PHP_EOL . $link[1]; + } + } + + $javascript = ''; + $scripts = $this->js; + $php_eol = ''; + + unset($order); + unset($index); + + if (!empty($scripts)) { + foreach ($scripts as $key => $row) { + $order[$key] = $row[0]; + $index[$key] = $key; + $script[$key] = $row[1]; + } + array_multisort($order, SORT_ASC, $index, SORT_ASC, $scripts); + foreach ($scripts as $js) { + if (!trim($js[1])) + continue; + + $js[1] = preg_replace('#\.js([\'\"]?>)$#i', '.js?ver=' . G5_JS_VER . '$1', $js[1]); + + $javascript .= $php_eol . $js[1]; + $php_eol = PHP_EOL; + } + } + + $buffer = preg_replace('#([^<]*]+>)#', "$1$stylesheet", $buffer); + $nl = ''; + if ($javascript) + $nl = "\n"; + $buffer = preg_replace('#([^<]*]*>)#', "$javascript{$nl}$1", $buffer); + return $buffer; + } +} diff --git a/AvocadoEdition_Light/lib/common.lib.php b/AvocadoEdition_Light/lib/common.lib.php index 5d9ec0e..5ff9ae3 100644 --- a/AvocadoEdition_Light/lib/common.lib.php +++ b/AvocadoEdition_Light/lib/common.lib.php @@ -2508,19 +2508,16 @@ if (!function_exists('file_put_contents')) { } } - // HTML 마지막 처리 function html_end() { global $html_process; - return $html_process->run(); } function add_stylesheet($stylesheet, $order = 0) { global $html_process; - if (trim($stylesheet)) $html_process->merge_stylesheet($stylesheet, $order); } @@ -2528,145 +2525,10 @@ function add_stylesheet($stylesheet, $order = 0) function add_javascript($javascript, $order = 0) { global $html_process; - if (trim($javascript)) $html_process->merge_javascript($javascript, $order); } -class html_process -{ - protected $css = []; - protected $js = []; - - function merge_stylesheet($stylesheet, $order) - { - $links = $this->css; - $is_merge = true; - - foreach ($links as $link) { - if ($link[1] == $stylesheet) { - $is_merge = false; - break; - } - } - - if ($is_merge) - $this->css[] = array($order, $stylesheet); - } - - function merge_javascript($javascript, $order) - { - $scripts = $this->js; - $is_merge = true; - - foreach ($scripts as $script) { - if ($script[1] == $javascript) { - $is_merge = false; - break; - } - } - - if ($is_merge) - $this->js[] = array($order, $javascript); - } - - function run() - { - global $config, $g5, $member; - - - // 현재접속자 처리 - $tmp_sql = "SELECT count(*) as cnt FROM {$g5['login_table']} where lo_ip = '{$_SERVER['REMOTE_ADDR']}' "; - $tmp_row = sql_fetch($tmp_sql); - - if ($tmp_row['cnt']) { - $tmp_sql = "UPDATE {$g5['login_table']} SET mb_id = '{$member['mb_id']}', lo_datetime = '" . G5_TIME_YMDHIS . "', lo_location = '{$g5['lo_location']}', lo_url = '{$g5['lo_url']}' where lo_ip = '{$_SERVER['REMOTE_ADDR']}' "; - sql_query($tmp_sql, FALSE); - } else { - $tmp_sql = "INSERT INTO {$g5['login_table']} ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '{$_SERVER['REMOTE_ADDR']}', '{$member['mb_id']}', '" . G5_TIME_YMDHIS . "', '{$g5['lo_location']}', '{$g5['lo_url']}' ) "; - sql_query($tmp_sql, FALSE); - - // 시간이 지난 접속은 삭제한다 - sql_query(" delete from {$g5['login_table']} where lo_datetime < '" . date("Y-m-d H:i:s", G5_SERVER_TIME - (60 * $config['cf_login_minutes'])) . "' "); - - // 부담(overhead)이 있다면 테이블 최적화 - //$row = sql_fetch(" SHOW TABLE STATUS FROM `$mysql_db` LIKE '$g5['login_table']' "); - //if ($row['Data_free'] > 0) sql_query(" OPTIMIZE TABLE $g5['login_table'] "); - } - - $buffer = ob_get_contents(); - ob_end_clean(); - - $stylesheet = ''; - $links = $this->css; - - if (!empty($links)) { - foreach ($links as $key => $row) { - $order[$key] = $row[0]; - $index[$key] = $key; - $style[$key] = $row[1]; - } - - array_multisort($order, SORT_ASC, $index, SORT_ASC, $links); - - foreach ($links as $link) { - if (!trim($link[1])) - continue; - - $link[1] = preg_replace('#\.css([\'\"]?>)$#i', '.css?ver=' . G5_CSS_VER . '$1', $link[1]); - - $stylesheet .= PHP_EOL . $link[1]; - } - } - - $javascript = ''; - $scripts = $this->js; - $php_eol = ''; - - unset($order); - unset($index); - - if (!empty($scripts)) { - foreach ($scripts as $key => $row) { - $order[$key] = $row[0]; - $index[$key] = $key; - $script[$key] = $row[1]; - } - - array_multisort($order, SORT_ASC, $index, SORT_ASC, $scripts); - - foreach ($scripts as $js) { - if (!trim($js[1])) - continue; - - $js[1] = preg_replace('#\.js([\'\"]?>)$#i', '.js?ver=' . G5_JS_VER . '$1', $js[1]); - - $javascript .= $php_eol . $js[1]; - $php_eol = PHP_EOL; - } - } - - /* - - - 밑으로 스킨의 스타일시트가 위치하도록 하게 한다. - */ - $buffer = preg_replace('#([^<]*]+>)#', "$1$stylesheet", $buffer); - - /* - - - 전에 스킨의 자바스크립트가 위치하도록 하게 한다. - */ - $nl = ''; - if ($javascript) - $nl = "\n"; - $buffer = preg_replace('#([^<]*]*>)#', "$javascript{$nl}$1", $buffer); - - return $buffer; - } -} - // 휴대폰번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다. function hyphen_hp_number($hp) { @@ -2674,7 +2536,6 @@ function hyphen_hp_number($hp) return preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $hp); } - // 로그인 후 이동할 URL function login_url($url = '') { @@ -2684,7 +2545,6 @@ function login_url($url = '') return urlencode(clean_xss_tags(urldecode($url))); } - // $dir 을 포함하여 https 또는 http 주소를 반환한다. function https_url($dir, $https = true) {