示例#1
0
 public function actionView($id)
 {
     $id = zmf::filterInput($id);
     $info = $this->loadModel($id);
     if ($info['redirect'] > 0) {
         $this->redirect(array('position/view', 'id' => $info['redirect']));
     }
     $_title = '';
     if ($info['title_cn'] != '') {
         $_title = $info['title_cn'];
     }
     if ($info['title_en'] != '' && $_title != '') {
         $_title .= '(' . $info['title_en'] . ')';
     } elseif ($info['title_local'] && $_title != '') {
         $_title .= '(' . $info['title_local'] . ')';
     } elseif ($info['title_en'] != '') {
         $_title .= $info['title_en'];
     } else {
         $_title .= $info['title_local'];
     }
     $_address = '';
     if ($info['address_cn'] != '') {
         $_address = $info['address_cn'];
     } elseif ($info['address_en'] != '') {
         $_address = $info['address_en'];
     } else {
         $_address = $info['address_local'];
     }
     if (!Yii::app()->user->isGuest) {
         if (Favorites::checkFavored($id, 'poi')) {
             $this->favorited = true;
         }
         $tipinfo = PoiPost::model()->findByAttributes(array('logid' => $id, 'uid' => Yii::app()->user->id), 'status=' . Posts::STATUS_PASSED);
         if ($tipinfo) {
             $this->tiped = $tipinfo;
         }
     }
     $info->faceimg = Attachments::faceImg($info, 600);
     //获取图片
     $images = Attachments::model()->findAll(array('condition' => "logid=:id AND " . ($info['faceimg'] > 0 ? "id!=" . $info['faceimg'] . ' AND ' : '') . " classify='poi' AND status=" . Posts::STATUS_PASSED, 'select' => 'id,filePath,classify,cTime', 'limit' => 6, 'order' => 'favor DESC', 'params' => array(':id' => $id)));
     $breads = array();
     $breads[] = CHtml::link('目的地', array('position/index'));
     if ($info['areaid']) {
         $areaInfo = Area::model()->findByPk($info['areaid']);
         if ($areaInfo) {
             $breads[] = CHtml::link($areaInfo['title'], array('position/index', 'areaid' => $areaInfo['id']));
         }
     }
     //获取购买地址
     $buylinks = array();
     if ($info['classify'] == Position::HOTEL) {
         $buylinks = Buylink::getAll('poi', $info->id);
     }
     //更新访问统计
     Posts::updateCount($id, 'Position');
     $breads[] = $_title;
     $this->pageTitle = $_title . ' - ' . zmf::config('sitename');
     $this->pageDescription = '【' . $_title . '】位于' . $_address . ',' . zmf::subStr($info['content'], 200);
     $this->render('view', array('info' => $info, 'type' => $type, 'breads' => $breads, 'buylinks' => $buylinks, 'images' => $images));
 }
示例#2
0
 public static function addAds($uid)
 {
     if (!$uid) {
         return false;
     }
     $model = new Ads();
     $thekeyid = zmf::filterInput($_POST['Ads']['id']);
     $attachid = zmf::filterInput($_POST['Ads']['attachid'], 't', 1);
     $intoData = $_POST['Ads'];
     $intoData['attachid'] = $attachid;
     $intoData['status'] = 1;
     $intoData['uid'] = $uid;
     if (isset($intoData['start_time'])) {
         $intoData['start_time'] = strtotime($intoData['start_time']);
     }
     if (isset($intoData['expired_time'])) {
         $intoData['expired_time'] = strtotime($intoData['expired_time']);
     }
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->updateByPk($thekeyid, $intoData)) {
             zmf::delFCache("notSaveAds{$uid}");
             if ($attachid) {
                 Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), "logid={$thekeyid} AND uid={$uid} AND classify='ads'");
                 Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED), "id={$attachid}");
             }
             return true;
         } else {
             $info = $_POST['Ads'];
         }
     } else {
         $info = $_POST['Ads'];
     }
     return $info;
 }
示例#3
0
文件: Tags.php 项目: ph7pal/momo
 public static function findAndAdd($title, $classify, $logid)
 {
     $title = zmf::filterInput($title, 't', 1);
     if (!$title) {
         return false;
     }
     $info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
     if (!$info) {
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $status = Posts::STATUS_STAYCHECK;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         unset(Yii::app()->session['checkHasBadword']);
         $_data = array('title' => $title, 'name' => zmf::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
         $modelB = new Tags();
         $modelB->attributes = $_data;
         if ($modelB->save()) {
             $tagid = $modelB->id;
         }
     } else {
         $tagid = $info['id'];
     }
     if ($tagid && $logid) {
         $_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
         if (!$_info) {
             $_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
             $modelC = new TagRelation();
             $modelC->attributes = $_tagre;
             $modelC->save();
         }
     }
     return $tagid;
 }
示例#4
0
 public function actionView($code)
 {
     $code = zmf::filterInput($code, 't', 1);
     $info = SiteInfo::model()->find('code=:code', array(':code' => $code));
     if (!$info) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'status=' . Posts::STATUS_PASSED));
     //更新访问统计
     Posts::updateCount($info['id'], 'SiteInfo');
     $data = array('info' => $info, 'allInfos' => $allInfos, 'code' => $code);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('/site/siteinfo', $data);
 }
示例#5
0
 public function actionManage()
 {
     $id = zmf::filterInput($_POST['id']);
     if (!Yii::app()->request->isAjaxRequest) {
         Admin::jsonOutPut(0, '不允许的操作');
     }
     if (!isset($id) or !is_numeric($id)) {
         Admin::jsonOutPut(0, '缺少参数');
     }
     $status = Feedback::STATUS_CHECKED;
     if (Feedback::model()->updateByPk($id, array('status' => $status))) {
         Admin::jsonOutPut(1, '操作成功!');
     } else {
         Admin::jsonOutPut(0, '操作失败');
     }
 }
