index.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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('您的账号正在审核或是已经被系统禁止,请联系网站管理员解决!');
  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. if ($_GPC['m'] == 'zh_jdgjb') {
  49. $construct = IA_ROOT . "/addons/zh_jdgjb/init.php";
  50. require $construct;
  51. checkOrder();
  52. }
  53. $init = IA_ROOT . "/web/source/{$controller}/__init.php";
  54. if (is_file($init)) {
  55. require $init;
  56. }
  57. $actions = array();
  58. $actions_path = file_tree(IA_ROOT . '/web/source/' . $controller);
  59. foreach ($actions_path as $action_path) {
  60. $action_name = str_replace('.ctrl.php', '', basename($action_path));
  61. $section = basename(dirname($action_path));
  62. if ($section !== $controller) {
  63. $action_name = $section . '-' .$action_name;
  64. }
  65. $actions[] = $action_name;
  66. }
  67. if (empty($actions)) {
  68. header('location: ?refresh');
  69. }
  70. if (!in_array($action, $actions)) {
  71. $action = $action . '-' . $action;
  72. }
  73. if (!in_array($action, $actions)) {
  74. $action = $acl[$controller]['default'] ? $acl[$controller]['default'] : $actions[0];
  75. }
  76. if (is_array($acl[$controller]['direct']) && in_array($action, $acl[$controller]['direct'])) {
  77. require _forward($controller, $action);
  78. exit();
  79. }
  80. checklogin();
  81. if ($_W['role'] != ACCOUNT_MANAGE_NAME_FOUNDER) {
  82. if ($_W['role'] == ACCOUNT_MANAGE_NAME_UNBIND_USER) {
  83. itoast('', url('user/third-bind'));
  84. }
  85. if (empty($_W['uniacid'])) {
  86. if (defined('FRAME') && FRAME == 'account') {
  87. itoast('', url('account/display'), 'info');
  88. }
  89. if (defined('FRAME') && FRAME == 'wxapp') {
  90. itoast('', url('wxapp/display'), 'info');
  91. }
  92. }
  93. $acl = permission_build();
  94. if (empty($acl[$controller][$_W['role']]) || (!in_array($controller.'*', $acl[$controller][$_W['role']]) && !in_array($action, $acl[$controller][$_W['role']]))) {
  95. message('不能访问, 需要相应的权限才能访问!');
  96. }
  97. }
  98. require _forward($controller, $action);
  99. define('ENDTIME', microtime());
  100. if (empty($_W['config']['setting']['maxtimeurl'])) {
  101. $_W['config']['setting']['maxtimeurl'] = 10;
  102. }
  103. if ((ENDTIME - STARTTIME) > $_W['config']['setting']['maxtimeurl']) {
  104. $data = array(
  105. 'type' => '1',
  106. 'runtime' => ENDTIME - STARTTIME,
  107. 'runurl' => $_W['sitescheme'] . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
  108. 'createtime' => TIMESTAMP
  109. );
  110. pdo_insert('core_performance', $data);
  111. }
  112. function _forward($c, $a) {
  113. $file = IA_ROOT . '/web/source/' . $c . '/' . $a . '.ctrl.php';
  114. if (!file_exists($file)) {
  115. list($section, $a) = explode('-', $a);
  116. $file = IA_ROOT . '/web/source/' . $c . '/' . $section . '/' . $a . '.ctrl.php';
  117. }
  118. return $file;
  119. }
  120. function _calc_current_frames(&$frames) {
  121. global $controller, $action;
  122. if (!empty($frames['section']) && is_array($frames['section'])) {
  123. foreach ($frames['section'] as &$frame) {
  124. if (empty($frame['menu'])) {
  125. continue;
  126. }
  127. foreach ($frame['menu'] as &$menu) {
  128. $query = parse_url($menu['url'], PHP_URL_QUERY);
  129. parse_str($query, $urls);
  130. if (empty($urls)) {
  131. continue;
  132. }
  133. if (defined('ACTIVE_FRAME_URL')) {
  134. $query = parse_url(ACTIVE_FRAME_URL, PHP_URL_QUERY);
  135. parse_str($query, $get);
  136. } else {
  137. $get = $_GET;
  138. $get['c'] = $controller;
  139. $get['a'] = $action;
  140. }
  141. if (!empty($do)) {
  142. $get['do'] = $do;
  143. }
  144. $diff = array_diff_assoc($urls, $get);
  145. if (empty($diff)) {
  146. $menu['active'] = ' active';
  147. }
  148. }
  149. }
  150. }
  151. }