本文整理汇总了PHP中zmf::setFCache方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::setFCache方法的具体用法?PHP zmf::setFCache怎么用?PHP zmf::setFCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::setFCache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getColImgs
public static function getColImgs($colid, $order = 'hits', $limit = 10)
{
if (!$colid) {
return false;
}
$_info = zmf::getFCache("getColImgs{$colid}-{$order}-{$limit}");
if ($_info) {
//return $_info;
}
$sql = "SELECT id FROM {{posts}} WHERE colid={$colid} AND status=" . Posts::STATUS_PASSED;
$info = Yii::app()->db->createCommand($sql)->queryAll();
if (empty($info)) {
return false;
}
$idsArr = array();
foreach ($info as $i) {
$idsArr[] = $i['id'];
}
$ids = join(',', $idsArr);
if ($ids == '') {
return false;
}
$_sql = "SELECT logid,filePath,classify FROM {{attachments}} WHERE logid IN({$ids}) AND status=" . Posts::STATUS_PASSED . " ORDER BY {$order} LIMIT 0,{$limit}";
$_info = Yii::app()->db->createCommand($_sql)->queryAll();
zmf::setFCache("getColImgs{$colid}-{$order}-{$limit}", $_info, 3600);
return $_info;
}
示例2: tops
public static function tops()
{
$tops = zmf::getFCache("top-searchs");
if (!$tops) {
$sql = "SELECT * FROM {{search_records}} ORDER BY times DESC LIMIT 10";
$tops = Yii::app()->db->createCommand($sql)->queryAll();
zmf::setFCache("top-searchs", $tops, 360);
}
return $tops;
}
示例3: actionLogin
function actionLogin()
{
$this->layout = 'common';
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作', Yii::app()->createUrl('admin/index/index'));
}
$model = new LoginForm();
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
if ($model->validate() && $model->login()) {
$arr = array('latestLoginTime' => zmf::now());
$uid = Yii::app()->user->id;
if (!$this->checkPower('user', $uid, true)) {
Yii::app()->user->logout();
$model->addError('username', '您不是管理员');
} else {
//User::model()->updateByPk($uid, $arr);
zmf::delCookie('checkWithCaptcha');
//只允许单点登录
$randKey = zmf::randMykeys(8);
zmf::setCookie('adminRandKey' . $uid, $randKey, 86400);
zmf::setFCache('adminRandKey' . $uid, $randKey, 86400);
//记录操作
//UserLog::add($uid, '登录后台'.Yii::app()->request->userHostAddress);
$uuid = zmf::uuid();
zmf::setCookie('userCheckedLogin' . $uid, $uuid, 86400);
$this->redirect(array('index/index'));
}
} else {
$times = zmf::getCookie('checkWithCaptcha');
zmf::setCookie('checkWithCaptcha', intval($times) + 1, 86400);
}
}
$data = array('model' => $model);
$this->render('login', $data);
}
示例4: checkRegTimes
public static function checkRegTimes()
{
if (!zmf::config('limitReg')) {
return false;
}
$ip = ip2long(Yii::app()->request->userHostAddress);
$times = zmf::getFCache("regTimes-{$ip}");
if ($times >= zmf::config('limitRegTimes')) {
return true;
} else {
zmf::setFCache("regTimes-{$ip}", intval($times) + 1, 86400);
return false;
}
}
示例5: actionSettings
public function actionSettings()
{
array_pop($_POST);
$arr = $_POST;
if (Yii::app()->user->isGuest) {
$this->message(0, Yii::t('default', 'loginfirst'), Yii::app()->createUrl('site/login'), 1);
}
$uid = zmf::uid();
foreach ($arr as $key => $val) {
$_k = zmf::filterInput($key, 't', 1);
$_v = zmf::filterInput($val, 't', 1);
$sinfo = UserSetting::model()->findByAttributes(array('stype' => $_k), "uid='{$uid}'");
$model = new UserSetting();
if (!$sinfo) {
$_input = array('uid' => $uid, 'stype' => $_k, 'svalue' => $_v);
$model->attributes = $_input;
if ($model->validate()) {
$model->save();
}
} elseif ($sinfo->svalue != $_v) {
$model->updateByPk($sinfo->id, array('svalue' => $_v));
}
}
zmf::setFCache("userSettings{$uid}", $arr);
$this->redirect(array('users/config'));
}
示例6: getTopPostsByTags
/**
* 根据文章的标签获取与此最类似的文章
* @param type $id 文章id
* @param type $tagids 文章的标签id串
* @return boolean
*/
public static function getTopPostsByTags($id, $tagids)
{
if (!$tagids || !$id) {
return false;
}
$key = "getTopPostsByTags-{$id}";
$posts = zmf::getFCache($key);
if (!empty($posts)) {
return $posts;
}
$sqlTagRel = "SELECT p.id,p.title,p.faceimg,p.uid,p.hits,p.comments,p.cTime,p.updateTime,p.favors,count(tr.id) AS total FROM {{tag_relation}} tr,{{posts}} p WHERE tr.logid!='{$id}' AND tagid IN({$tagids}) AND tr.logid=p.id AND p.status=" . Posts::STATUS_PASSED . " AND p.classify=" . Posts::CLASSIFY_WEDDING . " GROUP BY tr.logid ORDER BY total DESC limit 5";
$posts = Yii::app()->db->createCommand($sqlTagRel)->queryAll();
zmf::setFCache($key, $posts, 3600);
return $posts;
}
示例7: add
private function add($type = '')
{
$uid = zmf::filterInput(Yii::app()->request->getParam('uid'), 't', 1);
if (!$uid) {
$uid = zmf::uid();
}
if (zmf::config('fbLoginOnly')) {
if (!$uid) {
$this->jsonOutPut(0, Yii::t('default', 'fbLoginOnly'));
}
}
$url = zmf::filterInput(Yii::app()->request->getParam('url'), 't', 1);
$email = zmf::filterInput(Yii::app()->request->getParam('email'), 't', 1);
$content = zmf::filterInput(Yii::app()->request->getParam('content'), 't', 1);
$ip = zmf::filterInput(Yii::app()->request->getParam('ip'), 't', 1);
$appversion = zmf::filterInput(Yii::app()->request->getParam('appversion'), 't', 1);
$os = zmf::filterInput(Yii::app()->request->getParam('os'), 't', 1);
$platform = zmf::filterInput(Yii::app()->request->getParam('platform'), 't', 1);
$time = zmf::filterInput(Yii::app()->request->getParam('time'), 't', 1);
if (!$ip) {
$ip = ip2long(Yii::app()->request->userHostAddress);
}
if (!$platform) {
$platform = Yii::app()->request->getUserAgent();
}
if ($type == '' || !in_array($type, array('pc', 'mobile', 'ios', 'android'))) {
$type = 'pc';
}
if (!$time) {
$time = zmf::now();
}
$cacheKey = 'feedback_' . $ip;
if ($content == '') {
$this->jsonOutPut(0, Yii::t('default', 'fbNoEmpty'));
}
if (zmf::config('fbTimesLimit')) {
$times = intval(zmf::getFCache($cacheKey));
$_time = $times + 1;
//fbLimitTimes
zmf::setFCache($cacheKey, $_time, 60);
if ($_time >= zmf::config('fbLimitTimes')) {
$this->jsonOutPut(0, Yii::t('default', 'fbTimesLimit'));
}
}
$data = array('uid' => $uid, 'url' => $url, 'email' => $email, 'content' => $content, 'ip' => $ip, 'cTime' => $time, 'status' => Posts::STATUS_STAYCHECK, 'classify' => $type, 'appversion' => $appversion, 'os' => $os, 'platform' => $platform);
$model = new Feedback();
$model->attributes = $data;
if ($model->validate()) {
if ($model->save()) {
if (zmf::config("defaultNoticeUid")) {
$_data = array('uid' => zmf::config("defaultNoticeUid"), 'content' => ($email != '' ? $email . '反馈:' : '新反馈:') . $content, 'type' => 'feedback', 'from_id' => rand(1, 100000), 'from_idtype' => 'feedback');
Notification::add($_data);
}
$this->jsonOutPut(1, Yii::t('default', 'fbThanking'));
} else {
$this->jsonOutPut(0, Yii::t('default', 'fbThanking'));
}
} else {
$this->jsonOutPut(0, Yii::t('default', 'notvalidate'));
}
}
示例8: getUserInfo
/**
* 获取用户信息
* @param type $uid
* @param type $type
* @return boolean
*/
public static function getUserInfo($uid, $type = '', $avatarSize = 170)
{
if (!$uid) {
return false;
}
$cacheKey = "userInfo-{$uid}";
$info = zmf::getFCache($cacheKey);
if (!$info) {
$info = Users::model()->findByPk($uid);
if (!$info) {
return false;
}
$info->areaName = $info->avatarImg = '';
unset($info->password);
unset($info->username);
$info->desc = $info->content;
//获取地区名
if ($info['areaid']) {
$areaInfo = Area::model()->findByPk($info['areaid']);
$info->areaName = $areaInfo ? $areaInfo['title'] : '';
}
$info->avatarImg = self::getAvatar($info['avatar'], 'origin');
zmf::setFCache($cacheKey, $info, 86400);
}
if (!$info) {
return false;
}
$info->avatarImg = str_replace('origin', $avatarSize, $info->avatarImg);
if (!empty($type)) {
return $info->{$type};
} else {
return $info;
}
}
示例9: adminBar
public function adminBar()
{
$lang['config']['config'] = array(CHtml::link('基本设置', array('config/index'), array('target' => 'main')), CHtml::link('上传设置', array('config/index', 'type' => 'upload'), array('target' => 'main')), CHtml::link('分页设置', array('config/index', 'type' => 'page'), array('target' => 'main')), CHtml::link('站点信息', array('config/index', 'type' => 'siteinfo'), array('target' => 'main')));
$lang['content']['columns'] = CHtml::link('栏目', array('columns/index'), array('target' => 'main'));
$lang['content']['posts'] = CHtml::link('文章', array('posts/index'), array('target' => 'main'));
$lang['content']['comments'] = CHtml::link('评论', array('comments/index'), array('target' => 'main'));
$lang['content']['questions'] = CHtml::link('客服', array('questions/index'), array('target' => 'main'));
$lang['content']['tags'] = CHtml::link('标签', array('tags/index'), array('target' => 'main'));
$lang['users']['usergroup'] = CHtml::link('用户组', array('users/group'), array('target' => 'main'));
$lang['users']['users'] = CHtml::link('用户', array('users/index'), array('target' => 'main'));
$lang['users']['useraction'] = CHtml::link('用户记录', array('users/records'), array('target' => 'main'));
$lang['link']['link'] = CHtml::link('友链', array('link/index'), array('target' => 'main'));
$lang['ads']['ads'] = CHtml::link('广告', array('ads/index'), array('target' => 'main'));
$lang['attachments']['album'] = CHtml::link('相册', array('album/index'), array('target' => 'main'));
$lang['attachments']['attachments'] = CHtml::link('附件', array('attachments/index'), array('target' => 'main'));
$main['config'] = CHtml::link('设置', array('config/index'), array('target' => 'main'));
$main['content'] = CHtml::link('内容', array('columns/index'), array('target' => 'main'));
$main['users'] = CHtml::link('用户', array('users/group'), array('target' => 'main'));
$main['link'] = CHtml::link('友链', array('link/index'), array('target' => 'main'));
$main['ads'] = CHtml::link('广告', array('ads/index'), array('target' => 'main'));
$main['attachments'] = CHtml::link('附件', array('album/index'), array('target' => 'main'));
// $main['']=CHtml::link('',array('/index'));
// $main['']=CHtml::link('',array('/index'));
if (Yii::app()->user->isGuest) {
if (!$json and !Yii::app()->request->isAjaxRequest) {
$this->message(0, '请先登录', Yii::app()->createUrl('site/login'));
} else {
$this->jsonOutPut(0, '请先登录');
}
} else {
$uid = Yii::app()->user->id;
}
$userinfo = Users::model()->findByPk($uid);
if (!$userinfo) {
if (!$json and !Yii::app()->request->isAjaxRequest) {
$this->message(0, '不存在的用户,请核实', Yii::app()->createUrl('site/logout'));
} else {
$this->jsonOutPut(0, '不存在的用户,请核实');
}
}
$gid = $userinfo['groupid'];
$groupinfo = UserGroup::model()->findByPk($gid);
if (!$groupinfo) {
if (!$json and !Yii::app()->request->isAjaxRequest) {
$this->message(0, '该用户所在用户组不存在,请核实', Yii::app()->createUrl('site/logout'));
} else {
$this->jsonOutPut(0, '该用户所在用户组不存在,请核实');
}
}
$powers = GroupPowers::model()->findAllByAttributes(array('gid' => $gid));
$powers = CHtml::listData($powers, 'id', 'powers');
$allPowers = GroupPowers::getDesc('super');
$tables = array();
foreach ($allPowers as $k => $v) {
foreach ($v['detail'] as $k2 => $v2) {
if (in_array($k2, $powers)) {
$tables[] = $k;
}
}
}
$tables = array_unique(array_filter($tables));
$bars = array();
$mainbars = array();
foreach ($lang as $l => $v3) {
foreach ($v3 as $k3 => $v4) {
if (in_array($k3, $tables)) {
$mainbars[] = $l;
$bars['seconds'][$l][] = $v4;
}
}
}
$mainbars = array_unique(array_filter($mainbars));
foreach ($mainbars as $m => $mv) {
$bars['firsts'][$mv] = $main[$mv];
}
zmf::setFCache("usersBar{$uid}", $bars, 86400);
return $bars;
}