人人商城

bootstrap.inc.php 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. define('IN_IA', true);
  3. define('STARTTIME', microtime());
  4. define('IA_ROOT', str_replace("\\", '/', dirname(dirname(__FILE__))));
  5. define('MAGIC_QUOTES_GPC', (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) || @ini_get('magic_quotes_sybase'));
  6. define('TIMESTAMP', time());
  7. $_W = $_GPC = array();
  8. $configfile = IA_ROOT . "/data/config.php";
  9. if(!file_exists($configfile)) {
  10. if(file_exists(IA_ROOT . '/install.php')) {
  11. header('Content-Type: text/html; charset=utf-8');
  12. require IA_ROOT . '/framework/version.inc.php';
  13. echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
  14. echo "·如果你还没安装本程序,请运行<a href='".(strpos($_SERVER['SCRIPT_NAME'], 'web') === false ? './install.php' : '../install.php')."'> install.php 进入安装&gt;&gt; </a><br/><br/>";
  15. echo "&nbsp;&nbsp;<a href='http://www.we7.cc' style='font-size:12px' target='_blank'>Power by WE7 " . IMS_VERSION . " &nbsp;微擎公众平台自助开源引擎</a>";
  16. exit();
  17. } else {
  18. header('Content-Type: text/html; charset=utf-8');
  19. exit('配置文件不存在或是不可读,请检查“data/config”文件或是重新安装!');
  20. }
  21. }
  22. require $configfile;
  23. require IA_ROOT . '/framework/version.inc.php';
  24. require IA_ROOT . '/framework/const.inc.php';
  25. require IA_ROOT . '/framework/class/loader.class.php';
  26. load()->func('global');
  27. load()->func('compat');
  28. load()->func('pdo');
  29. load()->classs('account');
  30. load()->model('cache');
  31. load()->model('account');
  32. load()->model('setting');
  33. load()->model('module');
  34. load()->library('agent');
  35. load()->classs('db');
  36. load()->func('communication');
  37. define('CLIENT_IP', getip());
  38. $_W['config'] = $config;
  39. $_W['config']['db']['tablepre'] = !empty($_W['config']['db']['master']['tablepre']) ? $_W['config']['db']['master']['tablepre'] : $_W['config']['db']['tablepre'];
  40. $_W['timestamp'] = TIMESTAMP;
  41. $_W['charset'] = $_W['config']['setting']['charset'];
  42. $_W['clientip'] = CLIENT_IP;
  43. unset($configfile, $config);
  44. define('ATTACHMENT_ROOT', IA_ROOT .'/attachment/');
  45. error_reporting(0);
  46. if(!in_array($_W['config']['setting']['cache'], array('mysql', 'memcache', 'redis'))) {
  47. $_W['config']['setting']['cache'] = 'mysql';
  48. }
  49. load()->func('cache');
  50. if(function_exists('date_default_timezone_set')) {
  51. date_default_timezone_set($_W['config']['setting']['timezone']);
  52. }
  53. if(!empty($_W['config']['setting']['memory_limit']) && function_exists('ini_get') && function_exists('ini_set')) {
  54. if(@ini_get('memory_limit') != $_W['config']['setting']['memory_limit']) {
  55. @ini_set('memory_limit', $_W['config']['setting']['memory_limit']);
  56. }
  57. }
  58. if (isset($_W['config']['setting']['https']) && $_W['config']['setting']['https'] == '1') {
  59. $_W['ishttps'] = $_W['config']['setting']['https'];
  60. } else {
  61. $_W['ishttps'] = $_SERVER['SERVER_PORT'] == 443 ||
  62. (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ||
  63. strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ||
  64. strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https' ? true : false;
  65. }
  66. $_W['isajax'] = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
  67. $_W['ispost'] = $_SERVER['REQUEST_METHOD'] == 'POST';
  68. $_W['sitescheme'] = $_W['ishttps'] ? 'https://' : 'http://';
  69. $_W['script_name'] = htmlspecialchars(scriptname());
  70. $sitepath = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
  71. $_W['siteroot'] = htmlspecialchars($_W['sitescheme'] . $_SERVER['HTTP_HOST'] . $sitepath);
  72. if(substr($_W['siteroot'], -1) != '/') {
  73. $_W['siteroot'] .= '/';
  74. }
  75. $urls = parse_url($_W['siteroot']);
  76. $urls['path'] = str_replace(array('/web', '/app', '/payment/wechat', '/payment/alipay', '/payment/jueqiymf', '/api'), '', $urls['path']);
  77. $_W['siteroot'] = $urls['scheme'].'://'.$urls['host'].((!empty($urls['port']) && $urls['port']!='80') ? ':'.$urls['port'] : '').$urls['path'];
  78. if(MAGIC_QUOTES_GPC) {
  79. $_GET = istripslashes($_GET);
  80. $_POST = istripslashes($_POST);
  81. $_COOKIE = istripslashes($_COOKIE);
  82. }
  83. foreach($_GET as $key => $value) {
  84. if (is_string($value) && !is_numeric($value)) {
  85. $value = safe_gpc_string($value);
  86. }
  87. $_GET[$key] = $_GPC[$key] = $value;
  88. }
  89. $cplen = strlen($_W['config']['cookie']['pre']);
  90. foreach($_COOKIE as $key => $value) {
  91. if(substr($key, 0, $cplen) == $_W['config']['cookie']['pre']) {
  92. $_GPC[substr($key, $cplen)] = $value;
  93. }
  94. }
  95. unset($cplen, $key, $value);
  96. $_GPC = array_merge($_GPC, $_POST);
  97. $_GPC = ihtmlspecialchars($_GPC);
  98. $_W['siteurl'] = $urls['scheme'].'://'.$urls['host'].((!empty($urls['port']) && $urls['port']!='80') ? ':'.$urls['port'] : '') . $_W['script_name'] . '?' . http_build_query($_GET, '', '&');
  99. if (!$_W['isajax']) {
  100. $input = file_get_contents("php://input");
  101. if (!empty($input)) {
  102. $__input = @json_decode($input, true);
  103. if (!empty($__input)) {
  104. $_GPC['__input'] = $__input;
  105. $_W['isajax'] = true;
  106. }
  107. }
  108. unset($input, $__input);
  109. }
  110. setting_load();
  111. if (empty($_W['setting']['upload'])) {
  112. $_W['setting']['upload'] = array_merge($_W['config']['upload']);
  113. }
  114. define('DEVELOPMENT', $_W['setting']['copyright']['develop_status'] == 1 || $_W['config']['setting']['development'] == 1);
  115. if(DEVELOPMENT) {
  116. ini_set('display_errors', '1');
  117. error_reporting(E_ALL ^ E_NOTICE);
  118. }
  119. if ($_W['config']['setting']['development'] == 2) {
  120. load()->library('sentry');
  121. if (class_exists('Raven_Autoloader')) {
  122. error_reporting(E_ALL ^ E_NOTICE);
  123. Raven_Autoloader::register();
  124. $client = new Raven_Client('http://8d52c70dbbed4133b72e3b8916663ae3:0d84397f72204bf1a3f721edf9c782e1@sentry.w7.cc/6');
  125. $error_handler = new Raven_ErrorHandler($client);
  126. $error_handler->registerExceptionHandler();
  127. $error_handler->registerErrorHandler();
  128. $error_handler->registerShutdownFunction();
  129. }
  130. }
  131. $_W['os'] = Agent::deviceType();
  132. if($_W['os'] == Agent::DEVICE_MOBILE) {
  133. $_W['os'] = 'mobile';
  134. } elseif($_W['os'] == Agent::DEVICE_DESKTOP) {
  135. $_W['os'] = 'windows';
  136. } else {
  137. $_W['os'] = 'unknown';
  138. }
  139. $_W['container'] = Agent::browserType();
  140. if(Agent::isMicroMessage() == Agent::MICRO_MESSAGE_YES) {
  141. $_W['container'] = 'wechat';
  142. } elseif ($_W['container'] == Agent::BROWSER_TYPE_ANDROID) {
  143. $_W['container'] = 'android';
  144. } elseif ($_W['container'] == Agent::BROWSER_TYPE_IPAD) {
  145. $_W['container'] = 'ipad';
  146. } elseif ($_W['container'] == Agent::BROWSER_TYPE_IPHONE) {
  147. $_W['container'] = 'iphone';
  148. } elseif ($_W['container'] == Agent::BROWSER_TYPE_IPOD) {
  149. $_W['container'] = 'ipod';
  150. } elseif ($_W['container'] == Agent::BROWSER_TYPE_XZAPP) {
  151. $_W['container'] = 'baidu';
  152. } else {
  153. $_W['container'] = 'unknown';
  154. }
  155. if ($_W['container'] == 'wechat' || $_W['container'] == 'baidu') {
  156. $_W['platform'] = 'account';
  157. }
  158. $controller = $_GPC['c'];
  159. $action = $_GPC['a'];
  160. $do = $_GPC['do'];
  161. header('Content-Type: text/html; charset=' . $_W['charset']);