예제 #1
0
 public function actionAdd()
 {
     $commitUserID = Yii::app()->user->id;
     //获取用户ID
     if (empty($commitUserID)) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '请登录后再分享App'));
         // ReturnInfo($a,$b,$c)  传入的$b是什么类型,返回到js 的data就是什么类型
         Yii::app()->end();
         //            return;
     }
     if (!Yii::app()->request->isPostRequest) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '数据请求方式错误'));
         Yii::app()->end();
     }
     $appUrl = trim(Yii::app()->request->getParam('appUrl', ''));
     // 前台trim()之后,后台也要trim() 防止注入
     if (empty($appUrl)) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => 'App链接不能为空'));
         Yii::app()->end();
     }
     $appHost = parse_url($appUrl);
     $domains = Source::getSourceDomains();
     if (!isset($appHost['host']) || !in_array($appHost['host'], $domains)) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => 'App链接有误,请参考填写规则'));
         Yii::app()->end();
     }
     $userInfo = array();
     $userInfo = unserialize(Yii::app()->cache->get('user_' . $commitUserID));
     $md5AppUrl = md5($appUrl);
     if (isset($userInfo['share_list']) && in_array($md5AppUrl, $userInfo['share_list'])) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '您已经提交过该App了'));
         Yii::app()->end();
     }
     $explain = Yii::app()->request->getParam('explain');
     $officialUrl = Yii::app()->request->getParam('url');
     $link = new AppInfoList();
     $link->SourceId = Source::getSourceByDomain($appUrl);
     $link->CommitUserId = $commitUserID;
     $link->Remarks = empty($explain) ? '' : $explain;
     $link->AppUrl = $appUrl;
     $link->CommitTime = date('Y-m-d H:i:s');
     $link->OfficialWeb = empty($officialUrl) ? '' : $officialUrl;
     $link->Status = 1;
     $link->Sort = $link->model()->getMaxSort() + 1;
     if ($link->save()) {
         if (!isset($userInfo['share_list']) || empty($userInfo['share_list'])) {
             $userInfo['share_list'] = array();
         }
         $userInfo['share_list'][] = $md5AppUrl;
         Yii::app()->cache->set('user_' . $commitUserID, serialize($userInfo));
         echo new ReturnInfo(RET_SUC, 0);
     } else {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => $link->getErrors()));
     }
 }
예제 #2
0
 public function actionIndex()
 {
     $noticeModel = Notice::model();
     $targetUserid = Yii::app()->user->id;
     $msgs = $noticeModel->findAll(array('condition' => 'targetUserid =:targetUserid AND readFlag = 1', 'order' => 'createTime', 'params' => array(':targetUserid' => $targetUserid)));
     $noticeInfo = array();
     foreach ($msgs as $msg) {
         if ($msg->type == 0) {
             $noticeInfo[] = array('type' => $msg->type, 'msg' => $msg->msg, 'createTime' => $msg->createTime);
         } else {
             $appInfo = AppInfoList::model()->find(array('select' => 'Id, AppName', 'condition' => 'Id = :appId', 'params' => array(':appId' => $msg->appId)));
             $authorId = $msg->reviews->AuthorId;
             $noticeInfo[] = array('type' => $msg->type, 'msg' => $msg->reviews->Content, 'createTime' => $msg->createTime, 'appName' => $appInfo->AppName, 'appID' => $appInfo->Id, 'authorName' => htmlspecialchars(CommonFunc::getRedis('user_' . $authorId, 'userName')), 'authorID' => $authorId);
         }
     }
     $noticeModel->updateAll(array('readFlag' => '0'), 'targetUserid = :targetUserid', array(':targetUserid' => $targetUserid));
     $this->render('msg', array('msg' => $noticeInfo));
 }
