params.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. $hostData = \common\components\httpUtil::getHttpHost();
  3. $http = $hostData['http'];
  4. $suffix = $hostData['suffix'];
  5. $miniUrl = $http . 'mini.' . $suffix;
  6. $imgUrl = $http . 'img.' . $suffix;
  7. $adminUrl = $http . 'a.' . $suffix;
  8. $frontUrl = $http . 'm.' . $suffix;
  9. $mobileUrl = $http . 'm.' . $suffix;
  10. $openUrl = $http . 'o.' . $suffix;
  11. $picUrl = $http . 'pic.' . $suffix;
  12. $wwwUrl = $http . 'www.' . $suffix;
  13. $cssUrl = $http . 'css.' . $suffix;
  14. $jsUrl = $http . 'js.' . $suffix;
  15. $config = [
  16. //全站统一使用的秘钥
  17. 'secretKey' => 'CzWjvVY5F.dUqT65Knj81qh_eU2wI3SokO',
  18. 'imgUrl' => $imgUrl,
  19. 'adminUrl' => $adminUrl,
  20. 'frontUrl' => $frontUrl,
  21. 'openUrl' => $openUrl,
  22. 'picUrl' => $picUrl,
  23. 'wwwUrl' => $wwwUrl,
  24. 'mobileUrl' => $mobileUrl,
  25. 'miniUrl' => $miniUrl,
  26. //平台来源
  27. 'ptSource' => [
  28. //商城移动端
  29. 'mobile' => 1,
  30. //商城小程序
  31. 'mini' => 2,
  32. //商家后台PC端
  33. 'admin' => 3,
  34. //商家后台移动端
  35. 'back' => 4,
  36. //总后台
  37. 'saas' => 5,
  38. ],
  39. //永不过期时间
  40. 'neverExpireTime' => 4102416000,
  41. //永不过期日期
  42. 'neverExpireDate' => '2100-01-01 00:00:00',
  43. 'pageSize' => 20,
  44. ];
  45. $prefixHttp = 'http://';
  46. $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
  47. if (strpos($userAgent, 'miniprogram') === true) {
  48. $prefixHttp = 'https://';
  49. }
  50. $referrer = isset($_SERVER["HTTP_REFERER"]) ? strtolower($_SERVER["HTTP_REFERER"]) : '';
  51. if (strpos($referrer, 'servicewechat.com') === true) {
  52. $prefixHttp = 'https://';
  53. }
  54. if (strpos($referrer, 'https') === true) {
  55. $prefixHttp = 'https://';
  56. }
  57. if (getenv('YII_ENV') == 'local') {
  58. $config['c'] = $prefixHttp . 'api.m.hhb.com';
  59. $config['b'] = $prefixHttp . 'api.b.hhb.com';
  60. if (strpos($referrer, $prefixHttp . 'h') === true || strpos($referrer, $prefixHttp . 'api.h') === true) {
  61. $config['b'] = $prefixHttp . 'api.h.hhb.com';
  62. }
  63. $config['s'] = $prefixHttp . 'api.s.hhb.com';
  64. $config['host'] = 'hhb.com';
  65. }
  66. if (getenv('YII_ENV') == 'test') {
  67. $config['c'] = $prefixHttp . 'api.m.huaml.com';
  68. $config['b'] = $prefixHttp . 'api.b.huaml.com';
  69. if (strpos($referrer, $prefixHttp . 'h') === true || strpos($referrer, $prefixHttp . 'api.h') === true) {
  70. $config['b'] = $prefixHttp . 'api.h.huaml.com';
  71. }
  72. $config['s'] = $prefixHttp . 'api.s.huaml.com';
  73. $config['host'] = 'huaml.com';
  74. }
  75. if (getenv('YII_ENV') == 'development') {
  76. $config['c'] = $prefixHttp . 'api.m.huaml.com';
  77. $config['b'] = $prefixHttp . 'api.b.huaml.com';
  78. if (strpos($referrer, $prefixHttp . 'h') === true || strpos($referrer, $prefixHttp . 'api.h') === true) {
  79. $config['b'] = $prefixHttp . 'api.h.huaml.com';
  80. }
  81. $config['s'] = $prefixHttp . 'api.s.huaml.com';
  82. $config['host'] = 'huaml.com';
  83. }
  84. if (getenv('YII_ENV') == 'production') {
  85. $config['c'] = $prefixHttp . 'api.m.huahb.com';
  86. $config['b'] = $prefixHttp . 'api.b.huahb.com';
  87. $config['b'] = $prefixHttp . 'api.h.huahb.com';
  88. $config['s'] = $prefixHttp . 'api.s.huahb.com';
  89. $config['host'] = 'huahb.com';
  90. }
  91. return $config;