public function __construct()
 {
     $host = "cache.railpage.com.au";
     $port = 6379;
     $this->Cache = new Redis();
     $this->Cache->connect($host, $port);
     $Smarty = AppCore::GetSmarty();
     $Smarty->caching_type = "redis";
 }
Exemple #2
0
 static function initialize($config = array())
 {
     foreach ($config as $key => $value) {
         self::${$key} = $value;
     }
     $dsn = 'fs://' . self::$dir;
     $backend = Cache::connect($dsn, self::$lifetime);
     self::$client = $backend;
     // Cache_Tagged::Client($backend);
 }
Exemple #3
0
 /**
  * 取得缓存类实例
  * 
  * @static
  *
  * @access public
  * @return mixed
  */
 static function getInstance($type = '', $options = array())
 {
     static $_instance = array();
     $guid = $type . to_guid_string($options);
     if (!isset($_instance[$guid])) {
         $obj = new Cache();
         $_instance[$guid] = $obj->connect($type, $options);
     }
     return $_instance[$guid];
 }
Exemple #4
0
 /**
  * 测试操作缓存
  */
 public function testApc()
 {
     App::run(Config::get());
     $this->assertInstanceOf('\\think\\cache\\driver\\Apc', Cache::connect(['type' => 'apc', 'expire' => 1]));
     $this->assertTrue(Cache::set('key', 'value'));
     $this->assertEquals('value', Cache::get('key'));
     $this->assertTrue(Cache::rm('key'));
     $this->assertFalse(Cache::get('key'));
     $this->assertTrue(Cache::clear('key'));
     Config::reset();
 }
Exemple #5
0
 public static function initialize(array $options = array())
 {
     self::options($options);
     if (!class_exists('Google_Client') && set_include_path(get_include_path() . PATH_SEPARATOR . self::option('lib_path') . 'src/')) {
         if (!@(include_once 'Google_Client.php')) {
             throw new Service_Google_API_ClientLibraryModuleNotFoundException('src/Google_Client.php', self::option('lib_path'));
         }
     }
     self::$cache = Cache::connect(self::option('cache_path'), 0);
     self::$stdin = IO::stdin();
 }
