本文整理汇总了PHP中cache_write函数的典型用法代码示例。如果您正苦于以下问题:PHP cache_write函数的具体用法?PHP cache_write怎么用?PHP cache_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCardTicket
public function getCardTicket()
{
$cachekey = "cardticket:{$this->account['acid']}";
$cache = cache_load($cachekey);
if (!empty($cache) && !empty($cache['ticket']) && $cache['expire'] > TIMESTAMP) {
$this->account['card_ticket'] = $cache;
return $cache['token'];
}
load()->func('communication');
$access_token = $this->getAccessToken();
if (is_error($access_token)) {
return $access_token;
}
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$access_token}&type=wx_card";
$content = ihttp_get($url);
if (is_error($content)) {
return error(-1, '调用接口获取微信公众号 card_ticket 失败, 错误信息: ' . $content['message']);
}
$result = @json_decode($content['content'], true);
if (empty($result) || intval($result['errcode']) != 0 || $result['errmsg'] != 'ok') {
return error(-1, '获取微信公众号 card_ticket 结果错误, 错误信息: ' . $result['errmsg']);
}
$record = array();
$record['ticket'] = $result['ticket'];
$record['expire'] = TIMESTAMP + $result['expires_in'] - 200;
$this->account['card_ticket'] = $record;
cache_write($cachekey, $record);
return $record['ticket'];
}
示例2: setCache
function setCache($cacheActionUrl, $viewData)
{
if (!($result = checkCache($cacheActionUrl))) {
return false;
}
$viewData = '<?php if(!defined("BASEAPP"))die("Invalid Access"); ?>' . "\n" . $viewData;
cache_write(CACHE_PATH . $result['alias'] . '.php', $viewData);
}
示例3: tagtpl_cache
function tagtpl_cache() {
$relatedtag = unserialize(data_get('relatedtag'));
if(empty($relatedtag)) $relatedtag = array();
foreach($relatedtag['data'] as $appid => $data) {
$relatedtag['limit'][$appid] = empty($relatedtag['limit'][$appid])?0:intval($relatedtag['limit'][$appid]);
$data['template'] = trim($data['template']);
if(empty($relatedtag['limit'][$appid]) || empty($data['template'])) {
unset($relatedtag['data'][$appid]);
unset($relatedtag['limit'][$appid]);
}
}
cache_write('tagtpl', "_SGLOBAL['tagtpl']", $relatedtag);
}
示例4: config_cache
function config_cache($updatedata = true)
{
global $_SGLOBAL;
$_SCONFIG = array();
$query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('config'));
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
if ($value['var'] == 'privacy') {
$value['datavalue'] = empty($value['datavalue']) ? array() : unserialize($value['datavalue']);
}
$_SCONFIG[$value['var']] = $value['datavalue'];
}
cache_write('config', '_SCONFIG', $_SCONFIG);
}
示例5: getJsApiTicket
private function getJsApiTicket()
{
$ticket = cache_read("js_api_ticket");
if (empty($ticket) || $ticket["time"] <= time()) {
$token = $this->getWxAccessToken();
if (!empty($token)) {
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$token}&type=jsapi";
$js_token = ihttp_request($url);
if (!empty($js_token)) {
$content = @json_decode($js_token['content'], true);
$ticket = array("ticket" => $content["ticket"], "time" => TIMESTAMP + $content["expires_in"]);
cache_write("js_api_ticket", $ticket);
}
}
}
return $ticket["ticket"];
}
示例6: setting_load
function setting_load($key = '')
{
global $_W;
$cachekey = "setting";
$settings = cache_load($cachekey);
if (empty($settings)) {
$settings = pdo_fetchall('SELECT * FROM ' . tablename('core_settings'), array(), 'key');
if (is_array($settings)) {
foreach ($settings as $k => &$v) {
$settings[$k] = iunserializer($v['value']);
}
}
cache_write($cachekey, $settings);
}
if (!is_array($_W['setting'])) {
$_W['setting'] = array();
}
$_W['setting'] = array_merge($_W['setting'], $settings);
return $settings;
}
示例7: cache_build_fans_struct
function cache_build_fans_struct()
{
$struct = array();
$result = pdo_fetchall("SHOW COLUMNS FROM " . tablename('fans'));
if (!empty($result)) {
foreach ($result as $row) {
$struct[] = $row['Field'];
}
cache_write('fansfields', $struct);
}
return $struct;
}
示例8: mkdir
$sizelimit = $sizelimit ? (int) $sizelimit : 2048;
$bak_dir = PHPDISK_ROOT . './system/data/';
$default_index = $bak_dir . 'index.htm';
if (!is_dir($bak_dir)) {
mkdir($bak_dir, 0777);
}
if (!file_exists($default_index)) {
write_file($default_index, 'PHPDisk');
}
if ($tables && $fileid == 1) {
if (!isset($tables) || !is_array($tables)) {
$sysmsg[] = __('please_select_backup_db');
redirect($_SERVER['HTTP_REFERER'], $sysmsg);
}
$random = random(8);
cache_write('backup_temp_tables.php', $tables);
} else {
if (!($tables = cache_read('backup_temp_tables.php'))) {
$sysmsg[] = __('cannot_write_backup_database_list');
redirect($_SERVER['HTTP_REFERER'], $sysmsg);
}
}
$sql_data = '';
$tableid = $tableid ? $tableid - 1 : 0;
$startfrom = $startfrom ? $startfrom : 0;
$tablenumber = count($tables);
for ($i = $tableid; $i < $tablenumber && strlen($sql_data) < $sizelimit * 1000; $i++) {
$sql_data .= sql_dumptable($tables[$i], $startfrom, strlen($sql_data));
$startfrom = 0;
}
if (!$error) {
示例9: cloud_prepare
$r = cloud_prepare();
if (is_error($r)) {
message($r['message'], url('cloud/profile'), 'error');
}
$do = !empty($_GPC['do']) && in_array($do, array('module', 'system')) ? $_GPC['do'] : exit('Access Denied');
if ($do == 'system') {
$lock = cache_load('checkupgrade:system');
if (empty($lock) || TIMESTAMP - 3600 > $lock['lastupdate']) {
$upgrade = cloud_build();
if (!is_error($upgrade) && !empty($upgrade['upgrade'])) {
$upgrade = array('version' => $upgrade['version'], 'release' => $upgrade['release'], 'upgrade' => 1, 'lastupdate' => TIMESTAMP);
cache_write('checkupgrade:system', $upgrade);
message($upgrade, '', 'ajax');
} else {
$upgrade = array('lastupdate' => TIMESTAMP);
cache_write('checkupgrade:system', $upgrade);
}
} else {
message($lock, '', 'ajax');
}
} elseif ($do == 'module') {
$modulename = $_GPC['m'];
$module = pdo_fetch("SELECT mid, name, version, title FROM " . tablename('modules') . " WHERE name = :name", array(':name' => $modulename));
if (!empty($module)) {
$info = cloud_m_info($modulename);
if (!empty($info) && !empty($info['version']['version'])) {
if (ver_compare($module['version'], $info['version']['version'])) {
$upgrade = array('name' => $module['title'], 'version' => $info['version']['version'], 'upgrade' => 1, 'lastupdate' => TIMESTAMP);
message($upgrade, '', 'ajax');
}
} else {
示例10: implode
break;
}
$sqlstring = implode(' ', $sql);
$_POST['network'][$key]['sql'] = $sqlstring;
$network[$key] = $_POST['network'][$key];
} else {
$network[$key] = array();
$network[$key]['usedefault'] = 1;
}
foreach (array('space', 'doing', 'blog', 'album', 'share', 'mtag', 'slide', 'blogfrom') as $val) {
$sql = '';
$sql = $val != 'blogfrom' ? trim($network[$val]['sql']) : $network[$val];
$networkcache[$val] = empty($sql) ? '' : $sql;
}
include_once S_ROOT . './source/function_cache.php';
cache_write('network_setting', "network", $networkcache);
data_set('network', $network);
@unlink(S_ROOT . './data/data_network.php');
cpmessage('do_success', 'admincp.php?ac=network');
} elseif (submitcheck('settingsubmit')) {
$setarr = array();
foreach ($_POST['config'] as $var => $value) {
$value = trim($value);
if (!isset($_SCONFIG[$var]) || $_SCONFIG[$var] != $value) {
$setarr[] = "('{$var}', '{$value}')";
}
}
if ($setarr) {
$_SGLOBAL['db']->query("REPLACE INTO " . tname('config') . " (var, datavalue) VALUES " . implode(',', $setarr));
//更新缓存
include_once S_ROOT . './source/function_cache.php';
示例11: cache_write
if ($batch == 1) {
cache_write('upgrade:template', iserializer($wait_upgrade));
message($theme['title'] . ' 模块安装配置文件不存在或是格式不正确。系统将进入下一个模板的更新。<br>请勿关闭浏览器', url('extension/theme/upgrade', array('batch' => 1)), 'success');
}
message('模块安装配置文件不存在或是格式不正确!', '', 'error');
}
if (ver_compare($theme['version'], $packet['version']) != -1) {
if ($batch == 1) {
cache_write('upgrade:template', iserializer($wait_upgrade));
message($theme['title'] . ' 模板版本不低于要更新的版本。系统将进入下一个模板的更新。<br>请勿关闭浏览器', url('extension/theme/upgrade', array('batch' => 1)), 'success');
}
message('已安装的模板版本不低于要更新的版本, 操作无效.');
}
pdo_update('site_templates', array('version' => $packet['version']), array('id' => $theme['id']));
if ($batch == 1) {
cache_write('upgrade:template', iserializer($wait_upgrade));
message($theme['title'] . ' 模板更新成功。系统将进入下一个模板的更新。<br>请勿关闭浏览器', url('extension/theme/upgrade', array('batch' => 1)), 'success');
}
message('模板更新成功!', url('extension/theme'), 'success');
}
if ($do == 'web') {
$_W['page']['title'] = '管理后台风格 - 风格主题 - 扩展';
load()->model('setting');
if (checksubmit('submit')) {
$data = array('template' => $_GPC['template']);
setting_save($data, 'basic');
message('更新设置成功!', 'refresh');
}
$path = IA_ROOT . '/web/themes/';
if (is_dir($path)) {
if ($handle = opendir($path)) {
示例12: account_yixin_login
function account_yixin_login($username = '', $password = '', $imgcode = '')
{
$auth = cache_load('yxauth:' . $username . ':');
if (!empty($auth)) {
$response = ihttp_request(YIXIN_ROOT . '/index', '', array('CURLOPT_COOKIE' => $auth['cookie']));
if ($response['code'] == '200') {
return $auth['cookie'];
}
}
$loginurl = YIXIN_ROOT . '/rest/login';
$post = array('account' => $username, 'password' => $password, 'captcha' => $imgcode, 'loginType' => 'YiXinUserId');
$response = ihttp_request($loginurl, $post, array('CURLOPT_REFERER' => 'https://plus.yixin.im/'));
$data = json_decode($response['content'], true);
if ($data['code'] == '200') {
cache_write('yxauth:' . $username . ':cookie', implode('; ', $response['headers']['Set-Cookie']));
return implode('; ', $response['headers']['Set-Cookie']);
} else {
message($data['message'], referer(), 'error');
return false;
}
}
示例13: booking
private function booking($message)
{
global $_W;
if ($message['event'] == 'unsubscribe' || $message['event'] == 'subscribe') {
$todaystat = pdo_get('stat_fans', array('date' => date('Ymd'), 'uniacid' => $_W['uniacid']));
if ($message['event'] == 'unsubscribe') {
if (empty($todaystat)) {
$updatestat = array('new' => 0, 'uniacid' => $_W['uniacid'], 'cancel' => 1, 'cumulate' => 0, 'date' => date('Ymd'));
pdo_insert('stat_fans', $updatestat);
} else {
$updatestat = array('cancel' => $todaystat['cancel'] + 1);
$updatestat['cumulate'] = intval($todaystat['cumulate']) - 1;
pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id']));
}
} elseif ($message['event'] == 'subscribe') {
if (empty($todaystat)) {
$updatestat = array('new' => 1, 'uniacid' => $_W['uniacid'], 'cancel' => 0, 'cumulate' => 1, 'date' => date('Ymd'));
pdo_insert('stat_fans', $updatestat);
} else {
$updatestat = array('new' => $todaystat['new'] + 1, 'cumulate' => $todaystat['cumulate'] + 1);
pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id']));
}
}
}
$setting = uni_setting($_W['uniacid'], array('passport'));
load()->model('mc');
$fans = mc_fansinfo($message['from']);
$default_groupid = cache_load("defaultgroupid:{$_W['uniacid']}");
if (empty($default_groupid)) {
$default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid']));
cache_write("defaultgroupid:{$_W['uniacid']}", $default_groupid);
}
if (!empty($fans)) {
$rec = array();
if (!empty($fans['follow'])) {
if ($message['event'] == 'unsubscribe') {
$rec['follow'] = 0;
$rec['followtime'] = 0;
$rec['unfollowtime'] = $message['time'];
}
} else {
if ($message['event'] != 'unsubscribe' && $message['event'] != 'ShakearoundUserShake') {
$rec['follow'] = 1;
$rec['followtime'] = $message['time'];
$rec['unfollowtime'] = 0;
}
}
$member = array();
if (!empty($fans['uid'])) {
$member = mc_fetch($fans['uid']);
}
if (empty($member)) {
if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) {
$data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@012wz.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP);
$data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']);
pdo_insert('mc_members', $data);
$rec['uid'] = pdo_insertid();
}
}
if (!empty($rec)) {
pdo_update('mc_mapping_fans', $rec, array('acid' => $_W['acid'], 'openid' => $message['from'], 'uniacid' => $_W['uniacid']));
}
} else {
$rec = array();
$rec['acid'] = $_W['acid'];
$rec['uniacid'] = $_W['uniacid'];
$rec['uid'] = 0;
$rec['openid'] = $message['from'];
$rec['salt'] = random(8);
if ($message['event'] == 'unsubscribe') {
$rec['follow'] = 0;
$rec['followtime'] = 0;
$rec['unfollowtime'] = $message['time'];
} else {
$rec['follow'] = 1;
$rec['followtime'] = $message['time'];
$rec['unfollowtime'] = 0;
}
if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) {
$data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@012wz.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP);
$data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']);
pdo_insert('mc_members', $data);
$rec['uid'] = pdo_insertid();
}
pdo_insert('mc_mapping_fans', $rec);
}
}
示例14: uni_is_multi_acid
function uni_is_multi_acid($uniacid = 0)
{
global $_W;
if (!$uniacid) {
$uniacid = $_W['uniacid'];
}
$cachekey = "unicount:{$uniacid}";
$nums = cache_load($cachekey);
$nums = intval($nums);
if (!$nums) {
$nums = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('account_wechats') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid']));
cache_write($cachekey, $nums);
}
if ($nums == 1) {
return false;
}
return true;
}
示例15: getAccessToken
private function getAccessToken()
{
if (IMS_VERSION >= 0.6) {
load()->func('cache');
}
$api = cache_load("zombie.flight.api_share.json::" . $this->weid, true);
$new = false;
if (empty($api['appid']) || $api['appid'] !== $this->appId) {
$new = true;
}
if (empty($api['appsecret']) || $api['appsecret'] !== $this->appSecret) {
$new = true;
}
$data = cache_load("zombie.flight.access_token.json::" . $this->weid, true);
if (empty($data['expire_time']) || $data['expire_time'] < time() || $new) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}";
$res = json_decode($this->httpGet($url));
$access_token = $res->access_token;
if ($access_token) {
$data['expire_time'] = time() + 7000;
$data['access_token'] = $access_token;
cache_write("zombie.flight.access_token.json::" . $this->weid, iserializer($data));
cache_write("zombie.flight.api_share.json::" . $this->weid, iserializer(array("appid" => $this->appId, "appsecret" => $this->appSecret)));
}
} else {
$access_token = $data['access_token'];
}
return $access_token;
}