本文整理汇总了PHP中cache::save方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::save方法的具体用法?PHP cache::save怎么用?PHP cache::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache
的用法示例。
在下文中一共展示了cache::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: archive_cache
public function archive_cache($cache_id, $comment, $months = 0)
{
global $opt, $login, $translate;
$log = cachelog::createNew($cache_id, $login->userid);
if ($log === false) {
echo $this->name . ": cannot create log for cache {$cache_id}\n";
} else {
$cache = new cache($cache_id);
if (!$cache->setStatus(3) || !$cache->save()) {
echo $this->name . ": cannot change status of cache {$cache_id}\n";
} else {
// create log
$log->setType(cachelog::LOGTYPE_ARCHIVED, true);
$log->setOcTeamComment(true);
$log->setDate(date('Y-m-d'));
// Log without time, so that owner reactions will always appear AFTER
// the system log, no matter if logged with or without date.
// create log text in appropriate language
$translated_comment = $translate->t($comment, '', '', 0, '', 1, $cache->getDefaultDescLanguage());
$translated_comment = str_replace('%1', $months, $translated_comment);
$log->setText('<p>' . $translated_comment . '</p>');
$log->setTextHtml(1);
if (!$log->save()) {
echo $this->name . ": could not save archive log for cache {$cache_id}\n";
}
}
}
}
示例2: cron
public static function cron()
{
$now = date('Y-m-d H:i:s', strtotime('-1 second', strtotime(date('Y-m-d H:i:s'))));
$lastDatetime = cache::byKey('sarah::lastRetrievalInternalEvent', $now);
foreach (internalEvent::getNewInternalEvent('sarah') as $internalEvent) {
if (in_array($internalEvent->getEvent(), array('update::interactQuery'))) {
foreach (sarah::byType('sarah') as $sarah) {
if ($sarah->ping()) {
log::add('sarah', 'info', 'Mise à jour de la grammaire de Sarah');
$sarah->updateSrvSarah();
} else {
cache::save('sarah::lastRetrievalInternalEvent', $lastDatetime, 0);
}
}
}
}
}
示例3: parseInt
$(lid).innerHTML="<b>"+tag+"</b> ";
}
return false;
}
//]]>
</script>
<br /><br />
<script type="text/javascript">
//<![CDATA[
var posts = {}; posts[' . $id . '] = {}; posts[' . $id . '].comments = {}; posts[' . $id . '].ignored = {}; var cthreshold = parseInt(readCookie(\'comment_threshold\')) || 0; var users = readCookie(\'user_blacklist\').split(/[, ]|%20+/g);
//]]>
</script>';
$data = '';
$data = ob_get_contents();
ob_end_clean();
$cache->save("cache/" . $id . "/post.cache", $data);
echo str_replace("f6ca1c7d5d00a2a3fb4ea2f7edfa0f96a6d09c11717f39facabad2d724f16fbb", $domain, $data);
flush();
}
$user = new user();
$got_permission = $user->gotpermission('delete_comments');
if (isset($_GET['pid']) && is_numeric($_GET['pid']) && $_GET['pid'] > "0") {
$pid = ceil($_GET['pid']);
$page = $pid;
} else {
$page = 0;
$pid = 0;
}
$data = '';
if (file_exists("cache/{$id}/comments.{$pid}.cache")) {
$data = $cache->load("cache/{$id}/comments.{$pid}.cache");
示例4: misc
$misc = new misc();
print $misc->pagination($_GET['page'], $_GET['s'], $id, $limit, $page_limit, $numrows, $_GET['pid'], $_GET['tags']);
}
//Cache doesn't exist for search, make one.
if ($no_cache === true) {
$data = ob_get_contents();
ob_end_clean();
if (isset($_GET['pid']) && is_numeric($_GET['pid']) && $_GET['pid'] > 0) {
$page = $_GET['pid'] / $limit + 1;
} else {
$page = 0;
}
if ($new_tag_cache != "") {
if (!is_dir("{$main_cache_dir}" . "" . "search_cache/" . $new_tag_cache)) {
@mkdir("{$main_cache_dir}" . "" . "search_cache/" . $new_tag_cache);
}
$cache->save("search_cache/" . $new_tag_cache . "/" . $page . ".html", $data);
}
echo $data;
}
}
?>
<div id="footer">
<a href="index.php?page=post&s=add">Add</a> | <a href="help/">Help</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
示例5: flush
}
exit;
}
$prev_next = $post->prev_next($id);
if (!is_dir("{$main_cache_dir}" . "" . "\\api_cache/{$id}")) {
$cache->create_page_cache("cache/{$id}");
}
$data = $cache->load("api_cache/" . $id . "/post." . $api_type . ".cache");
if ($data !== false) {
echo str_replace("f6ca1c7d5d00a2a3fb4ea2f7edfa0f96a6d09c11717f39facabad2d724f16fbb", $domain, $data);
flush();
} else {
ob_start();
if ($api_type == 'json') {
header('Content-type: application/json');
$posts = array(createPostObject($post_data));
$postsArr = array('offset' => 0, 'count' => 1, 'posts' => $posts);
echo json_encode($postsArr);
} else {
header('Content-type: text/xml');
$posts = '<?xml version="1.0" encoding="UTF-8"?><posts offset="0" count="1">' . "\r\n";
$posts .= createPostXML($post_data);
$posts .= '</posts>';
echo $posts;
}
$data = '';
$data = ob_get_contents();
ob_end_clean();
$cache->save("cache/" . $id . "/post." . $api_type . ".cache", $data);
echo str_replace("f6ca1c7d5d00a2a3fb4ea2f7edfa0f96a6d09c11717f39facabad2d724f16fbb", $domain, $data);
}
示例6: array
//
//get hooks data from hooks table ...
//
if (!defined('STOP_HOOKS')) {
if (!($all_plg_h_p = $cache->get('data_plugins'))) {
//get all hooks
$query = array('SELECT' => 'h.hook_id,h.hook_name, h.hook_content, h.plg_id, p.plg_name', 'FROM' => "{$dbprefix}hooks AS h", 'JOINS' => array(array('INNER JOIN' => "{$dbprefix}plugins AS p", 'ON' => 'p.plg_id=h.plg_id')), 'WHERE' => 'p.plg_disabled=0', 'ORDER BY' => 'h.hook_id');
($hook = kleeja_run_hook('qr_select_hooks_cache')) ? eval($hook) : null;
//run hook
$result = $SQL->build($query);
while ($row = $SQL->fetch_array($result)) {
$all_plg_hooks[$row['hook_name']][$row['plg_name']] = $row['hook_content'];
$all_plg_plugins[$row['plg_name']] = null;
}
$SQL->freeresult($result);
$cache->save('data_plugins', array($all_plg_plugins, $all_plg_hooks));
}
list($all_plg_plugins, $all_plg_hooks) = $all_plg_h_p;
}
#plugins is on
//
//get config data from config table ...
//
if (!($config = $cache->get('data_config'))) {
$query = array('SELECT' => 'c.*', 'FROM' => "{$dbprefix}config c");
($hook = kleeja_run_hook('qr_select_config_cache')) ? eval($hook) : null;
//run hook
$result = $SQL->build($query);
while ($row = $SQL->fetch_array($result)) {
$config[$row['name']] = $row['value'];
}
示例7: disable
function disable()
{
global $login, $translate;
if ($this->canDisable() == false) {
return false;
}
// write old record to log
$backup = array();
$backup['username'] = $this->getUsername();
$backup['email'] = $this->getEMail();
$backup['last_name'] = $this->getLastName();
$backup['first_name'] = $this->getFirstName();
sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`, `details`)\n\t\t VALUES ('user', 6, '&1', '&2', '&3', '&4', '&5')", $login->userid, $this->nUserId, 0, 'User ' . sql_escape($this->getUsername()) . ' disabled', serialize($backup));
// delete private data
sql("UPDATE `user` SET `password`=NULL, `email`=NULL, \n\t\t `is_active_flag`=0, \n\t\t `latitude`=0, `longitude`=0, \n\t\t `last_name`='', `first_name`='', `country`=NULL, `accept_mailing`=0, `pmr_flag`=0,\n\t\t `new_pw_code`=NULL, `new_pw_date`=NULL,\n\t\t `new_email`=NULL, `new_email_code`=NULL, `new_email_date`=NULL,\n\t\t `email_problems`=0, `first_email_problem`=NULL, `last_email_problem`=NULL,\n\t\t `permanent_login_flag`=0, `activation_code`='',\n\t\t `notify_radius`=0\n\t\t WHERE `user_id`='&1'", $this->nUserId);
// Statpic and profile description texts are published under the data license
// terms and therefore need not to be deleted.
sql("DELETE FROM `user_options` WHERE `user_id`='&1'", $this->nUserId);
$this->reload();
sql("DELETE FROM `cache_lists` WHERE `user_id`='&1'", $this->nUserId);
// Triggers will do all the dependent clean-up.
sql("DELETE FROM `cache_adoption` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `cache_ignore` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `cache_watches` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `watches_waiting` WHERE `user_id`='&1'", $this->nUserId);
sql("DELETE FROM `notify_waiting` WHERE `user_id`='&1'", $this->nUserId);
// lock the user's caches
$error = false;
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `user_id`='&1' AND `status` IN (1,2,3)", $this->nUserId);
while (($rCache = sql_fetch_assoc($rs)) && !$error) {
$error = true;
$cache = new cache($rCache['cache_id']);
if ($cache->setStatus(6) && $cache->save()) {
$log = cachelog::createNew($rCache['cache_id'], $login->userid, true);
if ($log !== false) {
$log->setType(cachelog::LOGTYPE_LOCKED, true);
$log->setOcTeamComment(true);
$log->setDate(date('Y-m-d'));
$log->setText($translate->t('The user account has been disabled.', '', '', 0, '', 1, $cache->getDefaultDescLanguage()));
$log->setTextHtml(false);
if ($log->save()) {
$error = false;
}
}
}
echo "\n";
}
sql_free_result($rs);
return !$error;
}
示例8: disable
public function disable()
{
global $login, $translate;
if ($this->canDisable() == false) {
return false;
}
// write old record to log
$backup = array();
$backup['username'] = $this->getUsername();
$backup['email'] = $this->getEMail();
$backup['last_name'] = $this->getLastName();
$backup['first_name'] = $this->getFirstName();
$backup['country'] = $this->getCountryCode();
$backup['latitude'] = $this->getLatitude();
$backup['longitude'] = $this->getLongitude();
sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`, `details`)\n VALUES ('user', 6, '&1', '&2', '&3', '&4', '&5')", $login->userid, $this->nUserId, 0, 'User ' . sql_escape($this->getUsername()) . ' disabled', serialize($backup));
// delete private and system data
sql("UPDATE `user` SET `password`=NULL, `email`=NULL, `last_name`='', `first_name`='',\n `country`=NULL, `latitude`=0, `longitude`=0, `is_active_flag`=0, `activation_code`='',\n `new_pw_code`=NULL, `new_pw_date`=NULL, `new_email`=NULL, `new_email_code`=NULL,\n `new_email_date`=NULL, `email_problems`=0, `first_email_problem`=NULL,\n `last_email_problem`=NULL\n WHERE `user_id`='&1'", $this->nUserId);
// non-private data which need not to be deleted:
//
// - Statpic and profile description texts - published under the data license
// - profile settings: accept_mailing, pmr_flag, permanent_login_flag, notify_radius,
// user_options entries
// - watch and ignore lists
// - adoptions: may still be executed if offered to another user
// Handling of cache lists is unclear. They may be deleted by the Opencaching team
// if not considered useful.
// lock the user's caches
$error = false;
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `user_id`='&1' AND `status` IN (1,2,3)", $this->nUserId);
while (($rCache = sql_fetch_assoc($rs)) && !$error) {
$error = true;
$cache = new cache($rCache['cache_id']);
if ($cache->setStatus(6) && $cache->save()) {
$log = cachelog::createNew($rCache['cache_id'], $login->userid, true);
if ($log !== false) {
$log->setType(cachelog::LOGTYPE_LOCKED, true);
$log->setOcTeamComment(true);
$log->setDate(date('Y-m-d'));
$log->setText($translate->t('The user account has been disabled.', '', '', 0, '', 1, $cache->getDefaultDescLanguage()));
$log->setTextHtml(false);
if ($log->save()) {
$error = false;
}
}
}
echo "\n";
}
sql_free_result($rs);
return !$error;
}
示例9: ldProcessRequest
//.........这里部分代码省略.........
default:
ldSetContent('text/html; charset=utf-8');
break;
}
$ARCurrent->arContentTypeSent = true;
register_shutdown_function("ldOnFinish");
$auth_class = "mod_auth_" . $auth_config["method"];
$mod_auth = new $auth_class($auth_config);
$username = isset($args["ARLogin"]) ? $args["ARLogin"] : null;
$password = isset($args["ARPassword"]) ? $args["ARPassword"] : null;
$result = $mod_auth->checkLogin($username, $password, $path);
if ($result !== true) {
if ($result == LD_ERR_ACCESS) {
ldAccessDenied($path, $ARnls["accessdenied"], $args, $function);
$function = false;
} else {
if ($result == LD_ERR_SESSION && !$AR->hideSessionIDfromURL) {
ldAccessTimeout($path, $ARnls["sessiontimeout"], $args, $function);
$function = false;
} else {
if ($result == LD_ERR_EXPIRED) {
ldAccessPasswordExpired($path, $ARnls["sessionpasswordexpired"], $args, $function);
$function = false;
}
}
}
}
// valid new login, without a session, morph to login.redirect.php to redirect to a session containing url
if (!$session_id && $args["ARLogin"] && $args["ARPassword"] && $function !== false && !$AR->hideSessionIDfromURL) {
if (!$ARCurrent->session->get("oldArCallArgs", 1)) {
$ARCurrent->session->put("oldGET", $_GET, 1);
$ARCurrent->session->put("oldPOST", $_POST, 1);
$ARCurrent->session->put("oldArCallArgs", $args, 1);
$ARCurrent->session->save(0, true);
}
if ($arDefaultFunction !== $function) {
$args["arRequestedTemplate"] = $function;
} else {
$args["arRequestedTemplate"] = "";
}
$function = "login.redirect.php";
} else {
if ($session_id) {
if ($ARCurrent->session->get("ARSessionTimedout", 1)) {
if (!$ARCurrent->session->get("oldArCallArgs", 1)) {
$ARCurrent->session->put("oldGET", $_GET, 1);
$ARCurrent->session->put("oldPOST", $_POST, 1);
$ARCurrent->session->put("oldArCallArgs", $args, 1);
$ARCurrent->session->save(0, true);
}
} else {
if ($ARCurrent->session->get("oldArCallArgs", 1)) {
$_GET = array_merge($_GET, (array) $ARCurrent->session->get("oldGET", 1));
$_POST = array_merge($_POST, (array) $ARCurrent->session->get("oldPOST", 1));
$args = $ARCurrent->session->get("oldArCallArgs", 1);
$args = array_merge($_GET, $_POST, $args);
// $args, $_GET, $_POST );
$ARCurrent->session->put("oldArCallArgs", "", 1);
$ARCurrent->session->put("oldGET", "", 1);
$ARCurrent->session->put("oldPOST", "", 1);
}
}
}
}
$xss_vars = array();
ldGatherXSSInput($xss_vars, $_GET);
示例10: urlencode
$cache->setStatus(2);
} else {
if (isset($_REQUEST['statusArchived'])) {
$cache->setStatus(3);
} else {
if (isset($_REQUEST['statusLockedVisible'])) {
$cache->setStatus(6);
} else {
if (isset($_REQUEST['statusLockedInvisible'])) {
$cache->setStatus(7);
}
}
}
}
}
$cache->save();
$tpl->redirect('adminreports.php?id=' . urlencode($rid));
} elseif (isset($_REQUEST['done']) && $adminid == $login->userid) {
sql("UPDATE `cache_reports` SET `status`=3 WHERE `id`=&1", $rid);
$tpl->redirect('adminreports.php?id=' . $rid);
} elseif (isset($_REQUEST['assign']) && ($adminid == 0 || $adminid != $login->userid)) {
$error = 1;
if ($rid > 0) {
$id = $rid;
} else {
$id = 0;
}
} elseif (isset($_REQUEST['assign']) && $adminid == $login->userid) {
$error = 2;
$id = $rid;
} elseif (isset($_REQUEST['statusActive']) || isset($_REQUEST['statusTNA']) || isset($_REQUEST['statusArchived']) || isset($_REQUEST['done']) || isset($_REQUEST['statusLockedVisible']) || isset($_REQUEST['statusLockedInvisible'])) {
示例11: start
//.........这里部分代码省略.........
if (count($arr) == 3) {
load::handler($arr[0], $arr[1], $arr[2]);
}
}
}
/*
Load tmpl conf
*/
$tmpl_id = self::get('tmpl_id');
conf::parse('tmpls', $tmpl_id);
/*
Tmpl events
*/
if (conf::get('tmpls', 'events')) {
foreach (conf::get('tmpls', 'events') as $v) {
$arr = explode('::', trim($v));
if ($arr[0]) {
if (events::targetDetect($arr[0], $arr[1], $arr[2])) {
/*
:TODO: добавить передачу в params события, его названия и его значения
*/
if ($arr[3] == 'replace') {
$tmpl_replace_id = $arr[4];
db::table('templates');
db::where('tmpl_id', $tmpl_replace_id);
self::$site_tmpl = db::get('tmpl_file');
} else {
if ($arr[3] == 'handler') {
load::handler($arr[4], $arr[5], $arr[6]);
}
}
}
}
}
}
/*
Tmpl handlers
*/
if (conf::get('tmpls', 'methods')) {
foreach (conf::get('tmpls', 'methods') as $v) {
$arr = explode('::', trim($v));
if (count($arr) == 3) {
load::handler($arr[0], $arr[1], $arr[2]);
}
}
}
/*
Set site template
*/
s::setTmpl(SYS_ROOT . 'tmpls/' . SITE . '/' . self::$site_tmpl, $lang);
/*
Get handlers
*/
s::resolver();
/*
JIP
*/
if (self::$jip) {
s::set('legenda_jip_page_path', 'http://' . SITE . SYS_DIR . 'pages/main/edit/' . PAGE_ID . '/');
self::$jip_html = '
<script src="http://' . SERVER . SYS_DIR . 'gui/js/lib/prototype.js" type="text/javascript"></script>
<script src="http://' . SERVER . SYS_DIR . 'gui/original/js/jip.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://' . SERVER . SYS_DIR . 'gui/original/css/jip.css" type="text/css" />
<div id="legenda_jip_show" style="display: none;">
<a href="javascript:void(null);" onclick="legendaJIPShow();" id="legenda_jip_show_link">Показать</a>
</div>
<div id="legenda_jip" style="display: none;">
<div id="legenda_jip_inner">
<a href="javascript:void(null);" onclick="legendaJIPHide();" id="legenda_jip_hide_link">Скрыть</a>
<a href="{legenda_jip_page_path}">Редактировать страницу</a>
<select onchange="legendaJIPGoToEdit(this.value);">
<option value="0">Редактировать блок</option>
<option value="0">-----------------------------</option>
{start legenda_jip_blocks}
<option value="{path}">{name}</option>
{end legenda_jip_blocks}
</select>
<a href="http://' . SERVER . SYS_DIR . '?adminlogoff" id="legenda_jip_logout">Выход</a>
</div>
</div>
</body>';
}
/*
Site display
*/
$code = s::get();
if (isset($_SESSION['E404'])) {
headers::self();
}
echo $code;
if (PAGE_CACHE == true && GLOBAL_CACHE == false) {
if (self::$page['page_cache'] == '1') {
cache::save();
}
}
if (GLOBAL_CACHE == true) {
cache::save();
}
}
示例12: header
header('Content-type: application/json');
$posts = array();
$i = 0;
while ($row = $result->fetch_assoc()) {
$posts[$i++] = createPostObject($row);
}
$postsArr = array('offset' => $page, 'count' => $numrows, 'posts' => $posts);
$result->free_result();
echo json_encode($postsArr);
} else {
header('Content-type: text/xml');
$posts = '<?xml version="1.0" encoding="UTF-8"?><posts offset="' . $page . '" count="' . $numrows . '">' . "\r\n";
while ($row = $result->fetch_assoc()) {
$posts .= createPostXML($row);
}
$posts .= '</posts>';
echo $posts;
}
}
//Cache doesn't exist for search, make one.
if ($no_cache === true) {
$data = ob_get_contents();
ob_end_flush();
if ($new_tag_cache != "") {
if (!is_dir("{$main_cache_dir}" . "" . "api_cache/" . $new_tag_cache)) {
@mkdir("{$main_cache_dir}" . "" . "api_cache/" . $new_tag_cache);
}
$cache->save("api_cache/" . $new_tag_cache . "/" . $page . "." . $api_type, $data);
}
}
}
示例13: save
}
static function save()
{
//echo '<pre>'; var_dump(self::$data); echo '</pre>';
if (self::$changed) {
file_put_contents(appPATH . 'qg/qgCacheData.txt', serialize(self::$data));
}
if (self::$counters !== null) {
file_put_contents(appPATH . 'qg/qgCacheCounters.txt', serialize(self::$counters));
}
}
}
function cache()
{
return new cache(func_get_args());
}
register_shutdown_function(function () {
cache::save();
});
cache::init();
/* *
$Cache = cache('test',2);
if (!$Cache->get($data)) {
echo 'has not!<br>';
$data = 'test data from db'; // sets the cache on shutdown
} else {
echo 'has<br>';
}
var_dump($data);
//$Cache->remove();
/* */