버퍼의 내용에서 body 태그 중간의 외부 css 파일을 CAPTURE 하여 head 태그로 이동시켜준다.

This commit is contained in:
gnuboard
2013-04-22 14:13:47 +09:00
parent 2e8e1bc41c
commit 113231ac78
17 changed files with 75 additions and 167 deletions

View File

@ -436,9 +436,7 @@ if (G4_IS_MOBILE) {
$new_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/new/'.$config['cf_mobile_new_skin'];
$search_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/search/'.$config['cf_mobile_search_skin'];
$connect_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/connect/'.$config['cf_mobile_connect_skin'];
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/basic';
if (isset($_GET['skin_dir']))
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/'.$_GET['skin_dir'];
$connect_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/connect/'.$config['cf_mobile_connect_skin'];
} else {
$board_skin_path = G4_SKIN_PATH.'/board/'.$board['bo_skin'];
$board_skin_url = G4_SKIN_URL .'/board/'.$board['bo_skin'];
@ -447,9 +445,7 @@ if (G4_IS_MOBILE) {
$new_skin_path = G4_SKIN_PATH.'/new/'.$config['cf_new_skin'];
$search_skin_path = G4_SKIN_PATH.'/search/'.$config['cf_search_skin'];
$connect_skin_path = G4_SKIN_PATH.'/connect/'.$config['cf_connect_skin'];
$poll_skin_path = G4_SKIN_PATH.'/poll/basic';
if (isset($_GET['skin_dir']))
$poll_skin_path = G4_SKIN_PATH.'/poll/'.$_GET['skin_dir'];
$connect_skin_url = G4_SKIN_URL.'/connect/'.$config['cf_connect_skin'];
}
//==============================================================================
@ -466,6 +462,8 @@ while ($entry = $tmp->read()) {
include_once(G4_EXTEND_PATH.'/'.$entry);
}
ob_start('ob_gzhandler');
// 자바스크립트에서 go(-1) 함수를 쓰면 폼값이 사라질때 해당 폼의 상단에 사용하면
// 캐쉬의 내용을 가져옴. 완전한지는 검증되지 않음
header('Content-Type: text/html; charset=utf-8');

View File

@ -32,35 +32,19 @@ header("Pragma: no-cache"); // HTTP/1.0
<html lang="ko">
<head>
<meta charset="utf-8">
<title><?=$g4_head_title?></title>
<? if (G4_IS_MOBILE) {?>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=0,maximum-scale=10,user-scalable=yes">
<meta name="HandheldFriendly" content="true">
<meta name="format-detection" content="telephone=no">
<? } ?>
<? if (defined('G4_IS_ADMIN')) { ?>
<link rel="stylesheet" href="<?=G4_CSS_URL?>/admin.css">
<? } else { ?>
<link rel="stylesheet" href="<?=G4_CSS_URL?>/<?=(G4_IS_MOBILE?'mobile':'default')?>.css">
<?}?>
<title><?=$g4_head_title?></title>
<!-- <meta http-equiv="imagetoolbar" content="no"> -->
<!-- <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> -->
<? if (defined('G4_IS_ADMIN')) { ?>
<link rel="stylesheet" href="<?=G4_CSS_URL?>/admin.css?=<?=date("md")?>">
<? } else { ?>
<link rel="stylesheet" href="<?=G4_CSS_URL?>/<?=(G4_IS_MOBILE?'mobile':'default')?>.css?=<?=date("md")?>">
<?}?>
<? // 스킨의 style sheet 불러옴
if (!defined('G4_IS_ADMIN')) {
if(isset($board_skin_path))
echo get_skin_stylesheet($board_skin_path);
if(isset($member_skin_path))
echo get_skin_stylesheet($member_skin_path);
if(isset($new_skin_path))
echo get_skin_stylesheet($new_skin_path);
if(isset($search_skin_path))
echo get_skin_stylesheet($search_skin_path);
if(isset($connect_skin_path))
echo get_skin_stylesheet($connect_skin_path);
if(isset($poll_skin_path))
echo get_skin_stylesheet($poll_skin_path);
}
?>
<!--[if lte IE 8]>
<script src="<?=G4_JS_URL?>/html5.js"></script>
<![endif]-->
@ -78,24 +62,9 @@ var g4_cookie_domain = "<?=G4_COOKIE_DOMAIN?>";
?>
</script>
<script src="<?=G4_JS_URL?>/jquery-1.8.3.min.js"></script>
<script src="<?=G4_JS_URL?>/jquery.menu.js"></script>
<script src="<?=G4_JS_URL?>/common.js"></script>
<script src="<?=G4_JS_URL?>/wrest.js"></script>
<? // 스킨의 javascript 불러옴
if (!defined('G4_IS_ADMIN')) {
if(isset($board_skin_path))
echo get_skin_javascript($board_skin_path, 'js');
if(isset($member_skin_path))
echo get_skin_javascript($member_skin_path, 'js');
if(isset($new_skin_path))
echo get_skin_javascript($new_skin_path, 'js');
if(isset($search_skin_path))
echo get_skin_javascript($search_skin_path, 'js');
if(isset($connect_skin_path))
echo get_skin_javascript($connect_skin_path, 'js');
if(isset($poll_skin_path))
echo get_skin_javascript($poll_skin_path, 'js');
}
?>
<? if(G4_IS_MOBILE) { ?>
<script>
set_cookie("device_width", screen.width, 6, g4_cookie_domain);

View File

@ -1928,4 +1928,44 @@ if (!function_exists('file_put_contents')) {
}
}
}
// HTML 마지막 처리
function html_end()
{
global $g4;
// 현재접속자 처리
$tmp_sql = " select count(*) as cnt from {$g4['login_table']} where lo_ip = '{$_SERVER['REMOTE_ADDR']}' ";
$tmp_row = sql_fetch($tmp_sql);
//sql_query(" lock table $g4['login_table'] write ", false);
if ($tmp_row['cnt']) {
$tmp_sql = " update {$g4['login_table']} set mb_id = '{$member['mb_id']}', lo_datetime = '".G4_TIME_YMDHIS."', lo_location = '$lo_location', lo_url = '$lo_url' where lo_ip = '{$_SERVER['REMOTE_ADDR']}' ";
sql_query($tmp_sql, FALSE);
} else {
$tmp_sql = " insert into {$g4['login_table']} ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '{$_SERVER['REMOTE_ADDR']}', '{$member['mb_id']}', '".G4_TIME_YMDHIS."', '$lo_location', '$lo_url' ) ";
sql_query($tmp_sql, FALSE);
// 시간이 지난 접속은 삭제한다
sql_query(" delete from {$g4['login_table']} where lo_datetime < '".date("Y-m-d H:i:s", G4_SERVER_TIME - (60 * $config['cf_login_minutes']))."' ");
// 부담(overhead)이 있다면 테이블 최적화
//$row = sql_fetch(" SHOW TABLE STATUS FROM `$mysql_db` LIKE '$g4['login_table']' ");
//if ($row['Data_free'] > 0) sql_query(" OPTIMIZE TABLE $g4['login_table'] ");
}
// 버퍼의 내용에서 body 태그 중간의 외부 css 파일을 CAPTURE 하여 head 태그로 이동시켜준다.
$buffer = ob_get_contents();
ob_end_clean();
preg_match('#<body>(.*)</body>#is', $buffer, $bodys);
preg_match_all('/<link[^>]+>/i', $bodys[0], $links);
$stylesheet = '';
for ($i=0; $i<count($links[0]); $i++) {
$link = PHP_EOL.$links[0][$i];
$stylesheet .= $link;
$buffer = preg_replace('#'.$link.'#', '', $buffer);
}
return preg_replace('#(</title>)#', "$1$stylesheet", $buffer);
}
?>