Exemple #6
0
 /**
  * Запускает приложение
  *
  * @param array $argv
  *
  * @return int
  */
 public function run(array $argv)
 {
     $cache = Cache::connect($this->config->dsn);
     if ($this->config->modules != null) {
         foreach (Core_Strings::split_by(',', $this->config->modules) as $v) {
             Core::load($v);
         }
     }
     foreach ($argv as $v) {
         IO::stdout()->write_line($v)->write_line(var_export($cache[$v], true));
     }
     return 0;
 }
 /**
  * 取得缓存类实例
  * @static
  * @access public
  * @return mixed
  */
 static function getInstance($type = '', $options = array())
 {
     static $_instance = array();
     if (empty($type)) {
         $type = $options['type'];
     }
     $guid = md5(serialize($options));
     if (!isset($_instance[$guid])) {
         $obj = new Cache();
         $_instance[$guid] = $obj->connect($type, $options);
     }
     return $_instance[$guid];
 }
 /**
  * @brief init LogX 全局初始化方法
  *
  * @return void
  */
 public static function init()
 {
     // 输出 Logo
     if (isset($_GET['591E-D5FC-8065-CD36-D3E8-E45C-DB86-9197'])) {
         Response::logo();
     }
     // 非 DEBUG 模式下关闭错误输出
     if (defined('LOGX_DEBUG')) {
         error_reporting(E_ALL);
     } else {
         error_reporting(0);
     }
     // 设置自动载入函数
     function __autoLoad($className)
     {
         if (substr($className, -7) == 'Library' && is_file(LOGX_LIB . $className . '.php')) {
             @(require_once LOGX_LIB . $className . '.php');
         }
     }
     // 设置错误与异常处理函数
     set_error_handler(array(__CLASS__, 'error'));
     set_exception_handler(array(__CLASS__, 'exception'));
     // 运行环境检查
     if (!version_compare(PHP_VERSION, '5.0.0', '>=')) {
         throw new LogXException(sprintf(_t('LogX needs PHP 5.0.x or higher to run. You are currently running PHP %s.'), PHP_VERSION));
     }
     if (!version_compare(PHP_VERSION, '5.2.0', '>=')) {
         // 针对低版本 PHP 的兼容代码
         @(require_once LOGX_CORE . 'Compat.php');
     }
     // 设置语言
     if (defined('LOGX_LANGUAGE')) {
         Language::set(LOGX_LANGUAGE);
     } else {
         Language::set('zh-cn');
     }
     // 预编译核心文件
     global $coreFiles;
     if (!defined('LOGX_DEBUG') && !file_exists(LOGX_CACHE . '~core.php')) {
         Compile::build(LOGX_CACHE, $coreFiles, 'core');
     } elseif (!defined('LOGX_DEBUG')) {
         $file_time = filemtime(LOGX_CACHE . '~core.php');
         foreach ($coreFiles as $file) {
             if (filemtime($file) > $file_time) {
                 Compile::build(LOGX_CACHE, $coreFiles, 'core');
                 break;
             }
         }
     }
     self::$_globalVars = array('RUN' => array('TIME' => microtime(TRUE), 'MEM' => function_exists('memory_get_usage') ? memory_get_usage() : 0, 'LANG' => 'zh-cn'), 'SYSTEM' => array('OS' => PHP_OS, 'HTTP' => Request::S('SERVER_SOFTWARE', 'string'), 'PHP' => PHP_VERSION, 'MYSQL' => ''), 'SUPPORT' => array('MYSQL' => function_exists('mysql_connect'), 'GD' => function_exists('imagecreate'), 'MEMCACHE' => function_exists('memcache_connect'), 'SHMOP' => function_exists('shmop_open'), 'GZIP' => function_exists('ob_gzhandler'), 'TIMEZONE' => function_exists('date_default_timezone_set'), 'AUTOLOAD' => function_exists('spl_autoload_register')), 'INI' => array('ALLOW_CALL_TIME_PASS_REFERENCE' => ini_get('allow_call_time_pass_reference'), 'MAGIC_QUOTES_GPC' => ini_get('magic_quotes_gpc'), 'REGISTER_GLOBALS' => ini_get('register_globals'), 'ALLOW_URL_FOPEN' => ini_get('allow_url_fopen'), 'ALLOW_URL_INCLUDE' => ini_get('allow_url_include'), 'SAFE_MODE' => ini_get('safe_mode'), 'MAX_EXECUTION_TIME' => ini_get('max_execution_time'), 'MEMORY_LIMIT' => ini_get('memory_limit'), 'POST_MAX_SIZE' => ini_get('post_max_size'), 'FILE_UPLOADS' => ini_get('file_uploads'), 'UPLOAD_MAX_FILESIZE' => ini_get('upload_max_filesize'), 'MAX_FILE_UPLOADS' => ini_get('max_file_uploads')));
     // 清除不需要的变量,防止变量注入
     $defined_vars = get_defined_vars();
     foreach ($defined_vars as $key => $value) {
         if (!in_array($key, array('_POST', '_GET', '_COOKIE', '_SERVER', '_FILES'))) {
             ${$key} = '';
             unset(${$key});
         }
     }
     // 对用户输入进行转义处理
     if (!get_magic_quotes_gpc()) {
         $_GET = self::addSlashes($_GET);
         $_POST = self::addSlashes($_POST);
         $_COOKIE = self::addSlashes($_COOKIE);
     }
     // 开启输出缓存
     if (defined('LOGX_GZIP') && self::$_globalVars['SUPPORT']['GZIP']) {
         ob_start('ob_gzhandler');
     } else {
         ob_start();
     }
     // 连接到数据库
     Database::connect(DB_HOST, DB_USER, DB_PWD, DB_NAME, DB_PCONNECT);
     self::$_globalVars['SYSTEM']['MYSQL'] = Database::version();
     // 设定时区
     if (self::$_globalVars['SUPPORT']['TIMEZONE']) {
         date_default_timezone_set(OptionLibrary::get('timezone'));
     }
     // 连接到缓存
     Cache::connect(CACHE_TYPE);
     // 初始化路由表
     Router::init();
     // 初始化主题控制器
     Theme::init();
     // 初始化 Plugin
     Plugin::initPlugins();
     // 初始化全局组件
     Widget::initWidget('Global');
     Widget::initWidget('Widget');
     Widget::initWidget('Page');
     Widget::initWidget('User');
     // 尝试自动登录
     Widget::getWidget('User')->autoLogin();
     // 启动路由分发
     Router::dispatch();
 }
Exemple #9
0
 /**
  * 执行应用程序
  * @access public
  * @return void
  */
 public static function run()
 {
     // 初始化公共模块
     self::initModule(COMMON_MODULE, Config::get());
     // 读取扩展配置文件
     if (Config::get('extra_config_list')) {
         foreach (Config::get('extra_config_list') as $file) {
             Config::load($file, $file);
         }
     }
     // 获取配置参数
     $config = Config::get();
     // 加载额外文件
     if (!empty($config['extra_file_list'])) {
         foreach ($config['extra_file_list'] as $file) {
             $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
             if (is_file($file)) {
                 include_once $file;
             }
         }
     }
     // 日志初始化
     Log::init($config['log']);
     // 缓存初始化
     Cache::connect($config['cache']);
     // 设置系统时区
     date_default_timezone_set($config['default_timezone']);
     // 监听app_init
     APP_HOOK && Hook::listen('app_init');
     // 开启多语言机制
     if ($config['lang_switch_on']) {
         // 获取当前语言
         defined('LANG_SET') or define('LANG_SET', Lang::range());
         // 加载系统语言包
         Lang::load(THINK_PATH . 'lang' . DS . LANG_SET . EXT);
     }
     // 启动session CLI 不开启
     if (!IS_CLI && $config['use_session']) {
         Session::init($config['session']);
     }
     // 应用URL调度
     self::dispatch($config);
     // 监听app_run
     APP_HOOK && Hook::listen('app_run');
     // 执行操作
     if (!preg_match('/^[A-Za-z](\\/|\\.|\\w)*$/', CONTROLLER_NAME)) {
         // 安全检测
         throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000);
     }
     if (Config::get('action_bind_class')) {
         $class = self::bindActionClass(Config::get('empty_controller'));
         $instance = new $class();
         // 操作绑定到类后 固定执行run入口
         $action = 'run';
     } else {
         $instance = Loader::controller(CONTROLLER_NAME, '', Config::get('empty_controller'));
         // 获取当前操作名
         $action = ACTION_NAME . Config::get('action_suffix');
     }
     if (!$instance) {
         throw new Exception('class [ ' . Loader::parseClass(MODULE_NAME, CONTROLLER_LAYER, CONTROLLER_NAME) . ' ] not exists', 10001);
     }
     try {
         // 操作方法开始监听
         $call = [$instance, $action];
         APP_HOOK && Hook::listen('action_begin', $call);
         if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) {
             // 非法操作
             throw new \ReflectionException();
         }
         //执行当前操作
         $method = new \ReflectionMethod($instance, $action);
         if ($method->isPublic()) {
             // URL参数绑定检测
             if (Config::get('url_params_bind') && $method->getNumberOfParameters() > 0) {
                 // 获取绑定参数
                 $args = self::getBindParams($method, Config::get('url_parmas_bind_type'));
                 // 全局过滤
                 array_walk_recursive($args, 'think\\Input::filterExp');
                 $data = $method->invokeArgs($instance, $args);
             } else {
                 $data = $method->invoke($instance);
             }
             // 操作方法执行完成监听
             APP_HOOK && Hook::listen('action_end', $data);
             // 输出数据
             return Response::send($data, Response::type(), Config::get('response_return'));
         } else {
             // 操作方法不是Public 抛出异常
             throw new \ReflectionException();
         }
     } catch (\ReflectionException $e) {
         // 操作不存在
         if (method_exists($instance, '_empty')) {
             $method = new \ReflectionMethod($instance, '_empty');
             $data = $method->invokeArgs($instance, [$action, '']);
             // 操作方法执行完成监听
             APP_HOOK && Hook::listen('action_end', $data);
             // 输出数据
             return Response::send($data, Response::type(), Config::get('response_return'));
         } else {
             throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002);
         }
     }
 }
