Ejemplo n.º 1
0
 public function fetch($key, $meta = false, $timestamp = false)
 {
     if ($this->_session_cache->isCached($key)) {
         self::$session_hit_count++;
         if (!$this->_file_cache->isCached($key)) {
             # sync file with session
             $this->_file_cache->save($key, $this->_session_cache->fetch($key));
         }
     } elseif ($this->_file_cache->isCached($key)) {
         self::$file_hit_count++;
         # sync session with file
         $this->_session_cache->save($key, $this->_file_cache->fetch($key));
     } else {
         self::$missed_count++;
         # no key found
         return NULL;
     }
     # we made sure that the $_SESSION & FILE is synced
     return $this->_session_cache->fetch($key, $meta, $timestamp);
 }
Ejemplo n.º 2
0
 /**
  * 参数设置
  * 可以同时修改多个:key=a,b,c&value=1,2,3
  */
 public function set()
 {
     $key = $this->in['k'];
     $value = $this->in['v'];
     if ($key != '' && $value != '') {
         $conf = $this->config['user'];
         $arr_k = explode(',', $key);
         $arr_v = explode(',', $value);
         $num = count($arr_k);
         for ($i = 0; $i < $num; $i++) {
             $conf[$arr_k[$i]] = $arr_v[$i];
         }
         fileCache::save($this->config['user_seting_file'], $conf);
         show_json($this->L["setting_success"]);
     } else {
         show_json($this->L['error'], false);
     }
 }
Ejemplo n.º 3
0
function init_setting()
{
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //不存在则建立
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //设置默认控制器
    $GLOBALS['app']->setDefaultAction('index');
    //设置默认控制器函数
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
}
Ejemplo n.º 4
0
 /**
  *初始化用户数据和配置。
  */
 public function _initUser($name)
 {
     $root = array('home', 'recycle', 'data');
     $home = array('desktop', 'doc', 'download', 'image', 'movie', 'music');
     $user_path = USER_PATH . $name . '/';
     mk_dir($user_path);
     foreach ($root as $dir) {
         mk_dir($user_path . $dir);
     }
     foreach ($home as $dir) {
         mk_dir($user_path . 'home/' . $dir);
     }
     fileCache::save($user_path . 'data/config.php', $this->config['setting_default']);
 }
Ejemplo n.º 5
0
function init_setting()
{
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //It does not exist
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //Set the default controller
    $GLOBALS['app']->setDefaultAction('index');
    //Set the default controller function
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
    //Customized load
    $setting_user = BASIC_PATH . 'config/setting_user.php';
    if (file_exists($setting_user)) {
        include $setting_user;
    }
}
Ejemplo n.º 6
0
 /**
 * parameter settings
  * You can edit multiple: key = a, b, c & value = 1,2,3
 */
 public function set()
 {
     $file = $this->config['user_seting_file'];
     if (!is_writeable($file)) {
         //Configuration can not be written
         show_json($this->L['no_permission_write_file'], false);
     }
     $key = $this->in['k'];
     $value = $this->in['v'];
     if ($key != '' && $value != '') {
         $conf = $this->config['user'];
         $arr_k = explode(',', $key);
         $arr_v = explode(',', $value);
         $num = count($arr_k);
         for ($i = 0; $i < $num; $i++) {
             $conf[$arr_k[$i]] = $arr_v[$i];
         }
         fileCache::save($file, $conf);
         show_json($this->L["setting_success"]);
     } else {
         show_json($this->L['error'], false);
     }
 }
Ejemplo n.º 7
0
 /**
  *初始化用户数据和配置。
  */
 public function _initUser($name)
 {
     $root = array('home', 'recycle', 'data');
     $new_user_folder = $this->config['setting_system']['new_user_folder'];
     $home = explode(',', $new_user_folder);
     $user_path = USER_PATH . $name . '/';
     mk_dir($user_path);
     foreach ($root as $dir) {
         mk_dir($user_path . $dir);
     }
     foreach ($home as $dir) {
         mk_dir($user_path . 'home/' . $dir);
     }
     fileCache::save($user_path . 'data/config.php', $this->config['setting_default']);
 }
Ejemplo n.º 8
0
function init_setting()
{
    $member = new fileCache(USER_SYSTEM . 'member.php');
    // from environment variables
    $username = '******';
    $password = '******';
    $user = array('name' => $username, 'password' => md5($password), 'role' => 'default', 'status' => 0);
    $member->add($username, $user);
    initDaoCloudUser($username);
    $setting_file = USER_SYSTEM . 'system_setting.php';
    if (!file_exists($setting_file)) {
        //不存在则建立
        $setting = $GLOBALS['config']['setting_system_default'];
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
        fileCache::save($setting_file, $setting);
    } else {
        $setting = fileCache::load($setting_file);
    }
    if (!is_array($setting)) {
        $setting = $GLOBALS['config']['setting_system_default'];
    }
    if (!is_array($setting['menu'])) {
        $setting['menu'] = $GLOBALS['config']['setting_menu_default'];
    }
    $GLOBALS['app']->setDefaultController($setting['first_in']);
    //设置默认控制器
    $GLOBALS['app']->setDefaultAction('index');
    //设置默认控制器函数
    $GLOBALS['config']['setting_system'] = $setting;
    //全局
    $GLOBALS['L']['kod_name'] = $setting['system_name'];
    $GLOBALS['L']['kod_name_desc'] = $setting['system_desc'];
    if (isset($setting['powerby'])) {
        $GLOBALS['L']['kod_power_by'] = $setting['powerby'];
    }
}
Ejemplo n.º 9
0
 function _initUser()
 {
     echo '<br/>开始创建用户';
     flush();
     $root = array('home', 'recycle', 'data');
     $home = array('desktop', 'doc', 'download', 'image', 'movie', 'music');
     $user = array('admin' => array('admin', 'root'), 'demo' => array('demo', 'default'), 'guest' => array('guest', 'guest'));
     foreach ($user as $name => $v) {
         $user_path = $this->path_to . '/data/User/' . $name . '/';
         mk_dir($user_path);
         foreach ($root as $dir) {
             mk_dir($user_path . $dir);
         }
         foreach ($home as $dir) {
             mk_dir($user_path . 'home/' . $dir);
         }
         fileCache::save($user_path . 'data/config.php', $this->config['setting_default']);
     }
     $this->_initUserData();
 }