index.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. print_r('ok');exit();
  3. function isMobile()
  4. {
  5. // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
  6. if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
  7. {
  8. return true;
  9. }
  10. // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
  11. if (isset ($_SERVER['HTTP_VIA']))
  12. {
  13. // 找不到为flase,否则为true
  14. return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
  15. }
  16. // 脑残法,判断手机发送的客户端标志,兼容性有待提高
  17. if (isset ($_SERVER['HTTP_USER_AGENT']))
  18. {
  19. $clientkeywords = array ('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone','ipod', 'blackberry', 'meizu','android','netfront','symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile'
  20. );
  21. // 从HTTP_USER_AGENT中查找手机浏览器的关键字
  22. if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
  23. {
  24. return true;
  25. }
  26. }
  27. // 协议法,因为有可能不准确,放到最后判断
  28. if (isset ($_SERVER['HTTP_ACCEPT']))
  29. {
  30. // 如果只支持wml并且不支持html那一定是移动设备
  31. // 如果支持wml和html但是wml在html之前则是移动设备
  32. if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. //if(isMobile()){
  40. // header("Location:http://m.9026.com");
  41. //}
  42. /**
  43. * [Discuz!] (C)2001-2099 Comsenz Inc.
  44. * This is NOT a freeware, use is subject to license terms
  45. *
  46. * $Id: index.php 34524 2014-05-15 04:42:23Z nemohou $
  47. */
  48. if(!empty($_SERVER['QUERY_STRING']) && is_numeric($_SERVER['QUERY_STRING'])) {
  49. $_ENV['curapp'] = 'home';
  50. $_GET = array('mod'=>'space', 'uid'=>$_SERVER['QUERY_STRING']);
  51. } else {
  52. $url = '';
  53. $domain = $_ENV = array();
  54. $jump = false;
  55. @include_once './data/sysdata/cache_domain.php';
  56. $_ENV['domain'] = $domain;
  57. if(empty($_ENV['domain'])) {
  58. $_ENV['curapp'] = 'forum';
  59. } else {
  60. $_ENV['defaultapp'] = array('portal.php' => 'portal', 'forum.php' => 'forum', 'group.php' => 'group', 'home.php' => 'home');
  61. $_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);
  62. $_ENV['domainroot'] = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
  63. if(!empty($_ENV['domain']['app']) && is_array($_ENV['domain']['app']) && in_array($_SERVER['HTTP_HOST'], $_ENV['domain']['app'])) {
  64. $_ENV['curapp'] = array_search($_SERVER['HTTP_HOST'], $_ENV['domain']['app']);
  65. if($_ENV['curapp'] == 'mobile') {
  66. $_ENV['curapp'] = 'forum';
  67. if(!isset($_GET['mobile'])) {
  68. @$_GET['mobile'] = '2';
  69. }
  70. }
  71. if($_ENV['curapp'] == 'default' || !isset($_ENV['defaultapp'][$_ENV['curapp'].'.php'])) {
  72. $_ENV['curapp'] = '';
  73. }
  74. } elseif(!empty($_ENV['domain']['root']) && is_array($_ENV['domain']['root']) && in_array($_ENV['domainroot'], $_ENV['domain']['root'])) {
  75. $_G['setting']['holddomain'] = $_ENV['domain']['holddomain'] ? $_ENV['domain']['holddomain'] : array('www');
  76. $list = $_ENV['domain']['list'];
  77. if(isset($list[$_SERVER['HTTP_HOST']])) {
  78. $domain = $list[$_SERVER['HTTP_HOST']];
  79. switch($domain['idtype']) {
  80. case 'subarea':
  81. $_ENV['curapp'] = 'forum';
  82. $_GET['gid'] = intval($domain['id']);
  83. break;
  84. case 'forum':
  85. $_ENV['curapp'] = 'forum';
  86. $_GET['mod'] = 'forumdisplay';
  87. $_GET['fid'] = intval($domain['id']);
  88. break;
  89. case 'topic':
  90. $_ENV['curapp'] = 'portal';
  91. $_GET['mod'] = 'topic';
  92. $_GET['topicid'] = intval($domain['id']);
  93. break;
  94. case 'channel':
  95. $_ENV['curapp'] = 'portal';
  96. $_GET['mod'] = 'list';
  97. $_GET['catid'] = intval($domain['id']);
  98. break;
  99. case 'plugin':
  100. $_ENV['curapp'] = 'plugin';
  101. $_GET['id'] = $domain['id'];
  102. $_GET['fromapp'] = 'index';
  103. break;
  104. }
  105. } elseif(count($_ENV['hostarr']) > 2 && $_ENV['hostarr'][0] != 'www' && !checkholddomain($_ENV['hostarr'][0])) {
  106. $_ENV['prefixdomain'] = addslashes($_ENV['hostarr'][0]);
  107. $_ENV['domainroot'] = addslashes($_ENV['domainroot']);
  108. require_once './source/class/class_core.php';
  109. C::app()->init_setting = true;
  110. C::app()->init_user = false;
  111. C::app()->init_session = false;
  112. C::app()->init_cron = false;
  113. C::app()->init_misc = false;
  114. C::app()->init();
  115. $jump = true;
  116. $domain = C::t('common_domain')->fetch_by_domain_domainroot($_ENV['prefixdomain'], $_ENV['domainroot']);
  117. $apphost = $_ENV['domain']['app'][$domain['idtype']] ? $_ENV['domain']['app'][$domain['idtype']] : $_ENV['domain']['app']['default'];
  118. $apphost = $apphost ? 'http://'.$apphost.'/' : '';
  119. switch($domain['idtype']) {
  120. case 'home':
  121. if($_G['setting']['rewritestatus'] && in_array('home_space', $_G['setting']['rewritestatus'])) {
  122. $url = rewriteoutput('home_space', 1, $apphost, $domain['id']);
  123. } else {
  124. $url = $apphost.'home.php?mod=space&uid='.$domain['id'];
  125. }
  126. break;
  127. case 'group':
  128. if($_G['setting']['rewritestatus'] && in_array('group_group', $_G['setting']['rewritestatus'])) {
  129. $url = rewriteoutput('group_group', 1, $apphost, $domain['id']);
  130. } else {
  131. $url = $apphost.'forum.php?mod=group&fid='.$domain['id'].'&page=1';
  132. }
  133. break;
  134. }
  135. }
  136. } else {
  137. $jump = true;
  138. }
  139. if(empty($url) && empty($_ENV['curapp'])) {
  140. if(!empty($_ENV['domain']['defaultindex']) && !$jump) {
  141. if($_ENV['defaultapp'][$_ENV['domain']['defaultindex']]) {
  142. $_ENV['curapp'] = $_ENV['defaultapp'][$_ENV['domain']['defaultindex']];
  143. } else {
  144. $url = $_ENV['domain']['defaultindex'];
  145. }
  146. } else {
  147. if($jump) {
  148. $url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];
  149. } else {
  150. $_ENV['curapp'] = 'forum';
  151. }
  152. }
  153. }
  154. }
  155. }
  156. if(!empty($url)) {
  157. $delimiter = strrpos($url, '?') ? '&' : '?';
  158. if(isset($_GET['fromuid']) && $_GET['fromuid']) {
  159. $url .= sprintf('%sfromuid=%d', $delimiter, $_GET['fromuid']);
  160. } elseif(isset($_GET['fromuser']) && $_GET['fromuser']) {
  161. $url .= sprintf('%sfromuser=%s', $delimiter, rawurlencode($_GET['fromuser']));
  162. }
  163. header("HTTP/1.1 301 Moved Permanently");
  164. header("location: $url");
  165. } else {
  166. require './'.$_ENV['curapp'].'.php';
  167. }
  168. function checkholddomain($domain) {
  169. global $_G;
  170. $domain = strtolower($domain);
  171. if(preg_match("/^[^a-z]/i", $domain)) return true;
  172. $holdmainarr = empty($_G['setting']['holddomain']) ? array('www') : explode('|', $_G['setting']['holddomain']);
  173. $ishold = false;
  174. foreach ($holdmainarr as $value) {
  175. if(strpos($value, '*') === false) {
  176. if(strtolower($value) == $domain) {
  177. $ishold = true;
  178. break;
  179. }
  180. } else {
  181. $value = str_replace('*', '.*?', $value);
  182. if(@preg_match("/$value/i", $domain)) {
  183. $ishold = true;
  184. break;
  185. }
  186. }
  187. }
  188. return $ishold;
  189. }
  190. ?>