Exemple #10
0
 /**
  * 执行应用程序
  * @access public
  * @return void
  */
 public static function run(array $config = [])
 {
     // 初始化公共模块
     self::initModule(COMMON_MODULE, $config);
     // 读取扩展配置文件
     if ($config['extra_config_list']) {
         foreach ($config['extra_config_list'] as $file) {
             Config::load($file, $file);
         }
     }
     // 获取配置参数
     $config = Config::get();
     // 日志初始化
     Log::init($config['log']);
     // 缓存初始化
     Cache::connect($config['cache']);
     // 如果启动SocketLog调试, 进行SocketLog配置
     if (SLOG_ON) {
         Slog::config($config['slog']);
     }
     // 设置系统时区
     date_default_timezone_set($config['default_timezone']);
     // 默认语言
     $lang = strtolower($config['default_lang']);
     Lang::range($lang);
     // 加载默认语言包
     Lang::load(THINK_PATH . 'Lang/' . $lang . EXT);
     // 监听app_init
     APP_HOOK && Hook::listen('app_init');
     // 启动session API CLI 不开启
     if (!IS_CLI && !IS_API && $config['use_session']) {
         Session::init($config['session']);
     }
     // 应用URL调度
     self::dispatch($config);
     // 监听app_run
     APP_HOOK && Hook::listen('app_run');
     // 执行操作
     if (!preg_match('/^[A-Za-z](\\/|\\.|\\w)*$/', CONTROLLER_NAME)) {
         // 安全检测
         throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000);
     }
     if (Config::get('action_bind_class')) {
         $class = self::bindActionClass(Config::get('empty_controller'));
         $instance = new $class();
         // 操作绑定到类后 固定执行run入口
         $action = 'run';
     } else {
         $instance = Loader::controller(CONTROLLER_NAME, '', Config::get('empty_controller'));
         // 获取当前操作名
         $action = ACTION_NAME . Config::get('action_suffix');
     }
     if (!$instance) {
         throw new Exception('class [ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists', 10001);
     }
     try {
         // 操作方法开始监听
         $call = [$instance, $action];
         APP_HOOK && Hook::listen('action_begin', $call);
         if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) {
             // 非法操作
             throw new \ReflectionException();
         }
         //执行当前操作
         $method = new \ReflectionMethod($instance, $action);
         if ($method->isPublic()) {
             // URL参数绑定检测
             if (Config::get('url_params_bind') && $method->getNumberOfParameters() > 0) {
                 // 获取绑定参数
                 $args = self::getBindParams($method, Config::get('url_parmas_bind_type'));
                 // 全局过滤
                 array_walk_recursive($args, 'think\\Input::filterExp');
                 $data = $method->invokeArgs($instance, $args);
             } else {
                 $data = $method->invoke($instance);
             }
             // 操作方法执行完成监听
             APP_HOOK && Hook::listen('action_end', $data);
             // 返回数据
             Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit'));
         } else {
             // 操作方法不是Public 抛出异常
             throw new \ReflectionException();
         }
     } catch (\ReflectionException $e) {
         // 操作不存在
         if (method_exists($instance, '_empty')) {
             $method = new \ReflectionMethod($instance, '_empty');
             $data = $method->invokeArgs($instance, [$action, '']);
             // 返回数据
             Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit'));
         } else {
             throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002);
         }
     }
 }