示例#6
0
 public function actionUpdate($type)
 {
     if (!in_array($type, array('info', 'passwd'))) {
         $this->message(0, '您的操作有误');
     }
     if (isset($_POST) and !empty($_POST)) {
         $model = new Users();
         if ($type == 'info') {
             $intoData['truename'] = zmf::filterInput($_POST['truename'], 't', 1);
             if (!$intoData['truename']) {
                 $this->message(0, '用户名不能为空');
             }
             //如果用户修改了用户名,则判断是否被使用
             if ($intoData['truename'] != $this->userInfo['truename']) {
                 $info = Users::getInfoByName($intoData['truename']);
                 if ($info) {
                     $this->message(0, '该用户名已被使用');
                 }
             }
             $intoData['url'] = zmf::filterInput($_POST['url'], 't', 1);
             $intoData['desc'] = zmf::filterInput($_POST['desc'], 't', 1);
         } elseif ($type == 'passwd') {
             $old = zmf::filterInput($_POST['old_password'], 't', 1);
             $info = Users::model()->findByPk($this->uid);
             if (!$old) {
                 $this->message(0, '请输入原始密码');
             } elseif (md5($old) != $info['password']) {
                 $this->message(0, '原始密码不正确');
             }
             if (!$_POST['password']) {
                 $this->message(0, '请输入密码');
             } elseif (strlen($_POST['password']) < 5) {
                 $this->message(0, '新密码过短,请重新输入');
             }
             $intoData['password'] = md5($_POST['password']);
         }
         if ($model->updateByPk($this->uid, $intoData)) {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/index'));
         } else {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/index'));
         }
     }
     $data = array('info' => $this->userInfo, 'type' => $type);
     $this->render('update', $data);
 }
示例#7
0
 public function actionAdd()
 {
     $this->checkPower('setConfig');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     if ($type == '' or !in_array($type, array('baseinfo', 'upload', 'base', 'email'))) {
         $type = 'baseinfo';
     }
     unset($_POST['type']);
     unset($_POST['YII_CSRF_TOKEN']);
     $configs = $_POST;
     if (!empty($configs)) {
         foreach ($configs as $k => $v) {
             if (is_array($v)) {
                 $v = join(',', $v);
             }
             //组织出hash,根据变量、变量的值及分类的md5
             $_hash = md5($k . $v . $type);
             //如果能找到hash则说明该设置未变化
             $_configInfo = Config::model()->find('`hash`=:hash', array(':hash' => $_hash));
             if (!$_configInfo) {
                 //没找到说明已更改或者不存在该设置
                 //根据name和classify判断是否有该设置,没有则新增,有则更新
                 $_detailInfo = Config::model()->find('`name`=:name AND classify=:type', array(':name' => $k, ':type' => $type));
                 if (!$_detailInfo) {
                     //新增
                     $data = array('name' => zmf::filterInput($k, 't'), 'value' => zmf::filterInput($v, 't'), 'classify' => zmf::filterInput($type, 't'), 'hash' => $_hash);
                     $model = new Config();
                     $model->attributes = $data;
                     $model->save();
                 } else {
                     //更新
                     Config::model()->updateByPk($_detailInfo['id'], array('value' => zmf::filterInput($v, 't'), 'hash' => $_hash));
                 }
             } else {
                 //未做变化,不操作
             }
         }
     }
     //更新本地配置缓存
     $_c = Config::model()->findAll();
     $configs = CHtml::listData($_c, 'name', 'value');
     zmf::writeSet($configs);
     $this->redirect(array('config/index', 'type' => $type));
 }
示例#8
0
 /**
  * 婚庆列表
  */
 public function actionIndex()
 {
     $this->selectedType = zmf::filterInput($_GET['type']);
     if (!$this->selectedType || !in_array($this->selectedType, array('1', '2'))) {
         $this->selectedType = '1';
     }
     if ($this->selectedType == 1) {
         //用户
         $criteria = new CDbCriteria();
         $criteria->condition = 'classify=' . Users::USER_CLASSIFY_WEDDING;
         $criteria->select = 'id,truename,avatar,sex,tagids,content';
         //            $criteria->order = 'cTime DESC';
         $count = Users::model()->count($criteria);
         $pager = new CPagination($count);
         $pager->pageSize = 30;
         $pager->applyLimit($criteria);
         $posts = Users::model()->findAll($criteria);
         if (!empty($posts)) {
             foreach ($posts as $k => $val) {
                 $posts[$k]['avatarImg'] = Users::getAvatar($val['avatar']);
                 $posts[$k]['tagids'] = Tags::getByIds($val['tagids']);
             }
         }
     } elseif ($this->selectedType == 2) {
         //团队
         $criteria = new CDbCriteria();
         $criteria->order = 'cTime DESC';
         $count = WeddingGroup::model()->count($criteria);
         $pager = new CPagination($count);
         $pager->pageSize = 30;
         $pager->applyLimit($criteria);
         $posts = WeddingGroup::model()->findAll($criteria);
         if (!empty($posts)) {
             foreach ($posts as $k => $val) {
                 $posts[$k]['avatar'] = Users::getAvatar($val['avatar']);
             }
         }
     }
     //面包屑
     $breads[] = CHtml::link('婚庆', array('group/index'));
     $this->pageTitle = '婚礼人 - ' . zmf::config('sitename');
     $this->render('index', array('pages' => $pager, 'posts' => $posts, 'breads' => $breads));
 }
