Пример #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 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()));
     }
 }
Пример #3
0
 public function actionList()
 {
     $order = isset($_POST['order']) ? $_POST['order'] : 1;
     $order = CommonFunc::checkIntParam($order, 4, 1);
     $type = isset($_POST['type']) ? $_POST['type'] : '';
     $type = CommonFunc::checkIntParam($type, 2, '');
     $search = isset($_POST['search']) ? $_POST['search'] : '';
     $category = isset($_POST['category']) ? $_POST['category'] : '';
     $category = CommonFunc::checkIntParam($category, Category::getMaxCategory(), '');
     $maxId = isset($_POST['maxid']) ? $_POST['maxid'] : 0;
     $page = isset($_POST['page']) ? $_POST['page'] : 0;
     if (!$maxId) {
         $maxId = AppInfoList::getMaxId();
     }
     $appsInfo = AppInfoList::getData($order, $type, $search, $category, $_POST['page'] * 25, 25, $maxId);
     echo new ReturnInfo(RET_SUC, array('list' => $appsInfo['data'], 'maxid' => $maxId, 'pageCount' => $appsInfo['pageCount']));
 }
Пример #4
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));
 }
Пример #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 getData($order)
 {
     $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
     $limit = isset($_GET['limit']) ? $_GET['limit'] : 10;
     if (!is_numeric($offset) || !is_numeric($limit)) {
         return new ReturnInfo(RET_ERROR, 'offset or limit parameter error');
     }
     $offset = (int) $offset;
     $limit = (int) $limit;
     if ($offset < 0 || $limit < 0) {
         return new ReturnInfo(RET_ERROR, 'offset or limit parameter error');
     }
     $maxId = isset($_GET['maxid']) ? $_GET['maxid'] : 0;
     if (!is_numeric($maxId)) {
         return new ReturnInfo(RET_ERROR, 'maxid parameter error');
     }
     $maxId = (int) $maxId;
     $type = isset($_GET['type']) ? $_GET['type'] : 0;
     $type = CommonFunc::checkIntParam($type, 2, '');
     $search = isset($_GET['search']) ? $_GET['search'] : '';
     $category = isset($_GET['category']) ? $_GET['category'] : '';
     $category = CommonFunc::checkIntParam($category, Category::getMaxCategory(), '');
     $appsInfo = AppInfoList::getData($order, $type, $search, $category, $offset * $limit, $limit, $maxId);
     return new ReturnInfo(RET_SUC, array('offset' => $offset, 'data' => $appsInfo['data']));
 }
Пример #8
0
 public function actionFakeLike()
 {
     $this->_log->setLogFile('like.log');
     if ($this->_isFake(self::LIKE_NUM_MIN, self::LIKE_NUM_MAX)) {
         $likeApp = $this->_getRandomApp();
         if (!$likeApp) {
             return;
         }
         $date = date('Y-m-d H:i:s');
         $likedFakeUser = $this->_getLikedFakeUser($likeApp->Id);
         $userId = $this->_getRandomUserId($likedFakeUser);
         $user = User::model()->findByPk($userId);
         try {
             $result = AppInfoList::up($likeApp, $user, true);
             if ($result) {
                 $this->_log->log('userId#' . $userId . '#于#' . $date . '#赞了App Id#' . $likeApp->Id . '#');
             }
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Пример #9
0
 public function actionMyFavorite()
 {
     $userID = Yii::app()->user->id;
     if (!empty($userID)) {
         $userKey = 'user_' . $userID;
         $interactionApp = CommonFunc::getRedis($userKey, 'favorite');
         $interactionAppIds = array_keys($interactionApp);
         $data = AppInfoList::getInteractionApp($userID, $interactionAppIds);
         $this->render('myfavorite', array('data' => $data));
     } else {
         throw new THttpException('请登陆后再查看');
     }
 }
Пример #10
0
 public function actionMyFavorite()
 {
     $userID = Yii::app()->getRequest()->getQuery('memberid');
     //$this->apiUser->ID;
     if (!empty($userID)) {
         $userKey = 'user_' . $userID;
         $interactionApp = CommonFunc::getRedis($userKey, 'favorite');
         $interactionAppIds = array_keys($interactionApp);
         $data = AppInfoList::getInteractionApp($userID, $interactionAppIds);
         echo new ReturnInfo(RET_SUC, $data);
     } else {
         echo new ReturnInfo(RET_ERROR, '请登陆后再查看');
     }
 }
Пример #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 sendAppList($type, $txt)
 {
     switch ($type) {
         case 'APP_NEW_LIST':
             $appsInfo = AppInfoList::getData(0, 0, '', 0, 0, 10);
             $title = "App哥伦部最新应用";
             break;
         case 'SEARCH':
             $appsInfo = AppInfoList::getData(0, 0, $txt, 0, 0, 10);
             $title = "App搜索结果";
             break;
     }
     $aData = array();
     foreach ($appsInfo['data'] as $m) {
         $_ = "[强]" . $m['count'];
         $_ .= ' <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[] = $_;
     }
     if (count($aData) == 0) {
         $msg = '暂无符合条件的App, 请点击 <a href="http://www.appgrub.com">进入网站</a> 发现更多App';
     } else {
         $msg = implode("\n\n", $aData);
     }
     $this->sendMsg($title . "\n-------------------------\n" . $msg);
     break;
 }
Пример #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();
     }
 }