Exemple #11
0
 /**
  * 执行应用程序
  * @access public
  * @return void
  */
 public static function run(array $config = [])
 {
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         throw new Exception('require PHP > 5.4.0 !');
     }
     // 日志初始化
     Log::init($config['log']);
     // 缓存初始化
     Cache::connect($config['cache']);
     // 加载框架底层语言包
     if (is_file(THINK_PATH . 'Lang/' . strtolower($config['default_lang']) . EXT)) {
         Lang::set(include THINK_PATH . 'Lang/' . strtolower($config['default_lang']) . EXT);
     }
     if (is_file(APP_PATH . 'build.php')) {
         // 自动化创建脚本
         Create::build(include APP_PATH . 'build.php');
     }
     // 监听app_init
     Hook::listen('app_init');
     // 初始化公共模块
     self::initModule(APP_PATH . $config['common_module'] . '/', $config);
     // 启动session
     if ($config['use_session']) {
         Session::init($config['session']);
     }
     // 应用URL调度
     self::dispatch($config);
     // 监听app_run
     Hook::listen('app_run');
     // 执行操作
     if (!preg_match('/^[A-Za-z](\\/|\\w)*$/', CONTROLLER_NAME)) {
         // 安全检测
         $instance = false;
     } elseif ($config['action_bind_class']) {
         // 操作绑定到类:模块\controller\控制器\操作
         if (is_dir(MODULE_PATH . CONTROLLER_LAYER . '/' . CONTROLLER_NAME)) {
             $namespace = MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . CONTROLLER_NAME . '\\';
         } else {
             // 空控制器
             $namespace = MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . $config['empty_controller'] . '\\';
         }
         $actionName = strtolower(ACTION_NAME);
         if (class_exists($namespace . $actionName)) {
             $class = $namespace . $actionName;
         } elseif (class_exists($namespace . '_empty')) {
             // 空操作
             $class = $namespace . '_empty';
         } else {
             throw new Exception('_ERROR_ACTION_:' . ACTION_NAME);
         }
         $instance = new $class();
         // 操作绑定到类后 固定执行run入口
         $action = 'run';
     } else {
         $instance = Loader::controller(CONTROLLER_NAME, '', $config['empty_controller']);
         // 获取当前操作名
         $action = ACTION_NAME . $config['action_suffix'];
     }
     if (!$instance) {
         throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(CONTROLLER_NAME, 1) . ' ] not exists');
     }
     try {
         // 操作方法开始监听
         $call = [$instance, $action];
         Hook::listen('action_begin', $call);
         if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) {
             // 非法操作
             throw new \ReflectionException();
         }
         //执行当前操作
         $method = new \ReflectionMethod($instance, $action);
         if ($method->isPublic()) {
             // URL参数绑定检测
             if ($config['url_params_bind'] && $method->getNumberOfParameters() > 0) {
                 switch ($_SERVER['REQUEST_METHOD']) {
                     case 'POST':
                         $vars = array_merge($_GET, $_POST);
                         break;
                     case 'PUT':
                         parse_str(file_get_contents('php://input'), $vars);
                         break;
                     default:
                         $vars = $_GET;
                 }
                 $params = $method->getParameters();
                 $paramsBindType = $config['url_parmas_bind_type'];
                 foreach ($params as $param) {
                     $name = $param->getName();
                     if (1 == $paramsBindType && !empty($vars)) {
                         $args[] = array_shift($vars);
                     }
                     if (0 == $paramsBindType && isset($vars[$name])) {
                         $args[] = $vars[$name];
                     } elseif ($param->isDefaultValueAvailable()) {
                         $args[] = $param->getDefaultValue();
                     } else {
                         throw new Exception('_PARAM_ERROR_:' . $name);
                     }
                 }
                 array_walk_recursive($args, 'Input::filterExp');
                 $data = $method->invokeArgs($instance, $args);
             } else {
                 $data = $method->invoke($instance);
             }
             // 操作方法执行完成监听
             Hook::listen('action_end', $data);
             // 返回数据
             Response::returnData($data, $config['default_return_type']);
         } else {
             // 操作方法不是Public 抛出异常
             throw new \ReflectionException();
         }
     } catch (\ReflectionException $e) {
         // 操作不存在
         if (method_exists($instance, '_empty')) {
             $method = new \ReflectionMethod($instance, '_empty');
             $method->invokeArgs($instance, [$action, '']);
         } else {
             throw new Exception('[ ' . (new \ReflectionClass($instance))->getName() . ':' . $action . ' ] not exists ', 404);
         }
     }
     return;
 }
