本文整理匯總了PHP中Source::getSourceByDomain方法的典型用法代碼示例。如果您正苦於以下問題:PHP Source::getSourceByDomain方法的具體用法?PHP Source::getSourceByDomain怎麽用?PHP Source::getSourceByDomain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Source
的用法示例。
在下文中一共展示了Source::getSourceByDomain方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionAdd
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: actionAddApp
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()));
}
}