PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/NukeViet3.2/install/mainfile.php

http://nuke-viet.googlecode.com/
PHP | 172 lines | 157 code | 6 blank | 9 comment | 1 complexity | 58645e99126bacbfa5db8e867a5eb5f8 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  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', str_replace( '\\', '/', realpath( pathinfo( __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. if ( extension_loaded( 'suhosin' ) )
  39. {
  40. $sys_info['disable_functions'] = array_merge( $sys_info['disable_functions'], array_map( 'trim', preg_split( "/[\s,]+/", ini_get( "suhosin.executor.func.blacklist" ) ) ) );
  41. }
  42. $sys_info['ini_set_support'] = ( function_exists( 'ini_set' ) and ! in_array( 'ini_set', $sys_info['disable_functions'] ) ) ? true : false;
  43. require_once ( realpath( NV_ROOTDIR . "/install/config.php" ) );
  44. $global_config['my_domains'] = $_SERVER['SERVER_NAME'];
  45. //Ket noi voi cac file constants, config, timezone
  46. require_once ( NV_ROOTDIR . "/includes/constants.php" );
  47. require_once ( NV_ROOTDIR . '/includes/timezone.php' );
  48. define( 'NV_CURRENTTIME', time() );
  49. define( 'NV_CURRENTYEAR_FNUM', date( 'Y', NV_CURRENTTIME ) ); //2009
  50. define( 'NV_CURRENTYEAR_2NUM', date( 'y', NV_CURRENTTIME ) ); //09
  51. define( 'NV_CURRENTMONTH_NUM', date( 'm', NV_CURRENTTIME ) ); //01-12
  52. define( 'NV_CURRENTMONTH_FTXT', date( 'F', NV_CURRENTTIME ) ); //January - December
  53. define( 'NV_CURRENTMONTH_STXT', date( 'M', NV_CURRENTTIME ) ); //Jan - Dec
  54. define( 'NV_CURRENTDAY_2NUM', date( 'd', NV_CURRENTTIME ) ); //01 - 31
  55. define( 'NV_CURRENTDAY_1NUM', date( 'j', NV_CURRENTTIME ) ); //1 - 31
  56. define( 'NV_CURRENT12HOUR_2NUM', date( 'h', NV_CURRENTTIME ) ); //00-12
  57. define( 'NV_CURRENT12HOUR_1NUM', date( 'g', NV_CURRENTTIME ) ); //0-12
  58. define( 'NV_CURRENT24HOUR_2NUM', date( 'H', NV_CURRENTTIME ) ); //00-23
  59. define( 'NV_CURRENT24HOUR_1NUM', date( 'G', NV_CURRENTTIME ) ); //0-23
  60. define( 'NV_CURRENTMIN_2NUM', date( 'i', NV_CURRENTTIME ) ); //00-59
  61. define( 'NV_DEL_ONLINE_TIME', ( NV_CURRENTTIME - NV_ONLINE_UPD_TIME ) ); //Thoi gian xoa tinh trang online
  62. $global_config['log_errors_list'] = NV_LOG_ERRORS_LIST;
  63. $global_config['display_errors_list'] = NV_DISPLAY_ERRORS_LIST;
  64. $global_config['send_errors_list'] = NV_SEND_ERRORS_LIST;
  65. $global_config['error_log_path'] = NV_LOGS_DIR . '/error_logs';
  66. $global_config['error_log_filename'] = NV_ERRORLOGS_FILENAME;
  67. $global_config['error_log_fileext'] = NV_LOGS_EXT;
  68. //Ket noi voi class Error_handler
  69. require_once ( NV_ROOTDIR . '/includes/class/error.class.php' );
  70. $ErrorHandler = new Error( $global_config );
  71. set_error_handler( array( &$ErrorHandler, 'error_handler' ) );
  72. //Ket noi voi cac file cau hinh, function va template
  73. require_once ( NV_ROOTDIR . "/install/ini.php" );
  74. require_once ( NV_ROOTDIR . '/includes/functions.php' );
  75. require_once ( NV_ROOTDIR . '/includes/core/theme_functions.php' );
  76. require_once ( NV_ROOTDIR . "/includes/class/xtemplate.class.php" );
  77. $global_config['allow_request_mods'] = NV_ALLOW_REQUEST_MODS != '' ? array_map( "trim", explode( ",", NV_ALLOW_REQUEST_MODS ) ) : "request";
  78. $global_config['request_default_mode'] = NV_REQUEST_DEFAULT_MODE != '' ? trim( NV_REQUEST_DEFAULT_MODE ) : 'request';
  79. $global_config['XSS_replaceString'] = NV_XSS_REPLACESTRING != '' ? NV_XSS_REPLACESTRING : '';
  80. $global_config['cookie_key'] = $global_config['sitekey'];
  81. $global_config['cookie_secure'] = NV_COOKIE_SECURE;
  82. $global_config['cookie_httponly'] = NV_COOKIE_HTTPONLY;
  83. $global_config['session_save_path'] = ( is_writable( NV_ROOTDIR . '/' . NV_SESSION_SAVE_PATH ) ) ? NV_SESSION_SAVE_PATH : "";
  84. //Ket noi voi file xac dinh IP
  85. require_once ( NV_ROOTDIR . '/includes/class/ips.class.php' );
  86. $ips = new ips();
  87. define( 'NV_FORWARD_IP', $ips->forward_ip );
  88. define( 'NV_REMOTE_ADDR', $ips->remote_addr );
  89. //Xac dinh IP cua client
  90. $client_info['ip'] = $ips->remote_ip;
  91. $client_info['is_proxy'] = $ips->is_proxy;
  92. if ( $client_info['ip'] == "none" ) trigger_error( 'Error: Your IP address is not correct', 256 ); //Neu khong co IP
  93. //Ket noi voi class xu ly request
  94. require_once ( NV_ROOTDIR . '/includes/class/request.class.php' );
  95. $nv_Request = new Request( $global_config, $client_info['ip'] );
  96. //Ngon ngu
  97. $language_array = nv_parse_ini_file( NV_ROOTDIR . '/includes/ini/langs.ini', true );
  98. $site_lang = $nv_Request->get_string( NV_LANG_VARIABLE, 'get,post', $global_config['site_lang'] );
  99. require_once ( NV_ROOTDIR . '/includes/language.php' );
  100. require_once ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/global.php" );
  101. $global_config['cookie_path'] = $nv_Request->cookie_path; //vd: /ten_thu_muc_chua_site/
  102. $global_config['cookie_domain'] = $nv_Request->cookie_domain; //vd: .mydomain1.com
  103. $global_config['site_url'] = $nv_Request->site_url; //vd: http://mydomain1.com/ten_thu_muc_chua_site
  104. $global_config['my_domains'] = $nv_Request->my_domains; //vd: "mydomain1.com,mydomain2.com"
  105. $sys_info['register_globals'] = $nv_Request->is_register_globals; //0 = khong, 1 = bat
  106. $sys_info['magic_quotes_gpc'] = $nv_Request->is_magic_quotes_gpc; // 0 = khong, 1 = co
  107. $sys_info['sessionpath'] = $nv_Request->session_save_path; //vd: D:/AppServ/www/ten_thu_muc_chua_site/sess/
  108. $client_info['session_id'] = $nv_Request->session_id; //ten cua session
  109. $client_info['referer'] = $nv_Request->referer; //referer
  110. $client_info['is_myreferer'] = $nv_Request->referer_key; //0 = referer tu ben ngoai site, 1 = referer noi bo, 2 = khong co referer
  111. $client_info['selfurl'] = $nv_Request->my_current_domain . $nv_Request->request_uri; //trang dang xem
  112. $client_info['agent'] = $nv_Request->user_agent; //HTTP_USER_AGENT
  113. $global_config['sitekey'] = md5( $global_config['my_domains'] . NV_ROOTDIR . $client_info['session_id'] );
  114. define( 'NV_CLIENT_IP', $client_info['ip'] );
  115. define( 'NV_SERVER_NAME', $nv_Request->server_name ); //vd: mydomain1.com
  116. define( 'NV_SERVER_PROTOCOL', $nv_Request->server_protocol ); //vd: http
  117. define( 'NV_SERVER_PORT', $nv_Request->server_port ); //vd: 80
  118. define( 'NV_MY_DOMAIN', $nv_Request->my_current_domain ); //vd: http://mydomain1.com:80
  119. define( 'NV_HEADERSTATUS', $nv_Request->headerstatus ); //vd: HTTP/1.0
  120. define( 'NV_USER_AGENT', $nv_Request->user_agent ); //HTTP_USER_AGENT
  121. define( "NV_BASE_SITEURL", preg_replace( "/\/install$/", "/", $nv_Request->base_siteurl ) ); //vd: /ten_thu_muc_chua_site/
  122. define( "NV_BASE_ADMINURL", $nv_Request->base_adminurl . '/' ); //vd: /ten_thu_muc_chua_site/admin/
  123. define( 'NV_DOCUMENT_ROOT', $nv_Request->doc_root ); // D:/AppServ/www
  124. define( 'NV_EOL', ( strtoupper( substr( PHP_OS, 0, 3 ) == 'WIN' ) ? "\r\n" : ( strtoupper( substr( PHP_OS, 0, 3 ) == 'MAC' ) ? "\r" : "\n" ) ) ); //Ngat dong
  125. define( 'NV_UPLOADS_REAL_DIR', NV_ROOTDIR . '/' . NV_UPLOADS_DIR ); //Xac dinh duong dan thuc den thu muc upload
  126. //Chan truy cap neu HTTP_USER_AGENT == 'none'
  127. if ( NV_USER_AGENT == "none" )
  128. {
  129. 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 );
  130. }
  131. //Xac dinh borwser cua client
  132. $client_info['browser'] = array_combine( array( 'key', 'name' ), explode( "|", nv_getBrowser( NV_USER_AGENT, NV_ROOTDIR . '/includes/ini/br.ini' ) ) );
  133. //Class ma hoa du lieu $crypt->hash($data)
  134. require_once ( NV_ROOTDIR . '/includes/class/crypt.class.php' );
  135. $crypt = new nv_Crypt( $global_config['sitekey'], NV_CRYPT_SHA1 == 1 ? 'sha1' : 'md5' );
  136. if ( ! $crypt->_otk ) trigger_error( "sitekey not declared", 256 );
  137. ?>