View File

@ -13,6 +13,7 @@ function connect($skin_dir='')
if (!$skin_dir)
$skin_dir = $config['cf_connect_skin'];
$connect_skin_path = G4_SKIN_PATH.'/connect/'.$skin_dir;
$connect_skin_url = G4_SKIN_URL.'/connect/'.$skin_dir;
ob_start();
include_once ($connect_skin_path.'/connect.skin.php');

View File

@ -20,8 +20,10 @@ function poll($skin_dir='basic', $po_id=false)
ob_start();
if (G4_IS_MOBILE) {
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/'.$skin_dir;
$poll_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/poll/'.$skin_dir;
} else {
$poll_skin_path = G4_SKIN_PATH.'/poll/'.$skin_dir;
$poll_skin_url = G4_SKIN_URL.'/poll/'.$skin_dir;
}
include_once ($poll_skin_path.'/poll.skin.php');
$content = ob_get_contents();

View File

@ -9,6 +9,8 @@ if ($is_good) $colspan++;
if ($is_nogood) $colspan++;
?>
<link rel="stylesheet" href="<?=$board_skin_url?>/style.css">
<? if (!$wr_id) {?><h1 id="bo_list_title"><?=$board['bo_subject']?></h1><?}?>
<!-- 게시판 목록 시작 -->

