function actionRealAnalyze()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $url = Yii::app()->request->getParam("url");
     if (!(isset($url) && !is_null($url) && strlen($url) > 0)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::KEYWORD_IS_NULL);
         return;
     }
     try {
         $vodtype = $this->getVodtype($url);
         if ($vodtype !== "" && $vodtype != "joyplus") {
             $content = $this->getContent("http://localhost/" . $vodtype . '/?url=' . $url, "utf-8");
             $content = json_decode($content);
         }
         if (isset($content)) {
             IjoyPlusServiceUtils::exportEntity(array('results' => $content));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         }
     } catch (Exception $e) {
         //			var_dump($e);
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 public function actionOpenApiConfig()
 {
     header('Content-type: application/json');
     if (!Yii::app()->request->isPostRequest) {
         IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT);
         return;
     }
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     try {
         $device_name = Yii::app()->request->getParam("device_name");
         if (!(isset($device_name) && !is_null($device_name) && strlen($device_name) > 0)) {
             IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
             return;
         }
         $apiConfig = ApiConfig::model()->find(array("condition" => "device_name like '%" . $device_name . ",%' "));
         if ($apiConfig == null) {
             IjoyPlusServiceUtils::exportEntity(array());
         } else {
             IjoyPlusServiceUtils::exportEntity(array('api_url' => $apiConfig['api_url'], 'logo_url' => $apiConfig['logo_url'], 'app_key' => $apiConfig['app_key']));
         }
     } catch (Exception $e) {
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 public function actionViewRecommend()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     $prod_id = Yii::app()->request->getParam("prod_id");
     if (!isset($prod_id) || is_null($prod_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     $program = Program::model()->findByPk($prod_id);
     if ($program === null) {
         IjoyPlusServiceUtils::exportServiceError(Constants::OBJECT_NOT_FOUND);
         return;
     }
     $userid = Yii::app()->request->getParam("user_id");
     if (!isset($userid) || is_null($userid)) {
         $userid = Yii::app()->user->id;
     }
     $prod = ProgramUtil::exportProgramEntity($program);
     $reCom = Dynamic::model()->getDynamicByProd($userid, $prod_id, Constants::DYNAMIC_TYPE_RECOMMEND);
     if (isset($reCom) && !is_null($reCom)) {
         $prod['reason'] = $reCom->content_desc;
     }
     $comments = Comment::model()->getCommentsByProgram($prod_id, 10, 0);
     if (isset($comments) && is_array($comments)) {
         $commentTemps = array();
         foreach ($comments as $comment) {
             $commentTemps[] = IjoyPlusServiceUtils::transferComments($comment);
         }
         $prod['comments'] = $commentTemps;
     } else {
         $prod['comments'] = array();
     }
     $dynamic = Dynamic::model()->friendDynamicForProgram(Yii::app()->user->id, $prod_id, 10, 0);
     if (isset($dynamic) && is_array($dynamic)) {
         $prod['dynamics'] = $this->transferDynamics($dynamic);
     } else {
         $prod['dynamics'] = array();
     }
     $topics = Topic::model()->getRelatedTops($prod_id);
     if (isset($topics) && is_array($topics)) {
         $prod['topics'] = $topics;
     } else {
         $prod['topics'] = array();
     }
     IjoyPlusServiceUtils::exportEntity($prod);
 }
 /**
  * register user
  * Enter description here ...
  */
 function actionUpdateProfile()
 {
     header('Content-type: application/json');
     //	    if(!Yii::app()->request->isPostRequest){
     //	   		 IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT);
     //	   		 return ;
     //	   	}
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $nickname = Yii::app()->request->getParam("nickname");
     $pwd = Yii::app()->request->getParam("password");
     $username = Yii::app()->request->getParam("username");
     $sourceid = Yii::app()->request->getParam("source_id");
     $source_type = Yii::app()->request->getParam("source_type");
     if (!IjoyPlusServiceUtils::validateThirdPartSource($source_type)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::THIRD_PART_SOURCE_TYPE_INVALID);
         return;
     }
     if (!(isset($nickname) && !is_null($nickname) && strlen($nickname) > 0)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::NICKNAME_IS_NULL);
         return;
     }
     if (!(isset($pwd) && !is_null($pwd) && strlen($pwd) > 0)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PWD_IS_NULL);
         return;
     }
     if (isset($username) && !is_null($username) && strlen($username) > 0) {
         $emailValidator = new CEmailValidator();
         if (!$emailValidator->validateValue($username)) {
             IjoyPlusServiceUtils::exportServiceError(Constants::EMAIL_INVALID);
             return;
         } else {
             $record = User::model()->find('LOWER(username)=?', array(strtolower($username)));
             if ($record !== null) {
                 IjoyPlusServiceUtils::exportServiceError(Constants::USERNAME_EXIST);
                 return;
             }
         }
     }
     try {
         $record = User::model()->find('LOWER(nickname)=?', array(strtolower($nickname)));
         if ($record !== null) {
             IjoyPlusServiceUtils::exportServiceError(Constants::NICKNAME_IS_EXSTING);
             return;
         } else {
             $model = new User();
             $model->nickname = $nickname;
             $model->password = md5($pwd);
             $model->username = $username;
             $model->status = Constants::USER_APPROVAL;
             $model->create_date = new CDbExpression('NOW()');
             switch ($source_type) {
                 case Constants::THIRD_PART_ACCOUNT_DOUBAN:
                     $model->douban_user_id = $sourceid;
                     break;
                 case Constants::THIRD_PART_ACCOUNT_QQ:
                     $model->qq_wb_user_id = $sourceid;
                     break;
                 case Constants::THIRD_PART_ACCOUNT_REN_REN:
                     $model->ren_user_id = $sourceid;
                     break;
                 case Constants::THIRD_PART_ACCOUNT_SINA:
                     $model->sina_wb_user_id = $sourceid;
                     break;
             }
             if ($model->save()) {
                 $identity = new IjoyPlusUserIdentity($username, $pwd);
                 $identity->setId($model->id);
                 $identity->setState('nickname', $model->nickname);
                 Yii::app()->user->login($identity);
                 UserManager::followPrestiges($model->id);
                 IjoyPlusServiceUtils::exportServiceError(Constants::SUCC);
                 //
             } else {
                 Yii::log(CJSON::encode($model->getErrors()), "warning");
                 //   		    	var_dump();
                 IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
             }
         }
     } catch (Exception $e) {
         Yii::log(CJSON::encode($e), "error");
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 function actionPopShow()
 {
     header('Content-type: application/json');
     //	   if(Yii::app()->user->isGuest){
     //			IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED);
     //			return ;
     //		}
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     try {
         $prods = SearchManager::popularProgram(SearchManager::POPULAR_TV_SHOW_SPECIAL_ID, $page_size, $page_size * ($page_num - 1));
         if (isset($prods) && is_array($prods)) {
             IjoyPlusServiceUtils::exportEntity(array('show' => $prods));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('show' => array()));
         }
     } catch (Exception $e) {
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 function actionSohuProduce()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     $top_id = 12192;
     try {
         $lists = SearchManager::listSohuProduce($top_id, $page_size, $page_size * ($page_num - 1));
         if (isset($lists) && is_array($lists)) {
             IjoyPlusServiceUtils::exportEntity(array('results' => $lists));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         }
     } catch (Exception $e) {
         Yii::log(CJSON::encode($e), "error");
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 function actionReply()
 {
     header('Content-type: application/json');
     if (!Yii::app()->request->isPostRequest) {
         IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT);
         return;
     }
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     if (!IjoyPlusServiceUtils::checkCSRCToken()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::DUPLICAT_REQUEST);
         return;
     }
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $thread_id = Yii::app()->request->getParam("thread_id");
         $parentComm = Comment::model()->findByPk($thread_id);
         if (isset($parentComm) && !is_null($parentComm)) {
             $model = new Comment();
             $model->status = Constants::OBJECT_APPROVAL;
             $model->create_date = new CDbExpression('NOW()');
             $model->comments = Yii::app()->request->getParam("content");
             $model->thread_id = Yii::app()->request->getParam("thread_id");
             $model->author_id = Yii::app()->user->id;
             $model->author_username = Yii::app()->user->getState("nickname");
             $model->author_photo_url = Yii::app()->user->getState("pic_url");
             $model->save();
             //add dynamic
             $dynamic = new Dynamic();
             $dynamic->author_id = Yii::app()->user->id;
             $dynamic->content_id = $thread_id;
             $dynamic->status = Constants::OBJECT_APPROVAL;
             $dynamic->create_date = new CDbExpression('NOW()');
             $dynamic->content_desc = $model->comments;
             $dynamic->dynamic_type = Constants::DYNAMIC_TYPE_COMMENT_REPLI;
             $dynamic->content_name = $parentComm->content_name;
             $dynamic->content_type = $parentComm->content_type;
             $dynamic->content_pic_url = $parentComm->content_pic_url;
             $dynamic->save();
             if ($parentComm->author_id !== Yii::app()->user->id) {
                 // add notify msg
                 $msg = new NotifyMsg();
                 $msg->author_id = $parentComm->author_id;
                 $msg->nofity_user_id = Yii::app()->user->id;
                 $msg->notify_user_name = Yii::app()->user->getState("nickname");
                 $msg->notify_user_pic_url = Yii::app()->user->getState("pic_url");
                 $msg->content_id = $thread_id;
                 $msg->content_desc = $model->comments;
                 $msg->content_type = $parentComm->content_type;
                 $msg->content_info = $parentComm->content_name;
                 $msg->created_date = new CDbExpression('NOW()');
                 $msg->status = Constants::OBJECT_APPROVAL;
                 $msg->notify_type = Constants::NOTIFY_TYPE_REPLIE_COMMENT;
                 $msg->save();
             }
         }
         $transaction->commit();
         IjoyPlusServiceUtils::exportServiceError(Constants::SUCC);
     } catch (Exception $e) {
         $transaction->rollback();
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 public function actionRecommends()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     try {
         $recommends = Dynamic::model()->friendRecommends(Yii::app()->user->id, $page_size, $page_size * ($page_num - 1));
         if (isset($recommends) && !is_null($recommends) && is_array($recommends)) {
             IjoyPlusServiceUtils::exportEntity(array('recommends' => $recommends));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('recommends' => array()));
         }
     } catch (Exception $e) {
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
 public function actionUpdateBGPicUrl()
 {
     header('Content-type: application/json');
     if (!Yii::app()->request->isPostRequest) {
         IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT);
         return;
     }
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     try {
         $url = Yii::app()->request->getParam("url");
         $validator = new CUrlValidator();
         if (!$validator->validateValue($url)) {
             IjoyPlusServiceUtils::exportServiceError(Constants::URL_INVALID);
         }
         $msgs = User::model()->updateBGPicUrl(Yii::app()->user->id, $url);
         IjoyPlusServiceUtils::exportServiceError(Constants::SUCC);
     } catch (Exception $e) {
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }