Пример #1
0
//		Summary:	程序总入口
//		Author:		millken(迷路林肯)
//		LastModifed:2007-9-23
//		copyright (c)2007 millken@gmail.com
//====================================================
include './common.inc.php';
include ROOT_PATH . 'include/tree.class.php';
//print_r($GLOBALS);
//$sql = "SELECT * FROM mpf_catagory";
//$ctree = $db->cache($sql,5);
//print_r($ctree);
//rmdirs(ROOT_PATH . 'cache/de');
$mods = array('index', 'register', 'login', 'box', 'forum', 'thread', 'boxlist');
$m = preg_replace("/[^a-z]/", '', strtolower($m));
if (in_array($m, $mods) && file_exists(ROOT_PATH . 'mod/mod_' . $m . '.php')) {
    $mod_file = ROOT_PATH . 'mod/mod_' . $m . '.php';
} else {
    $mod_file = ROOT_PATH . 'mod/mod_index.php';
}
include $mod_file;
if (!isset($templatefile)) {
    $templatefile = 'index.html';
}
$cache_file = m_cachefile($onlineurl, 'html', $_GET ? true : false);
$tpl = new template($templatefile);
$tpl->tpl_dir = 'templates/default/';
$tpl->imgDir = array('images', 'css');
$tpl->debug = true;
$tpl->compress = false;
include $tpl->compiledFile();
//echo $db->print_debug();
Пример #2
0
 function cache($sql, $cacheTime = 3600)
 {
     if (SQL_CACHE) {
         $result = array();
         $result['filename'] = m_cachefile($sql);
         $result['data'] = @file_get_contents($result['filename']);
         if ($result['data']) {
             $result['filetime'] = substr($result['data'], 0, 10);
             if (time() - $result['filetime'] >= $cacheTime) {
                 $data = $this->getrows($sql);
                 @file_put_contents($result['filename'], '' . time() . gzcompress(serialize($data), 9));
             } else {
                 $data = unserialize(gzuncompress(substr($result['data'], 10)));
             }
         } else {
             touch($result['filename']) or error('Unable to create file \'' . $result['filename'] . '\'', __FILE__, __LINE__);
             $data = $this->getrows($sql);
             @file_put_contents($result['filename'], '' . time() . gzcompress(serialize($data), 9), LOCK_EX);
         }
     } else {
         $data = $this->getrows($sql);
     }
     return $data;
 }