| 123456789101112131415161718192021222324252627 |
- <?php
- namespace common\components;
- use Yii;
- use yii\web\Controller;
- /**
- * 前后台基类
- */
- class baseController extends Controller{
- public $imgUrl,$adminUrl,$frontUrl,$openUrl,$picUrl,$wwwUrl;
- public function beforeAction($action){
- $hostInfo = Yii::$app->urlManager->getHostInfo();
- $parse = parse_url($hostInfo);
- $host = $parse['host'];
- $pos = strpos($host,'.') + 1;
- $pre = substr($host,$pos);
- $this->imgUrl = 'http://img.'.$pre;
- $this->adminUrl = 'http://a.'.$pre;
- $this->frontUrl = 'http://m.'.$pre;
- $this->openUrl = 'http://o.'.$pre;
- $this->picUrl = 'http://pic.'.$pre;//阿里云oss图床
- $this->wwwUrl = 'http://www.'.$pre;
- return parent::beforeAction($action);
- }
- }
|