public function init_app($user_info) { $list = $this->sql->get(); $new_user_app = $this->config['setting_system']['new_user_app']; $default = explode(',', $new_user_app); $info = array(); foreach ($default as $key) { $info[$key] = $list[$key]; } $desktop = USER_PATH . $user_info['name'] . '/home/desktop/'; mk_dir($desktop); foreach ($info as $key => $data) { if (!is_array($data)) { continue; } $path = iconv_system($desktop . $key . '.oexe'); unset($data['name']); unset($data['desc']); unset($data['group']); file_put_contents($path, json_encode($data)); } $user_info['status'] = 1; $member = new fileCache(USER_SYSTEM . 'member.php'); $member->update($user_info['name'], $user_info); }
/** * 删除 */ public function del() { $role = $this->in['role']; if (!$role) { show_json($this->L["groupname_can_not_null"], false); } if ($role == 'root') { show_json($this->L['default_group_can_not_do'], false); } if ($this->sql->delete($role)) { $member = new fileCache($this->config['system_file']['member']); $member->update('role', '', $role); //改组用户设置为空 show_json($this->L['success']); } show_json($this->L['error'], false); }
public static function GetInstance($exp_time = 3600, $path = 'cache/') { if ($path[strlen($path) - 1] != '/') { $path .= '/'; } if (!isset(self::$instance)) { //doesn't exists the isntance self::$instance = new self($exp_time, $path); //goes to the constructor } return self::$instance; }
/** * 删除 */ public function del() { if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { $role = $this->in['role']; if (!$role) { show_json($this->L["groupname_can_not_null"], false); } if ($role == 'root') { show_json($this->L['default_group_can_not_do'], false); } if ($this->sql->delete($role)) { $member = new fileCache(USER_SYSTEM . 'member.php'); $member->update('role', '', $role); //改组用户设置为空 show_json($this->L['success']); } show_json($this->L['error'], false); } } else { header('Location: 403.php'); } }
/** * 参数设置 * 可以同时修改多个: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); } }
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']; } }
private function _assign_info() { $user_config = new fileCache(USER . 'data/config.php'); $config = $user_config->get(); if (count($config) < 1) { $config = $GLOBALS['config']['setting_default']; } $this->assign('config_theme', $config['theme']); $this->share_info['share_password'] = ''; $this->share_info['num_view'] = intval($this->share_info['num_view']); $this->share_info['num_download'] = intval($this->share_info['num_download']); $this->share_info['path'] = get_path_this(iconv_app($this->path)); $this->assign('share_info', $this->share_info); }
/** * 权限验证;统一入口检验 */ public function authCheck() { if (isset($GLOBALS['is_root']) && $GLOBALS['is_root'] == 1) { return; } if (in_array(ACT, $this->notCheck)) { return; } if (!array_key_exists(ST, $this->config['role_setting'])) { return; } if (!in_array(ACT, $this->config['role_setting'][ST]) && ST . ':' . ACT != 'user:common_js') { return; } //输出处理过的权限 //有权限限制的函数 $key = ST . ':' . ACT; $group = new fileCache(USER_SYSTEM . 'group.php'); $auth = $group->get($this->user['role']); //向下版本兼容处理 //未定义;新版本首次使用默认开放的功能 if (!isset($auth['userShare:set'])) { $auth['userShare:set'] = 1; } if (!isset($auth['explorer:fileDownload'])) { $auth['explorer:fileDownload'] = 1; } //默认扩展功能 等价权限 $auth['user:common_js'] = 1; //权限数据配置后输出到前端 $auth['explorer:pathChmod'] = $auth['explorer:pathRname']; $auth['explorer:pathDeleteRecycle'] = $auth['explorer:pathDelete']; $auth['explorer:pathCopyDrag'] = $auth['explorer:pathCuteDrag']; $auth['explorer:fileDownloadRemove'] = $auth['explorer:fileDownload']; $auth['explorer:zipDownload'] = $auth['explorer:fileDownload']; $auth['explorer:fileProxy'] = $auth['explorer:fileDownload']; $auth['editor:fileGet'] = $auth['explorer:fileDownload']; $auth['explorer:officeView'] = $auth['explorer:fileDownload']; $auth['explorer:officeSave'] = $auth['editor:fileSave']; $auth['userShare:del'] = $auth['userShare:set']; if ($auth[$key] != 1) { show_json($this->L['no_permission'], false); } $GLOBALS['auth'] = $auth; //全局 //扩展名限制:新建文件&上传文件&重命名文件&保存文件&zip解压文件 $check_arr = array('mkfile' => $this->check_key('path'), 'pathRname' => $this->check_key('rname_to'), 'fileUpload' => isset($_FILES['file']['name']) ? $_FILES['file']['name'] : '', 'fileSave' => $this->check_key('path')); if (array_key_exists(ACT, $check_arr) && !checkExt($check_arr[ACT])) { show_json($this->L['no_permission_ext'], false); } }
/** *初始化用户数据和配置。 */ 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']); }
<?php global $modx, $session, $tsvshop, $shop_lang, $folders, $tables; include_once 'cache.class.php'; include_once 'apiinit.inc.php'; $charset = $modx->config['modx_charset']; $charset = isset($charset) ? $charset : "utf-8"; header('Content-type: text/html; charset=' . $charset); $cache = fileCache::GetInstance(3600, $_api_path . 'assets/cache/'); if (!($tsvshop = $cache->cache('tsvshop', 'tsvshop'))) { $tsvshop['lang'] = "russian-UTF8"; } include_once $_api_path . 'assets/snippets/tsvshop/lang/' . $tsvshop['lang'] . '.inc.php'; include_once $_api_path . 'assets/snippets/tsvshop/admin/includes/core.inc.php'; include_once $_api_path . 'assets/snippets/tsvshop/include/cart.inc.php'; include_once $_api_path . 'assets/snippets/tsvshop/include/config.inc.php'; $modx->config['base_path'] = $tsvshop['basePath']; $modx->config['modx_charset'] = $tsvshop['charset']; define("TSVSHOP_PATH", MODX_BASE_PATH . "assets/snippets/tsvshop/"); define("TSVSHOP_URL", MODX_BASE_URL . "assets/snippets/tsvshop/"); define("TSVSHOP_SURL", MODX_SITE_URL . "assets/snippets/tsvshop/"); $mode = _filter($_REQUEST['mode']); $idnum = _filter(intval($_REQUEST['idnum'])); $name = _filter($_REQUEST['name']); $price = _filter($_REQUEST['price']); $icon = _filter($_REQUEST['icon']); $opt = _filter($_REQUEST['opt']); $qty = ($q = _filter($_REQUEST['qty'])) ? $q : 1; $typeitem = ($t = _filter($_REQUEST['typeitem'])) ? $t : 'physical'; //$url = ($u = _filter($_REQUEST['url'])) ? $u : "&tovar=".$idnum; //$url = ($tsvshop['TypeCat']=='docs' || empty($tsvshop['TypeCat'])) ? $modx->makeUrl($idnum) : "&tovar=".$idnum;
private function _tree_init($app) { if ($app == 'editor' && isset($this->in['project'])) { $list_project = $this->path(_DIR($this->in['project']), true, true); $project = array_merge($list_project['folderlist'], $list_project['filelist']); $tree_data = array(array('name' => get_path_this($this->in['project']), 'children' => $project, 'iconSkin' => "my", 'menuType' => "menuTreeRoot", 'open' => true, 'this_path' => $this->in['project'], 'isParent' => count($project) > 0 ? true : false)); show_json($tree_data); return; } $check_file = $app == 'editor' ? true : false; $favData = new fileCache($this->config['user_fav_file']); $fav_list = $favData->get(); $fav = array(); foreach ($fav_list as $key => $val) { $fav[] = array('name' => $val['name'], 'this_path' => $val['path'], 'iconSkin' => "fav", 'menuType' => "menuTreeFav", 'type' => 'folder', 'isParent' => path_haschildren(_DIR($val['path']), $check_file)); } $list_root = $this->path(_DIR(MYHOME), $check_file, true); $list_public = $this->path(PUBLIC_PATH, $check_file, true); if ($check_file) { //编辑器 $root = array_merge($list_root['folderlist'], $list_root['filelist']); $public = array_merge($list_public['folderlist'], $list_public['filelist']); } else { //文件管理器 $root = $list_root['folderlist']; $public = $list_public['folderlist']; } $root_isparent = count($root) > 0 ? true : false; $public_isparent = count($public) > 0 ? true : false; $tree_data = array(array('name' => $this->L['fav'], 'iconSkin' => "fav", 'menuType' => "menuTreeFavRoot", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'children' => $root, 'menuType' => "menuTreeRoot", 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => $root_isparent), array('name' => $this->L['public_path'], 'children' => $public, 'menuType' => "menuTreeRoot", 'iconSkin' => "lib", 'open' => true, 'this_path' => '*public*', 'isParent' => $public_isparent)); show_json($tree_data); }
<?php global $TypeCat, $session, $cache; if (!$cache) { include_once 'cache.class.php'; $cache = fileCache::GetInstance(3600, MODX_BASE_PATH . 'assets/cache/'); } if (!function_exists("session")) { function session($cache) { $session = empty($_COOKIE['tsvshop']) ? md5(uniqid(rand())) : $_COOKIE['tsvshop']; SetCookie("tsvshop", $session, time() + 7200, "/"); //set the cookie to remain for 2 hours if ($cache) { $cache->cache("session", "tsvshop", $session); } return $session; } } $session = !$session ? session($cache) : $session; if (!function_exists("tsv_ConvertPrice")) { function tsv_ConvertPrice($txt) { if (strpos($txt, "||") === false) { echo str_replace('\\r\\n', '', $txt); } else { $pieces = explode("||", "||" . $txt); $i = 0; $o = ""; $o2 = ""; foreach ($pieces as $value) {
/** * 用户app初始化 */ public function init_app($user) { $sql = new fileCache($this->config['system_file']['apps']); $list = $sql->get(); $desktop = USER_PATH . $user . '/home/desktop/'; foreach ($list as $key => $data) { //touch($path); $path = iconv_system($desktop . $key . '.oexe'); unset($data['name']); unset($data['desc']); unset($data['group']); file_put_contents($path, json_encode($data)); } }
/** * 用户app初始化 */ public function init_app($user) { $sql = new fileCache($this->config['system_file']['apps']); $list = $sql->get(); $default = array('365日历', 'pptv直播', 'ps', 'qq音乐', '搜狐影视', '时钟', '水果忍者', '计算器', '豆瓣电台', '音悦台'); $info = array(); foreach ($default as $key) { $info[$key] = $list[$key]; } $desktop = USER_PATH . $user['name'] . '/home/desktop/'; foreach ($info as $key => $data) { //touch($path); $path = iconv_system($desktop . $key . '.oexe'); unset($data['name']); unset($data['desc']); unset($data['group']); file_put_contents($path, json_encode($data)); } $user['status'] = 1; $member = new fileCache($this->config['system_file']['member']); $member->update($user['name'], $user); }
/** * 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); } }
/** * Permission Validation; unified entrance examination */ public function authCheck() { if (isset($GLOBALS['is_root']) && $GLOBALS['is_root'] == 1) { return; } if (in_array(ACT, $this->notCheck)) { return; } if (!array_key_exists(ST, $this->config['role_setting'])) { return; } if (!in_array(ACT, $this->config['role_setting'][ST]) && ST . ':' . ACT != 'user:common_js') { return; } //Outputs the processed permissions //With restricted access function $key = ST . ':' . ACT; $group = new fileCache(USER_SYSTEM . 'group.php'); $auth = $group->get($this->user['role']); // Downward compatible with version handling // Undefined; the new version features the first use of the default open if (!isset($auth['userShare:set'])) { $auth['userShare:set'] = 1; } if (!isset($auth['explorer:fileDownload'])) { $auth['explorer:fileDownload'] = 1; } //The default extension is functionally equivalent authority $auth['user:common_js'] = 1; //After permission to configure the output data to the front end $auth['explorer:pathChmod'] = $auth['explorer:pathRname']; $auth['explorer:pathDeleteRecycle'] = $auth['explorer:pathDelete']; $auth['explorer:pathCopyDrag'] = $auth['explorer:pathCuteDrag']; $auth['explorer:fileDownloadRemove'] = $auth['explorer:fileDownload']; $auth['explorer:zipDownload'] = $auth['explorer:fileDownload']; $auth['explorer:fileProxy'] = $auth['explorer:fileDownload']; $auth['editor:fileGet'] = $auth['explorer:fileDownload']; $auth['explorer:officeView'] = $auth['explorer:fileDownload']; $auth['explorer:officeSave'] = $auth['editor:fileSave']; $auth['userShare:del'] = $auth['userShare:set']; if ($auth[$key] != 1) { show_json($this->L['no_permission'], false); } $GLOBALS['auth'] = $auth; //Overall situation //Extension restrictions: New File Upload & File & rename files & save files Unzip & zip file $check_arr = array('mkfile' => $this->check_key('path'), 'pathRname' => $this->check_key('rname_to'), 'fileUpload' => isset($_FILES['file']['name']) ? $_FILES['file']['name'] : '', 'fileSave' => $this->check_key('path')); if (array_key_exists(ACT, $check_arr) && !checkExt($check_arr[ACT])) { show_json($this->L['no_permission_ext'], false); } }
/** *初始化用户数据和配置。 */ 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']); }
public function setConfig() { $file = USER . 'data/editor_config.php'; if (!is_writeable($file)) { //配置不可写 show_json($this->L['no_permission_write_file'], false); } $key = $this->in['k']; $value = $this->in['v']; if ($key != '' && $value != '') { $sql = new fileCache($file); if (!$sql->update($key, $value)) { $sql->add($key, $value); //没有则添加一条 } show_json($this->L["setting_success"]); } else { show_json($this->L['error'], false); } }
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(); }
public function setCachePath($path) { $this->_file_cache->setCachePath($path); }
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']; } }
private function _tree_init($app) { $check_file = $app == 'editor' ? true : false; $favData = new fileCache($this->config['user_fav_file']); $fav_list = $favData->get(); $fav = array(); foreach ($fav_list as $key => $val) { $fav[] = array('ext' => 'folder', 'name' => $val['name'], 'this_path' => $val['path'], 'iconSkin' => "fav", 'type' => 'folder', 'isParent' => path_haschildren(_DIR($val['path']), $check_file)); } $list_root = $this->path(_DIR(MYHOME), true, true); $list_share = $this->path(_DIR(PUBLIC_PATH), true, true); if ($check_file) { //编辑器 $root = array_merge($list_root['folderlist'], $list_root['filelist']); $share = array_merge($list_share['folderlist'], $list_share['filelist']); $tree_data = array(array('name' => $this->L['fav'], 'ext' => '__fav__', 'iconSkin' => "fav", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'ext' => '__root__', 'children' => $root, 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => true), array('name' => $this->L['public_path'], 'ext' => '__root__', 'children' => $share, 'iconSkin' => "lib", 'open' => true, 'this_path' => PUBLIC_PATH, 'isParent' => true)); } else { //文件管理器 $root = $list_root['folderlist']; $share = $list_share['folderlist']; $tree_data = array(array('name' => $this->L['fav'], 'ext' => '__fav__', 'iconSkin' => "fav", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'ext' => '__root__', 'children' => $root, 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => true), array('name' => $this->L['public_path'], 'ext' => '__root__', 'children' => $share, 'iconSkin' => "lib", 'open' => true, 'this_path' => PUBLIC_PATH, 'isParent' => true)); } show_json($tree_data); }
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; } }
/** * 用户app初始化 */ private function init_app($user) { $sql = new fileCache($this->config['system_file']['apps']); $list = $sql->get(); $desktop = USER_PATH . $user['name'] . '/home/desktop/'; foreach ($list as $key => $data) { $path = iconv_system($desktop . $key . '.oexe'); unset($data['name']); unset($data['desc']); unset($data['group']); file_put_contents($path, json_encode($data)); } $user['status'] = 1; $member = new fileCache($this->config['system_file']['member']); $member->update($user['name'], $user); }
public function setConfig() { $key = $this->in['k']; $value = $this->in['v']; if ($key != '' && $value != '') { $config_file = USER . 'data/editor_config.php'; $sql = new fileCache($config_file); $default = $sql->update($key, $value); show_json($this->L["setting_success"]); } else { show_json($this->L['error'], false); } }