Exemple #1
0
 public static function add($params = array())
 {
     $uid = zmf::uid();
     $data = array('uid' => $params['uid'], 'authorid' => $uid, 'content' => $params['content'], 'new' => 1, 'type' => $params['type'], 'cTime' => zmf::now(), 'from_id' => $params['from_id'], 'from_idtype' => $params['from_idtype'], 'from_num' => 1);
     if ($uid == $params['uid']) {
         return false;
     }
     $model = new Notification();
     $info = $model->find("uid=:uid AND authorid=:authorid AND from_id=:from AND type=:type", array(':uid' => $params['uid'], ':authorid' => $uid, ':from' => $params['from_id'], ':type' => $params['type']));
     if ($info) {
         //存在则更新最新操作时间
         if ($model->updateByPk($info['id'], array('cTime' => time(), 'new' => 1, 'from_num' => $info['from_num'] + 1))) {
             return true;
         } else {
             return false;
         }
     } else {
         //不存在则新增
         $model->attributes = $data;
         if ($model->save()) {
             return true;
         } else {
             return false;
         }
     }
 }
Exemple #2
0
 public function init()
 {
     parent::init();
     $passwdErrorTimes = zmf::getCookie('checkWithCaptcha');
     $time = zmf::config('adminErrorTimes');
     if ($time > 0) {
         if ($passwdErrorTimes >= $time) {
             header('Content-Type: text/html; charset=utf-8');
             echo '您暂时已被禁止访问';
             Yii::app()->end();
         }
     }
     $uid = zmf::uid();
     if ($uid) {
         //            $randKey_cookie = zmf::getCookie('adminRandKey' . $uid);
         //            $randKey_cache = zmf::getFCache('adminRandKey' . $uid);
         //            if (!$randKey_cookie || ($randKey_cache != $randKey_cookie)) {
         //                Yii::app()->user->logout();
         //                $this->message(0, '登录已过期,请重新登录', Yii::app()->createUrl('admin/site/login'));
         //            }
         $this->userInfo = Users::getOne($uid);
         $this->uid = $uid;
     } else {
         $currentUrl = Yii::app()->request->url;
         if (strpos($currentUrl, '/site/') === false) {
             $this->message(0, '请先登录', Yii::app()->createUrl('/site/login'));
         }
     }
 }
Exemple #3
0
Fichier : H.php Projet : ph7pal/mei
 public function init()
 {
     if (!zmf::uid()) {
         $this->redirect(zmf::config('baseurl'));
     }
     Users::checkPower('admin');
     Yii::app()->language = 'zh_cn';
 }
Exemple #4
0
 public function getNum()
 {
     $uid = zmf::uid();
     if (!$uid) {
         return '0';
     }
     $num = Notification::model()->count('new=1 AND uid=:uid', array(':uid' => $uid));
     if ($num > 0) {
         return $num;
     } else {
         return '0';
     }
 }
Exemple #5
0
 function init()
 {
     parent::init();
     $this->layout = 'user';
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($this->uid == zmf::uid()) {
         $this->mySelf = 'yes';
     }
     $this->pageTitle = $this->userInfo['truename'] . ' - ' . zmf::config('sitename');
     $this->mobileTitle = '个人中心';
     $this->pageDescription = $this->userInfo['truename'] . '的【' . zmf::config('sitename') . '】的个人主页,包括TA的原创文章、精美图片及各类悉心收藏,快来看看吧!';
 }
