<?php /** Actions that are done on regular page init * @package init */ preloadFudjanCore(true); session_start(); if (file_exists(BASE_DIR . \System\Loader::FILE_MODULES)) { require_once BASE_DIR . \System\Loader::FILE_MODULES; } $request = System\Http\Request::from_hit(); $request->load_config(); System\Cache::init(); System\Database::init(); $request->init(); $response = $request->create_response(); if ($response) { $response->init(); if ($response->is_readable()) { try { $response->locales->load_messages(); } catch (\System\Error\Locales $e) { $default = \System\Locales::get_default_lang(); $err = new \System\Error\SeeOther(); $err->location = $request->path . '?lang=' . $default; throw $err; } $response->create_flow()->exec()->render()->send(); } else { throw new \System\Error\AccessDenied(); }
/** * 缓存管理 * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 * @param mixed $value 缓存值 * @param mixed $options 缓存参数 * @return mixed */ function S($name, $value = '', $options = null) { static $cache = ''; if (is_array($options) && empty($cache)) { // 缓存操作的同时初始化 $type = isset($options['type']) ? $options['type'] : ''; $cache = System\Cache::getInstance($type, $options); } elseif (is_array($name)) { // 缓存初始化 $type = isset($name['type']) ? $name['type'] : ''; $cache = System\Cache::getInstance($type, $name); return $cache; } elseif (empty($cache)) { // 自动初始化 $cache = System\Cache::getInstance(); } if ('' === $value) { // 获取缓存 return $cache->get($name); } elseif (is_null($value)) { // 删除缓存 return $cache->rm($name); } else { // 缓存数据 if (is_array($options)) { $expire = isset($options['expire']) ? $options['expire'] : NULL; } else { $expire = is_numeric($options) ? $options : NULL; } return $cache->set($name, $value, $expire); } }