Ejemplo n.º 1
0
 /**
  * 设置缓存地址(如输入的是非法数据,则使用默认设置)
  * @param $dir 缓存地址
  */
 public static function set_dir($dir)
 {
     $dir = trim($dir);
     if (!$dir) {
         return;
     }
     self::$cache_dir = $dir . '/';
 }
Ejemplo n.º 2
0
 public function __construct($cacheFileName)
 {
     if (is_dir(self::$dir) == false) {
         mkdir(self::$dir);
     }
     $newCache = false;
     if (file_exists(self::$dir . '/' . $cacheFileName . '.cache') == false) {
         $newCache = true;
     }
     $handle = fopen(self::$dir . '/' . $cacheFileName . '.cache', 'a');
     if (is_writable(self::$dir . '/' . $cacheFileName . '.cache') == false) {
         chmod(self::$dir . '/' . $cacheFileName . '.cache', 0700);
     }
     self::$handle = $handle;
     self::$file = $cacheFileName . '.cache';
     self::$fullDir = self::$dir . '/' . self::$file;
     if ($newCache == true) {
         self::makeNewCacheFile(self::$fullDir);
     }
     fclose(self::$handle);
     return true;
 }
}
// Let's Add Slashes to REQUEST variable first, for safe.
$_MYGET = $_MYPOST = array();
// Init Security Unit here
$sec = new security($oops);
// First things will do when $sec has been loaded
if (!empty($_GET) && ($_MYGET = $sec->addSlashes($_GET))) {
    $_runtime['GetFilled'] = true;
}
if (!empty($_POST) && ($_MYPOST = $sec->addSlashes($_POST))) {
    $_runtime['PostFilled'] = true;
}
unset($_GET, $_POST);
// Unset it so no one can use
// Init Cache module
$cac = new filecache($cfg['cache'], $oops, $sec);
// Init Database Unit
$db = new db($cfg['db'], $oops, $sec, $cac);
/** START OF SITE SETTING **/
$site = array();
if (!($site = $cac->read('SITE', 'SITECFG', 86400))) {
    $temp_site = array();
    if ($temp_site = $db->fetch_all_array('SELECT `settype`, `setkey`, `setvalue` FROM `' . $db->pre . 'settings`')) {
        // Load sitesetting from database
        foreach ($temp_site as $key => $val) {
            $site[$val['settype']][$val['setkey']] = $val['setvalue'];
        }
        // Check php setting for this website
        if ($_ini = ini_get_all()) {
            $site['APIFastCGI'] = isset($_ini['cgi.check_shebang_line']);
            $site['AllowUrlFopen'] = $_ini['allow_url_fopen']['local_value'];