示例#9
0
 public function actionView($id)
 {
     $id = zmf::filterInput($id);
     if (!$id || !is_numeric($id)) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     $info = Naodong::model()->findByPk($id);
     if ($info == NULL) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     //更新访问次数
     Posts::updateCount($id, 'Naodong');
     //获取评论列表
     $sql = "SELECT * FROM {{comments}} WHERE logid='{$id}' AND classify='naodong' AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime ASC";
     Posts::getAll(array('sql' => $sql, 'pageSize' => 2), $pages, $comLists);
     //获取上下篇
     $preInfo = Naodong::model()->find(array('condition' => 'id>:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $nextInfo = Naodong::model()->find(array('condition' => 'id<:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $authorInfo = $recommends = array();
     if ($info['uid']) {
         //获取作者信息
         $authorInfo = Users::getUserInfo($info['uid']);
         //获取作者相关推荐
         $recommends = Naodong::getRecommends($info['uid'], $id);
     }
     //获取是否赞过
     if ($this->uid) {
         if (UserAction::checkAction($id, 'favorNaodong')) {
             $this->favored = true;
         }
     }
     $data = array('info' => $info, 'posts' => $comLists, 'pages' => $pages, 'userInfo' => $authorInfo, 'recommends' => $recommends, 'preInfo' => $preInfo, 'nextInfo' => $nextInfo);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->pageDescription = zmf::subStr($info['content'], 140);
     $this->mobileTitle = $authorInfo['truename'];
     $this->render('/index/view', $data);
 }
示例#10
0
文件: AppApi.php 项目: ph7pal/mei
 /**
  * 根据名称返回$_GET或$_POST的数据
  * @param type $key
  * @param type $notEmpty
  * @param type $ttype
  * @param type $textonly 0富文本,1纯文本,2数字,默认纯文本
  * @return type
  */
 public function getValue($key, $notEmpty = false, $textonly = 1, $decode = 0)
 {
     $return = zmf::filterInput($_GET[$key], $textonly);
     $arr = array('uid' => '作者ID', 'content' => '内容', 'type' => '类型', 'token' => '请求错误,请退出应用并重新启动');
     if ($notEmpty) {
         if (empty($return)) {
             $_info = $arr[$key];
             if (!$_info) {
                 $_info = $key;
             }
             self::output('[' . $_info . ']不能为空', $this->errorCode);
         }
     }
     return $return;
 }
示例#11
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, '操作失败');
         }
     }
 }
示例#12
0
 public function actionReg()
 {
     if (!Yii::app()->user->isGuest) {
         $this->message(0, '您已登录,请勿重复操作');
     }
     $model = new Users();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-addUser-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['Users'])) {
         if (UserAction::checkRegTimes()) {
             $this->message(0, '您今天的注册次数已用完');
         }
         $email = zmf::filterInput($_POST['Users']['email'], 't', 1);
         $truename = zmf::filterInput($_POST['Users']['truename'], 't', 1);
         $inputData = array('truename' => $truename, 'password' => $_POST['Users']['password'] != '' ? md5($_POST['Users']['password']) : '', 'email' => $email);
         $model->attributes = $inputData;
         if ($model->validate()) {
             if ($model->save()) {
                 $_model = new LoginForm();
                 $_model->email = $email;
                 $_model->password = $_POST['Users']['password'];
                 $_model->login();
                 $this->referer = array('users/index', 'id' => Yii::app()->user->id);
                 $this->redirect($this->referer);
             }
         }
     }
     $data = array('model' => $model);
     $this->pageTitle = '免费注册 - ' . zmf::config('sitename');
     $this->render('addUser', $data);
 }
示例#13
0
文件: tools.php 项目: ph7pal/mei
 /**
  * 获取传参
  * @param type $key,参数的键名
  * @param type $ttype,传参类型,n:数字,t:文本
  * @param type $textonly,是否纯文本
  * @return boolean
  */
 public static function val($key, $ttype = 'n', $textonly = 1)
 {
     $return = zmf::filterInput(Yii::app()->request->getParam($key), $ttype, $textonly);
     return $return;
 }
示例#14
0
 /**
  * 不入数据库的上传
  * 不做压缩和缩略图处理
  */
 public function actionSimpleUpload()
 {
     $uptype = zmf::filterInput($_GET['type'], 't', 1);
     $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
     //上传控件的ID
     $fileName = zmf::filterInput($_GET['fileName'], 't', 1);
     //上传后保存名字
     $keyid = zmf::filterInput($_GET['keyid']);
     //所属对象ID
     if (!isset($uptype) or !in_array($uptype, array('topArea', 'avatar'))) {
         $this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
     }
     if (Yii::app()->request->getParam('PHPSESSID')) {
         Yii::app()->session->close();
         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'));
     }
     if ($uptype == 'avatar' && !$keyid) {
         $this->jsonOutPut(0, '缺少参数');
     }
     $checkInfo = UserPower::check('addImage', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     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);
     }
     if (!$fileName) {
         $fileName = uniqid() . '.' . $ext;
     }
     if ($uptype == 'avatar') {
         $fileName = $keyid . '.jpg';
     }
     if ($uptype == 'topArea') {
         $todir = zmf::attachBase('app') . '/daodao/';
         $returnDir = zmf::attachBase('site') . '/daodao/';
     } elseif ($uptype == 'avatar') {
         $todir = zmf::attachBase('app') . '/avatar/origin/' . $keyid . '/';
         $todir2 = zmf::attachBase('app') . '/avatar/big/' . $keyid . '/';
         $todir3 = zmf::attachBase('app') . '/avatar/small/' . $keyid . '/';
         $returnDir = zmf::attachBase('site') . '/avatar/small/' . $keyid . '/';
     }
     zmf::createUploadDir($todir);
     if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $todir . $fileName)) {
         if ($uptype == 'avatar') {
             $image = Yii::app()->image->load($todir . $fileName);
             zmf::createUploadDir($todir2);
             zmf::createUploadDir($todir3);
             $image->smart_resize(100, 100)->quality(95);
             $image->save($todir2 . $fileName);
             $image->smart_resize(50, 50)->quality(95);
             $image->save($todir3 . $fileName);
         }
         $outPutData = array('status' => 1, 'imgsrc' => $returnDir . $fileName, 'attachid' => '');
         $json = CJSON::encode($outPutData);
         echo $json;
     } else {
         $this->jsonOutPut(0, '上传失败');
     }
 }
