当前位置: 首页>>代码示例>>PHP>>正文


PHP zmf::actionLimit方法代码示例

本文整理汇总了PHP中zmf::actionLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::actionLimit方法的具体用法?PHP zmf::actionLimit怎么用?PHP zmf::actionLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zmf的用法示例。


在下文中一共展示了zmf::actionLimit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionView

 public function actionView()
 {
     $id = zmf::val('id', 2);
     if (!$id) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $info = $this->loadModel($id);
     $pageSize = 30;
     $comments = Comments::getCommentsByPage($id, 'posts', 1, $pageSize);
     $tags = Tags::getByIds($info['tagids']);
     $relatePosts = Posts::getRelations($id, 5);
     if (!zmf::actionLimit('visit-Posts', $id, 5, 60)) {
         Posts::updateCount($id, 'Posts', 1, 'hits');
     }
     $size = '600';
     if ($this->isMobile) {
         $size = '640';
     }
     $info['content'] = zmf::text(array(), $info['content'], true, $size);
     $data = array('info' => $info, 'comments' => $comments, 'tags' => $tags, 'relatePosts' => $relatePosts, 'loadMore' => count($comments) == $pageSize ? 1 : 0);
     $this->favorited = Favorites::checkFavored($id, 'post');
     $this->pageTitle = $info['title'];
     $this->selectNav = 'posts';
     $this->render('view', $data);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:25,代码来源:PostsController.php

示例2: checkFavored

 public static function checkFavored($logid, $type, $uid = '')
 {
     if (!$uid) {
         $uid = zmf::uid();
     }
     if (!$uid) {
         if (zmf::actionLimit('favorite-' . $type, $logid, 1, 86400, true, true)) {
             return true;
         }
         return false;
     }
     if (!is_numeric($logid)) {
         return false;
     }
     if (!isset($type) or !in_array($type, array('post'))) {
         return false;
     }
     $attr = array('uid' => $uid, 'logid' => $logid, 'classify' => $type);
     if (Favorites::model()->findByAttributes($attr)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:24,代码来源:Favorites.php

示例3: favorite

 public static function favorite($code, $type, $from = 'web', $uid = '')
 {
     if (!$code || !$type) {
         return array('status' => 0, 'msg' => '数据不全,请核实');
     }
     if (!in_array($type, array('post'))) {
         return array('status' => 0, 'msg' => '暂不允许的分类');
     }
     if (is_numeric($code)) {
         $id = $code;
     } else {
         $codeArr = Posts::decode($code);
         if ($codeArr['type'] != $type || !is_numeric($codeArr['id']) || $codeArr['id'] < 1) {
             $this->jsonOutPut(0, '您所查看的内容不存在');
         }
         $id = $codeArr['id'];
     }
     if (!$uid) {
         $uid = zmf::uid();
     }
     if ($uid) {
         if (zmf::actionLimit('favorite-' . $type, $id)) {
             return array('status' => 0, 'msg' => '操作太频繁,请稍后再试');
         }
     } else {
         //没有登录的访客点收藏时判断是否已收藏过
         if (zmf::actionLimit('favorite-' . $type, $id, 1, 86400, true)) {
             return array('status' => 1, 'msg' => '已点赞', 'state' => 1);
         }
         $uid = 0;
     }
     $postInfo = Posts::model()->findByPk($id);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         return array('status' => 0, 'msg' => '文章不存在');
     }
     $attr = array('uid' => $uid, 'logid' => $id, 'classify' => $type);
     $info = false;
     if ($uid) {
         $info = Favorites::model()->findByAttributes($attr);
     }
     if ($info) {
         if (Favorites::model()->deleteByPk($info['id'])) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', -1, 'favorite');
             }
             return array('status' => 1, 'msg' => '取消点赞', 'state' => 3);
         } else {
             return array('status' => 0, 'msg' => '取消点赞失败', 'state' => 4);
         }
     } else {
         $attr['cTime'] = zmf::now();
         $model = new Favorites();
         $model->attributes = $attr;
         if ($model->save()) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', 1, 'favorite');
             }
             //点赞后给对方发提醒
             $_noticedata = array('uid' => $postInfo['uid'], 'authorid' => $uid, 'content' => "您的文章【{$postInfo['title']}】有了新的赞", 'new' => 1, 'type' => 'favorite', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
             Notification::add($_noticedata);
             return array('status' => 1, 'msg' => '点赞成功', 'state' => 1);
         } else {
             return array('status' => 0, 'msg' => '点赞失败', 'state' => 2);
         }
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:66,代码来源:Posts.php

示例4: actionFavor

 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     //        Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('naodong'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'naodong') {
         $classify = 'favorNaodong';
         $model = new Naodong();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     }
     //        elseif ($info['uid'] == zmf::uid()) {
     //            $this->jsonOutPut(0, '不能操作自己的哦~');
     //        }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 if ($model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid))) {
                     if ($type == 'naodong') {
                         $_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid));
                         $_content = '您的作品有了新的赞,' . $_url;
                         $toNotice = true;
                     }
                     if ($toNotice) {
                         $_noticedata = array('uid' => $info['uid'], 'authorid' => $this->uid, 'content' => $_content, 'new' => 1, 'type' => 'favor', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
                         Notification::add($_noticedata);
                     }
                 }
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:65,代码来源:AjaxController.php

