123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace frontend\base;
- use yii\web\Controller;
- use Yii;
- class CommonController extends Controller
- {
- public function init()
- {
- parent::init();
-
-
- $mobile = is_mobile();
- if($mobile === true)
- {
- $strUrl = '';
- if(isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != 'fresh/home')
- {
- $strUrl = $_SERVER['REQUEST_URI'];
- }
- header('Location:http://m.yigouf.com'.$strUrl);
- exit ;
- }
- $server = new \common\api\HttpServer();
- Yii::$app->queue->push(
- new \common\fm\HttpRequestRecord(['equipment'=>2,'ip'=>Yii::$app->request->userIP,
- 'referer'=> $server->GetReferer(),'self_url'=> $server->GetCurUrl(),'agent'=>$server->getAgentInfo()])
- );
- $view = Yii::$app->view;
-
- $hostName = Yii::$app->request->getHostName();
- $num = substr_count($hostName,'.');
- switch ($num)
- {
- case 1:
- $view->params['main_city_url'] = $hostName;
- break;
- case 2:
- $hostName = explode('.',$hostName);
- $view->params['main_city_url'] = $hostName[1].'.'.$hostName[2];;
- break;
- }
- $city = new \common\models\CategoryCity();
- $city->pid = 0;
- $city->state = 1;
- $view->params['main_city'] = $city->getList([]);
-
- $city->pid = 0;
- $city->state = 1;
- $city->del = 1;
- $city->abroad = 1;
- $view->params['city_within'] = $city->getList([]);
-
- $city->abroad = 2;
- $view->params['city_abroad'] = $city->getList([]);
- $view->params['nav_cityname'] = '全国';
- if(Yii::$app->hostserver->hostId != 0)
- {
- $view->params['nav_cityname'] = $city->FindById(Yii::$app->hostserver->hostId)['city_name'];
- }
-
- $sysmenu = new \common\models\Frontend();
- $sysmenu->pid = 4;
- $view->params['sysmenu'] = $sysmenu->SonList(7,['name','url','icon','function']);
- }
- }
|