View File

@ -3,6 +3,8 @@ if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once(G4_LIB_PATH.'/thumbnail.lib.php');
?>
<link rel="stylesheet" href="<?=$board_skin_url?>/style.css">
<div id="bo_v" style="width:<?=$width;?>">
<p id="bo_v_cate">

View File

@ -2,6 +2,8 @@
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$board_skin_url?>/style.css">
<h1 id="wrapper_title"><?=$g4['title']?></h1>
<form name="fwrite" id="fwrite" action="<?=$action_url?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?=$width;?>">

View File

@ -3,4 +3,6 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// 회원수는 $row['mb_cnt'];
?>
<link rel="stylesheet" href="<?=$connect_skin_url?>/style.css">
<?=$row['total_cnt']?>

View File

@ -2,6 +2,8 @@
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$connect_skin_url?>/style.css">
<table id="current_connect_tbl" class="basic_tbl">
<thead>
<tr>

View File

View File

@ -2,6 +2,7 @@
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$member_skin_url?>/style.css">
<script src="<?=G4_JS_URL?>/jquery.register_form.js"></script>
<form name="fregisterform" id="fregisterform" action="<?=$register_action_url?>" onsubmit="return fregisterform_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off">

View File

@ -2,6 +2,8 @@
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$new_skin_url?>/style.css">
<!-- 검색 -->
<fieldset id="new_sch">
<legend>상세검색</legend>

View File

@ -2,6 +2,8 @@
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$poll_skin_url?>/style.css">
<form name="fpoll" action="<?=G4_BBS_URL?>/poll_update.php" onsubmit="return fpoll_submit(this);" method="post">
<input type="hidden" name="po_id" value="<?=$po_id?>">
<input type="hidden" name="skin_dir" value="<?=$skin_dir?>">

View File

@ -2,6 +2,8 @@
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$poll_skin_url?>/style.css">
<div id="poll_result" class="new_win">
<h1><?=$g4['title']?></h1>

View File

@ -2,6 +2,8 @@
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<link rel="stylesheet" href="<?=$search_skin_url?>/style.css">
<form name="fsearch" onsubmit="return fsearch_submit(this);" method="get">
<input type="hidden" name="srows" value="<?=$srows?>">
<fieldset id="sch_result_detail">

View File