Exemple #6
0
 public static function recordAction($logid, $type, $touid, $uid = '')
 {
     $data = array('uid' => $uid != '' ? $uid : zmf::uid(), 'logid' => $logid, 'touid' => $touid, 'classify' => $type, 'cTime' => time(), 'ip' => ip2long(Yii::app()->request->userHostAddress));
     $model = new UserAction();
     $model->attributes = $data;
     if ($model->validate()) {
         if ($model->save()) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemple #7
0
 function init()
 {
     parent::init();
     Yii::app()->theme = 'web';
     if (zmf::config('mobile')) {
         if (zmf::checkmobile($this->platform)) {
             Yii::app()->theme = 'mobile';
             $this->isMobile = true;
         }
     }
     $uid = zmf::uid();
     if ($uid) {
         $this->uid = $uid;
         $this->userInfo = Users::getOne($uid);
     }
     self::_referer();
 }
Exemple #8
0
Fichier : Q.php Projet : ph7pal/mei
 function init()
 {
     parent::init();
     if (zmf::config('closeSite')) {
         header("Content-type: text/html; charset=utf-8");
         exit(zmf::config('closeSiteReason'));
     }
     $this->uid = zmf::uid();
     if (!Yii::app()->user->isGuest) {
         $uid = Yii::app()->user->id;
         $userInfo = Users::getUserInfo($uid);
         $this->truename = $userInfo['username'];
         $this->userInfo = $userInfo;
     }
     $this->pageTitle = zmf::config('sitename');
     self::_referer();
     $this->mobileTitle = zmf::config('sitename');
 }
Exemple #9
0
 public static function checkFavored($logid, $type)
 {
     if (Yii::app()->user->isGuest) {
         return false;
     }
     if (!is_numeric($logid)) {
         return false;
     }
     if (!isset($type) or !in_array($type, array('posts', 'attachments', 'poi', 'user', 'question', 'goods'))) {
         return false;
     }
     $attr = array('uid' => zmf::uid(), 'logid' => $logid, 'classify' => $type);
     if (Favorites::model()->findByAttributes($attr)) {
         return true;
     } else {
         return false;
     }
 }
Exemple #10
0
 public function init()
 {
     Yii::app()->language = 'zh_cn';
     if (zmf::config('mobile')) {
         if (tools::checkmobile($this->platform)) {
             Yii::app()->theme = 'frozen';
             $this->isMobile = 'yes';
             $this->layout = '//layouts/mobile';
             $this->currentModule = 'frozen';
         }
     }
     if (zmf::uid()) {
         $this->uid = zmf::uid();
         $userInfo = Users::getUserInfo($this->uid);
         $this->truename = $userInfo['truename'];
         $this->userInfo = $userInfo;
     }
     self::_referer();
 }
Exemple #11
0
 function init()
 {
     parent::init();
     if (zmf::config('closeSite')) {
         header("Content-type: text/html; charset=utf-8");
         exit(zmf::config('closeSiteReason'));
     }
     $this->uid = zmf::uid();
     if ($this->uid) {
         $uid = $this->uid;
         $userInfo = Users::getUserInfo($uid);
         $this->truename = $userInfo['truename'];
         $this->userInfo = $userInfo;
         $this->userCode = zmf::jiaMi('zmf#' . $this->uid);
     }
     $this->pageTitle = zmf::config('sitename');
     $this->mobileTitle = zmf::config('sitename');
     if ($this->isMobile == 'yes') {
         Yii::app()->theme = 'mobile';
     } else {
         Yii::app()->theme = 'naodong';
     }
     self::_referer();
 }
Exemple #12
0
 public function actionView($id)
 {
     $this->layout = '/layouts/group';
     $this->currentModule = 'group';
     $info = WeddingGroup::model()->findByPk($id);
     if (!$info) {
         throw new CHttpException(404, '你所查看的页面不存在');
     }
     $info->avatar = $info->getAvatar($info->avatar);
     if (zmf::uid()) {
         $reInfo = GroupLink::findRelation($this->uid, $id);
         if ($reInfo) {
             $this->joined = true;
         }
     }
     //获取团队成员
     $criteria = new CDbCriteria(array('condition' => 'gl.groupid=' . $id, 'join' => 'LEFT JOIN {{group_link}} gl ON t.id=gl.uid', 'select' => 't.id,t.truename,t.avatar'));
     $members = new CActiveDataProvider('Users', array('pagination' => array('pageSize' => 10), 'criteria' => $criteria));
     //获取团队案例列表
     $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p WHERE p.groupid='{$id}' AND p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $posts[$k]['faceimg'] = $_url;
             } else {
                 $posts[$k]['faceimg'] = '';
             }
         }
     }
     $data = array('info' => $info, 'posts' => $posts, 'pages' => $pages);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
