CommonController.php 5.1 KB

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