Exemple #12
0
 /**
  * 执行应用程序
  * @access public
  * @return void
  */
 public static function run()
 {
     // 初始化应用(公共模块)
     self::initModule(COMMON_MODULE, Config::get());
     // 读取扩展配置文件
     if (Config::get('extra_config_list')) {
         foreach (Config::get('extra_config_list') as $file) {
             Config::load(APP_PATH . $file . EXT, $file);
         }
     }
     // 获取配置参数
     $config = Config::get();
     // 加载额外文件
     if (!empty($config['extra_file_list'])) {
         foreach ($config['extra_file_list'] as $file) {
             $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
             if (is_file($file)) {
                 include_once $file;
             }
         }
     }
     // 日志初始化
     Log::init($config['log']);
     // 缓存初始化
     Cache::connect($config['cache']);
     // 设置系统时区
     date_default_timezone_set($config['default_timezone']);
     // 监听app_init
     APP_HOOK && Hook::listen('app_init');
     // 开启多语言机制
     if ($config['lang_switch_on']) {
         // 获取当前语言
         defined('LANG_SET') or define('LANG_SET', Lang::range());
         // 加载系统语言包
         Lang::load(THINK_PATH . 'lang' . DS . LANG_SET . EXT);
         if (!APP_MULTI_MODULE) {
             Lang::load(APP_PATH . 'lang' . DS . LANG_SET . EXT);
         }
     }
     // 启动session CLI 不开启
     if (!IS_CLI && $config['use_session']) {
         Session::init($config['session']);
     }
     if (empty(self::$dispatch['type'])) {
         // 未指定调度类型 则进行URL路由检测
         self::route($config);
     }
     // 监听app_begin
     APP_HOOK && Hook::listen('app_begin');
     // 根据类型调度
     switch (self::$dispatch['type']) {
         case 'redirect':
             // 执行重定向跳转
             header('Location: ' . self::$dispatch['url'], true, self::$dispatch['status']);
             break;
         case 'module':
             // 模块/控制器/操作
             $data = self::module(self::$dispatch['module'], $config);
             break;
         case 'controller':
             // 执行控制器操作
             $data = Loader::action(self::$dispatch['controller'], self::$dispatch['params']);
             break;
         case 'method':
             // 执行回调方法
             $data = self::invokeMethod(self::$dispatch['method'], self::$dispatch['params']);
             break;
         case 'function':
             // 规则闭包
             $data = self::invokeFunction(self::$dispatch['function'], self::$dispatch['params']);
             break;
         default:
             throw new Exception('dispatch type not support', 10008);
     }
     // 监听app_end
     APP_HOOK && Hook::listen('app_end', $data);
     // 输出数据到客户端
     return Response::send($data, Response::type(), Config::get('response_return'));
 }
Exemple #13
0
 public function __construct($backend)
 {
     $this->backend = is_object($backend) ? $backend : Cache::connect((string) $backend);
 }