Exemple #13
0
 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;
     }
 }
Exemple #14
0
 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'));
 }
Exemple #15
0
 /**
  * 判断发布内容是否应被禁止通过
  * @param string $content
  * @param string $type
  * @return array
  */
 public static function isForbidden($content, $type = 'post')
 {
     //todo,增加开关
     //        $checkStatus=zmf::config('ugcForbidCheck');
     //        if(!$checkStatus){
     //            return array(
     //                'status' => Posts::STATUS_PASSED,
     //                'msg' => '',
     //            );
     //        }
     $status = Posts::STATUS_PASSED;
     $uid = zmf::uid();
     $reason = '';
     $forbidden = false;
     //判断文章的重复率
     $rate = tools::calStrRate($content);
     if ($rate < 0.1) {
         $status = Posts::STATUS_STAYCHECK;
         $reason = '重复率太高';
         $forbidden = true;
     }
     //判断和以前发布的内容的重复率
     if (!$forbidden) {
         $posts = Users::getNewUgc($type, $uid, 5, 'content');
         if (!empty($posts)) {
             foreach ($posts as $val) {
                 $_content = tools::getContentOnly($val['content']);
                 similar_text($_content, $content, $_per);
                 if ($_per >= 85) {
                     $status = Posts::STATUS_STAYCHECK;
                     $reason = '和以前的重复';
                     $forbidden = true;
                     break;
                 }
             }
         }
     }
     //todo,根据内容KNN判断是否是广告
     if (!$forbidden) {
     }
     return array('status' => $status, 'msg' => $reason);
 }
Exemple #16
0
 /**
  * 获取用户绑定的三方信息
  * @param type $type 微博 微信 还是扣扣
  * @param type $uid
  * @return string|array
  */
 public static function getBindInfo($type, $uid = '')
 {
     $arr = array();
     if (!$uid) {
         $uid = zmf::uid();
     }
     if (!$uid) {
         return $arr;
     }
     switch ($type) {
         case 'weibo':
             $info = UserSina::model()->findByPk($uid);
             if ($info && $info['data']) {
                 $data = unserialize($info['data']);
                 $arr['nickname'] = $data['screen_name'];
                 $arr['avatarurl'] = $data['avatarurl'];
                 $arr['profile_url'] = $data['profile_url'];
             }
             break;
         case 'qq':
             $info = UserQq::model()->findByPk($uid);
             if ($info && $info['data']) {
                 $data = unserialize($info['data']);
                 $arr['nickname'] = $data['nickname'];
                 $arr['avatarurl'] = $data['avatarurl'];
                 $arr['profile_url'] = '';
             }
             break;
         case 'weixin':
             $info = UserWeixin::model()->findByPk($uid);
             if ($info && $info['data']) {
                 $data = unserialize($info['data']);
                 $arr['nickname'] = $data['nickname'];
                 $arr['avatarurl'] = $data['headimgurl'];
                 $arr['profile_url'] = '';
             }
             break;
         default:
             break;
     }
     return $arr;
 }
Exemple #17
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'));
     }
 }