示例5: actionAddComment

 public function actionAddComment()
 {
     $keyid = zmf::val('k', 2);
     $to = zmf::val('to', 2);
     $type = zmf::val('t', 1);
     $content = zmf::val('c', 1);
     $email = zmf::val('email', 1);
     $username = zmf::val('username', 1);
     if (!isset($type) or !in_array($type, array('posts'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     if ($this->uid) {
         $status = Posts::STATUS_PASSED;
         $uid = $this->uid;
     } else {
         if (!$username) {
             $this->jsonOutPut(0, '请填写称呼');
         }
         zmf::setCookie('noLoginUsername', $username, 2592000);
         if ($email != '') {
             $validator = new CEmailValidator();
             if (!$validator->validateValue($email)) {
                 $this->jsonOutPut(0, '请填写正确的邮箱地址');
             }
             zmf::setCookie('noLoginEmail', $email, 2592000);
         }
         $status = Posts::STATUS_STAYCHECK;
         $uid = 0;
         if (zmf::actionLimit($type, $keyid, 5, 86400, true)) {
             $this->jsonOutPut(0, '操作太频繁,请稍后再试');
         }
     }
     $postInfo = Posts::model()->findByPk($keyid);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您所评论的内容不存在');
     }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     $model = new Comments();
     $toNotice = true;
     $touid = $postInfo['uid'];
     if ($to) {
         $comInfo = Comments::model()->findByPk($to);
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'] > 0 ? $comInfo['uid'] : '';
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => '', 'tocommentid' => $to, 'status' => $status, 'username' => $username, 'email' => $email);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 if ($status == Posts::STATUS_PASSED) {
                     Posts::updateCommentsNum($keyid);
                 }
                 $_content = '您的文章有了新的评论,' . $_url;
             }
             if ($to && $_url) {
                 $_content = '您的评论有了新的回复,' . $_url;
             }
             if ($toNotice) {
                 $_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
                 Notification::add($_noticedata);
             }
             if ($uid) {
                 $intoData['loginUsername'] = $this->userInfo['truename'];
             }
             $html = $this->renderPartial('/posts/_comment', array('data' => $intoData, 'postInfo' => $postInfo), true);
             $this->jsonOutPut(1, $html);
         } else {
             $this->jsonOutPut(0, '新增评论失败');
         }
     } else {
         $this->jsonOutPut(0, '新增评论失败');
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:90,代码来源:AjaxController.php

示例6: actionJoinGroup

 public function actionJoinGroup()
 {
     self::checkLogin();
     $uid = zmf::uid();
     $groupid = zmf::filterInput(Yii::app()->request->getParam('gid'));
     if (zmf::actionLimit('joinGroup', $groupid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if (!$groupid || !is_numeric($groupid)) {
         $this->jsonOutPut(0, '加入失败');
     }
     $groupInfo = WeddingGroup::model()->findByPk($groupid);
     if (!$groupInfo) {
         $this->jsonOutPut(0, '您所查看的页面不存在');
     } elseif ($groupInfo['status'] == Posts::STATUS_STAYCHECK) {
         $this->jsonOutPut(0, '该团队暂未通过认证');
     }
     $reInfo = GroupLink::findRelation($uid, $groupid);
     if ($reInfo) {
         //已存在则退出
         if (GroupLink::model()->deleteByPk($reInfo['id'])) {
             $this->jsonOutPut(4, '已退出');
         } else {
             $this->jsonOutPut(0, '退出失败');
         }
     } else {
         $attr = array('groupid' => $groupid, 'uid' => $uid);
         if (GroupLink::add($attr)) {
             $this->jsonOutPut(3, '已加入');
         } else {
             $this->jsonOutPut(0, '加入失败');
         }
     }
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:34,代码来源:AjaxController.php


注:本文中的zmf::actionLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。