PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/init.inc.php

http://freewms.googlecode.com/
PHP | 139 lines | 69 code | 18 blank | 52 comment | 15 complexity | f844b9b1fce7183c8771ec9f3241fca3 MD5 | raw file
  1. <?php if(!defined('BASEPATH')) die('Access Denied');
  2. /*-------------------------------------------------
  3. * FreeWMS - A Free Website Management System
  4. * Ver:0.1.0 Update: 2010-05-16
  5. * Home: http://code.google.com/p/freewms
  6. * Copyright 2010, FreeWMS Team, SOVO, Neusoft
  7. * Released under the New BSD Licenses
  8. *-------------------------------------------------*/
  9. /*-------------------------------------------------
  10. | ????????
  11. *-----------------------------------------------*/
  12. error_reporting(E_ALL ^ E_NOTICE && E_STRICT);
  13. /*-------------------------------------------------
  14. | ??????????
  15. *-----------------------------------------------*/
  16. @set_magic_quotes_runtime(0);
  17. /*-------------------------------------------------
  18. | ??????????
  19. *-----------------------------------------------*/
  20. require_once BASEPATH.'config/database.php';
  21. require_once BASEPATH.'config/system.php';
  22. /*-------------------------------------------------
  23. | ?????????
  24. *-----------------------------------------------*/
  25. require_once BASEPATH.'inc/global.func.php';
  26. /*-------------------------------------------------
  27. | ??????????
  28. *-----------------------------------------------*/
  29. define('SYS_START_TIME', get_micro_time());
  30. /*-------------------------------------------------
  31. | ??????????
  32. *-----------------------------------------------*/
  33. unregister_globals();
  34. /*-------------------------------------------------
  35. | ??????
  36. *-----------------------------------------------*/
  37. if(function_exists('date_default_timezone_set')) {
  38. date_default_timezone_set(SITE_TIMEZONE);
  39. }
  40. /*-------------------------------------------------
  41. | ???????
  42. *-----------------------------------------------*/
  43. function __autoload($class_name) {
  44. $clsfile = BASEPATH.'inc/'.strtolower($class_name).'.class.php';
  45. if(!is_file($clsfile)) {
  46. die("<p>Load Class {$class_name} Failed.</p>");
  47. }
  48. require_once $clsfile;
  49. }
  50. /*-------------------------------------------------
  51. | ??????
  52. *-----------------------------------------------*/
  53. Config::load('site');
  54. /*-------------------------------------------------
  55. | ???SESSION??
  56. *-----------------------------------------------*/
  57. if(SESSION_TYPE == 'file') {
  58. session_save_path(SESSION_PATH);
  59. }else{
  60. $session_lib_file = BASEPATH.'inc/session/'.SESSION_TYPE.'.php';
  61. if(is_file($session_lib_file)) {
  62. @include_once $session_lib_file;
  63. session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
  64. }else{
  65. die('Can not find session library named '.SESSION_TYPE);
  66. }
  67. }
  68. session_cache_expire(SESSION_EXPIRES);
  69. session_start();
  70. /*-------------------------------------------------
  71. | ????????
  72. *-----------------------------------------------*/
  73. if(SITE_GZIP && function_exists('ob_gzhandler')) {
  74. ob_start('ob_gzhandler');
  75. }else{
  76. ob_start();
  77. }
  78. /*-------------------------------------------------
  79. | ??URL????, ??URL??
  80. *-----------------------------------------------*/
  81. URL::init();
  82. /*-------------------------------------------------
  83. | ????????
  84. *-----------------------------------------------*/
  85. if(defined('PAGE_MOD') && defined('PAGE_ACT')) {
  86. $module = PAGE_MOD;
  87. $action = PAGE_ACT;
  88. }else{
  89. $module = empty($_GET['m']) ? 'index' : $_GET['m'];
  90. $action = empty($_GET['a']) ? 'index' : $_GET['a'];
  91. }
  92. if(!preg_match('/^[a-z0-9-_]+$/i', $module.$action)) {
  93. $module = $action = 'index';
  94. }
  95. $mod_inc_file = BASEPATH.'module/'.$module.'/'.$action.'.inc.php';
  96. $mod_cls_file = BASEPATH.'module/'.$module.'/'.$module.'.class.php';
  97. $mod_cls_name = 'mod_'.$module;
  98. $mod_cls_action = 'action_'.$action;
  99. define('MOD_PATH', BASEPATH.'module/'.$module.'/');
  100. define('MOD_NAME', $module);
  101. if(is_file($mod_inc_file)) {
  102. //???????????
  103. include $mod_inc_file;
  104. }elseif(is_file($mod_cls_file)) {
  105. //???????????
  106. include_once $mod_cls_file;
  107. if(class_exists($mod_cls_name)) {
  108. $obj = new $mod_cls_name();
  109. if(!method_exists($obj, $mod_cls_action)) show_404();
  110. $obj->$mod_cls_action();
  111. }else{
  112. show_404();
  113. }
  114. }else{
  115. show_404();
  116. }
  117. //-----------------------------------------
  118. // ????
  119. //-----------------------------------------
  120. exit();
  121. /* End of this file */