예제 #3
0
 public function actionAddApp()
 {
     $commitUserID = $this->apiUser->ID;
     if (empty($commitUserID)) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '请登录后再分享App'));
         Yii::app()->end();
     }
     if (!Yii::app()->request->isPostRequest) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '数据请求方式错误'));
         Yii::app()->end();
     }
     $appUrl = Yii::app()->request->getParam('appUrl');
     if (empty($appUrl)) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => 'App链接不能为空'));
         Yii::app()->end();
     }
     $app = AppInfoList::model()->findByAttributes(array('CommitUserId' => $commitUserID, 'AppUrl' => $appUrl));
     if ($app instanceof AppInfoList) {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => '您已经提交过该App了'));
         Yii::app()->end();
     }
     $explain = Yii::app()->request->getParam('explain');
     $officialUrl = Yii::app()->request->getParam('url');
     $link = new AppInfoList();
     $link->SourceId = Source::getSourceByDomain($appUrl);
     $link->CommitUserId = $commitUserID;
     $link->Remarks = empty($explain) ? '' : $explain;
     $link->AppUrl = $appUrl;
     $link->CommitTime = date('Y-m-d H:i:s', time());
     $link->OfficialWeb = empty($officialUrl) ? '' : $officialUrl;
     $link->Status = 1;
     $link->Sort = $link->model()->getMaxSort() + 1;
     if ($link->save()) {
         echo new ReturnInfo(RET_SUC, 0);
     } else {
         echo new ReturnInfo(RET_SUC, array('code' => -1, 'msg' => $link->getErrors()));
     }
 }
