index.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. define('IN_SYS', true);
  3. define('IN_dianc_ADMIN', true);
  4. require '../../../framework/bootstrap.inc.php';
  5. //require IA_ROOT . '/web/common/bootstrap.sys.inc.php';
  6. define('dianc_ROOT', dirname(dirname(__FILE__)));
  7. define('IS_OPERATOR', true);
  8. require dianc_ROOT . '/admin/common/bootstrap.sys.inc.php';
  9. require dianc_ROOT . '/admin/common/template.func.php';
  10. require dianc_ROOT . '/admin/common/common.func.php';
  11. $urls = parse_url($_W['siteroot']);
  12. $arr = explode('/', $urls['path']);
  13. do {
  14. $val = array_pop($arr);
  15. } while ($val != 'addons');
  16. $path = implode('/', $arr);
  17. if(substr($path, -1) != '/') {
  18. $path .= '/';
  19. }
  20. $urls['path'] = $path;
  21. $_W['siteroot'] = $urls['scheme'].'://'.$urls['host'].((!empty($urls['port']) && $urls['port']!='80') ? ':'.$urls['port'] : '').$urls['path'];
  22. //load()->web('common');
  23. //load()->web('template');
  24. if (empty($_W['isfounder']) && !empty($_W['user']) && $_W['user']['status'] == 1) {
  25. message('您的账号正在审核或是已经被系统禁止,请联系网站管理员解决!');
  26. }
  27. $acl = array(
  28. 'user' => array(
  29. 'default' => 'login',
  30. 'direct' => array(
  31. 'login',
  32. 'register',
  33. 'logout',
  34. ),
  35. ),
  36. );
  37. if (($_W['setting']['copyright']['status'] == 1) && empty($_W['isfounder']) && $controller != 'cloud' && $controller != 'utility' && $controller != 'account') {
  38. $_W['siteclose'] = true;
  39. if ($controller == 'account' && $action == 'welcome') {
  40. template('account/welcome');
  41. exit;
  42. }
  43. if ($controller == 'user' && $action == 'login') {
  44. if (checksubmit()) {
  45. require _forward($controller, $action);
  46. }
  47. template('user/login');
  48. exit;
  49. }
  50. isetcookie('__session', '', -10000);
  51. message('站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason'], url('account/welcome'), 'info');
  52. }
  53. $controllers = array();
  54. $handle = opendir(IA_ROOT . '/web/source/');
  55. if(!empty($handle)) {
  56. while($dir = readdir($handle)) {
  57. if($dir != '.' && $dir != '..') {
  58. $controllers[] = $dir;
  59. }
  60. }
  61. }
  62. if(!in_array($controller, $controllers)) {
  63. $controller = 'account';
  64. }
  65. $init = IA_ROOT . "/web/source/{$controller}/__init.php";
  66. if(is_file($init)) {
  67. require $init;
  68. }
  69. $actions = array();
  70. $handle = opendir(IA_ROOT . '/web/source/' . $controller);
  71. if(!empty($handle)) {
  72. while($dir = readdir($handle)) {
  73. if($dir != '.' && $dir != '..' && strexists($dir, '.ctrl.php')) {
  74. $dir = str_replace('.ctrl.php', '', $dir);
  75. $actions[] = $dir;
  76. }
  77. }
  78. }
  79. if(empty($actions)) {
  80. header('location: ?refresh');
  81. }
  82. if(!in_array($action, $actions)) {
  83. $action = $acl[$controller]['default'];
  84. }
  85. if(!in_array($action, $actions)) {
  86. $action = $actions[0];
  87. }
  88. $_W['page'] = array();
  89. $_W['page']['copyright'] = $_W['setting']['copyright'];
  90. if(is_array($acl[$controller]['direct']) && in_array($action, $acl[$controller]['direct'])) {
  91. require _forward($controller, $action);
  92. exit;
  93. }
  94. if(is_array($acl[$controller]['founder']) && in_array($action, $acl[$controller]['founder'])) {
  95. if(!$_W['isfounder']) {
  96. message('不能访问, 需要创始人权限才能访问.');
  97. }
  98. }
  99. checklogin();
  100. if(!defined('IN_GW')) {
  101. // checkaccount();
  102. if(!in_array($_W['role'], array('manager', 'operator', 'founder', 'clerk'))) {
  103. // message('您的账号没有访问此公众号的权限.');
  104. }
  105. }
  106. require _forward($controller, $action);
  107. define('ENDTIME', microtime());
  108. if (empty($_W['config']['setting']['maxtimeurl'])) {
  109. $_W['config']['setting']['maxtimeurl'] = 10;
  110. }
  111. if ((ENDTIME - STARTTIME) > $_W['config']['setting']['maxtimeurl']) {
  112. $data = array(
  113. 'type' => '1',
  114. 'runtime' => ENDTIME - STARTTIME,
  115. 'runurl' => $_W['sitescheme'].$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
  116. 'createtime' => TIMESTAMP
  117. );
  118. pdo_insert('core_performance', $data);
  119. }
  120. function _forward($c, $a) {
  121. $file = dianc_ROOT . '/admin/source/' . $c . '/' . $a . '.ctrl.php';
  122. return $file;
  123. }
  124. function _calc_current_frames(&$frames) {
  125. global $controller, $action;
  126. if(!empty($frames) && is_array($frames)) {
  127. foreach($frames as &$frame) {
  128. if(empty($frame['items'])) continue;
  129. foreach($frame['items'] as &$fr) {
  130. $query = parse_url($fr['url'], PHP_URL_QUERY);
  131. parse_str($query, $urls);
  132. if(empty($urls)) continue;
  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. $fr['active'] = ' active';
  147. }
  148. }
  149. }
  150. }
  151. }