Пример #1
0
 /**
  * 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");
 }
Пример #2
0
 public function clear()
 {
     if ($this->apcu) {
         return apcu_clear_cache();
     }
     return apc_clear_cache();
 }
Пример #3
0
 public static function clearApc()
 {
     if (function_exists('apcu_clear_cache')) {
         apcu_clear_cache();
     }
     return true;
 }
Пример #4
0
 public function reset()
 {
     try {
         apcu_clear_cache();
     } catch (\Exception $e) {
         \Dsc\System::addMessage($e->getMessage(), 'error');
     }
     $this->app->reroute('/admin/cache/apcu');
 }
Пример #5
0
 /**
  * @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();
 }
Пример #6
0
 public function clear($id = null)
 {
     if ($id === null) {
         if (apcu_clear_cache()) {
             return true;
         }
     } else {
         if (apcu_delete($id)) {
             return true;
         }
     }
     return false;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 protected function doFlush()
 {
     return apcu_clear_cache() && apcu_clear_cache('user');
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     return apcu_clear_cache();
 }
Пример #9
0
 /**
  * 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);
 }
Пример #10
0
/**
 * 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;
}
Пример #11
0
 protected function tearDown()
 {
     if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
         apcu_clear_cache();
     }
 }
Пример #12
0
 public function flush()
 {
     return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user');
 }
Пример #13
0
            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/>&nbsp;<br/>&nbsp;
\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);
Пример #14
0
 /**
  * {@inheritdoc}
  */
 protected function doClear()
 {
     return apcu_clear_cache();
 }
Пример #15
0
 /**
  * Remove all items from the cache.
  *
  * @return void
  */
 public function flush()
 {
     $this->isApcUEnabled ? apcu_clear_cache() : apc_clear_cache('user');
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 protected function doClear($namespace)
 {
     return apcu_clear_cache();
 }
Пример #17
0
 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();
         }
     }
 }
Пример #18
0
 /**
  * {@inheritdoc}
  */
 public function flush()
 {
     if ($this->driver == self::APCU_DRIVER) {
         apcu_clear_cache();
         return;
     }
     apc_clear_cache('user');
 }
Пример #19
0
 /**
  * {@inheritdoc}
  */
 protected function doFlush()
 {
     return apcu_clear_cache();
 }
Пример #20
0
 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;
     }
 }
Пример #21
0
 /**
  * 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');
 }
Пример #22
0
 function apc_clear_cache($cache_type = "")
 {
     return apcu_clear_cache($cache_type);
 }
Пример #23
0
 /**
  * Flush the whole storage
  *
  * @return bool
  */
 public function flush()
 {
     return apcu_clear_cache();
 }
Пример #24
0
 public function invalidate()
 {
     if (function_exists('apcu_clear_cache')) {
         apcu_clear_cache();
     } else {
         if (function_exists('apc_clear_cache')) {
             apc_clear_cache("user");
         }
     }
 }
Пример #25
0
 /**
  * @inheritdoc
  */
 public function clear()
 {
     if ($this->is_enabled()) {
         // http://php.net/manual/en/function.apcu-clear-cache.php
         apcu_clear_cache();
     }
 }
Пример #26
0
 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     apcu_clear_cache();
 }
Пример #27
0
    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;
        }
    }
Пример #28
0
 /**
  * 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();
     }
 }
Пример #29
0
 protected function clearAllObjectsFromCache()
 {
     return apcu_clear_cache();
 }
Пример #30
0
 /**
  * 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;
 }