123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace wechat\base;
- use yii\web\Controller;
- use Yii;
- class CommonController extends Controller
- {
- public function init()
- {
- parent::init(); // TODO: Change the autogenerated stub
- // \common\api\IpInfoServer::LimitIp();
- // $city = new \frontend\server\IndexServer();
- // $view->params['main_city'] = $city->CityList();
- //分站
- // $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([]);
- // $view->params['nav_cityname'] = '全国';
- // if(Yii::$app->hostserver->hostId != 0)
- // {
- // $view->params['nav_cityname'] = $city->FindById(Yii::$app->hostserver->hostId)['city_name'];
- // }
- //分站
- $view = Yii::$app->view;
- //上一页
- if(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']))
- {
- if(strstr($_SERVER['HTTP_REFERER'],'yigouf.com'))
- {
- $view->params['referer'] = $_SERVER['HTTP_REFERER'];
- }else{
- $view->params['referer'] = '/';
- }
- }else{
- $view->params['referer'] = '/';
- }
- $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([]);
- $view->params['nav_cityname'] = '全国';
- if(Yii::$app->hostserver->hostId != 0)
- {
- $view->params['nav_cityname'] = $city->FindById(Yii::$app->hostserver->hostId)['city_name'];
- }
- // if(Yii::$app->request->get('city') && Yii::$app->hostserver->hostId == 0)
- // {
- // $row = $city->FindById(Yii::$app->request->get('city'));
- // $view->params['nav_cityname'] = $row['city_name'];
- // $pid = $city->FindById($row['pid']);
- //
- //
- // //省份跳转
- // if(!empty($pid))
- // {
- // $url = 'http://m'.$pid['a'].'.'.$view->params['main_city_url'];
- // if($hostName[0] !='m'.$pid['a']){
- // header('Location:'.$url.'?city='.Yii::$app->request->get('city'));
- // exit;
- //
- // }
- //
- // }
- // }
- // p($view->params['main_city_url']);
- }
- // public function beforeAction($action)
- // {
- // if(empty(Yii::$app->session['user_info'])){
- // echo "<script>alert('请登录!');window.parent.location.href='".'/public/login'."'</script>";
- // return false;
- // }
- //
- // //异地登录
- // $model = new \backend\server\Checkauthority();
- // $unique = $model->UniqueToken();
- // // if($unique == false)
- // // {
- // // echo "<script>alert('检测到该账号已在别的电脑登录!');window.parent.location.href='".'/public/logout'."'</script>";
- // // return false;
- // // }
- // //超级管理员
- // if(Yii::$app->session['user_info']['user'] === Yii::$app->params['UserSuperadministrator']) return true;
- //
- //
- // //权限控制
- // $controller = strtolower(Yii::$app->controller->id);
- // $action = strtolower(Yii::$app->controller->action->id);
- // if($model->Comparison($controller,$action) === true)
- // {
- // return true;
- // }
- //
- // if(Yii::$app->request->isAjax)
- // {
- // $list['code'] = 500;
- // $list['msg'] = '暂无操作权限';
- // $list['data'] = '';
- // echo json_encode($list);
- // return false;
- // }
- //// echo '<script>alert("暂无权限操作!")</script>';
- // return false;
- // }
- }
|