<?php
$libPath = "./Lib";
set_include_path( $libPath.":/yopt/apache_php/lib/php:".get_include_path() );
ini_set('memory_limit', "15M" );
session_cache_expire( 1 );
ini_set('session.lifetime', 30 );
ini_set('session.gc_maxlifetime', 40 );
define( '_D_SEP_', DIRECTORY_SEPARATOR );
ini_set('output_handler', 'mb_output_handler');
mb_detect_order( "eucjp-win,sjis-win,UTF-8,ISO-2022-JP,ASCII");
mb_internal_encoding('eucJP-win');
mb_http_input('auto');
mb_http_output('sjis-win');
mb_language('Japanese');
require_once('IniParser.class.php');
require_once('TemplateComponent.class.php');
ini_set( 'error_reporting', E_ALL);
ini_set( 'display_errors', 1);
$ini =& new IniParser('define.ini.txt');
$site = getcwd()."/".$ini->getValue('site');
$template_dir = $ini->getValue('template_dir');
$fields = $ini->getFields();
foreach ( $fields as $field ) {
if ( $field != 'general' ) {
$template = $ini->getValue('template',$field);
$template = implode( _D_SEP_, array( $template_dir, $template ) );
$els = $ini->getElements($field);
foreach ( $els as $key=>$val ) {
$val = mb_convert_encoding( $val, "SJIS", "auto" );
if ( 'template' != $key ) {
$dir = implode( _D_SEP_, array( $site, $field, $key ) );
if ( dirIsHere( $dir )) {
$tc =& new TemplateComponent($template, array('value'=>$val));
$string = $tc->getString();
if ( !($fp=fopen($dir._D_SEP_.'index.html',"w"))) {
echo "err: cannot make ".$dir._D_SEP_."index.html\n";
}
else {
echo "done: make ".$dir._D_SEP_."index.html\n";
fwrite( $fp, $string, strlen($string) );
fclose($fp);
}
}
}
}
echo "$field done.\n";
}
}
echo "finished SeoSite maker.\n";
@param
@return
function dirIsHere($dir_path){
if( is_dir($dir_path) ){
return TRUE;
}
$path_ary = explode("/",$dir_path);
$trash = array_shift($path_ary);
$file_path = "";
foreach( $path_ary as $t_path){
if( $t_path == "" ){
return FALSE;
}
$file_path = $file_path."/".$t_path;
if( !is_dir($file_path) ){
if( !mkdir($file_path,0775) ){
echo "<BR><FONT Color=BLUE>Cann't create Dir: $file_ath</Font><BR>";
return FALSE;
}
}
}
clearstatcache();
if( is_dir($dir_path) ){
return TRUE;
}else{
return FALSE;
}
}
?>