function indexAction() { $config_table = new Config(); $modules_table = new Modules("core"); $request = new Bolts_Request($this->getRequest()); if ($request->has('modid')) { $modid = $request->modid; } else { $modid = 'bolts'; } if ($this->_request->isPost()) { //we are posting $config_params = $this->_request->getParams(); foreach ($config_params as $ckey => $value) { $data = array('value' => $value); $config_table->update($data, "ckey = '" . $ckey . "' and module='" . $modid . "'"); } $this->view->success = $this->_T('Configuration Updated.'); $config_table->cache(); $params = array(); $this->_Bolts_plugin->doAction($this->_mca . '_post_save', $params); // ACTION HOOK } $config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid)); if (count($config) > 0) { $config = $config->toArray(); sort($config); $this->view->config = $config; } $modules = $modules_table->getEnabledModules(); sort($modules); $this->view->modules = $modules; $this->view->current = $modid; $this->view->modid = $modid; }
function secondstageAction() { $request = new Bolts_Request($this->getRequest()); $appNamespace = new Zend_Session_Namespace('Bolts_Temp'); $basepath = Zend_Registry::get('basepath'); $config_table = new Config(); $appname = "My Application"; if ($request->has('appname')) { $appname = $request->appname; } $config_table->set('bolts', 'site_name', $appname); $config_table->set('bolts', 'title_prefix', $appname); $config_table->set('bolts', 'upload_path', $basepath . "/uploads", true); $config_table->set('bolts', 'theme', 'default', true); $config_table->set('bolts', 'missing_image', $basepath . "/themes/frontend/bolts/images/image-missing.png", true); $config_table->set('bolts', 'site_url', 'http://' . $_SERVER['SERVER_NAME']); $config_table->set('bolts', 'salt', substr(md5(rand(1, 1000)), 0, 10)); $config_table->cache(); $username = $request->username; $users_table = new Users(); $user = $users_table->fetchByUsername($username); $password = substr(md5(rand(50000, 100000)), 0, 8); if (!is_null($user)) { $user->password = $password; $user->save(); $users_table->setMetaData($username, "is_installer", 1); $appNamespace->autoLogin = true; $appNamespace->autoLoginUsername = $username; $appNamespace->autoLoginPassword = $password; $appNamespace->autoLoginPasswordHash = md5($password); } else { die("Somehow the admin user didn't get created or didn't get sent with the request. This is bad. Really, really bad."); } $this->_redirect("/bolts/install/finished/username/" . $username); }
public static function init() { if (Config::config('cache') == true) { $config = Config::cache(); Loader::core('CacheCarry'); Loader::driver('caches', $config['driver']); self::$cache = new $config['driver']($config); } }
public static function delete_timeout($space = false, $lifetime = false) { if ($space == false) { $space = self::$cache->config['default_space']; } if ($lifetime == false) { $lifetime = Config::cache('lifetime'); } return self::$cache->delete_timeout($space, $lifetime); }
public function __construct($connection = 'default', $specifiedDriver = false) { $this->config = Config::cache(); $this->config = $this->config[$connection]; if ($specifiedDriver) { $this->config['driver'] = $specifiedDriver; } $driverNamespace = 'Drivers\\Cache\\' . ucwords($this->config['driver']); $this->driver = new $driverNamespace($this->config); }
/** * 实例化memcache * 如果设置$config则按照$config设置,否则按照config下cache.php设置 * @ */ public function __construct($config = false) { if ($config) { foreach ($config as $k => $v) { $this->config[$k] = $v; } } else { $this->config = Config::cache(); } $this->connect(); }
function indexAction() { $config_table = new Config(); // $modules_table = new Modules('core'); $modules_table = new Modules('modules'); $modules_table_core = new Modules('core'); $request = new RivetyCore_Request($this->getRequest()); $modid = $request->has('modid') ? $request->modid : 'default'; if ($this->_request->isPost()) { $config_params = $this->_request->getParams(); foreach ($config_params as $ckey => $value) { $data = array('value' => $value); $config_table->update($data, "ckey = '" . $ckey . "' and module = '" . $modid . "'"); } $this->view->success = $this->_T('Configuration Updated.'); $config_table->cache(); $params = array(); $this->_rivety_plugin->doAction($this->_mca . '_post_save', $params); // ACTION HOOK } $config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid)); if (count($config) > 0) { $config = $config->toArray(); sort($config); $this->view->config = $config; } $modules = $modules_table_core->getEnabledModules(); sort($modules); $this->view->modules = $modules; $this->view->current = $modid; $this->view->modid = $modid; if ($modid == 'default') $mod_cfg = $modules_table_core->parseIni($modid); else $mod_cfg = $modules_table->parseIni($modid); $this->view->module_title = $mod_cfg['general']['name']; $this->view->breadcrumbs = array('Module Config' => null); }
?> </td> </tr> <tr> <td class="text-right">PHP 版本:</td> <td colspan="2" class="text-left"> <?php echo phpversion(); ?> <?php echo phpversion(); ?> </td> <td class="text-right">缓存驱动:</td> <td colspan="2" class="text-left"><?php echo Config::cache('driver'); ?> </td> </tr> <tr> <td class="text-right">路由驱动:</td> <td colspan="2" class="text-left"> <?php echo Config::router('driver'); ?> </td> <td class="text-right">数据库驱动:</td> <td colspan="2" class="text-left"><?php echo Config::database('driver'); ?> </td>
public final function query($sql = false) { if (!$sql) { $this->compile(); } $sql = $sql ? $sql : $this->sql; //print_r($this); //echo Config::database('table_pre').Config::cache('table'); if (Config::database('cache') && preg_match('/^SELECT/i', $sql) && (Config::database('table_pre') . Config::cache('table') != $this->table || Config::cache('driver') != 'dbCache')) { //echo '开启缓存'; if (!Cache::is_cache(md5($sql), Config::database('cache_dir') . '/' . $this->section['table'])) { $data = $this->_query($sql); $cdata = '<?php exit;/*' . serialize($data) . '*/'; Cache::set(md5($sql), $cdata, Config::database('cache_dir') . '/' . $this->section['table']); //Cache::$cache->writeCache($sql,$data,(Config::database('cache_dir').'/'.$this->section['table'])); Debug::add('DB:Update Cache ' . $sql, 2); } else { //$data=Cache::$cache->readCache($sql,(Config::database('cache_dir').'/'.$this->section['table'])); $data = unserialize(substr(Cache::get(md5($sql), Config::database('cache_dir') . '/' . $this->section['table']), 13, -2)); //exit(); Debug::add('DB:Read Cache' . $sql, 2); } $this->_reset(); if ($data == null) { //防止直接返回Null $data = array(); } return $data; } else { Debug::add($sql, 2); $this->_reset(); $data = $this->_query($sql); if ($data == null) { //防止直接返回Null $data = array(); } return $data; } }
/** * Initialize the test environment. */ public function setUp() { Config::$items = array(); Config::$cache = array(); Asset::$containers = array(); }
public function testRequestCache() { // Munge the config. include self::config; Config::cache('foo')->whichInvokes('MockAlwaysReturnFooCache'); $config = Config::getConfiguration(); //$config[Config::CACHES]['foo']['class'] = 'MockAlwaysReturnFooCache'; Config::initialize($config); $ff = new FortissimoHarness(); ob_start(); $ff->handleRequest('testRequestCache1'); $res = ob_get_contents(); ob_end_clean(); $this->assertEquals('foo', $res); unset($config[Config::CACHES]['foo']); // Second, test to see if values can be written to cache. //$config[Config::CACHES]['foo']['class'] = 'MockAlwaysSetValueCache'; Config::cache('foo')->whichInvokes('MockAlwaysSetValueCache')->withParam('isDefault')->whoseValueIs(TRUE); //Config::initialize($config); $ff = new FortissimoHarness(); ob_start(); $ff->handleRequest('testRequestCache2'); $res = ob_get_contents(); ob_end_clean(); $cacheManager = $ff->cacheManager(); $key = $ff->genCacheKey('testRequestCache2'); $this->assertEquals('bar', $cacheManager->get($key), 'Has cached item.'); // We also want to make sure that the output was passed on correctly. $this->assertEquals('bar', $res, 'Output was passed through correctly.'); // Finally, make sure that a request still works if no cacher is configured. $ff = new FortissimoHarness(self::config); ob_start(); $ff->handleRequest('testRequestCache2'); $res = ob_get_contents(); ob_end_clean(); $this->assertEquals('bar', $res); }
/** * 清空指定文件夹的缓存 */ public function _flush($space) { $dir = __ROOT__ . parseDir(Config::config('app_dir'), Config::cache('cache_dir'), $space); if (!file_exists($dir)) { return true; } $dh = opendir($dir); while ($file = readdir($dh)) { if ($file != "." && $file != "..") { $fullpath = $dir . "/" . $file; if (!is_dir($fullpath)) { unlink($fullpath); } else { $this->flush($space . '/' . $file); } } } closedir($dh); //删除当前文件夹: if (rmdir($dir)) { return true; } else { return false; } }
public static function read($glob_config, $file, $file2 = null) { $debug = isset($glob_config["RX_MODE_DEBUG"]) && $glob_config["RX_MODE_DEBUG"] == TRUE; $debug_build = isset($_REQUEST["RX_MODE_BUILD"]) && $_REQUEST["RX_MODE_BUILD"] == TRUE; self::$cache = new RxCache("config", true); $reloadCache = FALSE; header("FLAGS:" . self::$cache->isEmpty() . "-" . $glob_config["RX_MODE_DEBUG"] . "-" . $debug); if (self::$cache->isEmpty()) { $reloadCache = TRUE; } else { $_glob_config = self::$cache->get("GLOBAL"); if ($_glob_config["RX_MODE_DEBUG"] != $debug || isset($_GET['ModPagespeed'])) { $reloadCache = TRUE; } } $RELOAD_VERSION = self::$cache->get("RELOAD_VERSION"); if ($debug_build || $debug || $reloadCache) { FileUtil::build_check(); define("FIRST_RELOAD", TRUE); $RELOAD_VERSION = microtime(true); RxCache::clean(); self::$cache->set("RELOAD_VERSION", $RELOAD_VERSION); $DEFAULT_CONFIG = parse_ini_file("_project.properties", TRUE); $localConfig = array(); if (file_exists($file)) { $localConfig = parse_ini_file($file, TRUE); } $localConfig = array_replace_recursive($DEFAULT_CONFIG, $localConfig); if ($file2 != null && file_exists($file2)) { $localConfig = array_replace_recursive($localConfig, parse_ini_file($file2, TRUE)); } self::$cache->merge($localConfig); self::$cache->set('GLOBAL', array_merge($DEFAULT_CONFIG['GLOBAL'], $localConfig['GLOBAL'], $glob_config)); $reloadMode = isset($_GET['ModPagespeed']) ? $_GET['ModPagespeed'] : NULL; call_user_func(rx_function("rx_reload_cache"), $reloadMode); self::$cache->save(); Browser::header("RX_MODE_BUILD"); } else { define("FIRST_RELOAD", FALSE); } define("RELOAD_VERSION", $RELOAD_VERSION); return self::$cache->getArray(); }
public function testCaches() { $cfg = Config::cache('memcache')->whichInvokes('Memcachier')->getConfiguration(); $this->assertEquals('Memcachier', $cfg[Config::CACHES]['memcache']['class']); }
/** * Tear down the testing environment. */ public function tearDown() { Config::$items = array(); Config::$cache = array(); }
public function _delete_timeout($space, $lifetime) { $dir = __ROOT__ . parseDir(Config::config('app_dir'), Config::cache('cache_dir'), $space); if (!file_exists($dir)) { return true; } foreach (glob($dir . '*') as $v) { $time = $lifetime + filemtime($v); if ($time < time()) { @unlink($v); } } return true; }