/** * remove deleted files in $path from the cache * * @param string $path */ public function cleanFolder($path) { $cachedContent = $this->cache->getFolderContents($path); foreach ($cachedContent as $entry) { if (!$this->storage->file_exists($entry['path'])) { $this->cache->remove($entry['path']); } } }
/** * Rename a file or folder in the cache and update the size, etag and mtime of the parent folders * * @param \OC\Files\Storage\Storage $sourceStorage * @param string $source * @param string $target */ public function renameFromStorage(\OC\Files\Storage\Storage $sourceStorage, $source, $target) { if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) { return; } $time = time(); $sourceCache = $sourceStorage->getCache($source); $sourceUpdater = $sourceStorage->getUpdater(); $sourcePropagator = $sourceStorage->getPropagator(); if ($sourceCache->inCache($source)) { if ($this->cache->inCache($target)) { $this->cache->remove($target); } if ($sourceStorage === $this->storage) { $this->cache->move($source, $target); } else { $this->cache->moveFromCache($sourceCache, $source, $target); } } if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) { // handle mime type change $mimeType = $this->storage->getMimeType($target); $fileId = $this->cache->getId($target); $this->cache->update($fileId, ['mimetype' => $mimeType]); } $sourceCache->correctFolderSize($source); $this->cache->correctFolderSize($target); $sourceUpdater->correctParentStorageMtime($source); $this->correctParentStorageMtime($target); $this->updateStorageMTimeOnly($target); $sourcePropagator->propagateChange($source, $time); $this->propagator->propagateChange($target, $time); }
/** * Release the lock. * * @param string $key Key that should fit the lock * @return boolean */ public function release($key) { if ($key != $this->getKey()) { return false; } if (!empty($this->info)) { $this->store->remove('lock:' . $this->name); } }
public static function onScriptShutdown() { Cache::remove('memory'); if (!is_null($err = error_get_last()) && !in_array($err['type'], array(E_NOTICE, E_WARNING))) { DB\dbQuery('UPDATE file_previews SET `status` = 3 WHERE status = 2'); DB\commitTransaction(); } }
public static function rebuildCacheFor($lang_id) { Cache::remove('language_' . $lang_id, true); Logger::warning('Cache for language ' . $lang_id . ' removed'); Database::query("OPTIMIZE TABLE PREFIX_translations"); $keys = Database::fetchAll("SELECT\n id,\n name,\n (\n SELECT value\n FROM PREFIX_translations\n WHERE language_id = :lang\n AND key_id = tk.id\n ) AS value\n FROM PREFIX_translations_keys AS tk\n WHERE DATE(date_used) > :date", array('lang' => $lang_id, 'date' => date('Y-m-d', strtotime('7 days ago')))); Logger::warning('Translations fetched'); foreach ($keys as $list) { if (!empty($list['value'])) { Cache::set('language_' . $lang_id, $list['name'], $list['value']); } } Logger::warning('Translations set'); }
public function saveTheme($theme_id, $data) { $dataCheck = Database::fetchAll("SELECT name, create_date FROM PREFIX_builder_themes WHERE theme_id = :id", array('id' => $theme_id)); if (!is_array($data) || !count($data)) { $theme_id = $this->addTheme($data['name']); } unset($data['name']); foreach ($data as $key => $value) { if (is_array($value)) { $value = json_encode($value); } Database::query("DELETE FROM PREFIX_builder_themes_settings WHERE setting_name = :key AND theme_id = :id", array('key' => $key, 'id' => $theme_id)); Database::insert("PREFIX_builder_themes_settings", array('setting_name' => $key, 'setting_value' => $value, 'theme_id' => $theme_id)); } Cache::remove('builder'); }
public function call() { $cacheEnabled = array_get($this->action, "cacheEnabled") && Config::item("application", "cache", true); if ($cacheEnabled && ($data = Cache::get(URI::current()))) { $headersEnd = strpos($data, "\n\n"); if ($headersEnd > 0) { $headers = explode("\n", substr($data, 0, $headersEnd)); foreach ($headers as $header) { header($header); } } $data = substr($data, $headersEnd + 2); return $data; } $response = $this->response(); if ($cacheEnabled) { $headersList = implode("\n", headers_list()); Cache::save(URI::current(), $headersList . "\n\n" . $response, array_get($this->action, "cacheExpirationTime")); } else { Cache::remove(URI::current()); } return $response; }
/** * removes an entry from the cache * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param string serial * @return mixed */ public function remove($serial) { $this->implementation->remove($serial); }
/** * Clean getAllUsersCount() cache */ function cleanAllUsersCount() { $Cache = new Cache(); $Cache->lifeTime = 3600; $Cache->prefix = 'statistic'; if ($Cache->check('cnt_registered_users')) { $Cache->remove('cnt_registered_users'); } }
/** * Check if host is blocked. * Returns 0 if unblockable. * * @param string $host * @param boolean $attempt Increment attempts (bool) or attempt (int) * @return boolean */ public function isBlocked($host = null, $attempt = false) { if (empty($this->loginAttempts)) { return 0; } if (!isset($host)) { $host = HTTP::getClientIP(HTTP::CONNECTED_CLIENT); } if (empty($host) || in_array($host, $this->unblockableHosts, true)) { return 0; } if (!isset($this->storeAttemps)) { if (!Cache::hasInstance()) { return 0; } $this->storeAttemps = Cache::i(); } elseif (!$this->storeAttemps instanceof Cache) { $this->storeAttemps = Cache::with($this->storeAttemps, array('overwrite' => true)); } if (is_bool($attempt)) { $attempt = (int) $this->storeAttemps->get("AUTH-login_attempts:{$host}") + 1; } if ($attempt) { $this->storeAttemps->save("AUTH-login_attempts:{$host}", $attempt); } else { $this->storeAttemps->remove("AUTH-login_attempts:{$host}"); } return $this->loginAttempts - $attempt < 0; }
/** Configure framework according to .ini file settings and cache auto-generated PHP code to speed up execution @param $_file string @public **/ public static function config($_file) { // Generate hash code for config file $_hash = 'php.' . self::hashCode($_file); $_cached = Cache::cached($_hash); if ($_cached && filemtime($_file) < $_cached['time']) { // Retrieve from cache $_save = Cache::fetch($_hash); } else { if (!file_exists($_file)) { // .ini file not found self::$global['CONTEXT'] = $_file; trigger_error(self::TEXT_Config); return; } // Map sections to framework methods $_map = array('global' => 'set', 'routes' => 'route', 'maps' => 'map'); // Read the .ini file preg_match_all('/\\s*(?:\\[(.+?)\\]|(?:;.+?)?|(?:([^=]+)=(.+?)))(?:\\v|$)/s', file_get_contents($_file), $_matches, PREG_SET_ORDER); $_cfg = array(); $_ptr =& $_cfg; foreach ($_matches as $_match) { if ($_match[1]) { // Section header if (!isset($_map[$_match[1]])) { // Unknown section self::$global['CONTEXT'] = $_section; trigger_error(self::TEXT_Section); return; } $_ptr =& $_cfg[$_match[1]]; } elseif ($_match[2]) { $_csv = array_map(function ($_val) { // Typecast if necessary return is_numeric($_val) || preg_match('/^(TRUE|FALSE)\\b/i', $_val) ? eval('return ' . $_val . ';') : $_val; }, str_getcsv($_match[3])); // Convert comma-separated values to array $_match[3] = count($_csv) > 1 ? $_csv : $_csv[0]; if (preg_match('/(.+?)\\[(.*?)\\]/', $_match[2], $_sub)) { if ($_sub[2]) { // Associative array $_ptr[$_sub[1]][$_sub[2]] = $_match[3]; } else { // Numeric-indexed array $_ptr[$_sub[1]][] = $_match[3]; } } else { // Key-value pair $_ptr[$_match[2]] = $_match[3]; } } } ob_start(); foreach ($_cfg as $_section => $_pairs) { $_func = $_map[$_section]; foreach ($_pairs as $_key => $_val) { // Generate PHP snippet echo 'F3::' . $_func . '(' . var_export($_key, TRUE) . ',' . ($_func == 'set' || !is_array($_val) ? var_export($_val, TRUE) : self::listArgs($_val)) . ');' . "\n"; } } $_save = ob_get_contents(); ob_end_clean(); // Compress and save to cache Cache::store($_hash, $_save); } // Execute cached PHP code eval($_save); if (self::$global['ERROR']) { // Remove from cache Cache::remove($_hash); } }
/** *缓存检查 */ public function check_cache() { //缓存路径 $this->cache_path = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '/' . $_SERVER['REAL_REQUEST_URI']; if (isset($_SERVER['YYUC_RENEW'])) { Cache::remove($this->cache_path . '_key'); Redirect::to($_SERVER['YYUC_RENEW']); return false; } $res = Cache::get($this->cache_path . '_key'); if (Conf::$is_developing || empty($res)) { return false; } else { $lines = explode('@YYUC@', $res); $access_m = true; if (count($lines) > 1) { //数据库缓存 $dbs = explode(',', $lines[1]); foreach ($dbs as $db) { if (Cache::has('YYUC_TABLE_TIME' . Conf::$db_tablePrefix . $db) && intval(Cache::get('YYUC_TABLE_TIME' . Conf::$db_tablePrefix . $db)) >= intval($lines[0])) { //如果某一库表的更新时间大于等于缓存时间 return false; } } if (isset($lines[2]) && !empty($lines[2])) { $access_m = $lines[2]; } } else { //'@'则没有前置校验 $access_m = $res == '@' ? true : $res; } $this->html = Cache::get($this->cache_path); return $access_m; } }
public static function array_delete($name, $module_name = 'config') { Cache::remove($name, $module_name); }
public function ajax() { $this->load->model('design/sumobuilder'); if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action'])) { $theme_id = isset($this->request->post['theme_id']) ? $this->request->post['theme_id'] : 1; $response = array(); switch ($this->request->post['action']) { case 'pages': $this->data['settings'] = $this->model_design_sumobuilder->getTheme($theme_id); if (isset($this->session->data['builder_' . $theme_id])) { foreach ($this->session->data['builder_' . $theme_id] as $key => $value) { $this->data['settings'][$key] = $value; } } $this->load->model('localisation/language'); $this->data['languages'] = $this->model_localisation_language->getLanguages(); $this->load->model('catalog/information'); $pages = $this->model_catalog_information->getInformations(); $this->load->model('setting/store'); $stores = $this->model_settings_stores->getStores(); $this->data['stores'][0] = $this->config->get('name'); foreach ($stores as $list) { $this->data['stores'][$list['store_id']] = $list['name']; } foreach ($pages as $list) { $list['title'] = $this->data['stores'][$list['store_id']] . ': ' . $list['title']; $this->data['pages'][] = $list; } $this->data['icons'] = $this->model_design_sumobuilder->getIcons(true); $this->template = 'design/sumobuilder/pages.tpl'; return $this->response->setOutput($this->render()); break; case 'backgrounds': // RC3/V1 break; case 'colors': $this->data['settings'] = $this->model_design_sumobuilder->getTheme($theme_id); if (isset($this->session->data['builder_' . $theme_id])) { foreach ($this->session->data['builder_' . $theme_id] as $key => $value) { $this->data['settings'][$key] = $value; } } $this->template = 'design/sumobuilder/colors.tpl'; return $this->response->setOutput($this->render()); break; case 'fonts': $this->data['settings'] = $this->model_design_sumobuilder->getTheme($theme_id); if (isset($this->session->data['builder_' . $theme_id])) { foreach ($this->session->data['builder_' . $theme_id] as $key => $value) { $this->data['settings'][$key] = $value; } } $this->data['fonts'] = $this->model_design_sumobuilder->getFonts(); $this->template = 'design/sumobuilder/fonts.tpl'; return $this->response->setOutput($this->render()); break; case 'custom': $this->data['settings'] = $this->model_design_sumobuilder->getTheme($theme_id); if (isset($this->session->data['builder_' . $theme_id])) { foreach ($this->session->data['builder_' . $theme_id] as $key => $value) { $this->data['settings'][$key] = $value; } } $this->template = 'design/sumobuilder/custom.tpl'; return $this->response->setOutput($this->render()); break; case 'save': $this->data['token'] = $this->session->data['token']; $this->template = 'design/sumobuilder/save.tpl'; return $this->response->setOutput($this->render()); break; case 'save_as': $new_theme_id = $this->model_design_sumobuilder->addTheme($this->request->post['name']); if (!$new_theme_id) { $response['result'] = Language::getVar('SUMO_ADMIN_DESIGN_SUMOBUILDER_SAVE_ERROR_NAME_IN_USE'); } else { $this->session->data['builder_' . $theme_id]['lastmodified'] = time(); $this->session->data['builder_' . $theme_id]['theme_id'] = $new_theme_id; $this->model_design_sumobuilder->saveTheme($new_theme_id, $this->session->data['builder_' . $theme_id]); $this->session->data['builder_' . $theme_id] = $this->model_design_sumobuilder->getTheme($theme_id); $this->session->data['builder_' . $new_theme_id] = $this->model_design_sumobuilder->getTheme($new_theme_id); $this->createStylesheet($this->session->data['builder_' . $new_theme_id], $new_theme_id); $response['result'] = 'OK'; Cache::remove('builder', true); } break; case 'absolutesave': $this->session->data['builder_' . $theme_id]['lastmodified'] = time(); $this->session->data['builder_' . $theme_id]['theme_id'] = $theme_id; $this->model_design_sumobuilder->saveTheme($theme_id, $this->session->data['builder_' . $theme_id]); $this->session->data['builder_' . $theme_id] = $this->model_design_sumobuilder->getTheme($theme_id); $this->createStylesheet($this->session->data['builder_' . $theme_id], $theme_id); $response['saved'] = 'true'; Cache::remove('builder', true); break; case 'midsave': if (isset($this->request->post['data'])) { $tmp = array(); parse_str(str_replace('amp;', '', $this->request->post['data']), $tmp); $response['data'] = $tmp; if (!isset($this->session->data['builder_' . $theme_id])) { $this->session->data['builder_' . $theme_id] = array(); } $tmp = $this->cleanOut($tmp); foreach ($tmp as $key => $values) { $this->session->data['builder_' . $theme_id][$key] = $values; } $response['saved'] = true; } break; case 'delete': if ($theme_id <= 1) { $response['removed'] = false; $response['result'] = Language::getVaR('SUMO_ADMIN_DESIGN_BUILDER_REMOVE_DEFAULT'); } else { $result = $this->model_design_sumobuilder->removeTheme($theme_id); if (!$result) { $response['removed'] = false; $response['result'] = Language::getVar('SUMO_ADMIN_DESIGN_BUILDER_REMOVE_FAILED'); } else { $response['removed'] = true; $response['result'] = Language::getVar('SUMO_ADMIN_DESIGN_BUILDER_REMOVE_SUCCESSFULL'); } } break; } $this->response->setOutput(json_encode($response)); } }
public function deleteGeoZone($geo_zone_id) { $this->db->query("DELETE FROM " . DB_PREFIX . "geo_zone WHERE geo_zone_id = '" . (int) $geo_zone_id . "'"); $this->db->query("DELETE FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int) $geo_zone_id . "'"); Cache::remove('geo_zone'); }
protected function removeData($name) { return Cache::remove($this->getKey($name)); }
function onScriptShutdown() { Cache::remove('memory'); if (!is_null($err = error_get_last()) && !in_array($err['type'], array(E_NOTICE, E_WARNING))) { //mark last processed file to be skipped parsing $id = Cache::get('lastRecId', false); if (!empty($id)) { DB\dbQuery('UPDATE files_content SET skip_parsing = 1 WHERE id = $1', $id) or die(DB\dbQueryError()); } } }
function YYUC_session_destroy($k) { return Cache::remove('YYUC_SESSION/' . $k); }
public function unloadChunk($X, $Z) { if (!isset($this->level)) { return false; } Cache::remove("world:{$this->name}:{$X}:{$Z}"); return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled); }
public function saveMenuOrder($data) { #exit(print_r($data,true)); #Database::query("UPDATE PREFIX_admin_menu SET sort_order = 0, parent_id = 0"); $so = $co = 0; foreach ($data as $list) { $so++; Database::query("UPDATE PREFIX_admin_menu SET sort_order = :order, parent_id = 0 WHERE menu_id = :id", array('order' => $so, 'id' => $list['id'])); if (isset($list['children']) && count($list['children'])) { #$co = 0; foreach ($list['children'] as $child) { #$co++; $so++; Database::query("UPDATE PREFIX_admin_menu SET sort_order = :order, parent_id = :parent WHERE menu_id = :id", array('order' => $so, 'parent' => $list['id'], 'id' => $child['id'])); } } } Cache::remove('admin_menu', true); return true; }