<?php
include_once("class.inc.php");
include_once("config.php");
include_once('smarty/Smarty.class.php');
mysql_query("set names 'GBK'");
$result=mysql_query("select * from template");
if ($info=mysql_fetch_array($result)) {
	$dir_name=$info['tdefault'];
}
$result_cache=mysql_query("select * from extends");
if ($info_cache=mysql_fetch_array($result_cache)) {
	$lifetime=$info_cache['lifetime'];
	$caching=$info_cache['caching'];
}
$smarty = new Smarty();
$smarty->caching   =  $caching;
$smarty->cache_lifetime  =  $lifetime;
$smarty->template_dir = "./admin/templates/".$dir_name;
$smarty->compile_dir = "./templates_c";
//$smarty->left_delimiter = "<{"; 
//$smarty->right_delimiter = "}>";

function MakeHtmlFile($file_name, $content)
     {     //目录不存在就创建
         if (!file_exists (dirname($file_name))) {
              if (!@mkdir (dirname($file_name), 0777)) {
                      die($file_name."目录创建失败！");
              }
          }
                    
          if(!$fp = fopen($file_name, "w")){
              echo "文件打开失败！";
              return false;
          }


          if(!fwrite($fp, $content)){
              echo "文件写入失败！";
             fclose($fp);
              return false;
          }
        
         fclose($fp);
             chmod($file_name,0666);
      } 


?>