示例#15
0
 /**
  * 不入数据库的上传
  * 不做压缩和缩略图处理
  */
 public function actionSimpleUpload()
 {
     $uptype = zmf::filterInput($_GET['type'], 't', 1);
     $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
     //上传控件的ID
     $fileName = zmf::filterInput($_GET['fileName'], 't', 1);
     //上传后保存名字
     $keyid = zmf::filterInput($_GET['keyid']);
     //所属对象ID
     if (!isset($uptype) or !in_array($uptype, array('avatar'))) {
         $this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
     }
     if (Yii::app()->request->getParam('PHPSESSID')) {
         Yii::app()->session->close();
         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 (!$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);
     }
     if (!$fileName) {
         $fileName = uniqid() . '.' . $ext;
     }
     if ($uptype == 'avatar') {
         $fileName = $keyid . '.jpg';
     }
     $ctime = zmf::now();
     $dirs = zmf::uploadDirs($ctime, 'app', $uptype, null, true);
     $fileName = uniqid() . '.' . $ext;
     $origin = $dirs['origin'];
     unset($dirs['origin']);
     $fileNameWithoutDomain = zmf::getUpExtraUrl($ctime) . '/600_' . $fileName;
     //相对于网站的存放路径
     if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
         Yii::import('application.vendors.thinkphp.*');
         require_once 'ImageGd.php';
         foreach ($dirs as $dk => $_dir) {
             $image = new ImageGd($origin . $fileName);
             $image->thumb($dk, $dk, 'center');
             $image->save($_dir . $fileName);
         }
         Users::model()->updateByPk($this->uid, array('avatar' => $fileNameWithoutDomain));
         $imgsize = $reImgsize > 0 ? $reImgsize : 170;
         $returnimg = zmf::uploadDirs($ctime, 'site', $uptype, $imgsize) . $fileName;
         $outPutData = array('status' => 1, 'imgsrc' => $returnimg, 'attachid' => '');
         $json = CJSON::encode($outPutData);
         echo $json;
     } else {
         $this->jsonOutPut(0, '上传失败');
     }
 }
示例#16
0
 /**
  * 按地区显示的主页
  */
 public function actionShow()
 {
     $areaid = zmf::filterInput($_GET['areaid']);
     $where = $order = $areaInfo = '';
     if ($areaid) {
         $extra = Area::getAreaInfo($areaid);
         $areaIds = $extra['areaIds'];
         $areaInfo = $extra['areaInfo'];
         if ($areaIds) {
             $where .= " areaid IN({$areaIds}) AND ";
         }
     }
     //获取热门游记
     $_postsql = "SELECT * FROM {{posts}} WHERE {$where} classify='" . Posts::CLASSIFY_TRAVEL_LOG . "' AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime DESC LIMIT 8";
     $posts = Yii::app()->db->createCommand($_postsql)->queryAll();
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             $posts[$k]['coltitle'] = '';
             if ($p['colid']) {
                 $coltitle = Column::getOne($p['colid'], 'title');
                 if ($coltitle) {
                     $posts[$k]['coltitle'] = $coltitle;
                 }
             }
         }
     }
     //获取图片
     //        $_attsql = "SELECT * FROM {{attachments}} WHERE areaid IN(" . $this->areaIds . ") AND classify='poi' AND status=" . Posts::STATUS_PASSED . " ORDER BY  cTime DESC LIMIT 8";
     //        $attaches = Yii::app()->db->createCommand($_attsql)->queryAll();
     //获取点评
     //        $_postsql = "SELECT * FROM {{poi_post}} WHERE areaid IN(" . $this->areaIds . ") AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime DESC LIMIT 5";
     //        $poiposts = Yii::app()->db->createCommand($_postsql)->queryAll();
     //        foreach ($poiposts as $k => $poipost) {
     //            $_info = Posts::getSimpleInfo(array('keyid' => $poipost['logid'], 'origin' => 'position'), 'title');
     //            $poiposts[$k]['poiTitle'] = $_info;
     //        }
     //将问题和回答混合到动态里
     //        $_qasql = "SELECT * FROM ((SELECT 'question' AS type,id,uid,'logid',title,content,cTime,answers,comments,favorite AS favor,'nouse' FROM {{question}} WHERE areaid IN(" . $this->areaIds . ") AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime DESC LIMIT 5) UNION (SELECT 'answer' AS type,id,uid,logid,'title',content,cTime,'answers',comments,favor,nouse FROM {{answer}} WHERE areaid IN(" . $this->areaIds . ") AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime DESC LIMIT 5)) as t ORDER BY t.cTime DESC";
     //        $questions = Yii::app()->db->createCommand($_qasql)->queryAll();
     //        foreach ($questions as $k => $v) {
     //            if ($v['type'] == 'answer') {
     //                $_info = Posts::getSimpleInfo(array('keyid' => $v['logid'], 'origin' => 'question'), 'title');
     //                $questions[$k]['qtitle'] = $_info;
     //            }
     //        }
     //热门坐标
     $_poisql = "SELECT id,title_cn,title_en,title_local,address_cn,address_en,address_local,score,scorer,attach,lat,`long`,faceimg,classify FROM {{position}} WHERE {$where} status=" . Posts::STATUS_PASSED . " ORDER BY scorer DESC LIMIT 5";
     $positions = Yii::app()->db->createCommand($_poisql)->queryAll();
     //获取小提示
     //        $_poi_tips_sql = "SELECT 'PoiTips' AS type,id,uid,content,'score','cost',favor,comments,cTime,platform FROM {{poi_tips}} WHERE logid={$this->theAreaId} AND classify=" . Position::AREA . " AND status=" . Posts::STATUS_PASSED . " ORDER BY favor LIMIT 10";
     //        $poitips = Yii::app()->db->createCommand($_poi_tips_sql)->queryAll();
     //        //获取所有受推荐地区
     $areas = Area::getTops(0);
     //面包屑
     $breads[] = CHtml::link('目的地', array('position/index'));
     //页面SEO
     //        $this->pageTitle = $this->areaInfo['title'] . '攻略,' . $this->areaInfo['title'] . '游记,' . $this->areaInfo['title'] . '行程推荐,' . $this->areaInfo['title'] . '问答 - ' . zmf::config('sitename');
     //        $this->keywords = zmf::time('', 'Y年') . $this->areaInfo['title'] . '游记,' . $this->areaInfo['title'] . '行程推荐,' . $this->areaInfo['title'] . '问答,' . $this->areaInfo['title'] . '景点';
     //        $this->pageDescription = '【' . $this->areaInfo['title'] . '】' . $this->areaInfo['title'] . '游记,' . $this->areaInfo['title'] . '照片,' . $this->areaInfo['title'] . '热门景点、酒店、餐厅、购物以及与' . $this->areaInfo['title'] . '有关的问与答';
     $data = array('areaInfo' => $areaInfo, 'areaid' => $areaid, 'posts' => $posts, 'areas' => $areas, 'breads' => $breads, 'attaches' => $attaches, 'poiposts' => $poiposts, 'questions' => $questions, 'positions' => $positions, 'poitips' => $poitips, 'weather' => $weather);
     $this->render('show', $data);
 }