Exemple #18
0
 /**
  * 根据当前选择地区生产导航条
  * @param type $areaId 地区ID
  * @param type $areaTitle 地区标题
  * @param type $likeAreas 用户关注的地区
  * @return string
  */
 public static function navbar($areaId = '', $areaTitle = '', $likeAreas = '')
 {
     $arr = $attr = array();
     if ($areaId) {
         $attr['areaid'] = $areaId;
     }
     $arr[] = array('title' => zmf::t('travelStory'), 'url' => Yii::app()->createUrl('posts/story', $attr), 'active' => Yii::app()->getController()->id == 'posts' && Yii::app()->getController()->getAction()->id != 'create');
     $arr[] = array('title' => zmf::t('question'), 'url' => Yii::app()->createUrl('question/index', $attr), 'active' => Yii::app()->getController()->id == 'question' && Yii::app()->getController()->getAction()->id != 'create');
     $arr[] = array('title' => zmf::t('positions'), 'url' => Yii::app()->createUrl('position/index', $attr), 'active' => Yii::app()->getController()->id == 'position');
     //        $arr[] = array(
     //            'title' => zmf::t('travelJournal'),
     //            'url' => Yii::app()->createUrl('travel/index', $attr),
     //            'active' => (Yii::app()->getController()->id == 'travel' && in_array(Yii::app()->getController()->getAction()->id, array('index', 'view')))
     //        );
     $arr[] = array('title' => '约伴', 'url' => Yii::app()->createUrl('yueban/index', $attr), 'active' => Yii::app()->getController()->id == 'yueban');
     $arr[] = array('title' => '什么值得买', 'url' => Yii::app()->createUrl('goods/index', $attr), 'active' => Yii::app()->getController()->id == 'goods');
     $arr[] = array('title' => '<span class="icon-plus"></span> 写游记', 'url' => zmf::uid() ? Yii::app()->createUrl('posts/create') : Yii::app()->createUrl('site/login'), 'active' => Yii::app()->getController()->id == 'posts' && Yii::app()->getController()->getAction()->id == 'create');
     $arr[] = array('title' => '<span class="icon-plus"></span> 提问题', 'url' => zmf::uid() ? Yii::app()->createUrl('question/create') : Yii::app()->createUrl('site/login'), 'active' => Yii::app()->getController()->id == 'question' && Yii::app()->getController()->getAction()->id == 'create');
     return $arr;
 }
Exemple #19
0
 public function actionConfig()
 {
     $keyid = zmf::uid();
     if (!$keyid) {
         $this->redirect(array('site/login'));
     }
     $type = zmf::filterInput($_GET['type'], 't', 1);
     if (!$type || !in_array($type, array('info', 'third', 'avatar'))) {
         $type = 'info';
     }
     $this->userInfo = Users::getUserInfo($keyid);
     if (!$this->userInfo) {
         $this->message(0, '该用户不存在,请核实');
     }
     $data = array('info' => $this->userInfo, 'type' => $type);
     $this->pageTitle = '个人设置 - ' . zmf::config('sitename');
     $this->render('config', $data);
 }
Exemple #20
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     // NOTE: you should only define rules for those attributes that
     // will receive user inputs.
     return array(array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('platform', 'default', 'setOnEmpty' => true, 'value' => tools::getPlatform()), array('uid, logid,content,classify, status, cTime', 'required'), array('status', 'numerical', 'integerOnly' => true), array('uid, touid, logid, commentid, tocommentid, cTime', 'length', 'max' => 11), array('content', 'length', 'max' => 255), array('platform, classify', 'length', 'max' => 16), array('id, uid, touid, logid, commentid, tocommentid, content, platform, classify, status, cTime', 'safe', 'on' => 'search'));
 }
Exemple #21
0
 public function rules()
 {
     return array(array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('lat,long', 'default', 'setOnEmpty' => true, 'value' => '0'), array('areaid,classify', 'required'), array('mapZoom, classify, status,faceimg,forWedding', 'numerical', 'integerOnly' => true), array('areaid, uid, scorer, coster, cTime, updateTime, favorite, hits, attach, wanna, visited,faceimg,redirect', 'length', 'max' => 11), array('title_cn, title_en, title_local, pinyin, address_cn, address_en, address_local, traffic,url, phone, email, fax, brand, openTime, sourceurl, sourceinfo,nickname,ticket,playtime', 'length', 'max' => 255), array('long, lat', 'length', 'max' => 25), array('score, star, units', 'length', 'max' => 6), array('cost', 'length', 'max' => 16), array('content', 'safe'), array('status', 'default', 'setOnEmpty' => true, 'value' => Posts::STATUS_PASSED), array('cTime,updateTime', 'default', 'setOnEmpty' => true, 'value' => time()), array('id, areaid, title_cn, title_en, title_local', 'safe', 'on' => 'search'));
 }
