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); } }
public static function validateUserID() { $userid = isset($_SERVER['HTTP_USER_ID']) ? $_SERVER['HTTP_USER_ID'] : ""; if (!(isset($userid) && !is_null($userid) && strlen($userid) > 0)) { $userid = Yii::app()->request->getParam("user_id"); } if (isset($userid) && !is_null($userid) && strlen($userid) > 0) { return IjoyPlusServiceUtils::login($userid); } return true; }
public static function listSohuProduce($top_id, $limit, $offset) { $device = IjoyPlusServiceUtils::getDevice(); $where = ''; if ($device === false) { $key = SearchManager::CACHE_LIST_ITEMS_BY_TYPE_LIMIT_OFFSET . '_SohuProduce_' . $top_id . '_LIMIT_' . $limit . '_OFFSET_' . $offset; } else { $where = ' AND (can_search_device like \'%' . $device . '%\' or can_search_device is null or can_search_device =\'\' ) '; $key = SearchManager::CACHE_LIST_ITEMS_BY_TYPE_LIMIT_OFFSET . '_SohuProduce_' . $top_id . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_DEVICE_' . $device; } if (IjoyPlusServiceUtils::isExcludeCopyMovie()) { $where = $where . " and vod.d_area not like '%美国%' "; } $items = CacheManager::getValueFromCache($key); if ($items) { return $items; } $items = Yii::app()->db->createCommand()->select('vod.d_id as prod_id,vod.d_name as prod_name,vod.d_playfrom as sources,vod.d_level as definition, vod.d_type as prod_type, substring_index( vod.d_pic, \'{Array}\', 1 ) as prod_pic_url, substring_index( vod.d_pic_ipad, \'{Array}\', 1 ) as big_prod_pic_url, vod.d_content as prod_summary,vod.d_starring as star,vod.d_directed as director ,vod.d_score as score,vod.favority_user_count as favority_num ,vod.good_number as support_num ,vod.d_year as publish_date,vod.d_area as area, vod.d_remarks as max_episode, vod.d_state as cur_episode , vod.duraning as duration ')->from('mac_vod_topic_items as items')->join("mac_vod as vod", "items.vod_id=vod.d_id")->where('items.flag=:t_flag and items.topic_id=:topic_id and vod.d_hide=0 ' . $where, array(':t_flag' => 1, ':topic_id' => $top_id))->order('items.disp_order desc, vod.d_level desc ,vod.d_good desc,vod.d_time DESC ')->limit($limit)->offset($offset)->queryAll(); if (isset($items) && !is_null($items)) { $prodExpired = CacheManager::getExpireByCache(CacheManager::CACHE_PARAM_EXPIRED_POPULAR_PROGRAM); CacheManager::setValueToCache($key, $items, $prodExpired); } return $items; }
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); } }