示例#17
0
 public function actionReg()
 {
     $type = zmf::filterInput($_GET['type'], 't', 1);
     $modelUser = new Users();
     switch ($type) {
         case 'doctor':
             $model = new Doctor();
             $view = $type;
             break;
         case 'hospital':
             $model = new Hospital();
             $view = $type;
             break;
         default:
             $view = 'user';
     }
     if (isset($_POST['Users'])) {
         //            if (UserAction::checkRegTimes()) {
         //                $this->message(0, '您今天的注册次数已用完');
         //            }
         $email = zmf::filterInput($_POST['Users']['email'], 't', 1);
         $username = zmf::filterInput($_POST['Users']['username'], 't', 1);
         $classify = Users::CLASSIFY_COMMON_USER;
         if (isset($_POST['Doctor'])) {
             $classify = Users::CLASSIFY_DOCTOR;
         } elseif (isset($_POST['Hospital'])) {
             $classify = Users::CLASSIFY_HOSPITAL;
         }
         $inputData = array('username' => $username, 'password' => $_POST['Users']['password'], 'phone' => $_POST['Users']['phone'], 'email' => $email);
         if ($type == 'doctor') {
             $returnModel = $this->doctorReg($modelUser, $model, $inputData, $_POST['Doctor']);
             $modelUser = $returnModel['modelUser'];
             $model = $returnModel['model'];
         } elseif ($type == 'hospital') {
             $returnModel = $this->hospitalReg($modelUser, $model, $inputData, $_POST['Hospital']);
             $modelUser = $returnModel['modelUser'];
             $model = $returnModel['model'];
         } else {
             $modelUser = $this->commonUserReg($modelUser, $inputData);
         }
     }
     $data = array('modelUser' => $modelUser, 'model' => $model);
     $this->render($view, $data);
 }
示例#18
0
 public function actionLogin($from = '')
 {
     if (!Yii::app()->user->isGuest) {
         $this->message(0, '您已登录,请勿重复操作');
     }
     if (!$from) {
         $from = 'login';
     }
     $bind = tools::val('bind', 't');
     $model = new LoginForm();
     //登录
     $modelUser = new Users();
     //注册
     if ($bind == 'weibo') {
         $strdata = zmf::getCookie('userWeiboData');
         //取出cookie中用户的微博信息
         if ($strdata) {
             $data = unserialize($strdata);
             $modelUser->truename = $data['screen_name'];
         }
     } elseif ($bind == 'qq') {
         $strdata = zmf::getCookie('userQQData');
         //取出cookie中用户的微博信息
         if ($strdata) {
             $data = unserialize($strdata);
             $modelUser->truename = $data['nickname'];
         }
     } elseif ($bind == 'weixin') {
         $strdata = zmf::getCookie('userWeixinData');
         //取出cookie中用户的微博信息
         if ($strdata) {
             $data = unserialize($strdata);
             $modelUser->truename = $data['nickname'];
         }
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-addUser-form') {
         echo CActiveForm::validate($modelUser);
         Yii::app()->end();
     }
     //登录
     if (isset($_POST['LoginForm'])) {
         $from = 'login';
         $model->attributes = $_POST['LoginForm'];
         if ($model->validate()) {
             $hasBind = false;
             //判断是否绑定过微博
             if ($bind == 'weibo') {
                 $strdata = zmf::getCookie('userWeiboData');
                 //取出cookie中用户的微博信息
                 if (!$strdata) {
                     $model->addError('email', '未能获取微博绑定信息,请重试');
                 } else {
                     $binddata = unserialize($strdata);
                 }
                 //根据当前用户名获取他是否已经绑定过
                 $email = $_POST['LoginForm']['email'];
                 $validator = new CEmailValidator();
                 if ($validator->validateValue($email)) {
                     $user = Users::model()->find('email=:email', array(':email' => $email));
                 } else {
                     $user = Users::model()->find('truename=:truename', array(':truename' => $email));
                 }
                 if ($user) {
                     $bindInfo = UserSina::model()->findByPk($user['id']);
                     if ($bindInfo) {
                         $hasBind = true;
                     }
                     $binddata['uid'] = $user['id'];
                 }
             } elseif ($bind == 'qq') {
                 $strdata = zmf::getCookie('userQQData');
                 //取出cookie中用户的微博信息
                 if (!$strdata) {
                     $model->addError('email', '未能获取微博绑定信息,请重试');
                 } else {
                     $binddata = unserialize($strdata);
                 }
                 //根据当前用户名获取他是否已经绑定过
                 $email = $_POST['LoginForm']['email'];
                 $validator = new CEmailValidator();
                 if ($validator->validateValue($email)) {
                     $user = Users::model()->find('email=:email', array(':email' => $email));
                 } else {
                     $user = Users::model()->find('truename=:truename', array(':truename' => $email));
                 }
                 if ($user) {
                     $bindInfo = UserQq::model()->findByPk($user['id']);
                     if ($bindInfo) {
                         $hasBind = true;
                     }
                     $binddata['uid'] = $user['id'];
                 }
             } elseif ($bind == 'weixin') {
                 $strdata = zmf::getCookie('userWeixinData');
                 //取出cookie中用户的微博信息
                 if (!$strdata) {
                     $model->addError('email', '未能获取微信绑定信息,请重试');
                 } else {
                     $binddata = unserialize($strdata);
                 }
                 //根据当前用户名获取他是否已经绑定过
                 $email = $_POST['LoginForm']['email'];
                 $validator = new CEmailValidator();
                 if ($validator->validateValue($email)) {
                     $user = Users::model()->find('email=:email', array(':email' => $email));
                 } else {
                     $user = Users::model()->find('truename=:truename', array(':truename' => $email));
                 }
                 if ($user) {
                     $bindInfo = UserWeixin::model()->findByPk($user['id']);
                     if ($bindInfo) {
                         $hasBind = true;
                     }
                     $binddata['uid'] = $user['id'];
                 }
             }
             if ($hasBind) {
                 $model->addError('email', '该账号已绑定其他账号');
             } elseif ($model->login()) {
                 $arr = array('last_login_ip' => ip2long(Yii::app()->request->userHostAddress), 'last_login_time' => time());
                 Users::model()->updateByPk(Yii::app()->user->id, $arr);
                 Users::model()->updateCounters(array('login_count' => 1), ':id=id', array(':id' => Yii::app()->user->id));
                 if ($this->referer == '') {
                     $this->referer = array('users/index', 'id' => Yii::app()->user->id);
                 }
                 zmf::delCookie('checkWithCaptcha');
                 //微博绑定已有账号
                 if ($bind == 'weibo') {
                     UserSina::addCookie($binddata);
                 } elseif ($bind == 'qq') {
                     UserQq::addCookie($binddata);
                 } elseif ($bind == 'weixin') {
                     UserWeixin::addCookie($binddata);
                 }
                 $this->redirect($this->referer);
             }
         } else {
             zmf::setCookie('checkWithCaptcha', 1, 86400);
         }
     } elseif (isset($_POST['Users'])) {
         $from = 'reg';
         //注册
         if (UserAction::checkRegTimes()) {
             $this->message(0, '您今天的注册次数已用完');
         }
         $email = zmf::filterInput($_POST['Users']['email'], 't', 1);
         $truename = zmf::filterInput($_POST['Users']['truename'], 't', 1);
         $inputData = array('truename' => $truename, 'password' => $_POST['Users']['password'] != '' ? md5($_POST['Users']['password']) : '', 'email' => $email, 'cTime' => time(), 'register_time' => time(), 'last_login_time' => time(), 'groupid' => zmf::config('userDefaultGroup'), 'register_ip' => ip2long(Yii::app()->request->userHostAddress), 'last_login_ip' => ip2long(Yii::app()->request->userHostAddress));
         $modelUser->attributes = $inputData;
         if ($modelUser->validate()) {
             if ($modelUser->save()) {
                 $_model = new LoginForm();
                 $_model->email = $email;
                 $_model->password = $_POST['Users']['password'];
                 $_model->login();
                 if ($bind == 'weibo') {
                     $strdata = zmf::getCookie('userWeiboData');
                     //取出cookie中用户的微博信息
                     if ($strdata) {
                         $binddata = unserialize($strdata);
                         $binddata['uid'] = Yii::app()->user->id;
                         UserSina::addCookie($binddata);
                     }
                 } elseif ($bind == 'qq') {
                     $strdata = zmf::getCookie('userQQData');
                     //取出cookie中用户的微博信息
                     if ($strdata) {
                         $binddata = unserialize($strdata);
                         $binddata['uid'] = Yii::app()->user->id;
                         UserQq::addCookie($binddata);
                     }
                 } elseif ($bind == 'weixin') {
                     $strdata = zmf::getCookie('userWeixinData');
                     //取出cookie中用户的微信信息
                     if ($strdata) {
                         $binddata = unserialize($strdata);
                         $binddata['uid'] = Yii::app()->user->id;
                         UserWeixin::addCookie($binddata);
                     }
                 }
                 //登录成功后跳转到修改个人资料页面
                 $this->redirect(array('users/update', 'type' => 'info'));
             }
         }
     }
     if ($bind) {
         $this->loginTitle = '绑定已有账户';
         $this->regTitle = '完善资料';
     } else {
         $this->loginTitle = '登录';
         $this->regTitle = '注册';
     }
     if ($from == 'login') {
         $this->pageTitle = $this->loginTitle . ' - ' . zmf::config('sitename');
     } else {
         $this->pageTitle = $this->regTitle . ' - ' . zmf::config('sitename');
     }
     //登录页面的幻灯片
     $flashArr = Ads::getAllByPo('twindex', 'flash', '', 5);
     if (!empty($flashArr)) {
         foreach ($flashArr as $k => $val) {
             $_imgurl = zmf::uploadDirs($val['cTime'], 'site', $val['classify'], 600) . $val['filePath'];
             $flashArr[$k]['imgurl'] = $_imgurl;
         }
     }
     $this->render('login', array('model' => $model, 'modelUser' => $modelUser, 'from' => $from, 'flashs' => $flashArr));
 }
示例#19
0
 /**
  * 已取消其他文章类型,默认为游记
  * @param type $classify,分类
  */
 public function actionCreate($id = '')
 {
     $id = zmf::filterInput($id);
     if (!zmf::uid()) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
         if ($model->uid != zmf::uid()) {
             if (!Users::checkPower('editpost', false, true)) {
                 throw new CHttpException(403, '不被允许的操作.');
             }
         }
     } else {
         $model = new Posts();
         $model->classify = Posts::CLASSIFY_WEDDING;
         //文章分类
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['Posts'])) {
         //判断是否应被禁止
         //todo,应排除编辑
         //            $forbidInfo = Posts::isForbidden($_POST['Posts']['content'], 'post');
         //            if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
         //                //todo,增加用户非法操作次数
         //                $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
         //            }
         //处理文本
         $filter = Posts::handleContent($_POST['Posts']['content']);
         $_POST['Posts']['content'] = $filter['content'];
         foreach ($_POST['Posts'] as $k => $val) {
             $_POST['Posts'][$k] = zmf::filterInput($val, 't');
         }
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
         }
         if (!$model->isNewRecord) {
             $_POST['Posts']['updateTime'] = zmf::now();
             $isNew = false;
         } else {
             $isNew = true;
         }
         unset(Yii::app()->session['checkHasBadword']);
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['Posts']['faceimg'] = $attkeys[0];
                 //默认将文章中的第一张图作为封面图
             }
         } else {
             $_POST['Posts']['faceimg'] = '';
             //否则将封面图置为空(有可能编辑后没有图片了)
         }
         //相关标签
         $tags = $_POST['tagnames'];
         $tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
         $model->attributes = $_POST['Posts'];
         if ($model->save()) {
             //将上传的图片置为通过
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             //相关标签
             $tagids = array();
             if (!empty($tags)) {
                 foreach ($tags as $str) {
                     $_tmp = explode('-', $str);
                     if ($_tmp[1] > 0) {
                         //添加对应关系
                         if (Tags::addRelation($_tmp[1], $model->id, 'posts')) {
                             $tagids[] = $_tmp[1];
                         }
                     } else {
                         //查找是否有对应话题
                         $_tagid = Tags::findAndAdd($_tmp[0], 'posts', $model->id);
                         if ($_tagid) {
                             $tagids[] = $_tagid;
                         }
                     }
                 }
                 $tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
                 $tagStr = join(',', $tagids);
                 if ($tagStr != '') {
                     Posts::model()->updateByPk($model->id, array('tagids' => $tagStr));
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     //未认证用户不能创建团队
     if (!$this->userInfo['creditStatus']) {
         $this->message(0, '请完善资料并提交个人认证', Yii::app()->createurl('users/config', array('type' => 'info')));
     }
     //文章分类
     $cols = Column::allCols(1, 0, 1, Posts::CLASSIFY_WEDDING);
     if (!$model->isNewRecord) {
         $model->content = zmf::text(array('action' => 'edit'), $model->content, false, 600);
     }
     //获取所有受推荐地区
     $topAreas = Area::getTops(0);
     $areas = CHtml::listData($topAreas, 'id', 'title');
     //推荐的标签
     $suggestTags = Tags::getTops('posts');
     //我所加入的团队
     $groups = WeddingGroup::getUserGroup($this->uid);
     $this->pageTitle = '新增作品 - ' . zmf::config('sitename');
     $this->render('create', array('model' => $model, 'cols' => $cols, 'action' => $action, 'areas' => $areas, 'suggestTags' => $suggestTags, 'groups' => $groups));
 }
示例#20
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'));
     }
 }
