本文整理汇总了PHP中setcache函数的典型用法代码示例。如果您正苦于以下问题:PHP setcache函数的具体用法?PHP setcache怎么用?PHP setcache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setcache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manage
/**
* member list
*/
function manage()
{
if (isset($_POST['dosubmit'])) {
$member_setting = array2string($_POST['info']);
$this->db->update(array('module' => 'member', 'setting' => $member_setting), array('module' => 'member'));
setcache('member_setting', $_POST['info']);
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_scroll = true;
$member_setting = $this->db->get_one(array('module' => 'member'), 'setting');
$member_setting = string2array($member_setting['setting']);
$email_config = getcache('common', 'commons');
$this->sms_setting_arr = getcache('sms', 'sms');
$siteid = get_siteid();
if (empty($email_config['mail_user']) || empty($email_config['mail_password'])) {
$mail_disabled = 1;
}
if (!empty($this->sms_setting_arr[$siteid])) {
$this->sms_setting = $this->sms_setting_arr[$siteid];
if ($this->sms_setting['sms_enable'] == '0') {
$sms_disabled = 1;
} else {
if (empty($this->sms_setting['userid']) || empty($this->sms_setting['productid']) || empty($this->sms_setting['sms_key'])) {
$sms_disabled = 1;
}
}
} else {
$sms_disabled = 1;
}
include $this->admin_tpl('member_setting');
}
}
示例2: add
/**
* 添加规则
*/
public function add() {
if (isset($_POST['dosubmit'])) {
$ruledata['fromid'] = isset($_POST['fromid']) ? intval($_POST['fromid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
$ruledata['toid'] = isset($_POST['toid']) ? intval($_POST['toid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
$ruledata['fromrate'] = isset($_POST['fromrate']) ? intval($_POST['fromrate']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
$ruledata['torate'] = isset($_POST['torate']) ? intval($_POST['torate']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
if(empty($_POST['from']) || empty($_POST['to'])) {
showmessage(L('illegal_parameters'), HTTP_REFERER);
}
$fromarr = explode('_', $_POST['from']);
$toarr = explode('_', $_POST['to']);
$ruledata['from'] = isset($fromarr[0]) ? $fromarr[0] : '';
$ruledata['fromname'] = isset($fromarr[1]) ? $fromarr[1] : '';
$ruledata['fromunit'] = isset($fromarr[2]) ? $fromarr[2] : '';
$ruledata['to'] = isset($toarr[0]) ? $toarr[0] : '';
$ruledata['toname'] = isset($toarr[1]) ? $toarr[1] : '';
$ruledata['tounit'] = isset($toarr[2]) ? $toarr[2] : '';
$creditlistarr = $this->db->get_one(array('name'=>'creditrate'));
$creditlist = string2array($creditlistarr['data']);
$creditlist[] = $ruledata;
$noticedata['creditlist'] = $creditlist;
//加入消息队列
messagequeue::add('credit_update', $noticedata);
setcache('creditlist', $creditlist);
$this->db->insert(array('name'=>'creditrate', 'data'=>array2string($creditlist)), 1, 1);
showmessage(L('operation_success'), HTTP_REFERER);
}
$applist = getcache('applist');
include $this->admin_tpl('credit_add');
}
示例3: update_cache_model
/**
* 更新模型缓存
*/
public static function update_cache_model()
{
$sitemodel_db = pc_base::load_model('sitemodel_model');
$data = $sitemodel_db->select(array('type' => 2), "*", 1000, 'sort', '', 'modelid');
setcache('member_model', $data, 'commons');
if (!defined('MODEL_PATH')) {
//模型原型存储路径
define('MODEL_PATH', PC_PATH . 'modules' . DIRECTORY_SEPARATOR . 'member' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR);
}
if (!defined('CACHE_MODEL_PATH')) {
//模型缓存路径
define('CACHE_MODEL_PATH', PHPCMS_PATH . 'caches' . DIRECTORY_SEPARATOR . 'caches_model' . DIRECTORY_SEPARATOR . 'caches_data' . DIRECTORY_SEPARATOR);
}
require MODEL_PATH . 'fields.inc.php';
//更新内容模型类:表单生成、入库、更新、输出
$classtypes = array('form', 'input', 'update', 'output');
foreach ($classtypes as $classtype) {
$cache_data = file_get_contents(MODEL_PATH . 'member_' . $classtype . '.class.php');
$cache_data = str_replace('}?>', '', $cache_data);
foreach ($fields as $field => $fieldvalue) {
if (file_exists(MODEL_PATH . $field . DIRECTORY_SEPARATOR . $classtype . '.inc.php')) {
$cache_data .= file_get_contents(MODEL_PATH . $field . DIRECTORY_SEPARATOR . $classtype . '.inc.php');
}
}
$cache_data .= "\r\n } \r\n?>";
file_put_contents(CACHE_MODEL_PATH . 'member_' . $classtype . '.class.php', $cache_data);
chmod(CACHE_MODEL_PATH . 'member_' . $classtype . '.class.php', 0777);
}
return true;
}
示例4: get
public function get() {
$id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit();
if ($data = $this->db->get_one(array('id'=>$id))) {
if (!$str = tpl_cache('dbsource_'.$id,$data['cache'])) {
if ($data['type'] == 1) { //自定义SQL调用
$get_db = pc_base::load_model("get_model");
$sql = $data['data'].(!empty($data['num']) ? " LIMIT $data[num]" : '');
$r= $get_db->query($sql);
while(($s = $get_db->fetch_next()) != false) {
$str[] = $s;
}
} else {
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$data['module'].DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.$data['module'].'_tag.class.php';
if (file_exists($filepath)) {
$pc_tag = pc_base::load_app_class($data['module'].'_tag', $data['module']);
if (!method_exists($pc_tag, $data['action'])) {
exit();
}
$sql = string2array($data['data']);
$sql['action'] = $data['action'];
$sql['limit'] = $data['num'];
unset($data['num']);
$str = $pc_tag->$data['action']($sql);
} else {
exit();
}
}
if ($data['cache']) setcache('dbsource_'.$id, $str, 'tpl_data');
}
echo $this->_format($data['id'], $str, $data['dis_type']);
}
}
示例5: createindex
/**
* 创建索引
*/
public function createindex()
{
if (isset($_GET['dosubmit'])) {
//重建索引首先清空表所有数据,然后根据搜索类型接口重新全部重建索引
if (!isset($_GET['have_truncate'])) {
$db_tablepre = $this->db->db_tablepre;
//删除该站点全文索引
$this->db->delete(array('siteid' => $this->siteid));
$types = $this->type_db->select(array('siteid' => $this->siteid, 'module' => 'search'));
setcache('search_types', $types, 'search');
} else {
$types = getcache('search_types', 'search');
}
//$key typeid 的索引
$key = isset($_GET['key']) ? intval($_GET['key']) : 0;
foreach ($types as $_k => $_v) {
if ($key == $_k) {
$typeid = $_v['typeid'];
if ($_v['modelid']) {
if ($_v['typedir'] !== 'yp') {
$search_api = pc_base::load_app_class('search_api', 'content');
} else {
$search_api = pc_base::load_app_class('search_api', $_v['typedir']);
}
if (!isset($_GET['total'])) {
$total = $search_api->total($_v['modelid']);
} else {
$total = intval($_GET['total']);
$search_api->set_model($_v['modelid']);
}
} else {
$module = trim($_v['typedir']);
$search_api = pc_base::load_app_class('search_api', $module);
if (!isset($_GET['total'])) {
$total = $search_api->total();
} else {
$total = intval($_GET['total']);
}
}
$pagesize = $_GET['pagesize'] ? intval($_GET['pagesize']) : 50;
$page = max(intval($_GET['page']), 1);
$pages = ceil($total / $pagesize);
$datas = $search_api->fulltext_api($pagesize, $page);
foreach ($datas as $id => $r) {
$this->db->update_search($typeid, $id, $r['fulltextcontent'], $r['title'], $r['adddate'], 1);
}
$page++;
if ($pages >= $page) {
showmessage("正在更新 <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total} - 当前第 <font color='red'>{$page}</font> 页", "?m=search&c=search_admin&a=createindex&menuid=909&page={$page}&total={$total}&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1");
}
$key++;
showmessage("开始更新: <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total}条", "?m=search&c=search_admin&a=createindex&menuid=909&page=1&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1");
}
}
showmessage('全站索引更新完成', 'blank');
} else {
$big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=search&c=search_type&a=add\', title:\'' . L('add_search_type') . '\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_search_type'));
include $this->admin_tpl('createindex');
}
}
示例6: tpl_setcache
/**
* 加载模板标签缓存
* @param string $name 缓存名
*/
function tpl_setcache($name, $data, $action, $timeout = 0)
{
$filepath = 'tpl_data/' . $action;
if (empty($action)) {
$filepath = 'tpl_data/' . $action;
}
return setcache($name, $data, $filepath, 'file', $timeout, '');
}
示例7: public_cache_urlrule
/**
* 更新URL规则
*/
public function public_cache_urlrule() {
$datas = $this->db->select('','*','','','','urlruleid');
$basic_data = array();
foreach($datas as $roleid=>$r) {
$basic_data[$roleid] = $r['urlrule'];;
}
setcache('urlrules_detail',$datas,'commons');
setcache('urlrules',$basic_data,'commons');
}
示例8: set_cache
/**
* 设置站点缓存
*/
public function set_cache() {
$list = $this->db->select();
$data = array();
foreach ($list as $key=>$val) {
$data[$val['siteid']] = $val;
$data[$val['siteid']]['url'] = $val['domain'] ? $val['domain'] : pc_base::load_config('system', 'web_path').$val['dirname'].'/';
}
setcache('sitelist', $data, 'commons');
}
示例9: ajax_clear
public function ajax_clear()
{
/*写入应用列表缓存*/
$applist = $this->applications_db->listinfo('', '', 1, 100, 'appid');
setcache('applist', $applist);
$applistinfo = getcacheinfo('applist');
$return['filesize'] = sizecount($applistinfo['filesize']);
$return['filemtime'] = date('Y-m-d H:i:s', $applistinfo['filemtime']);
exit(json_encode($return));
}
示例10: dbsource_cache
/**
* 外部数据源缓存
*/
function dbsource_cache() {
$db = pc_base::load_model('dbsource_model');
$list = $db->select();
$data = array();
if ($list) {
foreach ($list as $val) {
$data[$val['name']] = array('hostname'=>$val['host'].':'.$val['port'], 'database' =>$val['dbname'] , 'db_tablepre'=>$val['dbtablepre'], 'username' =>$val['username'],'password' => $val['password'],'charset'=>$val['charset'],'debug'=>0,'pconnect'=>0,'autoconnect'=>0);
}
} else {
return false;
}
return setcache('dbsource', $data, 'commons');
}
示例11: sms_setting
public function sms_setting()
{
$siteid = get_siteid();
if (isset($_POST['dosubmit'])) {
$this->sms_setting_arr[$siteid] = $_POST['setting'];
$setting = array2string($this->sms_setting);
setcache('sms', $this->sms_setting_arr);
$this->module_db->update(array('setting' => $setting), array('module' => 'sms'));
showmessage(L('operation_success'), HTTP_REFERER);
} else {
$show_pc_hash = '';
include $this->admin_tpl('sms_setting');
}
}
示例12: sp4
public function sp4()
{
if (isset($_POST['dosubmit'])) {
$data = isset($_POST['data']) ? $_POST['data'] : '';
$data['sp4use'] = isset($_POST['sp4use']) && intval($_POST['sp4use']) ? intval($_POST['sp4use']) : 0;
$data['sp4_password_key'] = isset($_POST['sp4_password_key']) && $_POST[sp4_password_key] ? $_POST['sp4_password_key'] : '';
$this->db->insert(array('name' => 'sp4', 'data' => array2string($data)), 1, 1);
setcache('settings_sp4', $data);
showmessage(L('operation_success'), HTTP_REFERER);
}
$data = array();
$data = getcache('settings_sp4');
include $this->admin_tpl('system_sp4');
}
示例13: public_regcnzz
public function public_regcnzz() {
if (empty($this->config)) {
$key = md5(APP_PATH.'F0dkYYtw');
if ($data = @file_get_contents('http://wss.cnzz.com/user/companion/phpcms.php?domain='.APP_PATH.'&key='.$key.'&cms=phpcms')) {
//ʧ°Ü
if (substr($data, 0, 1) == '-') {
showmessage(L('application_fails'));
} else {
$data = explode('@', $data);
$data['siteid'] = $data[0];
$data['password'] = $data[1];
unset($data[0], $data[1]);
setcache('cnzz', $data, 'commons');
showmessage(L('success'), '?m=cnzz&c=index&a=init');
}
} else {
showmessage(L('donot_connect_server'));
}
} else {
showmessage(L('has_been_registered'));
}
}
示例14: player_list
private function player_list($return_data = 0)
{
$infos = $this->ku6api->player_list();
$infos = $infos['data'];
$player_caches = array();
foreach ($infos as $info) {
if ($info['default'] == 1) {
$player_caches[$info['channelid']]['default'] = $info['style'];
}
$player_caches[$info['channelid']]['STY-' . $info['style']] = $info;
}
setcache('player', $player_caches, 'video');
if ($return_data) {
return $infos;
}
/*
1=>array(
'default'=> 'idZwHK_aOJ7E-oGT',
'STY-idZwHK_aOJ7E-oGT'=> array('auto'=>1),
'STY-7i8TjPi7A3o.'=> array(),
),
*/
}
示例15: cache_field
/**
* 更新指定表单向导的字段缓存
*
* @param $formid 表单向导id
* @param $disabled 字段状态
*/
public function cache_field($formid = 0, $disabled = 0)
{
$field_array = array();
$fields = $this->db->select(array('modelid' => $formid, 'disabled' => $disabled), '*', 100, 'listorder ASC');
foreach ($fields as $_value) {
$setting = string2array($_value['setting']);
$_value = array_merge($_value, $setting);
$field_array[$_value['field']] = $_value;
}
setcache('formguide_field_' . $formid, $field_array, 'model');
return true;
}