Exemple #22
0
 public function actionUpload()
 {
     $uptype = zmf::filterInput($_GET['type'], 't', 1);
     $logid = zmf::filterInput($_GET['id']);
     //所属对象
     $reImgsize = zmf::filterInput($_GET['imgsize']);
     //返回图片的尺寸
     $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
     //上传控件的ID
     if (!isset($uptype) or !in_array($uptype, array('posts', 'siteinfo'))) {
         $this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
     }
     if (Yii::app()->request->getParam('PHPSESSID')) {
         Yii::app()->session->close();
         $res = Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
         Yii::app()->session->open();
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, '请先登录');
     }
     if (!$fileholder) {
         $fileholder = 'filedata';
     }
     if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) {
         $this->jsonOutPut(0, '无效上传,请重试');
     }
     $img = CUploadedFile::getInstanceByName($fileholder);
     $ext = $img->getExtensionName();
     $size = $img->getSize();
     if ($size > zmf::config('imgMaxSize')) {
         $this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
     }
     $upExt = zmf::config("imgAllowTypes");
     if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
         $this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
     }
     $sizeinfo = getimagesize($_FILES[$fileholder]["tmp_name"]);
     if ($sizeinfo['0'] < zmf::config('imgMinWidth') or $sizeinfo[1] < zmf::config('imgMinHeight')) {
         $this->jsonOutPut(0, "要求上传的图片尺寸,宽不能不小于" . zmf::config('imgMinWidth') . "px,高不能小于" . zmf::config('imgMinHeight') . "px.");
     }
     $ctime = zmf::now();
     $dir = zmf::uploadDirs($ctime, 'app', $uptype);
     zmf::createUploadDir($dir);
     $fileName = zmf::uuid() . '.' . $ext;
     $origin = $dir;
     if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
         $data = array();
         $status = Posts::STATUS_NOTPASSED;
         $data['uid'] = zmf::uid();
         $data['logid'] = $logid;
         $data['filePath'] = $fileName;
         $data['fileDesc'] = '';
         $data['classify'] = $uptype;
         $data['covered'] = '0';
         $data['cTime'] = $ctime;
         $data['status'] = $status;
         $data['width'] = $sizeinfo[0];
         $data['height'] = $sizeinfo[1];
         $data['size'] = $size;
         $model = new Attachments();
         $model->attributes = $data;
         if ($model->save()) {
             $attachid = $model->id;
             $returnImgDir = zmf::getUpExtraUrl($ctime);
             $saveName = $uptype . '/' . $returnImgDir . '/' . $fileName;
             $accessKey = zmf::config('qiniuAk');
             $secretKey = zmf::config('qiniuSk');
             $bucket = zmf::config('qiniuBucket');
             if ($accessKey && $secretKey && $bucket) {
                 $auth = new Auth($accessKey, $secretKey);
                 $token = $auth->uploadToken($bucket);
                 $uploadMgr = new UploadManager();
                 list($ret, $err) = $uploadMgr->putFile($token, $saveName, $origin . $fileName);
                 if ($err !== null) {
                     zmf::fp(var_export($err));
                     $this->jsonOutPut(0, '上传至云服务错误');
                 }
             }
             $returnimg = zmf::uploadDirs($ctime, 'site', $uptype) . $fileName;
             $returnimg = zmf::getThumbnailUrl($returnimg, '650', $uptype);
             $_attr = array('id' => $attachid, 'imgurl' => $returnimg);
             $html = '';
             if ($uptype == 'posts') {
                 //$html=  $this->renderPartial('/posts/_addImg',array('data'=>$_attr),true);
             }
             $outPutData = array('status' => 1, 'attachid' => $attachid, 'imgsrc' => $returnimg, 'html' => $html);
             $json = CJSON::encode($outPutData);
             echo $json;
         } else {
             $this->jsonOutPut(0, '写入数据库错误');
         }
     }
 }
