CommonController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/2/26/026
  6. * Time: 9:56
  7. */
  8. namespace mobile\base;
  9. use yii\web\Controller;
  10. use Yii;
  11. class CommonController extends Controller
  12. {
  13. public function init()
  14. {
  15. parent::init(); // TODO: Change the autogenerated stub
  16. // \common\api\IpInfoServer::LimitIp();
  17. // $city = new \frontend\server\IndexServer();
  18. // $view->params['main_city'] = $city->CityList();
  19. //分站
  20. // $view = Yii::$app->view;
  21. // $hostName = Yii::$app->request->getHostName();
  22. // $num = substr_count($hostName,'.');
  23. // switch ($num)
  24. // {
  25. // case 1:
  26. // $view->params['main_city_url'] = $hostName;
  27. // break;
  28. // case 2:
  29. // $hostName = explode('.',$hostName);
  30. //
  31. // $view->params['main_city_url'] = $hostName[1].'.'.$hostName[2];;
  32. // break;
  33. // }
  34. //
  35. // $city = new \common\models\CategoryCity();
  36. // $city->pid = 0;
  37. // $city->state = 1;
  38. // $view->params['main_city'] = $city->getList([]);
  39. // $view->params['nav_cityname'] = '全国';
  40. // if(Yii::$app->hostserver->hostId != 0)
  41. // {
  42. // $view->params['nav_cityname'] = $city->FindById(Yii::$app->hostserver->hostId)['city_name'];
  43. // }
  44. $server = new \common\api\HttpServer();
  45. Yii::$app->queue->push(
  46. new \common\fm\HttpRequestRecord(['equipment'=>1,'ip'=>Yii::$app->request->userIP,
  47. 'referer'=> $server->GetReferer(),'self_url'=> $server->GetCurUrl(),'agent'=>$server->getAgentInfo()])
  48. );
  49. //分站
  50. $view = Yii::$app->view;
  51. //上一页
  52. if(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']))
  53. {
  54. if(strstr($_SERVER['HTTP_REFERER'],'yigouf.com'))
  55. {
  56. $view->params['referer'] = $_SERVER['HTTP_REFERER'];
  57. }else{
  58. $view->params['referer'] = '/';
  59. }
  60. }else{
  61. $view->params['referer'] = '/';
  62. }
  63. $hostName = Yii::$app->request->getHostName();
  64. $num = substr_count($hostName,'.');
  65. switch ($num)
  66. {
  67. case 1:
  68. $view->params['main_city_url'] = $hostName;
  69. break;
  70. case 2:
  71. $hostName = explode('.',$hostName);
  72. $view->params['main_city_url'] = $hostName[1].'.'.$hostName[2];;
  73. break;
  74. }
  75. $city = new \common\models\CategoryCity();
  76. $city->pid = 0;
  77. $city->state = 1;
  78. $view->params['main_city'] = $city->getList([]);
  79. $view->params['nav_cityname'] = '全国';
  80. if(Yii::$app->hostserver->hostId != 0)
  81. {
  82. $view->params['nav_cityname'] = $city->FindById(Yii::$app->hostserver->hostId)['city_name'];
  83. }
  84. // if(Yii::$app->request->get('city') && Yii::$app->hostserver->hostId == 0)
  85. // {
  86. // $row = $city->FindById(Yii::$app->request->get('city'));
  87. // $view->params['nav_cityname'] = $row['city_name'];
  88. // $pid = $city->FindById($row['pid']);
  89. //
  90. //
  91. // //省份跳转
  92. // if(!empty($pid))
  93. // {
  94. // $url = 'http://m'.$pid['a'].'.'.$view->params['main_city_url'];
  95. // if($hostName[0] !='m'.$pid['a']){
  96. // header('Location:'.$url.'?city='.Yii::$app->request->get('city'));
  97. // exit;
  98. //
  99. // }
  100. //
  101. // }
  102. // }
  103. // p($view->params['main_city_url']);
  104. }
  105. // public function beforeAction($action)
  106. // {
  107. // if(empty(Yii::$app->session['user_info'])){
  108. // echo "<script>alert('请登录!');window.parent.location.href='".'/public/login'."'</script>";
  109. // return false;
  110. // }
  111. //
  112. // //异地登录
  113. // $model = new \backend\server\Checkauthority();
  114. // $unique = $model->UniqueToken();
  115. // // if($unique == false)
  116. // // {
  117. // // echo "<script>alert('检测到该账号已在别的电脑登录!');window.parent.location.href='".'/public/logout'."'</script>";
  118. // // return false;
  119. // // }
  120. // //超级管理员
  121. // if(Yii::$app->session['user_info']['user'] === Yii::$app->params['UserSuperadministrator']) return true;
  122. //
  123. //
  124. // //权限控制
  125. // $controller = strtolower(Yii::$app->controller->id);
  126. // $action = strtolower(Yii::$app->controller->action->id);
  127. // if($model->Comparison($controller,$action) === true)
  128. // {
  129. // return true;
  130. // }
  131. //
  132. // if(Yii::$app->request->isAjax)
  133. // {
  134. // $list['code'] = 500;
  135. // $list['msg'] = '暂无操作权限';
  136. // $list['data'] = '';
  137. // echo json_encode($list);
  138. // return false;
  139. // }
  140. //// echo '<script>alert("暂无权限操作!")</script>';
  141. // return false;
  142. // }
  143. }