Exemple #14
0
 public function __construct()
 {
     $this->cache = Cache::connect(self::option('less_cache_dns'));
     $this->output = self::option('less_output_dir');
 }
Exemple #15
0
 public function run(WS_Environment $env)
 {
     $dsn = $this->dsn ? $this->dsn : $env->config->cache->dsn;
     if (empty($dsn)) {
         $dsn = 'dummy://';
     }
     $timeout = $this->timeout ? $this->timeout : (isset($env->config->cache->timeout) ? $env->config->cache->timeout : null);
     $env->cache = Cache::connect($dsn, $timeout);
     $tagged = !is_null($this->tagged) ? $this->tagged : (isset($env->config->cache->tagged) ? $env->config->cache->tagged : !$env->cache->is_support_nesting());
     $locked = !is_null($this->locked) ? $this->locked : (isset($env->config->cache->locked) ? $env->config->cache->locked : false);
     if ($tagged) {
         Core::load('Cache.Tagged');
         $env->cache = Cache_Tagged::Client($env->cache);
     }
     if ($locked) {
         Core::load('Cache.Locked');
         $env->cache = Cache_Locked::Client($env->cache);
     }
     $response = null;
     foreach ($this->urls as $regexp => $timeout) {
         if (preg_match($regexp, $env->request->path)) {
             if (($response = $env->cache->get('ws.middlweware.cache.pages:' . $env->request->url)) === null) {
                 $response = $this->application->run($env);
                 $env->cache->set('ws.middleware.cache.pages:' . $env->request->url, $response, $timeout);
             }
             break;
         }
     }
     return $response ? $response : $this->application->run($env);
 }
Exemple #16
0
 public function __construct()
 {
     $this->cache = Cache::connect(Templates_HTML_Preprocess::option('less_cache_dns'));
     $output = Templates_HTML_Preprocess::option('less_output_dir');
     IO_FS::mkdir($output, null, true);
 }
// LogX 根路径
define('LOGX_ROOT', str_replace('\\', '/', dirname(__FILE__)) . '/');
// LogX WEB 路径
define('LOGX_PATH', str_replace('install.php', '', $_SERVER['SCRIPT_NAME']));
// 载入 LogX 配置
if (!@(include_once LOGX_ROOT . 'LogX/Config.php')) {
    die('LogX Config file missing.');
}
// 载入系统文件
foreach ($coreFiles as $file) {
    if (!@(include_once $file)) {
        die('Core files missing.');
    }
}
// 连接到缓存
Cache::connect(CACHE_TYPE);
// 检查安装
if (file_exists('./config.php')) {
    showError("<strong>检测到重复安装请求</strong><br />您已经安装过 LogX,为保证您的数据安全,安装程序自动拒绝了此安装请求。<br>如果您确实希望重新安装 LogX,请先删除 LogX 程序根目录下的 config.php 文件,再重新运行安装程序。");
}
// 执行安装程序
switch (Request::G('step')) {
    case 1:
        showHead();
        // 检查系统环境
        $result = TRUE;
        if (!version_compare(PHP_VERSION, '5.0.0', '>=')) {
            $result = FALSE;
        }
        if (!function_exists('mysql_connect')) {
            $result = FALSE;
Exemple #18
0
 /**
  */
 protected function build_client()
 {
     $this->store = Cache::connect($this->config->store_dsn, $this->config->store_to);
     $this->client = Service_OAuth::Client($this->store)->consumer_key($this->config->consumer_key)->consumer_secret($this->config->consumer_secret)->request_token_url($this->config->request_token_url)->access_token_url($this->config->access_token_url)->authorize_url($this->config->authorize_url);
 }
Exemple #19
0
 /**
  * @param mixed $backend
  */
 public function __construct($backend)
 {
     $this->backend = $backend instanceof Cache_Backend ? $backend : Cache::connect((string) $backend);
 }