PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/install/mainfile.php

http://creative-portal.googlecode.com/
PHP | 170 lines | 155 code | 6 blank | 9 comment | 1 complexity | 0f635e7a72779ddfdebe44a6b740b3ca MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-1-2010 22:42
  7. */
  8. if ( ! defined( 'NV_SYSTEM' ) and ! defined( 'NV_ADMIN' ) and ! defined( 'NV_WYSIWYG' ) )
  9. {
  10. Header( "Location: index.php" );
  11. exit();
  12. }
  13. define( 'NV_MAINFILE', true );
  14. //Thoi gian bat dau phien lam viec
  15. define( 'NV_START_TIME', array_sum( explode( " ", microtime() ) ) );
  16. //Khong cho xac dinh tu do cac variables
  17. $db_config = array();
  18. $global_config = array();
  19. $module_config = array();
  20. $client_info = array();
  21. $user_info = array();
  22. $admin_info = array();
  23. $sys_info = array();
  24. $lang_global = array();
  25. $lang_ = array();
  26. $rss = array();
  27. $nv_vertical_menu = array();
  28. $content_type = array();
  29. $blocks = array();
  30. $contents = "";
  31. $submenu = array();
  32. $select_options = array();
  33. $error_info = array();
  34. unset( $key_words, $page_title, $mod_title, $editor, $editor_password, $my_head );
  35. //Xac dinh thu muc goc cua site
  36. define( 'NV_ROOTDIR', realpath( pathinfo( str_replace( '\\', '/', __file__ ), PATHINFO_DIRNAME ) . '/../' ) );
  37. $sys_info['disable_functions'] = ( ini_get( "disable_functions" ) != "" and ini_get( "disable_functions" ) != false ) ? array_map( 'trim', preg_split( "/[\s,]+/", ini_get( "disable_functions" ) ) ) : array();
  38. $sys_info['ini_set_support'] = ( function_exists( 'ini_set' ) and ! in_array( 'ini_set', $sys_info['disable_functions'] ) ) ? true : false;
  39. require_once ( realpath( NV_ROOTDIR . "/install/config.php" ) );
  40. $global_config['my_domains'] = $_SERVER['SERVER_NAME'];
  41. //Ket noi voi cac file constants, config, timezone
  42. require_once ( NV_ROOTDIR . "/includes/constants.php" );
  43. require_once ( NV_ROOTDIR . '/includes/timezone.php' );
  44. define( 'NV_CURRENTTIME', time() );
  45. define( 'NV_CURRENTYEAR_FNUM', date( 'Y', NV_CURRENTTIME ) ); //2009
  46. define( 'NV_CURRENTYEAR_2NUM', date( 'y', NV_CURRENTTIME ) ); //09
  47. define( 'NV_CURRENTMONTH_NUM', date( 'm', NV_CURRENTTIME ) ); //01-12
  48. define( 'NV_CURRENTMONTH_FTXT', date( 'F', NV_CURRENTTIME ) ); //January - December
  49. define( 'NV_CURRENTMONTH_STXT', date( 'M', NV_CURRENTTIME ) ); //Jan - Dec
  50. define( 'NV_CURRENTDAY_2NUM', date( 'd', NV_CURRENTTIME ) ); //01 - 31
  51. define( 'NV_CURRENTDAY_1NUM', date( 'j', NV_CURRENTTIME ) ); //1 - 31
  52. define( 'NV_CURRENT12HOUR_2NUM', date( 'h', NV_CURRENTTIME ) ); //00-12
  53. define( 'NV_CURRENT12HOUR_1NUM', date( 'g', NV_CURRENTTIME ) ); //0-12
  54. define( 'NV_CURRENT24HOUR_2NUM', date( 'H', NV_CURRENTTIME ) ); //00-23
  55. define( 'NV_CURRENT24HOUR_1NUM', date( 'G', NV_CURRENTTIME ) ); //0-23
  56. define( 'NV_CURRENTMIN_2NUM', date( 'i', NV_CURRENTTIME ) ); //00-59
  57. define( 'NV_DEL_ONLINE_TIME', ( NV_CURRENTTIME - NV_ONLINE_UPD_TIME ) ); //Thoi gian xoa tinh trang online
  58. $global_config['log_errors_list'] = NV_LOG_ERRORS_LIST;
  59. $global_config['display_errors_list'] = NV_DISPLAY_ERRORS_LIST;
  60. $global_config['send_errors_list'] = NV_SEND_ERRORS_LIST;
  61. $global_config['error_log_path'] = NV_LOGS_DIR . '/error_logs';
  62. $global_config['error_log_filename'] = NV_ERRORLOGS_FILENAME;
  63. $global_config['error_log_fileext'] = NV_LOGS_EXT;
  64. //Ket noi voi class Error_handler
  65. require_once ( NV_ROOTDIR . '/includes/class/error.class.php' );
  66. $ErrorHandler = new Error( $global_config );
  67. set_error_handler( array(
  68. &$ErrorHandler, 'error_handler'
  69. ) );
  70. //Ket noi voi cac file cau hinh, function va template
  71. require_once ( NV_ROOTDIR . "/install/ini.php" );
  72. require_once ( NV_ROOTDIR . '/includes/functions.php' );
  73. require_once ( NV_ROOTDIR . '/includes/core/theme_functions.php' );
  74. require_once ( NV_ROOTDIR . "/includes/class/xtemplate.class.php" );
  75. $global_config['allow_request_mods'] = NV_ALLOW_REQUEST_MODS != '' ? array_map( "trim", explode( ",", NV_ALLOW_REQUEST_MODS ) ) : "request";
  76. $global_config['request_default_mode'] = NV_REQUEST_DEFAULT_MODE != '' ? trim( NV_REQUEST_DEFAULT_MODE ) : 'request';
  77. $global_config['XSS_replaceString'] = NV_XSS_REPLACESTRING != '' ? NV_XSS_REPLACESTRING : '';
  78. $global_config['cookie_key'] = $global_config['sitekey'];
  79. $global_config['cookie_secure'] = NV_COOKIE_SECURE;
  80. $global_config['cookie_httponly'] = NV_COOKIE_HTTPONLY;
  81. $global_config['session_save_path'] = "";
  82. //Ket noi voi file xac dinh IP
  83. require_once ( NV_ROOTDIR . '/includes/class/ips.class.php' );
  84. $ips = new ips();
  85. define( 'NV_CLIENT_IP', $ips->client_ip );
  86. define( 'NV_FORWARD_IP', $ips->forward_ip );
  87. define( 'NV_REMOTE_ADDR', $ips->remote_addr );
  88. //Xac dinh IP cua client
  89. $client_info['ip'] = $ips->remote_ip;
  90. $client_info['is_proxy'] = $ips->is_proxy;
  91. if ( $client_info['ip'] == "none" ) trigger_error( 'Error: Your IP address is not correct', 256 ); //Neu khong co IP
  92. //Ket noi voi class xu ly request
  93. require_once ( NV_ROOTDIR . '/includes/class/request.class.php' );
  94. $nv_Request = new Request( $global_config, $client_info['ip'] );
  95. //Ngon ngu
  96. $language_array = nv_parse_ini_file( NV_ROOTDIR . '/includes/ini/langs.ini', true );
  97. require_once ( NV_ROOTDIR . '/includes/language.php' );
  98. require_once ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/global.php" );
  99. $global_config['cookie_path'] = $nv_Request->cookie_path; //vd: /ten_thu_muc_chua_site/
  100. $global_config['cookie_domain'] = $nv_Request->cookie_domain; //vd: .mydomain1.com
  101. $global_config['site_url'] = $nv_Request->site_url; //vd: http://mydomain1.com/ten_thu_muc_chua_site
  102. $global_config['my_domains'] = $nv_Request->my_domains; //vd: "mydomain1.com,mydomain2.com"
  103. $sys_info['register_globals'] = $nv_Request->is_register_globals; //0 = khong, 1 = bat
  104. $sys_info['magic_quotes_gpc'] = $nv_Request->is_magic_quotes_gpc; // 0 = khong, 1 = co
  105. $sys_info['sessionpath'] = $nv_Request->session_save_path; //vd: D:/AppServ/www/ten_thu_muc_chua_site/sess/
  106. $client_info['session_id'] = $nv_Request->session_id; //ten cua session
  107. $client_info['referer'] = $nv_Request->referer; //referer
  108. $client_info['is_myreferer'] = $nv_Request->referer_key; //0 = referer tu ben ngoai site, 1 = referer noi bo, 2 = khong co referer
  109. $client_info['selfurl'] = $nv_Request->my_current_domain . $nv_Request->request_uri; //trang dang xem
  110. $client_info['agent'] = $nv_Request->user_agent; //HTTP_USER_AGENT
  111. $global_config['sitekey'] = md5( $global_config['my_domains'] . NV_ROOTDIR . $client_info['session_id'] );
  112. define( 'NV_SERVER_NAME', $nv_Request->server_name ); //vd: mydomain1.com
  113. define( 'NV_SERVER_PROTOCOL', $nv_Request->server_protocol ); //vd: http
  114. define( 'NV_SERVER_PORT', $nv_Request->server_port ); //vd: 80
  115. define( 'NV_MY_DOMAIN', $nv_Request->my_current_domain ); //vd: http://mydomain1.com:80
  116. define( 'NV_HEADERSTATUS', $nv_Request->headerstatus ); //vd: HTTP/1.0
  117. define( 'NV_USER_AGENT', $nv_Request->user_agent ); //HTTP_USER_AGENT
  118. define( "NV_BASE_SITEURL", $nv_Request->base_siteurl . '/' ); //vd: /ten_thu_muc_chua_site/
  119. define( "NV_BASE_ADMINURL", $nv_Request->base_adminurl . '/' ); //vd: /ten_thu_muc_chua_site/admin/
  120. define( 'NV_DOCUMENT_ROOT', $nv_Request->doc_root ); // D:/AppServ/www
  121. define( 'NV_EOL', ( strtoupper( substr( PHP_OS, 0, 3 ) == 'WIN' ) ? "\r\n" : ( strtoupper( substr( PHP_OS, 0, 3 ) == 'MAC' ) ? "\r" : "\n" ) ) ); //Ngat dong
  122. define( 'NV_UPLOADS_REAL_DIR', NV_ROOTDIR . '/' . NV_UPLOADS_DIR ); //Xac dinh duong dan thuc den thu muc upload
  123. //Chan truy cap neu HTTP_USER_AGENT == 'none'
  124. if ( NV_USER_AGENT == "none" )
  125. {
  126. trigger_error( 'We\'re sorry. The software you are using to access our website is not allowed. Some examples of this are e-mail harvesting programs and programs that will copy websites to your hard drive. If you feel you have gotten this message in error, please send an e-mail addressed to admin. Your I.P. address has been logged. Thanks.', 256 );
  127. }
  128. //Xac dinh borwser cua client
  129. $client_info['browser'] = array_combine( array(
  130. 'key', 'name'
  131. ), explode( "|", nv_getBrowser( NV_USER_AGENT, NV_ROOTDIR . '/includes/ini/br.ini' ) ) );
  132. //Class ma hoa du lieu $crypt->hash($data)
  133. require_once ( NV_ROOTDIR . '/includes/class/crypt.class.php' );
  134. $crypt = new nv_Crypt( $global_config['sitekey'], NV_CRYPT_SHA1 == 1 ? 'sha1' : 'md5' );
  135. if ( ! $crypt->_otk ) trigger_error( "sitekey not declared", 256 );
  136. ?>