示例#1
0
 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
0
 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
0
 public function actionLogin()
 {
     $this->onlyOnPc();
     $this->layout = 'common';
     if (!Yii::app()->user->isGuest) {
         $this->message(0, '您已登录,请勿重复操作');
     }
     $canLogin = true;
     $ip = Yii::app()->request->getUserHostAddress();
     $cacheKey = 'loginErrors-' . $ip;
     $errorTimes = zmf::getFCache($cacheKey);
     if ($errorTimes >= 5) {
         $canLogin = false;
     }
     if ($canLogin) {
         $model = new FrontLogin();
         if (isset($_POST['FrontLogin'])) {
             $model->attributes = $_POST['FrontLogin'];
             if ($model->validate() && $model->login()) {
                 $arr = array('latestLoginTime' => zmf::now());
                 $uid = Yii::app()->user->id;
                 //                    User::model()->updateByPk($uid, $arr);
                 zmf::delCookie('checkWithCaptcha');
                 zmf::delFCache($cacheKey);
                 if ($this->referer) {
                     $this->redirect($this->referer);
                 } else {
                     $this->redirect(zmf::config('baseurl'));
                 }
             } else {
                 zmf::updateFCacheCounter($cacheKey, 1, 3600);
                 zmf::setCookie('checkWithCaptcha', 1, 86400);
             }
         }
     }
     $this->pageTitle = '登录';
     $this->render('login', array('model' => $model));
 }
示例#4
0
 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
0
文件: Posts.php 项目: ph7pal/wedding
 /**
  * 根据文章的标签获取与此最类似的文章
  * @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;
 }
示例#6
0
 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'));
     }
 }
示例#7
0
文件: Users.php 项目: ph7pal/wedding
 /**
  * 获取用户信息
  * @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;
     }
 }