[지운아빠님] "g5의 css관련된글"에 대한 예시 > 자유게시판

자유게시판

[지운아빠님] "g5의 css관련된글"에 대한 예시 정보

[지운아빠님] "g5의 css관련된글"에 대한 예시

본문

에 이어지는 글입니다.

대충 짜보았습니다.
(설명용 소스)

css.php 내용
<?php
header("Content-type: text/css");
include_once('_common.php');
include_once('_head.php');
function auto_stylesheet()
{
    global $config, $g5, $member;


$buffer = ob_get_contents();
    ob_end_clean();
preg_match('#<body>(.*)</body>#is', $buffer, $bodys);
    preg_match_all('/(\r|\n)?<link[^>]+>/i', $bodys[0], $links);
foreach ($links[0] as $key=>$link) {
        $stylesheet .= $link;
    }
preg_match_all("@(http(s)?:\/\/)[^ \"\'<>]*@m", $stylesheet, $match);

echo "@charset \"utf-8\";\n\n";
for($i=0; $i<count($match[0]); $i++){
$style[$i] = str_replace($match[1][0].$_SERVER['SERVER_NAME'], G5_PATH, $match[0][$i]);
echo "/* ===== {$match[0][$i]} start ===== */\n";
$TempStyle = implode("", file($style[$i]));
$TempStyle = str_replace('@charset "utf-8";', '', $TempStyle);
echo $TempStyle;
echo "\n/* ===== {$match[0][$i]} End ===== */\n";

echo "\n\n";
}
}


echo  "</div></div>";
echo "</body></html>";

echo auto_stylesheet();
?>
추천
0

댓글 6개

결과값(css파일로 인식)
=========================================

@charset "utf-8";

/* ===== http://wp.foxrain.me/skin/connect/basic/style.css start ===== */

/* ===== http://wp.foxrain.me/skin/connect/basic/style.css End ===== */


/* ===== http://wp.foxrain.me/skin/outlogin/basic/style.css start ===== */

/* SIR 지운아빠 */

/* 아웃로그인 스킨 */
.ol {position:relative;padding:15px 15px 14px 14px}
.ol h2 {margin:0;padding:0;width:1px;height:1px;font-size:0;line-height:0;overflow:hidden}
.ol ul {margin:0;padding:0;list-style:none}

.ol a.btn_admin {display:inline-block;padding:0 10px;height:23px;border:1px solid #e8180c;background:#e8180c;color:#fff;text-decoration:none;line-height:2.15em;vertical-align:middle} /* 관리자 전용 버튼 */
.ol a.btn_admin:focus, .ol a.btn_admin:hover {text-decoration:none}

#ol_before {}
#ol_before fieldset {position:relative}
#ol_id {display:block;margin:0 0 5px !important;margin:0 0 3px;padding:0 5px;width:168px;height:22px;border:1px solid #b8c9c2;background:#f7f7f7;line-height:1.6em}
.ol_idlabel {position:absolute;top:6px;left:5px;color:#333;font-size:0.95em}
#ol_pw {display:block;margin:0 0 5px !important;margin:0 0 3px;padding:0 5px;width:168px;height:22px;border:1px solid #b8c9c2;background:#f7f7f7;vertical-align:top;line-height:1.6em}
.ol_pwlabel {position:absolute;top:35px;left:5px;color:#333;font-size:0.95em}
#auto_login {}
#auto_login_label {letter-spacing:-0.1em}
#ol_submit {display:inline-block;width:60px;height:24px;border:0;background:#333;color:#fff;font-size:0.9em;font-weight:bold;vertical-align:top}
#ol_before a {letter-spacing:-0.15em}
#ol_svc {float:left;margin:5px 0 0}
#ol_password_lost {display:inline-block;margin:0 0 0 5px}
#ol_auto {position:relative;float:right;margin:5px 0 0}
#ol_auto label {letter-spacing:-0.1em}
#ol_auto input {width:13px;height:13px;vertical-align:bottom}

#ol_after {}
#ol_after_hd {margin:0 0 3px}
#ol_after_hd .btn_admin {margin-top:5px;width:158px;text-align:center}
#ol_after_private {margin:0 0 3px;zoom:1}
#ol_after_private:after {display:block;visibility:hidden;clear:both;content:""}
#ol_after_private li {float:left}
#ol_after_private a {display:block;padding-top:8px;height:37px;background:#f7f7f7;text-align:center}
#ol_after_private a strong {display:block;padding-top:3px;color:#000;font-weight:normal}
#ol_after_private a:focus,
#ol_after_private a:hover {background:#333;color:#fff;text-decoration:none}
#ol_after_private a:focus strong,
#ol_after_private a:hover strong {color:#fff;text-decoration:none}
#ol_after_memo {width:50px;margin-right:1px}
#ol_after_pt {width:80px;margin-right:1px}
#ol_after_scrap {width:48px;line-height:2.6em !important}
#ol_after_ft {text-align:justify}
#ol_after_ft a {display:inline-block;width:88px;height:22px;background:#333;color:#fff;text-align:center;line-height:1.8em}
#ol_after_ft a:focus,
#ol_after_ft a:hover {text-decoration:none !important}
/* ===== http://wp.foxrain.me/skin/outlogin/basic/style.css End ===== */
"흠... 쥐잡자고 초가집 홀라당 태울기세.php " 이제 이해 했네요.
저건 페이지 전체를 수정해버리는게 아니라 css파일만 리드하여 출력 부분이라 기존 출력에는 문제가 없습니다.
preg_match('#<body>(.*)</body>#is', $buffer, $bodys);
preg_match_all('/(\r|\n)?<link[^>]+>/i', $bodys[0], $links);

이게 아무래도 좀 페이지에 코드가 무진장 들어간다면
2-3만라인정도..

무리가 오지 않을까요?
무리가 안온다고는 할수는 없지요.
그누보드 기본 라이브러리(./lib/common.lib.php)에도 사용중(약 2168줄 html_end 함수)이라 그대로 뜯어와 수정한것입니다 ㅎㅎㅎㅎㅎㅎ


위 소스는 간단한 예시임으로 만약 정식으로 적용이 된다면 방식을 바꿔야겠지요.
전체 199,631 |RSS
자유게시판 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT