当前位置: 首页>>代码示例>>PHP>>正文


PHP Source::getSourceByDomain方法代码示例

本文整理汇总了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()));
     }
 }
开发者ID:hucongyang,项目名称:test,代码行数:55,代码来源:ShareController.php

示例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()));
     }
 }
开发者ID:hucongyang,项目名称:test,代码行数:38,代码来源:ShareController.php


注:本文中的Source::getSourceByDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。