사이트 내 전체검색
그누보드
[팁] howcode htlm 템플릿 -> 그누보드 테마로 사전 작업
로빈
https://cmd.kr/gnu/717 URL이 복사되었습니다.

본문

<?php
/*
howcode htlm 템플릿 -> 그누보드 테마로 사전 작업
제작 : howcode.co.kr 로빈아빠 김성대 2019-02-18
기능 : html 템플릿을 테마로 다운로드한뒤 그누보드 테마에 맞게 경로변경등 사전작업

필요조건 : 새 템플릿 경로는 웹에서 쓰기 가능한 권한으로 되어야 함.
*/

//Maximize script execution time
//ini_set('max_execution_time', 0);

// 템프릿 테마를 저장한 디렉토리 을 입력하세요.
// /theme/***  <- *** 에 해당하는 디렉토리명
// 그누보드는 data

include_once('./_common.php');
$theme_name='ar.moose';
$thema_path=G5_PATH.'/theme/'.$theme_name;


// 1단계 basic 테마에서 필수 파일 다운로드함
$thema_path_def=G5_PATH.'/theme/basic';
$arr=explode(' ','head.php head.sub.php index.php readme.txt screenshot.png tail.php tail.sub.php theme.config.php');
foreach($arr as $file) {
$filename_ori=$thema_path_def.'/'.$file;
$filename_new=$thema_path.'/'.$file;
if (is_file($filename_new)) continue;
copy($filename_ori,$filename_new);
chmod($filename_new,0777);
if ($file=='readme.txt' && is_file($filename_new)) {
$buff=file_get_contents($filename_ori);
if (preg_match('#^Theme Name:(.+)$#im', $buff, $match)) {
//var_dump($match);
$buff=str_replace($match[1],' '.$theme_name,$buff);
file_put_contents($filename_new,$buff);
//echo $buff;
}
//Theme Name: 베이직

}
}


// 2단계 테마경로에서 파일 읽어서 변환함
$count=0;
$count_proc=0;
ar_make_theme($thema_path);
echo "<BR>총 $count 파일중 $count_proc 처리 done.. <BR>";

function ar_make_theme($thema_path) {
global $count,$count_proc;
$count++;
//if ($count++>100) exit;
if (!is_dir($thema_path)) return false;
//echo "path : $thema_path <BR>";
flush();


        define('G5_THEME_PATH',        $theme_path);
        define('G5_THEME_URL',        G5_URL.'/'.G5_THEME_DIR.'/'.$config['cf_theme']);
        define('G5_THEME_MOBILE_PATH', $theme_path.'/'.G5_MOBILE_DIR);
        define('G5_THEME_LIB_PATH',    $theme_path.'/'.G5_LIB_DIR);
        define('G5_THEME_CSS_URL',    G5_THEME_URL.'/'.G5_CSS_DIR);
        define('G5_THEME_IMG_URL',    G5_THEME_URL.'/'.G5_IMG_DIR);
        define('G5_THEME_JS_URL',      G5_THEME_URL.'/'.G5_JS_DIR);



$arr_tr=array(
"=\"style/"=>"=\"<"."?php echo G5_THEME_URL?>/style/"
,"=\"css/"=>"=\"<"."?php echo G5_THEME_CSS_URL?>/"
,"=\"js/"=>"=\"<"."?php echo G5_THEME_JS_URL?>/"
,"=\"img/"=>"=\"<"."?php echo G5_THEME_IMG_URL?>/"
,"='style/"=>"='<"."?php echo G5_THEME_URL?>/style/"
,"='css/"=>"='<"."?php echo G5_THEME_CSS_URL?>/"
,"='js/"=>"='<"."?php echo G5_THEME_JS_URL?>/"
,"='img/"=>"='<"."?php echo G5_THEME_IMG_URL?>/"
);

$dir = opendir($thema_path);
if (!$dir) return false;
while(($file = readdir($dir))!== false) {
if ($file=='.'||$file=='..') continue;
//if ($file!="index.html") continue;
$filename = $thema_path.'/'.$file;
if (is_dir($filename)) {
ar_make_theme($filename);
continue;
}
if (!stristr($filename,'.php')&&!stristr($filename,'.html')) continue;
if (!is_file($filename)) continue;


$buff=file_get_contents($filename);
$buff_new=strtr($buff,$arr_tr);
if ($buff!=$buff_new) {
echo "$filename : ".number_format(filesize($filename))." <BR>";
$err=file_put_contents($filename,$buff_new);
if (!$err) {
echo " --> 파일 저장 실패 $err <BR>";
}
else {
$count_proc++;
echo " --> 파일 처리됨 <BR>";
}
//echo "<xmp>";
//echo $buff_new;
//echo '</xmp>';
}

}
closedir($dir);
}

?>

첨부파일

댓글목록

등록된 댓글이 없습니다.

그누보드
190 (1/4P)

Search

Copyright © Cmd 명령어 18.227.114.125