人人商城

index.php 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. define('IN_SYS', true);
  3. require '../framework/bootstrap.inc.php';
  4. require IA_ROOT . '/web/common/bootstrap.sys.inc.php';
  5. if (!empty($_GPC['state'])) {
  6. $login_callback_params = OAuth2Client::supportParams($_GPC['state']);
  7. if (!empty($login_callback_params)) {
  8. $controller = 'user';
  9. $action = 'login';
  10. $_GPC['login_type'] = $login_callback_params['from'];
  11. $_GPC['handle_type'] = $login_callback_params['mode'];
  12. }
  13. }
  14. if (empty($_W['isfounder']) && !empty($_W['user']) && ($_W['user']['status'] == USER_STATUS_CHECK || $_W['user']['status'] == USER_STATUS_BAN)) {
  15. message('您的账号正在审核或是已经被系统禁止,请联系网站管理员解决!', url('user/login'), 'info');
  16. }
  17. $acl = require IA_ROOT . '/web/common/permission.inc.php';
  18. $_W['page'] = array();
  19. $_W['page']['copyright'] = $_W['setting']['copyright'];
  20. if (($_W['setting']['copyright']['status'] == 1) && empty($_W['isfounder']) && $controller != 'cloud' && $controller != 'utility' && $controller != 'account') {
  21. $_W['siteclose'] = true;
  22. if ($controller == 'account' && $action == 'welcome') {
  23. template('account/welcome');
  24. exit();
  25. }
  26. if ($controller == 'user' && $action == 'login') {
  27. if (checksubmit()) {
  28. require _forward($controller, $action);
  29. }
  30. template('user/login');
  31. exit();
  32. }
  33. isetcookie('__session', '', - 10000);
  34. message('站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason'], url('account/welcome'), 'info');
  35. }
  36. $controllers = array();
  37. $handle = opendir(IA_ROOT . '/web/source/');
  38. if (!empty($handle)) {
  39. while ($dir = readdir($handle)) {
  40. if ($dir != '.' && $dir != '..') {
  41. $controllers[] = $dir;
  42. }
  43. }
  44. }
  45. if (!in_array($controller, $controllers)) {
  46. $controller = 'home';
  47. }
  48. $init = IA_ROOT . "/web/source/{$controller}/__init.php";
  49. if (is_file($init)) {
  50. require $init;
  51. }
  52. if (!(defined('FRAME') && in_array(FRAME, array('site', 'system')))) {
  53. if (!empty($_W['uniacid'])) {
  54. $_W['uniaccount'] = $_W['account'] = uni_fetch($_W['uniacid']);
  55. if (empty($_W['account'])) {
  56. unset($_W['uniacid']);
  57. }
  58. $_W['acid'] = $_W['account']['acid'];
  59. $_W['weid'] = $_W['uniacid'];
  60. }
  61. }
  62. $actions = array();
  63. $actions_path = file_tree(IA_ROOT . '/web/source/' . $controller);
  64. foreach ($actions_path as $action_path) {
  65. $action_name = str_replace('.ctrl.php', '', basename($action_path));
  66. $section = basename(dirname($action_path));
  67. if ($section !== $controller) {
  68. $action_name = $section . '-' .$action_name;
  69. }
  70. $actions[] = $action_name;
  71. }
  72. if (empty($actions)) {
  73. header('location: ?refresh');
  74. }
  75. if (!in_array($action, $actions)) {
  76. $action = $action . '-' . $action;
  77. }
  78. if (!in_array($action, $actions)) {
  79. $action = $acl[$controller]['default'] ? $acl[$controller]['default'] : $actions[0];
  80. }
  81. if (is_array($acl[$controller]['direct']) && in_array($action, $acl[$controller]['direct'])) {
  82. require _forward($controller, $action);
  83. exit();
  84. }
  85. checklogin();
  86. if ($_W['role'] != ACCOUNT_MANAGE_NAME_FOUNDER) {
  87. if ($_W['role'] == ACCOUNT_MANAGE_NAME_UNBIND_USER) {
  88. itoast('', url('user/third-bind'));
  89. }
  90. if (empty($_W['uniacid'])) {
  91. if (defined('FRAME') && FRAME == 'account') {
  92. itoast('', url('account/display', array('type' => ACCOUNT_TYPE_SIGN)), 'info');
  93. }
  94. if (defined('FRAME') && FRAME == 'wxapp') {
  95. itoast('', url('account/display', array('type' => WXAPP_TYPE_SIGN)), 'info');
  96. }
  97. }
  98. $acl = permission_build();
  99. if (empty($acl[$controller][$_W['role']]) || (!in_array($controller.'*', $acl[$controller][$_W['role']]) && !in_array($action, $acl[$controller][$_W['role']]))) {
  100. message('不能访问, 需要相应的权限才能访问!');
  101. }
  102. }
  103. require _forward($controller, $action);
  104. define('ENDTIME', microtime());
  105. if (empty($_W['config']['setting']['maxtimeurl'])) {
  106. $_W['config']['setting']['maxtimeurl'] = 10;
  107. }
  108. if ((ENDTIME - STARTTIME) > $_W['config']['setting']['maxtimeurl']) {
  109. $data = array(
  110. 'type' => '1',
  111. 'runtime' => ENDTIME - STARTTIME,
  112. 'runurl' => $_W['sitescheme'] . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
  113. 'createtime' => TIMESTAMP
  114. );
  115. pdo_insert('core_performance', $data);
  116. }
  117. function _forward($c, $a) {
  118. $file = IA_ROOT . '/web/source/' . $c . '/' . $a . '.ctrl.php';
  119. if (!file_exists($file)) {
  120. list($section, $a) = explode('-', $a);
  121. $file = IA_ROOT . '/web/source/' . $c . '/' . $section . '/' . $a . '.ctrl.php';
  122. }
  123. return $file;
  124. }
  125. function _calc_current_frames(&$frames) {
  126. global $controller, $action;
  127. if (!empty($frames['section']) && is_array($frames['section'])) {
  128. foreach ($frames['section'] as &$frame) {
  129. if (empty($frame['menu'])) {
  130. continue;
  131. }
  132. foreach ($frame['menu'] as $key => &$menu) {
  133. $query = parse_url($menu['url'], PHP_URL_QUERY);
  134. parse_str($query, $urls);
  135. if (empty($urls)) {
  136. continue;
  137. }
  138. if (defined('ACTIVE_FRAME_URL')) {
  139. $query = parse_url(ACTIVE_FRAME_URL, PHP_URL_QUERY);
  140. parse_str($query, $get);
  141. } else {
  142. $get = $_GET;
  143. $get['c'] = $controller;
  144. $get['a'] = $action;
  145. }
  146. if (!empty($do)) {
  147. $get['do'] = $do;
  148. }
  149. $diff = array_diff_assoc($urls, $get);
  150. if (empty($diff) ||
  151. $key == 'platform_site' && in_array($get['a'], array('style', 'article', 'category')) ||
  152. $key == 'mc_member' && in_array($get['a'], array('editor', 'group', 'fields')) ||
  153. $key == 'profile_setting' && in_array($get['a'], array('passport', 'tplnotice', 'notify', 'common')) ||
  154. $key == 'profile_payment' && in_array($get['a'], array('refund')) ||
  155. $key == 'statistics_visit' && in_array($get['a'], array('site', 'setting')) ||
  156. $key == 'wxapp_payment' && in_array($get['a'], array('refund'))) {
  157. $menu['active'] = ' active';
  158. }
  159. }
  160. }
  161. }
  162. }