/** * Deletes all items in the pool. * * @return boolean * True if the pool was successfully cleared. False if there was an error. */ public function clear() { if (function_exists('apcu_clear_cache')) { return apcu_clear_cache(); } return apc_clear_cache("user"); }
public function clear() { if ($this->apcu) { return apcu_clear_cache(); } return apc_clear_cache(); }
public static function clearApc() { if (function_exists('apcu_clear_cache')) { apcu_clear_cache(); } return true; }
public function reset() { try { apcu_clear_cache(); } catch (\Exception $e) { \Dsc\System::addMessage($e->getMessage(), 'error'); } $this->app->reroute('/admin/cache/apcu'); }
/** * @requires extension apcu */ protected function setUp() { if (!extension_loaded('apcu')) { $this->markTestSkipped('apcu extension not installed'); } if ((bool) ini_get('apc.enable_cli') === false) { $this->markTestSkipped('apcu extension not enabled for CLI'); } apcu_clear_cache(); parent::setUp(); }
public function clear($id = null) { if ($id === null) { if (apcu_clear_cache()) { return true; } } else { if (apcu_delete($id)) { return true; } } return false; }
/** * {@inheritdoc} */ protected function doFlush() { return apcu_clear_cache() && apcu_clear_cache('user'); }
/** * {@inheritdoc} */ public function clear() { return apcu_clear_cache(); }
/** * Factory method for Doctrine EntityManager * * @todo add other caching drivers (memcache, xcache) * @todo put into static class? singleton? function or state class? */ public static function createEntityManager($admin = FALSE) { $config = new ORM\Configuration(); if (Util\Configuration::read('devmode') == FALSE) { $cache = null; if (extension_loaded('apcu')) { $cache = new Cache\ApcuCache(); } if ($cache) { $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); } } else { if (extension_loaded('apcu')) { // clear cache apcu_clear_cache('user'); } } $driverImpl = $config->newDefaultAnnotationDriver(VZ_DIR . '/lib/Model'); $config->setMetadataDriverImpl($driverImpl); $config->setProxyDir(VZ_DIR . '/lib/Model/Proxy'); $config->setProxyNamespace('Volkszaehler\\Model\\Proxy'); $config->setAutoGenerateProxyClasses(Util\Configuration::read('devmode')); $dbConfig = Util\Configuration::read('db'); if ($admin && isset($dbConfig['admin'])) { $dbConfig = array_merge($dbConfig, $dbConfig['admin']); } return ORM\EntityManager::create($dbConfig, $config); }
/** * Clears all cached data. * * @return bool */ function clear_cache() { \clearstatcache(); if (\extension_loaded('apcu')) { \apcu_clear_cache(); } $dirs = ['comments', 'csp_hash', 'csp_static', 'html_purifier', 'markdown', 'static']; foreach ($dirs as $dir) { if (!\is_dir($dir)) { \mkdir($dir, 0775, true); continue; } foreach (\Airship\list_all_files(ROOT . '/tmp/cache/' . $dir) as $f) { if (\is_dir($f)) { continue; } if (\preg_match('#/([0-9a-z]+)$#', $f)) { \unlink($f); } } } // Nuke the Twig cache separately: foreach (\Airship\list_all_files(ROOT . '/tmp/cache/twig') as $f) { if (\is_dir($f)) { continue; } if (\preg_match('#/([0-9a-z]+).php$#', $f)) { \unlink($f); } } foreach (\glob(ROOT . '/tmp/cache/*.json') as $file) { \unlink($file); } \clearstatcache(); return true; }
protected function tearDown() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { apcu_clear_cache(); } }
public function flush() { return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user'); }
echo <<<EOB \t\t\t\t<html><body> \t\t\t\t<h1>Rejected!</h1> \t\t\t\t<big>Wrong Username or Password!</big><br/> <br/> \t\t\t\t<big><a href='{$PHP_SELF}?OB={$MYREQUEST['OB']}'>Continue...</a></big> \t\t\t\t</body></html> EOB; exit; } else { $AUTHENTICATED = 1; } } } // clear cache if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) { apcu_clear_cache(); } if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) { apcu_delete($MYREQUEST['DU']); } if (!function_exists('apcu_cache_info')) { echo "No cache info available. APC does not appear to be running."; exit; } $cache = apcu_cache_info(); $mem = apcu_sma_info(); // don't cache this page // header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false);
/** * {@inheritdoc} */ protected function doClear() { return apcu_clear_cache(); }
/** * Remove all items from the cache. * * @return void */ public function flush() { $this->isApcUEnabled ? apcu_clear_cache() : apc_clear_cache('user'); }
/** * {@inheritdoc} */ protected function doClear($namespace) { return apcu_clear_cache(); }
function clear() { if (function_exists('\\apcu_clear_cache')) { \apcu_clear_cache(); } else { if (function_exists('\\apc_clear_cache')) { \apc_clear_cache('user'); } else { parent::clear(); } } }
/** * {@inheritdoc} */ public function flush() { if ($this->driver == self::APCU_DRIVER) { apcu_clear_cache(); return; } apc_clear_cache('user'); }
/** * {@inheritdoc} */ protected function doFlush() { return apcu_clear_cache(); }
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case Zend_Cache::CLEANING_MODE_ALL: $ret = true; if (php_sapi_name() == 'cli') { $ret = Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user')); } return $ret && apcu_clear_cache(); break; case Zend_Cache::CLEANING_MODE_OLD: $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); break; case Zend_Cache::CLEANING_MODE_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND); break; default: Zend_Cache::throwException('Invalid mode for clean() method'); break; } }
/** * Deletes all values from cache. * This is the implementation of the method declared in the parent class. * @return boolean whether the flush operation was successful. * @since 1.1.5 */ protected function flushValues() { return $this->useApcu ? apcu_clear_cache() : apc_clear_cache('user'); }
function apc_clear_cache($cache_type = "") { return apcu_clear_cache($cache_type); }
/** * Flush the whole storage * * @return bool */ public function flush() { return apcu_clear_cache(); }
public function invalidate() { if (function_exists('apcu_clear_cache')) { apcu_clear_cache(); } else { if (function_exists('apc_clear_cache')) { apc_clear_cache("user"); } } }
/** * @inheritdoc */ public function clear() { if ($this->is_enabled()) { // http://php.net/manual/en/function.apcu-clear-cache.php apcu_clear_cache(); } }
/** * {@inheritdoc} */ public function clear() { apcu_clear_cache(); }
public function install($ctn) { if (!$ctn['config']['installed']) { $msg = ""; // no sec here, just install if ($_REQUEST['action'] == 'save') { $file = $ctn['pathApp'] . "config.json"; $config = $ctn['config']; // update DB settings $config['database']['name'] = $_REQUEST['db_name']; $config['database']['user'] = $_REQUEST['db_user']; $config['database']['pass'] = $_REQUEST['db_pass']; $config['database']['host'] = $_REQUEST['db_host']; $config['database']['port'] = $_REQUEST['db_port']; unset($config['database']['nodatabase']); // set basic data $config['url'] = $_REQUEST['url']; $config['site'] = preg_replace("/[^0-9a-zA-Z_\\s]+/", "", $_REQUEST['url']); $config['salt'] = md5(time() . rand(10, 20)); // connect to database (with new parameters) try { $db = new pdo('mysql:host=' . $_REQUEST['db_host'] . ':' . $_REQUEST['db_port'] . ';dbname=' . $_REQUEST['db_name'], $_REQUEST['db_user'], $_REQUEST['db_pass']); // install mysql structure $structureFile = $ctn['pathApp'] . "database.sql"; if (!file_exists($structureFile)) { $msg = "Could not fine database file"; } else { $cmd = file_get_contents($structureFile); $sth = $db->prepare($cmd); $sth->execute(); // create user $sth = $db->prepare("INSERT INTO user (role_id,username,password) VALUES (3,:user,:pass); "); $sth->bindValue("user", $_REQUEST['user']); $sth->bindValue("pass", password_hash($_REQUEST['pass'] . $config['salt'], PASSWORD_BCRYPT, array('cost' => 12))); $sth->execute(); $config['installed'] = true; $json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); file_put_contents($file, $json); apcu_clear_cache(); header("Location: /"); } } catch (\PDOException $e) { $msg = $e->getMessage(); } } ?> <form action="/"> <input type="hidden" name="action" value="save" /> <h1>Install</h1> <h2>Website Settings</h2> <table> <tr> <td>URL:</td> <td><input type="text" name="url" value="<?php echo $_REQUEST['url']; ?> " /></td> </tr> <tr> <td>Username:</td> <td><input type="text" name="user" value="<?php echo $_REQUEST['user']; ?> " /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pass" value="<?php echo $_REQUEST['pass']; ?> " /></td> </tr> </table> <h2>Database Settings</h2> <p style='color: red;'><?php echo $msg; ?> </p> <table> <tr> <td>DB-Name:</td> <td><input type="text" name="db_name" value="<?php echo $_REQUEST['db_name']; ?> " /></td> </tr> <tr> <td>Username:</td> <td><input type="text" name="db_user" value="<?php echo $_REQUEST['db_user']; ?> " /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="db_pass" value="<?php echo $_REQUEST['db_pass']; ?> " /></td> </tr> <tr> <td>Host:</td> <td><input type="text" name="db_host" value="<?php echo $_REQUEST['db_host']; ?> " /></td> </tr> <tr> <td>Port:</td> <td><input type="text" name="db_port" value="<?php echo $_REQUEST['db_port']; ?> " /></td> </tr> </table> <p> <input type="submit" value="Install"> </p> </form> <?php die; } }
/** * Deletes all items in the pool. * * @return bool * True if the pool was successfully cleared. False if there was an error. */ public function clear() { $this->deferredStack = []; if ($this->legacy) { return apc_clear_cache(); } else { return apcu_clear_cache(); } }
protected function clearAllObjectsFromCache() { return apcu_clear_cache(); }
/** * Attempt to save the user-provided cabin configuration * * @param string $cabinName * @param array $cabins * @param array $post * @return bool */ protected function saveSettings(string $cabinName, array $cabins = [], array $post = []) : bool { $ds = DIRECTORY_SEPARATOR; $twigEnv = \Airship\configWriter(ROOT . $ds . 'config' . $ds . 'templates'); // Content-Security-Policy $csp = []; foreach ($post['content_security_policy'] as $dir => $rules) { if ($dir === 'upgrade-insecure-requests' || $dir === 'inherit') { continue; } if (empty($rules['allow'])) { $csp[$dir]['allow'] = []; } else { $csp[$dir]['allow'] = []; foreach ($rules['allow'] as $url) { if (!empty($url) && \is_string($url)) { $csp[$dir]['allow'][] = $url; } } } if (isset($rules['disable-security'])) { $csp[$dir]['allow'][] = '*'; } if ($dir === 'script-src') { $csp[$dir]['unsafe-inline'] = !empty($rules['unsafe-inline']); $csp[$dir]['unsafe-eval'] = !empty($rules['unsafe-eval']); $csp[$dir]['self'] = !empty($rules['self']); } elseif ($dir === 'style-src') { $csp[$dir]['unsafe-inline'] = !empty($rules['unsafe-inline']); $csp[$dir]['self'] = !empty($rules['self']); } elseif ($dir !== 'plugin-types') { $csp[$dir]['self'] = !empty($rules['self']); $csp[$dir]['data'] = !empty($rules['data']); } } $csp['inherit'] = !empty($post['content_security_policy']['inherit']); $csp['upgrade-insecure-requests'] = !empty($post['content_security_policy']['upgrade-insecure-requests']); $saveCabins = []; foreach ($cabins as $cab => $cab_data) { if ($cab_data['name'] !== $cabinName) { // Pass-through $saveCabins[$cab] = $cab_data; } else { $saveCabins[$post['config']['path']] = $post['config']; if (isset($cab_data['namespace'])) { // This should be immutable. $saveCabins[$post['config']['path']]['namespace'] = $cab_data['namespace']; } unset($saveCabins['path']); } } // Save CSP \file_put_contents(ROOT . $ds . 'config' . $ds . 'Cabin' . $ds . $cabinName . $ds . 'content_security_policy.json', \json_encode($csp, JSON_PRETTY_PRINT)); // Configuration if (!empty($post['cabin_manage_fallback'])) { $config_extra = \json_decode($post['config_extra'], true); $twig_vars = \json_decode($post['twig_vars'], true); } else { $config_extra = $post['config_extra']; $twig_vars = $post['twig_vars']; } if (!empty($config_extra)) { \Airship\saveJSON(ROOT . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'Cabin' . DIRECTORY_SEPARATOR . $cabinName . DIRECTORY_SEPARATOR . 'config.json', $config_extra); } if (!empty($twig_vars)) { \Airship\saveJSON(ROOT . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'Cabin' . DIRECTORY_SEPARATOR . $cabinName . DIRECTORY_SEPARATOR . 'twig_vars.json', $twig_vars); } // Clear the cache \unlink(ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'csp.' . $cabinName . '.json'); if (\extension_loaded('apcu')) { \apcu_clear_cache(); } // Save cabins.json \file_put_contents(ROOT . $ds . 'config' . $ds . 'cabins.json', $twigEnv->render('cabins.twig', ['cabins' => $saveCabins])); // Delete the cabin cache if (\file_exists(ROOT . 'tmp' . $ds . 'cache' . $ds . 'cabin_data.json')) { \unlink(ROOT . 'tmp' . $ds . 'cache' . $ds . 'cabin_data.json'); } return true; }