示例#21
0
 public function addPostImg()
 {
     $logid = zmf::filterInput($_GET['id']);
     $uptype = zmf::filterInput($_GET['imgtype'], 't', 1);
     if (!$uptype) {
         $this->jsonOutPut(0, '不允许的分类');
     }
     if (!$logid) {
         $logid = 0;
     }
     $ctime = time();
     $dirs = zmf::upDirs($ctime, 'app', $uptype);
     $origin = $dirs['origin'] . '/';
     unset($dirs['origin']);
     zmf::createUploadDir($origin);
     $img = CUploadedFile::getInstanceByName('filedata');
     if ($img->getHasError()) {
         $this->jsonOutPut(0, '上传有误,请重试');
     }
     $ext = $img->getExtensionName();
     $upExt = zmf::config("imgAllowTypes");
     if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
         $this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
     }
     $size = $img->getSize();
     if ($size > zmf::config('imgMaxSize')) {
         $this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
     }
     $_imgInfo = getimagesize($_FILES["filedata"]["tmp_name"]);
     if ($_imgInfo['0'] < zmf::config('imgMinWidth') or $_imgInfo[1] < zmf::config('imgMinHeight')) {
         $this->jsonOutPut(0, "宽不能小于" . zmf::config('imgMinWidth') . "px<br/>高不能小于" . zmf::config('imgMinHeight') . "px");
     }
     $fileName = uniqid() . '.' . $ext;
     //    $_extra=self::getUpExtraUrl($ctime);
     //    $filePath=$_extra.'/'.$fileName;
     if (move_uploaded_file($_FILES["filedata"]["tmp_name"], $origin . $fileName)) {
         $uid = Yii::app()->user->id;
         $uid = 1;
         $data['uid'] = $uid;
         $data['logid'] = $logid;
         $data['filePath'] = $fileName;
         $data['fileDesc'] = $fileName;
         $data['classify'] = $uptype;
         $data['covered'] = '0';
         $data['cTime'] = $ctime;
         $data['status'] = Posts::STATUS_DELED;
         $model = new Attachments();
         $model->attributes = $data;
         if ($model->validate()) {
             if (!$model->save()) {
                 $this->jsonOutPut(0, '写入数据库出错');
             } else {
                 $attachid = $model->id;
             }
         } else {
             $this->jsonOutPut(0, '数据验证错误');
         }
         $image = Yii::app()->image->load($origin . $fileName);
         $_quality = zmf::config('imgQuality');
         $quality = isset($quality) ? $quality : 100;
         foreach ($dirs as $dk => $_dir) {
             zmf::createUploadDir($_dir);
             if ($_imgInfo[0] < $dk && $_imgInfo[1] < $dk) {
                 $image->resize($_imgInfo[0], $_imgInfo[1])->quality($quality);
             } else {
                 $image->smart_resize($dk, ceil($dk * 0.75))->quality($quality);
             }
             $image->save($_dir . '/' . $fileName, false);
         }
         $_dir = zmf::upDirs($ctime, 'site', $uptype, '600');
         $returnimg = $_dir . '/' . $fileName;
         $data = array('imgsrc' => $returnimg, 'attachid' => $attachid);
         $this->jsonOutPut(1, $data);
     }
 }
示例#22
0
文件: Area.php 项目: ph7pal/wedding
 public function getColByName($keyword, $limit = 1)
 {
     $keyword = zmf::filterInput($keyword, 't', 1);
     if (!$keyword) {
         return false;
     }
     $cols = Area::model()->findAll(array('condition' => '(title=:keyword) OR (name=:keyword)', 'limit' => $limit, 'params' => array(':keyword' => strtr($keyword, array('%' => '\\%', '_' => '\\_', '\\' => '\\\\')), ':keyword' => strtr($keyword, array('%' => '\\%', '_' => '\\_', '\\' => '\\\\')))));
     if (!empty($cols)) {
         return $cols;
     } else {
         return false;
     }
 }
示例#23
0
 public function actionGetContents()
 {
     $data = zmf::filterInput($_POST['data']);
     $page = zmf::filterInput($_POST['page']);
     $type = zmf::filterInput($_POST['type'], 't', 1);
     if (!$data || !$type) {
         $this->jsonOutPut(0, '数据不全,请核实');
     }
     if (!in_array($type, array('comments'))) {
         $this->jsonOutPut(0, '暂不允许的分类');
     }
     if ($page < 1 || !is_numeric($page)) {
         $page = 1;
     }
     $limit = 30;
     $longHtml = '';
     $postInfo = array();
     switch ($type) {
         case 'comments':
             $limit = 30;
             $posts = Comments::getCommentsByPage($data, 'posts', $page, $limit);
             $view = '/posts/_comment';
             break;
         default:
             $posts = array();
             break;
     }
     if (!empty($posts)) {
         foreach ($posts as $k => $row) {
             $longHtml .= $this->renderPartial($view, array('data' => $row, 'k' => $k, 'postInfo' => $postInfo), true);
         }
     }
     $data = array('html' => $longHtml, 'loadMore' => count($posts) == $limit ? 1 : 0, 'formHtml' => '');
     $this->jsonOutPut(1, $data);
 }