Exemple #23
0
 public function rules()
 {
     return array(array('title,content', 'required'), array('cTime', 'default', 'setOnEmpty' => true, 'value' => zmf::now()), array('status', 'default', 'setOnEmpty' => true, 'value' => Posts::STATUS_PASSED), array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('status, top', 'numerical', 'integerOnly' => true), array('uid, attachid, hits, comments, favors, cTime', 'length', 'max' => 10), array('title, source, sourceurl', 'length', 'max' => 255), array('classify', 'length', 'max' => 16), array('uid, title, classify, content', 'safe', 'on' => 'search'));
 }
Exemple #24
0
 /**
  * 删除内容
  */
 public function actionDelPost()
 {
     $logid = zmf::filterInput($_POST['logid']);
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $admin = false;
     if (empty($logid) or !is_numeric($logid)) {
         $this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
     }
     if (!Yii::app()->request->isAjaxRequest) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     if (!in_array($type, array('naodong', 'comment', 'notice'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if ($type == 'naodong') {
         $tinfo = Naodong::model()->findByPk($logid);
         if (!$tinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($tinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delpost', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => Posts::STATUS_DELED);
         if (Naodong::model()->updateByPk($logid, $attr)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'comment') {
         $cinfo = Comments::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delcomment', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => $status);
         if (Comments::model()->updateByPk($logid, $attr)) {
             if (strtolower($cinfo['classify']) == 'naodong') {
                 Posts::updateCount($cinfo['logid'], 'Naodong', -1, 'comments');
             }
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'notice') {
         $cinfo = Notification::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             $this->jsonOutPut(0, '请勿越权操作');
         }
         if (Notification::model()->deleteByPk($logid)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(0, '操作失败');
         }
     }
 }
Exemple #25
0
$this->renderPartial('/common/_user', array('uid' => $data['uid'], 'userInfo' => $_userInfo, 'type' => 'l'));
if ($data['tocommentid'] > 0) {
    $cominfo = Comments::getSimpleInfo($data['tocommentid']);
    $_cuInfo = Users::getUserInfo($cominfo['uid']);
    ?>
&nbsp;回复&nbsp;<?php 
    $this->renderPartial('/common/_user', array('uid' => $cominfo['uid'], 'userInfo' => $_cuInfo, 'type' => 'l'));
}
?>
</p><p><?php 
echo zmf::filterOutput($data['content'], true);
?>
</p><p class="color-grey"><?php 
echo tools::formatTime($data['cTime']);
?>
<span class="pull-right action-bar"><?php 
if ($data['uid'] != zmf::uid()) {
    echo CHtml::link('举报', 'javascript:void(0)', array('onclick' => 'report(' . $data['id'] . ',"comments");'));
}
if (zmf::uid()) {
    if ($data['uid'] == zmf::uid()) {
        echo CHtml::link('删除', 'javascript:;', array('onclick' => "deletePost('" . $data['id'] . "','comment')"));
    } else {
        echo CHtml::link('回复', 'javascript:void(0)', array('onclick' => 'replyOne("' . $data['id'] . '","' . $data['logid'] . '","' . $_uname . '");'));
        if (Users::checkPower('delcomment', false, true)) {
            echo CHtml::link(zmf::t('delete'), 'javascript:', array('onclick' => 'deletePost("' . $data['id'] . '","comment","")'));
        }
    }
}
?>
</span></p></div></div>
Exemple #26
0
 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);
         }
     }
 }
Exemple #27
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     // NOTE: you should only define rules for those attributes that
     // will receive user inputs.
     return array(array('uid', 'default', 'setOnEmpty' => true, 'value' => zmf::uid()), array('uid, title,code, content', 'required'), array('code', 'unique'), array('status', 'default', 'setOnEmpty' => true, 'value' => Posts::STATUS_PASSED), array('status', 'numerical', 'integerOnly' => true), array('cTime,updateTime', 'default', 'setOnEmpty' => true, 'value' => zmf::now()), array('uid, colid, faceimg, hits, cTime, updateTime', 'length', 'max' => 10), array('code', 'length', 'max' => 16), array('title', 'length', 'max' => 255), array('id, uid, colid, faceimg, code, title, content, hits, cTime, updateTime, status', 'safe', 'on' => 'search'));
 }
Exemple #28
0
<?php

$this->beginContent('/layouts/common');
?>
<div class="top-header">                
    <nav class="navbar navbar-default">
        <div class="container">
        <div class="navbar-header">                        
            <?php 
echo CHtml::link('管理中心', array('index/index'), array('class' => 'navbar-brand'));
?>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <?php 
if (zmf::uid()) {
    ?>
            <ul class="nav navbar-nav">
                <?php 
    $navs = AdminCommon::navbar();
    foreach ($navs as $nav) {
        if (!$nav['seconds']) {
            echo "<li class='" . ($nav['active'] ? 'active' : '') . "'>" . CHtml::link($nav['title'], $nav['url']) . "</li>";
        } else {
            echo "<li class='" . ($nav['active'] ? 'active' : '') . " dropdown'><a href='{$nav['url']}' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>{$nav['title']} <span class='caret'></span></a><ul class='dropdown-menu' role='menu'>";
            foreach ($nav['seconds'] as $val) {
                echo "<li>" . CHtml::link($val['title'], $val['url']) . "</li>";
            }
            echo '</ul></li>';
        }
    }
    ?>
Exemple #29
0
<?php

$this->beginContent('/layouts/common');
$_btnclass = $this->favored ? 'default' : 'default';
$_btntitle = $this->favored ? '<span class="icon-ok"></span>已关注' : '<span class="icon-plus"></span> 关注他';
?>
<div class="user-fixed-topbar">
    <?php 
echo CHtml::link('全站首页', zmf::config('baseurl'));
$uid = zmf::uid();
if ($uid) {
    echo CHtml::link('我的首页', array('users/index', 'id' => $uid));
} else {
    echo CHtml::link('登录', array('site/login'));
    echo CHtml::link('注册', array('site/reg'));
}
?>
</div>
<div class="user-fixed-toolbar">
    <ul>
        <li class="<?php 
echo !$_GET['type'] && Yii::app()->getController()->getAction()->id == 'index' ? 'active' : '';
?>
"><?php 
echo CHtml::link('<i class="icon-home"></i> 首页', array('users/index', 'id' => $this->uid));
?>
</li>
        <li><?php 
echo CHtml::link('<i class="icon-group"></i> 团队', array('users/group', 'id' => $this->uid));
?>
</li>        
 public function actionUpload()
 {
     $uptype = zmf::filterInput($_GET['type'], 't', 1);
     $logid = zmf::filterInput($_GET['id']);
     //所属对象
     $reImgsize = zmf::filterInput($_GET['imgsize']);
     //返回图片的尺寸
     $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
     //上传控件的ID
     //将ads替换为flash
     if (!isset($uptype) or !in_array($uptype, array('columns', 'coverimg', 'flash', 'link', 'album', 'posts', 'poi', 'poipost', 'answer', 'question', 'siteinfo', 'goods', 'group', 'avatar'))) {
         $this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
     }
     if (Yii::app()->request->getParam('PHPSESSID')) {
         Yii::app()->session->close();
         $res = Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
         Yii::app()->session->open();
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     $checkInfo = UserPower::check('addImage', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     if ($uptype == 'poi') {
         if (!$logid || !is_numeric($logid)) {
             $this->jsonOutPut(0, '无效上传,请重试');
         } else {
             $poiInfo = Position::model()->findByPk($logid);
             if (!$poiInfo || $poiInfo['status'] != Posts::STATUS_PASSED) {
                 $this->jsonOutPut(0, '无效上传,请重试');
             }
         }
     }
     if (!$fileholder) {
         $fileholder = 'filedata';
     }
     if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) {
         $this->jsonOutPut(0, '无效上传,请重试');
     }
     $model = new Attachments();
     $img = CUploadedFile::getInstanceByName($fileholder);
     $ext = $img->getExtensionName();
     $size = $img->getSize();
     if ($size > zmf::config('imgMaxSize')) {
         $this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
     }
     $upExt = zmf::config("imgAllowTypes");
     if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
         $this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
     }
     $sizeinfo = getimagesize($_FILES[$fileholder]["tmp_name"]);
     if ($sizeinfo['0'] < zmf::config('imgMinWidth') or $sizeinfo[1] < zmf::config('imgMinHeight')) {
         $this->jsonOutPut(0, "要求上传的图片尺寸,宽不能不小于" . zmf::config('imgMinWidth') . "px,高不能小于" . zmf::config('imgMinHeight') . "px.");
     }
     $ctime = zmf::now();
     $uid = zmf::uid();
     $dirs = zmf::uploadDirs($ctime, 'app', $uptype, null, true);
     $fileName = uniqid() . '.' . $ext;
     $origin = $dirs['origin'];
     unset($dirs['origin']);
     $uploadedFiles = array();
     $uploadedFiles[] = array('from' => $origin . $fileName, 'to' => zmf::ftpPath($ctime, $uptype, 'origin') . $fileName);
     if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
         $data = array();
         if ($uptype == 'posts') {
             $status = Posts::STATUS_DELED;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         $data['uid'] = $uid;
         $data['logid'] = $logid;
         $data['filePath'] = $fileName;
         $data['fileDesc'] = $fileName;
         $data['classify'] = $uptype;
         $data['covered'] = '0';
         $data['cTime'] = time();
         $data['status'] = $status;
         $data['width'] = $sizeinfo[0];
         $data['height'] = $sizeinfo[1];
         $data['size'] = $size;
         if ($uptype == 'poi') {
             $data['areaid'] = $poiInfo['areaid'];
         }
         $model->attributes = $data;
         if ($model->validate()) {
             if ($model->save()) {
                 if ($uptype == 'poi') {
                     Posts::updateCount($logid, 'Position', 1, 'attach');
                 } elseif ($uptype == 'avatar') {
                     Users::model()->updateByPk($uid, array('avatar' => $model->id));
                 }
                 //                    $image = Yii::app()->image->load($origin . $fileName);
                 //                    $_quality = zmf::config('imgQuality');
                 //                    $quality = isset($quality) ? $quality : 100;
                 Yii::import('application.vendors.thinkphp.*');
                 require_once 'ImageGd.php';
                 if (in_array($uptype, array('group', 'avatar'))) {
                     $rate = 1;
                 } else {
                     $rate = 0.75;
                 }
                 foreach ($dirs as $dk => $_dir) {
                     $image = new ImageGd($origin . $fileName);
                     if ($dk < 600) {
                         $image->thumb($dk, $dk * $rate, 'center');
                     } else {
                         $image->thumb($dk, 10000);
                         //$image->water(Yii::app()->basePath . '/../common/images/water.png',2);
                     }
                     $image->save($_dir . $fileName);
                     $_todir = zmf::ftpPath($ctime, $uptype, $dk);
                     $uploadedFiles[] = array('id' => $model->id, 'from' => $_dir . $fileName, 'to' => $_todir . $fileName);
                 }
                 $imgsize = $reImgsize > 0 ? $reImgsize : 170;
                 $returnimg = zmf::uploadDirs($ctime, 'site', $uptype, $imgsize) . $fileName;
                 $outPutData = array('status' => 1, 'attachid' => $model->id, 'imgsrc' => $returnimg);
                 $json = CJSON::encode($outPutData);
                 if (zmf::config('ftpon')) {
                     $asyncdata = "method=ftpupload&json=" . zmf::jiaMi(CJSON::encode($uploadedFiles));
                     AsyncController::Async($asyncdata);
                 }
                 if ($uptype == 'avatar') {
                     zmf::delFCache("userInfo-{$uid}");
                 }
                 echo $json;
             } else {
                 $this->jsonOutPut(0, '写入数据库错误');
             }
         } else {
             $this->jsonOutPut(0, '数据验证错误');
         }
     } else {
         $this->jsonOutPut(0, '移动到指定文件夹出错');
     }
 }