/** * @covers Phossa\Config\Env\Environment::save() * @covers Phossa\Config\Env\Environment::get() * @covers Phossa\Config\Env\Environment::clear() */ public function testSave() { $data = ['db' => ['dsn' => 'bingo']]; $this->object->save($data); $this->assertEquals($data, $this->object->get()); $this->object->clear(); $this->assertFalse($this->object->get()); }
/** * @param string $path * @return $this */ public function setPath($path) { $last = substr($path, -1); if ($last === '/') { $path = substr($path, 0, -1); } $this->path = $path; $this->cache->clear(); return $this; }
public function __construct() { $guid = pageArray(2); adminGateKeeper(); $plugin = getEntity($guid); Setting::updateSettingsTable(); clearCache(); Cache::clear(); Cache::clear(); if ($plugin->enable()) { new SystemMessage("Plugin Enabled"); new Cache("enabled_plugins_", false, "site"); new Cache("enabled_plugins_reversed", false, "site"); Systemvariable::set("setup_complete", false); forward("admin/plugins"); } Setting::updateSettingsTable(); clearCache(); Cache::clear(); Cache::clear(); Admintab::deleteAll(); $translations = getEntities(array("type" => "Translationentity")); if ($translations) { foreach ($translations as $translation) { $translation->delete(); } } new SystemMessage("Your plugin can't be enabled. Check requirements"); forward("admin/plugins"); }
public function __construct() { if (!pageArray(2)) { forward("admin/plugins"); } $guid = pageArray(2); adminGateKeeper(); $plugin = getEntity($guid); classGateKeeper($plugin, "Plugin"); $plugin->status = "disabled"; $plugin->save(); Cache::clear(); Cache::clear(); Admintab::deleteAll(); Setting::updateSettingsTable(); clearCache(); Cache::clear(); Systemvariable::set("setup_complete", false); $translations = getEntities(array("type" => "Translationentity")); if ($translations) { foreach ($translations as $translation) { $translation->delete(); } } new SystemMessage("Your plugin has been disabled."); forward("admin/plugins"); }
/** * tearDown method * * @return void */ public function tearDown() { unset($this->ApiUserApplication); unset($this->testAppToken); Cache::clear(); parent::tearDown(); }
/** * Clears cache */ public function view() { adminGateKeeper(); Cache::clear(); new SystemMessage("All caches have been cleared."); forward(); }
function clear($checkExpiry) { foreach ($this->settings['stack'] as $engine => $stack) { Cache::clear($checkExpiry, $engine); } return true; }
/** * function to clear all cache data * by default accessible only for admin * * @access Public * @return void */ public function clear_cache() { $this->autoRender = false; Cache::clear(); clearCache(); $files = array(); $files = array_merge($files, glob(CACHE . '*')); // remove cached css $files = array_merge($files, glob(CACHE . 'css' . DS . '*')); // remove cached css $files = array_merge($files, glob(CACHE . 'js' . DS . '*')); // remove cached js $files = array_merge($files, glob(CACHE . 'models' . DS . '*')); // remove cached models $files = array_merge($files, glob(CACHE . 'persistent' . DS . '*')); // remove cached persistent foreach ($files as $f) { if (is_file($f)) { unlink($f); } } if (function_exists('apc_clear_cache')) { apc_clear_cache(); apc_clear_cache('user'); } $this->set(compact('files')); $this->layout = 'ajax'; }
function clear_cache() { Cache::clear(false, 'file'); Cache::clear(false, 'long_term'); $this->Session->setFlash(__('The cache has been cleared.', true), 'default', array('class' => 'success')); $this->redirect('/'); }
public function load() { // Load config // Try from cache $cachekey = "config"; if ($this->user) { $cachekey .= ":" . $this->user; } $this->config = Cache::load("config"); if (!is_array($this->config) || $this->get('cache.active') != 1) { // Load config from database $sql = new SqlManager(); if (!is_null($this->user)) { $sql->setQuery("SELECT * FROM config WHERE user_id = {{user}}"); $sql->bindParam("{{user}}", $this->user); } else { $sql->setQuery("SELECT * FROM config WHERE user_id IS NULL"); } $sql->execute(); $this->config = array(); while ($row = $sql->fetch()) { $this->config[$row['name']] = $row['value']; } if (!isset($this->config['cache.active']) || $this->config['cache.active'] != 1) { // If cache is deactivated, clear possible cache file Cache::clear($cachekey); } else { // If cache is activeated, save config for later use Cache::save($cachekey, $this->config); } } }
/** * Called by Cake after every model is saved. * This method clears the cache if we're saving to one of the specified models to check. * */ function afterSave() { $check_models = array('Content', 'Template', 'Stylesheet', 'MicroTemplate', 'GlobalContentBlock'); if (in_array($this->name, $check_models)) { Cache::clear(); } }
/** * * @param string $file * @param string $event * @return mixed */ public static function removeHandler($file, $event) { $file = DataBase::Current()->EscapeString($file); $event = DataBase::Current()->EscapeString($event); Cache::clear("eventmanager", "handler"); return DataBase::Current()->Execute("DELETE FROM {'dbprefix'}events WHERE event = '" . $event . "' AND file = '" . $file . "'"); }
public static function save($code, $value, $lang = null) { // Save specific locale value by given key if (!$lang) { $lang = self::getLanguage(); } // Check if locale already exists $sql = new SqlManager(); $sql->setQuery("\n\t\t\tSELECT code FROM locale \n\t\t\tWHERE code = '{{code}}' \n\t\t\tAND language = {{lang}}\n\t\t\tLIMIT 1"); $sql->bindParam('{{code}}', $code); $sql->bindParam('{{lang}}', $lang, "int"); $check = $sql->result(); $loc = array('code' => $sql->escape($code), 'language' => $sql->escape($lang, "int"), 'text' => $sql->escape($value), 'lastchanged' => DateManager::now()); // Either update database or insert new entry for given locale if (!$check['code']) { $loc['created'] = DateManager::now(); $sql->insert("locale", $loc); } else { $sql->update("locale", $loc); } // Refresh cache to make sure new locale entry will be used $cachekey = "locale:" . $lang; Cache::clear($cachekey); self::load($lang); }
/** * beforeFilter * * @access public * @return void */ function beforeFilter() { Cache::clear(false, 'configuration'); $this->set('title_for_layout', __('Upgrade', true)); if (!class_exists('DATABASE_CONFIG')) { // not a valid installation $this->Session->setFlash(__('It seems you do not have a installation of iPeer. Please install it first!', true)); $this->redirect('/install'); return; } elseif (IS_INSTALLED) { // 2.x upgrade $sysp = ClassRegistry::init('SysParameter'); if (null == $sysp->get('system.version', null)) { return; } } // 3.x and above upgrade, enable permission // Workaround to avoid loading the User model with an iPeer2 database. // If we tried loading iPeer3's User model with an iPeer2 database, // we'll get missing table errors. App::import('Model', 'User'); $permission = array_filter(array('controllers', ucwords($this->params['plugin']), ucwords($this->params['controller']), $this->params['action'])); if (!User::hasPermission(join('/', $permission))) { $this->Session->setFlash('Error: You do not have permission to access the page.'); $this->redirect('/home'); } }
public function display() { $template = new Template(); $template->load("plugin_changepassword_changepassword"); $template->show_if('PASSWORD_WRONG', false); $template->show_if('SUCCESSFUL', false); $template->show_if('OLD_PASSWORD_WRONG', false); if (isset($_REQUEST['old_password']) && !empty($_REQUEST['old_password']) && is_string($_REQUEST['old_password']) && isset($_REQUEST['new_password']) && !empty($_REQUEST['new_password']) && is_string($_REQUEST['new_password']) && isset($_REQUEST['confirm_password']) && !empty($_REQUEST['confirm_password']) && is_string($_REQUEST['confirm_password'])) { $old_password = DataBase::Current()->EscapeString($_REQUEST['old_password']); $new_password = DataBase::Current()->EscapeString($_REQUEST['new_password']); $confirm_password = DataBase::Current()->EscapeString($_REQUEST['confirm_password']); if ($new_password != $confirm_password) { $template->show_if('PASSWORD_WRONG', true); } else { $password = DataBase::Current()->EscapeString(md5($new_password . Settings::getInstance()->get("salt"))); $old_password = DataBase::Current()->EscapeString(md5($old_password . Settings::getInstance()->get("salt"))); $db_password = DataBase::Current()->ReadField("SELECT `password` FROM `{'dbprefix'}user` WHERE `id` = '" . User::Current()->id . "'; "); if ($db_password && $db_password != null) { if ($db_password != $old_password) { $template->show_if('OLD_PASSWORD_WRONG', true); } else { DataBase::Current()->Execute("UPDATE `{'dbprefix'}user` SET `password` = '" . $password . "' WHERE `id` = '" . User::Current()->id . "'; "); $template->show_if('SUCCESSFUL', true); EventManager::raiseEvent("plugin_changepassword_change", array('old_password' => $old_password, 'new_password' => $password, 'userid' => User::Current()->id)); Cache::clear("tables", "userlist"); } } else { //Der User ist nicht in der Datenbank aufgeführt. } } } $template->assign_var('ACTION', UrlRewriting::GetUrlByAlias($this->page->alias)); echo $template->getCode(); }
public function afterSave($model, $created) { $allowed = true; if (empty($model->data)) { $model->data = $model->read(); } if (!empty($this->settings[$model->alias]['scope'])) { foreach ($this->settings[$model->alias]['scope'] as $field => $value) { if ($model->data[$model->alias][$field] != $value) { $allowed = false; } } } if (empty($model->data[$model->alias]['title'])) { $allowed = false; } if ($allowed) { $tweet = $model->data[$model->alias]['title']; if (!empty($this->settings[$model->alias]['append'])) { $tweet .= ' '; $tweet .= $this->settings[$model->alias]['append']; } $TwitterStatuses = ClassRegistry::init('Twitter.TwitterStatuses'); if ($TwitterStatuses->update($tweet)) { Cache::clear(); } } return true; }
public function __construct() { adminGateKeeper(); Admintab::deleteAll(); Cache::clear(); Cache::clear(); $plugins = Plugin::getAll(); if ($plugins) { foreach ($plugins as $plugin) { $plugin->enable(); } Cache::clear(); Cache::clear(); Cache::clear(); new SystemMessage("All possible plugins have been enabled."); } Systemvariable::set("setup_complete", false); $translations = getEntities(array("type" => "Translationentity")); if ($translations) { foreach ($translations as $translation) { $translation->delete(); } } forward("admin/plugins"); }
function admin_empty() { $this->Configurator->deleteAll(array('1' => '1')); Cache::clear(); $this->Session->setFlash(__('La configurazione è stata completamente rimossa', true)); $this->redirect(array('controller' => 'configurator', 'action' => 'index')); }
/** * testTranslationCaching method * * @return void */ public function testTranslationCaching() { Configure::write('Config.language', 'cache_test_po'); // reset internally stored entries I18n::clear(); Cache::clear(false, '_cake_core_'); $lang = Configure::read('Config.language'); Cache::config('_cake_core_', Cache::config('default')); // make some calls to translate using different domains $this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1')); $this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1')); $domains = I18n::domains(); $this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']); // reset internally stored entries I18n::clear(); // now only dom1 should be in cache $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_'); $this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']); $this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']); // dom2 not in cache $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_')); // translate a item of dom2 (adds dom2 to cache) $this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2')); // verify dom2 was cached through manual read from cache $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_'); $this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']); $this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']); // modify cache entry manually to verify that dom1 entries now will be read from cache $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO'; Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_'); $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1')); }
function testCacheMiss() { $cache = new Cache(); $cache->clear(); $id = 'myid'; // // Test Meta cache // // MISS $this->assertTrue($cache->getMetaInfo($id) == false); $meta = array('mymeta' => 'mydata'); // POPULATE $this->assertTrue($cache->cacheMetaInfo($id, $meta)); // HIT $this->assertTrue($cache->getMetaInfo($id) == $meta); // HIT - different object $cache = new Cache(); $this->assertTrue($cache->getMetaInfo($id) == $meta); // TWEAK - timeout $staledate = time() - CACHE_TIMEOUT - 1; mysql_query("UPDATE icerss_meta SET `lastscanned`='$staledate' WHERE `id`='$id'"); // MISS $this->assertTrue($cache->getMetaInfo($id) == false); // Even though we miss, the db is not up-to-date (we live with this!!) $this->assertTrue($cache->cacheMetaInfo($id, $meta) == false); // MISS - new object = cleanup $cache = new Cache(); $this->assertTrue($cache->getMetaInfo($id) == false); // // Test Movies Cache // $url = 'myurl'; $offset = 10; $count = 10; $start = 10; $end = 20; $this->assertTrue($cache->getMovies($url, $offset, $count) == false); $movies = array('movies' => array('mymoooovie'), 'count' => 1); $this->assertTrue($cache->cacheMovies($url, $start, $end, $movies)); $movies2 = $cache->getMovies($url, $start, $count); #print json_encode($movies) . "|" . json_encode($movies2) . "\n"; $this->assertTrue($movies2 == $movies); // TWEAK - timeout $staledate = time() - CACHE_TIMEOUT - 1; mysql_query("UPDATE icerss_cache SET `lastscanned`='$staledate' WHERE `url`='$url'"); $this->assertTrue($cache->getMovies($url, $start, $count) == false); $this->assertTrue($cache->cacheMovies($url, $start, $end, $movies) == true); }
/** * @GET * @POST */ public function clear() { if (false === Runtime::isManagementAccess()) { throw new Http_Exception('cache/resource', null, Http_Exception::FORBIDDEN); } Cache::clear(); clearstatcache(true); }
public function action() { set_time_limit(0); Cache::clear(); ModuleManager::create_common_cache(); Base_ThemeCommon::themeup(); return true; }
public function __construct() { adminGateKeeper(); Cache::clear(); Cache::clear(); Cache::clear(); new SystemMessage(translate("system:cache:cleaned:success:system:message")); forward(); }
/** * Clears any form validation data stored with the Cache module. This method is called during the * caffeine.start event to clear any un-used form data. */ public function clear() { if (isset($_SESSION['forms'])) { foreach ($_SESSION['forms'] as $formId) { Cache::clear($formId); } } unset($_SESSION['forms']); }
function startTest() { $this->Seo = new SeoHelper(); $this->Seo->Html = new HtmlHelper(); $cacheEngine = SeoUtil::getConfig('cacheEngine'); if (!empty($cacheEngine)) { Cache::clear($cacheEngine); } }
/** * 测试操作缓存 */ 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(); }
/** * setup */ public function setUp() { parent::setUp(); $Controller = new Controller(); $this->View = new View($Controller); $this->Seo = new SeoHelper($this->View); $this->Seo->Html = new HtmlHelper($this->View); $cacheEngine = SeoUtil::getConfig('cacheEngine'); if (!empty($cacheEngine)) { Cache::clear($cacheEngine); } }
/** * Clear cache. * * @param boolean $check If true will check expiration, otherwise delete all * @param string $config Name of the configuration to use. Defaults to 'default' * @return boolean True if the cache was successfully cleared, false otherwise */ public static function clear($check = true, $config = 'default') { $EventManager = new CommonEventManager(); $EventManager->loadListeners($EventManager, 'Cache'); $Event = new CakeEvent('Cache.clear', null, compact('check', 'config')); list($Event->break, $Event->breakOn) = array(true, false); $EventManager->trigger($Event); if (false === $Event->result) { return false; } return Cache::clear($check, $config); }
public function getEditableCode() { Cache::clear(); $change = htmlentities(Language::GetGlobal()->getString("CHANGE")); $plugin_contactform_res = "<h3>" . Language::DirectTranslate("plugin_contactform_pagetypetitle") . "</h3>"; $settings = Settings::getRootInstance()->specify("plugin", "contactform"); if ($settings->get("contactform_mail") == "") { $plugin_contactform_res .= "<p><a href=\"" . Settings::getInstance()->get("host") . "admin/pluginsettings.html?plugin=contactform\">" . Language::DirectTranslate("plugin_contactform_nomailfound") . "</a></p>"; } $plugin_contactform_res .= "<input name=\"save\" type=\"submit\" value=\"" . $change . "\" onclick=\"form.action='" . UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $this->page->alias) . "' ; target='_self' ; return true\" />"; return $plugin_contactform_res; }
/** * Clears content of cache engines * * @param mixed any amount of strings - keys of configure cache engines * @return array associative array with cleanup results * @access public */ function engines() { $result = array(); $keys = Cache::configured(); if ($engines = func_get_args()) { $keys = array_intersect($keys, $engines); } foreach ($keys as $key) { $result[$key] = Cache::clear(false, $key); } return $result; }