示例#24
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, '写入数据库错误');
         }
     }
 }
示例#25
0
 public function actionUpdate($type)
 {
     if (!in_array($type, array('info', 'passwd', 'tags'))) {
         $this->message(0, '您的操作有误');
     }
     if (isset($_POST) and !empty($_POST)) {
         $model = new Users();
         if ($type == 'info') {
             $intoData['truename'] = zmf::filterInput($_POST['truename'], 't', 1);
             if (!$intoData['truename']) {
                 $this->message(0, '用户名不能为空');
             }
             //如果用户修改了用户名,则判断是否被使用
             if ($intoData['truename'] != $this->userInfo['truename']) {
                 $info = Users::getInfoByName($intoData['truename']);
                 if ($info) {
                     $this->message(0, '该用户名已被使用');
                 }
             }
             $intoData['sex'] = tools::val('sex');
             $intoData['areaid'] = tools::val('areaid');
             $intoData['content'] = zmf::filterInput($_POST['desc'], 't', 1);
         } elseif ($type == 'passwd') {
             $old = zmf::filterInput($_POST['old_password'], 't', 1);
             $info = Users::model()->findByPk($this->uid);
             if (!$old) {
                 $this->message(0, '请输入原始密码');
             } elseif (md5($old) != $info['password']) {
                 $this->message(0, '原始密码不正确');
             }
             if (!$_POST['password']) {
                 $this->message(0, '请输入密码');
             } elseif (strlen($_POST['password']) < 5) {
                 $this->message(0, '新密码过短,请重新输入');
             }
             $intoData['password'] = md5($_POST['password']);
         } elseif ($type == 'tags') {
             //相关标签
             $tags = $_POST['tagnames'];
             $tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
             $tagids = array();
             if (!empty($tags)) {
                 foreach ($tags as $str) {
                     $_tmp = explode('-', $str);
                     if ($_tmp[1] > 0) {
                         //添加对应关系
                         if (Tags::addRelation($_tmp[1], $this->uid, 'user')) {
                             $tagids[] = $_tmp[1];
                         }
                     } else {
                         //查找是否有对应话题
                         $_tagid = Tags::findAndAdd($_tmp[0], 'user', $this->uid);
                         if ($_tagid) {
                             $tagids[] = $_tagid;
                         }
                     }
                 }
                 $tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
             }
             $tagStr = join(',', $tagids);
             $intoData['tagids'] = $tagStr;
         }
         zmf::delFCache("userInfo-{$this->uid}");
         if ($model->updateByPk($this->uid, $intoData)) {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
         } else {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
         }
     }
     $suggestTags = array();
     if ($type == 'tags') {
         //推荐的标签
         $suggestTags = Tags::getTops('posts');
     }
     $data = array('info' => $this->userInfo, 'type' => $type, 'suggestTags' => $suggestTags);
     $this->render('update', $data);
 }
示例#26
0
 /**
  * 写评论
  */
 public function actionComment()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
     } else {
         $uid = zmf::uid();
     }
     $checkInfo = UserPower::check('addComment', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     $keyid = zmf::filterInput($_POST['k']);
     $to = zmf::filterInput($_POST['to']);
     $type = zmf::filterInput($_POST['t'], 't', 1);
     $content = zmf::filterInput($_POST['c'], 't', 1);
     if (!isset($type) or !in_array($type, array('attachments', 'posts', 'poipost', 'poitips', 'question', 'answer', 'yueban', 'goods'))) {
         $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, '评论不能为空哦~');
     }
     $status = Posts::STATUS_PASSED;
     //判断是否应被禁止
     //        $forbidInfo = Posts::isForbidden($content, 'comment');
     //        if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
     //            //todo,增加用户非法操作次数
     //            $status = Posts::STATUS_STAYCHECK;
     //        }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     if (Yii::app()->session['checkHasBadword'] == 'yes') {
         $status = Posts::STATUS_STAYCHECK;
     }
     $model = new Comments();
     $ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
     if (!$ainfo) {
         $this->jsonOutPut(0, Yii::t('default', 'contentnotexists'));
     }
     $toNotice = true;
     if ($ainfo['uid'] == $uid) {
         $toNotice = false;
     }
     //当为商品评论且不是回复某人时,不提醒发布商品的人
     if ($type == 'goods' && !$to) {
         $toNotice = false;
     }
     $touid = $ainfo['uid'];
     if ($to) {
         $comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'];
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'answer') {
                 Answer::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的回答有了新的评论,' . $_url;
             } elseif ($type == 'poitips') {
                 PoiTips::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的短评有了新的评论,' . $_url;
             } elseif ($type == 'poipost') {
                 $_url = CHtml::link('查看详情', array('poipost/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 PoiPost::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的点评有了新的评论,' . $_url;
             } elseif ($type == 'question') {
                 $_url = CHtml::link('查看详情', array('question/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Question::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的提问有了新的评论,' . $_url;
             } elseif ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/index', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Posts::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的文章有了新的评论,' . $_url;
             } elseif ($type == 'attachments') {
                 $_url = CHtml::link('查看详情', array('attachments/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Attachments::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的图片有了新的评论,' . $_url;
             } elseif ($type == 'yueban') {
                 $_url = CHtml::link('查看详情', array('yueban/index', 'areaid' => $ainfo['toAreaid'], 'year' => zmf::time($ainfo['startTime'], 'Y'), 'month' => zmf::time($ainfo['startTime'], 'm'), 'day' => zmf::time($ainfo['startTime'], 'd')));
                 Posts::updateCount($keyid, 'UserYueban', 1, 'comments');
                 $_content = '您的约伴有了新的评论,' . $_url;
             } elseif ($type == 'goods') {
                 $_url = CHtml::link('查看详情', array('goods/detail', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Posts::updateCount($keyid, 'Goods', 1, 'comments');
                 $_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);
             }
             $html = $this->renderPartial('//comments/_comment', array('data' => $model), true);
             $this->jsonOutPut(1, $html);
         } else {
             $this->jsonOutPut(0, '新增评论失败');
         }
     } else {
         $this->jsonOutPut(0, '新增评论失败');
     }
 }