admin.inc.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. require_once(APP.'config.inc.php');
  3. if(defined("TIMEZONE") && function_exists("date_default_timezone_set"))
  4. {
  5. date_default_timezone_set(TIMEZONE);
  6. }
  7. header("Content-type: text/html; charset=utf-8");
  8. //取得Get或Post参数信息
  9. //配置返回资料是否自动加入反斜线当溢出字符,设置为0关闭该功能
  10. @set_magic_quotes_runtime(0);
  11. $time = explode(" ",microtime());
  12. $time_start = $time[0] + $time[1];
  13. define("SYS_TIME_START",$time_start);
  14. unset($time_start,$time);
  15. //读取内存
  16. if(function_exists("memory_get_usage") && !defined("SYS_MEMORY_START"))
  17. {
  18. define("SYS_MEMORY_START",memory_get_usage());
  19. }
  20. if(defined("SYS_GZIP") && SYS_GZIP == true && function_exists("ob_gzhandler"))
  21. {
  22. ob_start("ob_gzhandler");
  23. }
  24. else
  25. {
  26. ob_start();
  27. }
  28. //域名授权在此修改 -开始
  29. //域名授权在此修改 -结束
  30. //判断是否有启用调试功能
  31. if(defined("SYS_IF_DEBUG") && SYS_IF_DEBUG == true)
  32. {
  33. //error_reporting(E_ALL);
  34. error_reporting(7);
  35. }
  36. else
  37. {
  38. error_reporting(0);
  39. }
  40. require_once(LIBS.'control.sys.php');
  41. //加载辅助函数,这里的辅助函数均不涉及到APP层上的信息
  42. //即这里的辅助函数均可以单独运行
  43. require_once(LIBS.'helper.sys.php');
  44. //[格式化Get,Post及$_FILES参数]
  45. @extract(sys_rgpc_safe($_POST));
  46. @extract(sys_rgpc_safe($_GET));
  47. if(!get_magic_quotes_gpc()) $_FILES = sys_rgpc_safe($_FILES);
  48. //执行GET参数,以获取有效的控制文件
  49. //如果没有检查到C层
  50. $p_c = sys_get_cf($config['control_trigger']);
  51. if(!$p_c) $p_c = "index";
  52. $p_f = sys_get_cf($config['function_trigger']);
  53. if(!$p_f) $p_f = "index";
  54. $p_d = sys_get_d($config['dir_trigger']);
  55. if($p_d)
  56. {
  57. if(substr($p_d,-1) != '/')
  58. {
  59. $p_d .= '/';
  60. }
  61. $control_file = APP.'control/'.$p_d.$p_c.'.php';
  62. }
  63. else
  64. {
  65. $control_file = APP.'control/'.$p_c.'.php';
  66. }
  67. if(!file_exists($control_file))
  68. {
  69. exit('error: file '.$p_c.'.php no exists!');
  70. }
  71. //判断文件是否存在
  72. $control_file = APP.'control/'.$p_d.$p_c.'.php';
  73. require_once($control_file);
  74. $control_name = strtolower($p_c)."_c";
  75. $APP = new $control_name();
  76. $APP->control_name = $p_c;//指定模块
  77. $system_time = time() + (defined("TIMETUNING") ? TIMETUNING : 0);
  78. $APP->system_time = $system_time;//系统时间
  79. //执行session信息
  80. $APP->session_lib->start($APP->db,$APP->db->prefix);
  81. //运行以下参数,以实现在函数中使用Control操作
  82. function sys_init()
  83. {
  84. global $APP;
  85. return $APP;
  86. }
  87. //
  88. function sys_app($var)
  89. {
  90. $app = sys_init();
  91. return $app->$var;
  92. }
  93. //将数据存到URL类中
  94. $APP->set_config($config);
  95. $APP->url = $APP->url(array("c"=>$p_c,"f"=>$p_f,"d"=>$p_d));
  96. $APP->tpl->assign("sys_app",$APP);
  97. //加载公共函数
  98. $dirlist = $APP->file_lib->ls(APP);
  99. foreach($dirlist AS $key=>$value)
  100. {
  101. $basename = strtolower(basename($value));
  102. if(substr($basename,-8) == "func.php")
  103. {
  104. include_once($value);
  105. }
  106. }
  107. unset($dirlist);
  108. //判断自动载入的model配置信息
  109. if(file_exists(APP."model.config.php"))
  110. {
  111. include(APP."model.config.php");
  112. if($_model_config["autoload"] && is_array($_model_config["autoload"]) && count($_model_config["autoload"])>0)
  113. {
  114. foreach($_model_config["autoload"] AS $key=>$value)
  115. {
  116. $APP->load_model($value);
  117. }
  118. }
  119. }
  120. //判断是否有新的语言模块,有就重写
  121. if($APP->langconfig_m)
  122. {
  123. $_tmp_langid = $_SESSION["sys_lang_id"] ? $_SESSION["sys_lang_id"] : "";
  124. $_tmp_rs = $APP->langconfig_m->get_one($_tmp_langid);
  125. if($_tmp_rs)
  126. {
  127. $_SESSION["sys_lang_id"] = $_tmp_rs["langid"];
  128. }
  129. else
  130. {
  131. $_SESSION["sys_lang_id"] = defined("SYS_LANG") ? SYS_LANG : "zh";
  132. }
  133. //读取语言包数据,后台强制为中文
  134. $_lang = $APP->langconfig_m->get_list("zh");
  135. //$_lang = $APP->langconfig_m->get_list($_SESSION["sys_lang_id"]);
  136. }
  137. else
  138. {
  139. $_SESSION["sys_lang_id"] = defined("SYS_LANG") ? SYS_LANG : "zh";
  140. $_lang = array();
  141. }
  142. //指定语言包
  143. $_lang = $APP->lang($_SESSION["sys_lang_id"],$_lang);
  144. $APP->langid = $_SESSION["sys_lang_id"];
  145. //验证管理员
  146. if(defined("SYS_IF_CHECKED") && SYS_IF_CHECKED == true)
  147. {
  148. if(!defined("SYS_CHECKED_SESSION_ID") || SYS_CHECKED_SESSION_ID == "" || !defined("SYS_CHECKED_FALSE") || SYS_CHECKED_FALSE == "")
  149. {
  150. exit("error: setting false.");
  151. }
  152. if(!$_SESSION[SYS_CHECKED_SESSION_ID] && $p_c != SYS_CHECKED_FALSE)
  153. {
  154. $url = $APP->url(SYS_CHECKED_FALSE);
  155. sys_header($url);
  156. }
  157. }
  158. $function_name = strtolower($p_f)."_f";
  159. unset($p_c,$p_f,$p_d,$control_file);
  160. $APP->$function_name();
  161. ?>