@ -21,133 +21,12 @@ $(function() {
<![endif]-->
<script>
$(function(){
var hide_menu = false;
var mouse_event = false;
var oldX = oldY = 0;
$(document).mousemove(function(e) {
if(oldX == 0) {
oldX = e.pageX;
oldY = e.pageY;
}
if(oldX != e.pageX || oldY != e.pageY) {
mouse_event = true;
}
});
// 주메뉴
var $gnb = $(".gnb_1depth > a");
$gnb.mouseover(function() {
if(mouse_event) {
$(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on");
$(this).parent().addClass("gnb_1depth_over gnb_1depth_on");
menu_rearrange($(this).parent());
hide_menu = false;
}
});
$gnb.mouseout(function() {
hide_menu = true;
});
$(".gnb_1depth li").mouseover(function() {
hide_menu = false;
});
$(".gnb_1depth li").mouseout(function() {
hide_menu = true;
});
$gnb.focusin(function() {
$(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on");
$(this).parent().addClass("gnb_1depth_over gnb_1depth_on");
menu_rearrange($(this).parent());
hide_menu = false;
});
$gnb.focusout(function() {
hide_menu = true;
});
$(".gnb_1depth ul a").focusin(function() {
$(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on");
var $gnb_li = $(this).closest(".gnb_1depth").addClass("gnb_1depth_over gnb_1depth_on");
menu_rearrange($(this).closest(".gnb_1depth"));
hide_menu = false;
});
$(".gnb_1depth ul a").focusout(function() {
hide_menu = true;
});
$('#gnb_ul>li').bind('mouseleave',function(){
submenu_hide();
});
$(document).bind('click focusin',function(){
if(hide_menu) {
submenu_hide();
}
});
function submenu_hide() {
$(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on");
}
// 텍스트 리사이즈 카운트 쿠키있으면 실행
var resize_act;
var text_resize_count = parseInt(get_cookie("ck_font_resize_count"));
if(!isNaN(text_resize_count)) {
if(text_resize_count > 0)
resize_act = "increase";
else if(text_resize_count < 0)
resize_act = "decrease";
if(Math.abs(text_resize_count) > 0)
font_resize2("container", resize_act, Math.abs(text_resize_count));
}
});
function menu_rearrange(el)
{
var width = $("#gnb_ul").width();
var left = w1 = w2 = 0;
var idx = $(".gnb_1depth").index(el);
for(i=0; i<=idx; i++) {
w1 = $(".gnb_1depth:eq("+i+")").outerWidth();
w2 = $(".gnb_2depth > a:eq("+i+")").outerWidth(true);
if((left + w2) > width) {
el.removeClass("gnb_1depth_over").addClass("gnb_1depth_over2");
}
left += w1;
}
}
</script>
</body>
</html>
<?
$tmp_sql = " select count(*) as cnt from {$g4['login_table']} where lo_ip = '{$_SERVER['REMOTE_ADDR']}' ";
$tmp_row = sql_fetch($tmp_sql);
//sql_query(" lock table $g4['login_table'] write ", false);
if ($tmp_row['cnt']) {
$tmp_sql = " update {$g4['login_table']} set mb_id = '{$member['mb_id']}', lo_datetime = '".G4_TIME_YMDHIS."', lo_location = '$lo_location', lo_url = '$lo_url' where lo_ip = '{$_SERVER['REMOTE_ADDR']}' ";
sql_query($tmp_sql, FALSE);
} else {
$tmp_sql = " insert into {$g4['login_table']} ( lo_ip, mb_id, lo_datetime, lo_location, lo_url ) values ( '{$_SERVER['REMOTE_ADDR']}', '{$member['mb_id']}', '".G4_TIME_YMDHIS."', '$lo_location', '$lo_url' ) ";
sql_query($tmp_sql, FALSE);
// 시간이 지난 접속은 삭제한다
sql_query(" delete from {$g4['login_table']} where lo_datetime < '".date("Y-m-d H:i:s", G4_SERVER_TIME - (60 * $config['cf_login_minutes']))."' ");
// 부담(overhead)이 있다면 테이블 최적화
//$row = sql_fetch(" SHOW TABLE STATUS FROM `$mysql_db` LIKE '$g4['login_table']' ");
//if ($row['Data_free'] > 0) sql_query(" OPTIMIZE TABLE $g4['login_table'] ");
}
// HTML 마지막 처리 함수 : 반드시 넣어주시기 바랍니다.
echo html_end();
?>