예제 #4
0
 public function actionGetAppComment()
 {
     $appID = Yii::app()->getRequest()->getQuery('appid');
     if (empty($appID)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $app = AppInfoList::model()->findByPk($appID);
     if (empty($app)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.');
         Yii::app()->end();
     }
     $replies = AppReviews::model()->with('author_icon')->together()->findAll(array('select' => array('Id', 'Pid', 'Content', 'UpdateTime', 'AuthorName'), 'order' => 't.Id desc', 'condition' => 'AppId = :AppId', 'params' => array(':AppId' => $appID)));
     $appReply = array();
     if (!empty($replies)) {
         foreach ($replies as $reply) {
             if (!isset($appReply[$reply->Id])) {
                 $appReply[$reply->Id] = array('Id' => $reply->Id, 'Content' => $reply->Content, 'Pid' => $reply->Pid, 'AuthorName' => $reply->AuthorName, 'UpdateTime' => $reply->UpdateTime, 'AuthorIcon' => $reply->author_icon->Icon, 'children' => array());
             }
             if ($reply->Pid == 0) {
                 continue;
             } else {
                 if (isset($appReply[$reply->Pid])) {
                     $appReply[$reply->Pid]['children'][] = $appReply[$reply->Id];
                     unset($appReply[$reply->Id]);
                 } else {
                     $parentReply = AppReviews::model()->findByPk($reply->Pid);
                     $appReply[$parentReply->Id] = array('Id' => $parentReply->Id, 'Content' => $parentReply->Content, 'Pid' => $parentReply->Pid, 'AuthorName' => $parentReply->AuthorName, 'UpdateTime' => $parentReply->UpdateTime, 'AuthorIcon' => $parentReply->author_icon->Icon, 'children' => array());
                     $appReply[$parentReply->Id]['children'][] = $appReply[$reply->Id];
                     unset($appReply[$reply->Id]);
                 }
             }
         }
         //foreach
     }
     echo new ReturnInfo(RET_SUC, $appReply);
 }
예제 #5
0
 public function actionShareResultNotice()
 {
     $appID = Yii::app()->request->getParam('appID');
     $app = AppInfoList::model()->findByPk($appID);
     if (!$app instanceof AppInfoList) {
         echo new ReturnInfo(RET_ERROR, 'app id error');
         Yii::app()->end();
     }
     $user = User::model()->findByPk($app->CommitUserId);
     if (!$user instanceof User || $user->Status != 0) {
         echo new ReturnInfo(RET_ERROR, 'user id or user status error');
         Yii::app()->end();
     }
     $message = '';
     if ($app->Status == 0) {
         $message = '您分享的<a href="/produce/index/' . $appID . '">App《' . htmlspecialchars($app->AppName) . '》</a>已经通过审核';
     } else {
         if ($app->Status == 2) {
             $message = '您分享的App(<a href="' . rawurlencode($app->AppUrl) . '" target="_blank">' . htmlspecialchars($app->AppUrl) . '</a>),没有通过审核';
         } else {
             echo new ReturnInfo(RET_ERROR, 'app status error');
             Yii::app()->end();
         }
     }
     $notice = new Notice();
     $notice->type = 0;
     $notice->targetUserid = $app->CommitUserId;
     $notice->msg = $message;
     $notice->createTime = date('Y-m-d H:i:s');
     $notice->appId = $appID;
     if ($notice->save()) {
         echo new ReturnInfo(RET_SUC, true);
     } else {
         echo new ReturnInfo(RET_ERROR, $notice->getErrors());
     }
 }
예제 #6
0
 public function actionSearchUser()
 {
     $appID = Yii::app()->request->getParam('appID');
     $app = AppInfoList::model()->findByPk($appID);
     if (!$app instanceof AppInfoList) {
         throw new THttpException("操作错误");
     }
     $array = AppReviews::model()->findAll(array('select' => array('AuthorId'), 'distinct' => true, 'condition' => 'AppId = :AppId', 'params' => array(':AppId' => $appID)));
     $userArray = array();
     foreach ($array as $row) {
         $userArray[] = array('encode_name' => htmlspecialchars($row->author_icon->UserName), 'icon' => $row->author_icon->Icon, 'name' => $row->author_icon->UserName);
     }
     echo new ReturnInfo(RET_SUC, $userArray);
 }
예제 #7
0
 public function actionFakeShare()
 {
     $this->_log->setLogFile('share.log');
     if ($this->_isFake(self::SHARE_NUM_MIN, self::SHARE_NUM_MAX)) {
         $hasFilteredModel = AppHasFiltered::model()->findAll(array('condition' => 'Status=1', 'order' => new CDbExpression('RAND()'), 'limit' => 1));
         if (!$hasFilteredModel || !$hasFilteredModel[0]) {
             return;
         }
         $userId = $this->_getRandomUserId();
         if (!$userId) {
             return;
         }
         $hasFiltered = $hasFilteredModel[0];
         $date = date('Y-m-d H:i:s');
         $appInfoModel = new AppInfoList();
         $appInfoModel->PushId = $hasFiltered->PushId;
         $appInfoModel->AppId = $hasFiltered->AppId;
         $appInfoModel->SourceId = $hasFiltered->SourceId;
         $appInfoModel->AppName = $hasFiltered->AppName;
         $appInfoModel->MainCategory = $hasFiltered->MainCategory;
         $appInfoModel->CommitUserId = $userId;
         $appInfoModel->IconUrl = $hasFiltered->IconUrl;
         $appInfoModel->AppUrl = $hasFiltered->AppUrl;
         $appInfoModel->ScreenShoot = $hasFiltered->ScreenShoot;
         $appInfoModel->VideoUrl = $hasFiltered->VideoUrl;
         $appInfoModel->UpdateTime = $date;
         $appInfoModel->CommitTime = $date;
         $appInfoModel->OfficialWeb = $hasFiltered->OfficialWeb;
         $appInfoModel->AppInfo = $hasFiltered->AppInfo;
         $appInfoModel->ApkUrl = $hasFiltered->ApkUrl;
         $appInfoModel->Sort = $appInfoModel->model()->getMaxSort() + 1;
         $appInfoModel->ShareType = 1;
         $hasFiltered->Status = 0;
         $transaction = Yii::app()->db->beginTransaction();
         try {
             if (!$appInfoModel->save() || !$hasFiltered->save()) {
                 throw new Exception();
             }
             $this->_log->log('userId#' . $userId . '#于#' . $date . '#分享App PushId#' . $hasFiltered->PushId . '#');
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollBack();
         }
         //线上请求baidu sitemap api
         if (CommonFunc::getProjectEnv() == 'online') {
             $this->baiduSiteMap($appInfoModel->Id);
         }
     }
 }
예제 #8
0
 public function actionMyAppList()
 {
     $memberID = Yii::app()->getRequest()->getQuery('memberid');
     $condition = 'CommitUserId = :CommitUserId';
     if (empty($memberID)) {
         $memberID = Yii::app()->user->id;
     }
     if ($memberID != Yii::app()->user->id) {
         $condition .= ' and Status = 0';
     }
     $member = User::model()->findByPk($memberID);
     if (!$member instanceof User) {
         throw new THttpException("操作错误");
     }
     $this->render('myapplist', array('data' => AppInfoList::parseData(AppInfoList::model()->findAll(array('condition' => $condition, 'order' => 'Id desc', 'params' => array(':CommitUserId' => $memberID))), $memberID)));
 }
예제 #9
0
 public function actionReplyComment()
 {
     if (!Yii::app()->request->isPostRequest) {
         echo new ReturnInfo(RET_ERROR, 'Data request error,post please.');
         Yii::app()->end();
     }
     $content = Yii::app()->getRequest()->getQuery('content');
     if (empty($content)) {
         echo new ReturnInfo(RET_ERROR, 'Argument content passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $appID = Yii::app()->getRequest()->getQuery('appID');
     if (empty($appID)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appID passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $pid = Yii::app()->getRequest()->getQuery('pid');
     if (empty($pid)) {
         echo new ReturnInfo(RET_ERROR, 'Argument pid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $app = AppInfoList::model()->findByPk($appID);
     if (!$app instanceof AppInfoList) {
         echo new ReturnInfo(RET_ERROR, 'Argument appID passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.');
         Yii::app()->end();
     }
     $reply = AppReviews::model()->findByPk($pid);
     if (!$reply instanceof AppReviews) {
         echo new ReturnInfo(RET_ERROR, 'Argument pid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.');
         Yii::app()->end();
     }
     try {
         AppReviews::comment($app->Id, $this->apiUser, $content, $pid);
         $return = array();
         $return['content'] = $content;
         $return['username'] = $this->apiUser->UserName;
         echo new ReturnInfo(RET_SUC, $return);
     } catch (Exception $e) {
         echo new ReturnInfo(RET_ERROR, $e->getMessage());
     }
 }
예제 #10
0
 public function actionGetAppComment()
 {
     $appID = Yii::app()->getRequest()->getQuery('appid');
     if (empty($appID)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not be empty.');
         Yii::app()->end();
     }
     $app = AppInfoList::model()->findByPk($appID);
     if (empty($app)) {
         echo new ReturnInfo(RET_ERROR, 'Argument appid passed to ' . __CLASS__ . '::' . __FUNCTION__ . '() that can not find a record.');
         Yii::app()->end();
     }
     $aReply = array();
     $replies = AppReviews::model()->with('author_icon')->together()->findAll(array('select' => array('Id', 'Pid', 'Content', 'UpdateTime', 'AuthorId', 'ToAuthorId'), 'order' => 't.Pid asc, t.UpdateTime desc', 'condition' => 'AppId = :AppId', 'params' => array(':AppId' => $appID)));
     if (!empty($replies)) {
         foreach ($replies as $single_reply) {
             $toAuthorNanme = '';
             if ($single_reply->ToAuthorId) {
                 $toAuthorNanme = htmlspecialchars($single_reply->toAuthor->UserName);
             }
             $replay_info = array('Id' => $single_reply->Id, 'Content' => $single_reply->Content, 'Pid' => $single_reply->Pid, 'AuthorName' => htmlspecialchars($single_reply->replyUser->UserName), 'UpdateTime' => AppInfoList::getPeriod($single_reply->UpdateTime), 'AuthorIcon' => $single_reply->author_icon->Icon, 'AuthorId' => $single_reply->AuthorId, 'ToAuthorID' => $single_reply->ToAuthorId, 'ToAuthorName' => $toAuthorNanme);
             if ($single_reply->Pid != 0) {
                 if (!isset($aReply[$single_reply->Pid])) {
                     $aReply[$single_reply->Pid] = array('children' => array($replay_info));
                 } else {
                     if (!isset($aReply[$single_reply->Pid]['children'])) {
                         $aReply[$single_reply->Pid]['children'] = array();
                     }
                     $aReply[$single_reply->Pid]['children'][] = $replay_info;
                 }
             } else {
                 if (!isset($aReply[$single_reply->Id])) {
                     $aReply[$single_reply->Id] = $replay_info;
                     $aReply[$single_reply->Id]['children'] = array();
                 } else {
                     $aReply[$single_reply->Id] = array_merge($aReply[$single_reply->Id], $replay_info);
                 }
             }
         }
     }
     foreach ($aReply as $key => $value) {
         if (!isset($value['Id']) || empty($value['Id'])) {
             unset($aReply[$key]);
         }
     }
     echo new ReturnInfo(RET_SUC, $aReply);
 }
예제 #11
0
 public function sendAppList($type)
 {
     switch ($type) {
         case 'APP_NEW_LIST':
             $criteria = new CDbCriteria();
             $criteria->order = 'Sort desc';
             $criteria->offset = 0;
             $criteria->limit = 10;
             $aModels = AppInfoList::model()->published()->findAll($criteria);
             $aData = array();
             foreach ($aModels as $m) {
                 $_ = "+" . $m->Up;
                 $_ .= ' <a href="http://appgrub.com/produce/index/' . $m->Id . '">' . $m->AppName . "</a>\n";
                 if (!empty($m->Remarks)) {
                     $content = strip_tags($m->Remarks);
                 } else {
                     $content = strip_tags($m->AppInfo);
                 }
                 $_ .= mb_substr($content, 0, 30, "utf-8");
                 $aData[] = $_;
             }
             $msg = implode("\n\n", $aData);
             $this->sendMsg("App哥伦部最新应用\n-------------------------\n" . $msg);
             break;
     }
 }
예제 #12
0
 public function actionAlertAppInfoListCategory()
 {
     $mainCategory = Yii::app()->request->getParam('main_category');
     $subcategory = Yii::app()->request->getParam('subcategory');
     $mainCategory = CommonFunc::checkIntParam($mainCategory, Category::getMaxCategory(), '');
     $categoryModel = new Category();
     $systemCategory = $categoryModel->category;
     if (!isset($systemCategory[$mainCategory])) {
         throw new THttpException('一级分类有误');
     }
     if (!in_array($subcategory, explode(',', $systemCategory[$mainCategory]['value']))) {
         throw new THttpException('子分类有误');
     }
     $app = AppInfoList::model()->findByPk(Yii::app()->request->getParam('appID'));
     if (!$app instanceof AppInfoList) {
         throw new THttpException('应用ID有误');
     }
     $app->MainCategory = $subcategory;
     if ($app->save()) {
         echo new ReturnInfo(0, 1);
     } else {
         throw new THttpException('修改失败');
     }
 }
예제 #13
0
 public function actionUploadSiteMap()
 {
     $yesterday = date('Y-m-d', strtotime("-1 day"));
     $today = date('Y-m-d');
     $yesterdayApps = AppInfoList::model()->findAll('CommitTime > "' . $yesterday . '" and CommitTime < "' . $today . '" and Status = 0');
     foreach ($yesterdayApps as $app) {
         $this->baiduSiteMap($app->Id);
     }
 }
예제 #14
0
 static function getAppsByIds($Ids, $status = 0)
 {
     $conditions = "Id in (" . implode(',', $Ids) . ")";
     if ($status !== '') {
         $conditions .= " and Status=" . $status;
     }
     return AppInfoList::model()->published()->findAll(array('condition' => $conditions));
 }
예제 #15
0
 public function actionInteractionApp()
 {
     $memberID = Yii::app()->getRequest()->getQuery('memberid');
     if (empty($memberID)) {
         $memberID = $this->apiUser->ID;
     }
     $member = User::model()->findByPk($memberID);
     if (!$member instanceof User) {
         throw new THttpException("操作错误");
     }
     $userKey = 'user_' . $memberID;
     $userArray = Yii::app()->cache->get($userKey);
     $memberArray = empty($userArray) ? array() : unserialize($userArray);
     $apps = array();
     if (!empty($memberArray)) {
         $type = 1;
         if (isset($_GET['type'])) {
             $type = $_GET['type'];
         }
         if ($type == 1) {
             if (isset($memberArray['like']) && !empty($memberArray['like'])) {
                 $apps = AppInfoList::parseData(AppInfoList::model()->findAll(array('condition' => "Id in (" . implode(',', $memberArray['like']) . ")")), $memberID);
             }
         } else {
             if ($type == 2) {
                 if (isset($memberArray['comment']) && !empty($memberArray['comment'])) {
                     $apps = AppInfoList::parseData(AppInfoList::model()->findAll(array('condition' => "Id in (" . implode(',', $memberArray['comment']) . ")")), $memberID);
                 }
             }
         }
     }
     echo new ReturnInfo(RET_SUC, $apps);
 }
예제 #16
0
 public function actionUpdateAppUp()
 {
     $apps = AppInfoList::model()->findAll();
     foreach ($apps as $app) {
         $appUp = CommonFunc::getRedis('link_' . $app->Id, 'count');
         if (empty($appUp)) {
             continue;
         }
         $app->Up = $appUp;
         $app->save();
     }
 }