PageRenderTime 44ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/mainfile.php

http://viet-group.googlecode.com/
PHP | 474 lines | 414 code | 34 blank | 26 comment | 41 complexity | fdc011bc72fa059b2336854a8718fd99 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 31/05/2010, 00:36
  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. $array_mod_title = array();
  29. $content_type = array();
  30. $blocks = array();
  31. $contents = "";
  32. $submenu = array();
  33. $select_options = array();
  34. $error_info = array();
  35. $rewrite = array();
  36. unset( $key_words, $page_title, $mod_title, $editor, $editor_password, $my_head, $my_footer, $description, $rewrite );
  37. //Xac dinh thu muc goc cua site
  38. define( 'NV_ROOTDIR', pathinfo( str_replace( '\\', '/', __file__ ), PATHINFO_DIRNAME ) );
  39. $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();
  40. $sys_info['ini_set_support'] = ( function_exists( 'ini_set' ) and ! in_array( 'ini_set', $sys_info['disable_functions'] ) ) ? true : false;
  41. //Ket noi voi cac file constants, config, timezone
  42. require_once ( NV_ROOTDIR . "/includes/constants.php" );
  43. if ( file_exists( NV_ROOTDIR . "/" . NV_CONFIG_FILENAME ) )
  44. {
  45. require_once ( realpath( NV_ROOTDIR . "/" . NV_CONFIG_FILENAME ) );
  46. }
  47. else
  48. {
  49. if ( file_exists( NV_ROOTDIR . '/install/index.php' ) )
  50. {
  51. $base_siteurl = pathinfo( $_SERVER['PHP_SELF'], PATHINFO_DIRNAME );
  52. if ( $base_siteurl == '\\' or $base_siteurl == '/' ) $base_siteurl = '';
  53. if ( ! empty( $base_siteurl ) ) $base_siteurl = str_replace( '\\', '/', $base_siteurl );
  54. if ( ! empty( $base_siteurl ) ) $base_siteurl = preg_replace( "/[\/]+$/", '', $base_siteurl );
  55. if ( ! empty( $base_siteurl ) ) $base_siteurl = preg_replace( "/^[\/]*(.*)$/", '/\\1', $base_siteurl );
  56. if ( defined( 'NV_ADMIN' ) )
  57. {
  58. $base_siteurl = preg_replace( "#/" . NV_ADMINDIR . "(.*)$#", '', $base_siteurl );
  59. }
  60. if ( ! empty( $base_siteurl ) ) $base_siteurl = preg_replace( "#/index\.php(.*)$#", '', $base_siteurl );
  61. Header( "Location: " . $base_siteurl . "/install/index.php" );
  62. }
  63. die();
  64. }
  65. require_once ( NV_ROOTDIR . "/" . NV_DATADIR . "/config_global.php" );
  66. //Kiem tra trang thai cua may chu, neu > 80 se thong bao "Server too busy. Please try again later"
  67. if ( $global_config['getloadavg'] ) require_once ( NV_ROOTDIR . "/includes/getloadavg.php" );
  68. $global_config['file_allowed_ext'] = ! empty( $global_config['file_allowed_ext'] ) ? explode( ",", $global_config['file_allowed_ext'] ) : array();
  69. $global_config['forbid_extensions'] = ! empty( $global_config['forbid_extensions'] ) ? explode( ",", $global_config['forbid_extensions'] ) : array();
  70. $global_config['forbid_mimes'] = ! empty( $global_config['forbid_mimes'] ) ? explode( ",", $global_config['forbid_mimes'] ) : array();
  71. $global_config['allow_sitelangs'] = ! empty( $global_config['allow_sitelangs'] ) ? explode( ",", $global_config['allow_sitelangs'] ) : array();
  72. $global_config['allow_adminlangs'] = ! empty( $global_config['allow_adminlangs'] ) ? explode( ",", $global_config['allow_adminlangs'] ) : array();
  73. $global_config['openid_servers'] = ! empty( $global_config['openid_servers'] ) ? explode( ",", $global_config['openid_servers'] ) : array();
  74. if ( empty( $global_config['openid_servers'] ) ) $global_config['openid_mode'] = 0;
  75. if ( $global_config['is_user_forum'] )
  76. {
  77. $forum_files = @scandir( NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet' );
  78. if ( ! empty( $forum_files ) and in_array( 'is_user.php', $forum_files ) and in_array( 'changepass.php', $forum_files ) and in_array( 'editinfo.php', $forum_files ) and in_array( 'login.php', $forum_files ) and in_array( 'logout.php', $forum_files ) and in_array( 'lostpass.php', $forum_files ) and in_array( 'register.php', $forum_files ) )
  79. {
  80. define( 'NV_IS_USER_FORUM', true );
  81. }
  82. else
  83. {
  84. $global_config['is_user_forum'] = 0;
  85. }
  86. }
  87. if ( $global_config['openid_mode'] )
  88. {
  89. define( 'NV_OPENID_ALLOWED', true );
  90. $openid_servers = array();
  91. require_once ( NV_ROOTDIR . '/includes/openid.php' );
  92. $openid_servers = array_intersect_key( $openid_servers, array_flip( $global_config['openid_servers'] ) );
  93. }
  94. require_once ( NV_ROOTDIR . '/includes/timezone.php' );
  95. define( 'NV_CURRENTTIME', time() );
  96. define( 'NV_CURRENTYEAR_FNUM', date( 'Y', NV_CURRENTTIME ) ); //2009
  97. define( 'NV_CURRENTYEAR_2NUM', date( 'y', NV_CURRENTTIME ) ); //09
  98. define( 'NV_CURRENTMONTH_NUM', date( 'm', NV_CURRENTTIME ) ); //01-12
  99. define( 'NV_CURRENTMONTH_FTXT', date( 'F', NV_CURRENTTIME ) ); //January - December
  100. define( 'NV_CURRENTMONTH_STXT', date( 'M', NV_CURRENTTIME ) ); //Jan - Dec
  101. define( 'NV_CURRENTDAY_2NUM', date( 'd', NV_CURRENTTIME ) ); //01 - 31
  102. define( 'NV_CURRENTDAY_1NUM', date( 'j', NV_CURRENTTIME ) ); //1 - 31
  103. define( 'NV_CURRENT12HOUR_2NUM', date( 'h', NV_CURRENTTIME ) ); //00-12
  104. define( 'NV_CURRENT12HOUR_1NUM', date( 'g', NV_CURRENTTIME ) ); //0-12
  105. define( 'NV_CURRENT24HOUR_2NUM', date( 'H', NV_CURRENTTIME ) ); //00-23
  106. define( 'NV_CURRENT24HOUR_1NUM', date( 'G', NV_CURRENTTIME ) ); //0-23
  107. define( 'NV_CURRENTMIN_2NUM', date( 'i', NV_CURRENTTIME ) ); //00-59
  108. define( 'NV_DEL_ONLINE_TIME', ( NV_CURRENTTIME - NV_ONLINE_UPD_TIME ) ); //Thoi gian xoa tinh trang online
  109. $global_config['log_errors_list'] = NV_LOG_ERRORS_LIST;
  110. $global_config['display_errors_list'] = NV_DISPLAY_ERRORS_LIST;
  111. $global_config['send_errors_list'] = NV_SEND_ERRORS_LIST;
  112. $global_config['error_log_path'] = NV_LOGS_DIR . '/error_logs';
  113. $global_config['error_log_filename'] = NV_ERRORLOGS_FILENAME;
  114. $global_config['error_log_fileext'] = NV_LOGS_EXT;
  115. //Ket noi voi class Error_handler
  116. require_once ( NV_ROOTDIR . '/includes/class/error.class.php' );
  117. $ErrorHandler = new Error( $global_config );
  118. set_error_handler( array( &$ErrorHandler, 'error_handler' ) );
  119. if ( empty( $global_config['allow_sitelangs'] ) or empty( $global_config['allow_adminlangs'] ) )
  120. {
  121. trigger_error( "Error! Language variables is empty!", 256 );
  122. }
  123. //Ket noi voi cac file cau hinh, function va template
  124. require_once ( NV_ROOTDIR . "/includes/ini.php" );
  125. require_once ( NV_ROOTDIR . '/includes/functions.php' );
  126. require_once ( NV_ROOTDIR . '/includes/core/theme_functions.php' );
  127. require_once ( NV_ROOTDIR . "/includes/class/xtemplate.class.php" );
  128. $global_config['allow_request_mods'] = NV_ALLOW_REQUEST_MODS != '' ? array_map( "trim", explode( ",", NV_ALLOW_REQUEST_MODS ) ) : "request";
  129. $global_config['request_default_mode'] = NV_REQUEST_DEFAULT_MODE != '' ? trim( NV_REQUEST_DEFAULT_MODE ) : 'request';
  130. $global_config['XSS_replaceString'] = NV_XSS_REPLACESTRING != '' ? NV_XSS_REPLACESTRING : '';
  131. $global_config['cookie_key'] = $global_config['sitekey'];
  132. $global_config['cookie_secure'] = NV_COOKIE_SECURE;
  133. $global_config['cookie_httponly'] = NV_COOKIE_HTTPONLY;
  134. $global_config['session_save_path'] = NV_SESSION_SAVE_PATH;
  135. //Ket noi voi file xac dinh IP
  136. require_once ( NV_ROOTDIR . '/includes/class/ips.class.php' );
  137. $ips = new ips();
  138. //define( 'NV_SERVER_IP', $ips->server_ip );
  139. define( 'NV_FORWARD_IP', $ips->forward_ip );
  140. define( 'NV_REMOTE_ADDR', $ips->remote_addr );
  141. //Xac dinh IP cua client
  142. $client_info['ip'] = $ips->remote_ip;
  143. if ( $client_info['ip'] == "none" ) trigger_error( 'Error: Your IP address is not correct', 256 ); //Neu khong co IP
  144. if ( nv_is_banIp( $client_info['ip'] ) ) trigger_error( "Hi and Good-bye!!!", 256 ); //IP Ban
  145. if ( $global_config['proxy_blocker'] != 0 ) //Chan proxy
  146. {
  147. $client_info['is_proxy'] = $ips->nv_check_proxy();
  148. if ( nv_is_blocker_proxy( $client_info['is_proxy'], $global_config['proxy_blocker'] ) )
  149. {
  150. trigger_error( 'ERROR: You are behind a proxy server. Please disconnect and come again!', 256 );
  151. }
  152. }
  153. //Xac dinh cac search_engine
  154. $global_config['engine_allowed'] = array();
  155. if ( file_exists( NV_ROOTDIR . '/' . NV_DATADIR . '/search_engine.xml' ) )
  156. {
  157. $global_config['engine_allowed'] = nv_object2array( simplexml_load_file( NV_ROOTDIR . '/' . NV_DATADIR . '/search_engine.xml' ) );
  158. }
  159. $language_array = nv_parse_ini_file( NV_ROOTDIR . '/includes/ini/langs.ini', true );
  160. if ( defined( 'NV_SYSTEM' ) )
  161. {
  162. require_once ( NV_ROOTDIR . '/includes/request_uri.php' );
  163. }
  164. //Ket noi voi class xu ly request
  165. require_once ( NV_ROOTDIR . '/includes/class/request.class.php' );
  166. $nv_Request = new Request( $global_config, $client_info['ip'] );
  167. define( 'NV_CLIENT_IP', $client_info['ip'] );
  168. define( 'NV_SERVER_NAME', $nv_Request->server_name ); //vd: mydomain1.com
  169. define( 'NV_SERVER_PROTOCOL', $nv_Request->server_protocol ); //vd: http
  170. define( 'NV_SERVER_PORT', $nv_Request->server_port ); //vd: 80
  171. define( 'NV_MY_DOMAIN', $nv_Request->my_current_domain ); //vd: http://mydomain1.com:80
  172. define( 'NV_HEADERSTATUS', $nv_Request->headerstatus ); //vd: HTTP/1.0
  173. define( 'NV_USER_AGENT', $nv_Request->user_agent ); //HTTP_USER_AGENT
  174. define( "NV_BASE_SITEURL", $nv_Request->base_siteurl . '/' ); //vd: /ten_thu_muc_chua_site/
  175. define( "NV_BASE_ADMINURL", $nv_Request->base_adminurl . '/' ); //vd: /ten_thu_muc_chua_site/admin/
  176. define( 'NV_DOCUMENT_ROOT', $nv_Request->doc_root ); // D:/AppServ/www
  177. define( 'NV_EOL', ( strtoupper( substr( PHP_OS, 0, 3 ) == 'WIN' ) ? "\r\n" : ( strtoupper( substr( PHP_OS, 0, 3 ) == 'MAC' ) ? "\r" : "\n" ) ) ); //Ngat dong
  178. define( 'NV_UPLOAD_MAX_FILESIZE', min( nv_converttoBytes( ini_get( 'upload_max_filesize' ) ), nv_converttoBytes( ini_get( 'post_max_size' ) ), $global_config['nv_max_size'] ) );
  179. define( 'NV_UPLOADS_REAL_DIR', NV_ROOTDIR . '/' . NV_UPLOADS_DIR ); //Xac dinh duong dan thuc den thu muc upload
  180. define( 'NV_CACHE_PREFIX', md5( $global_config['sitekey'] . NV_BASE_SITEURL ) ); //Hau to cua file cache
  181. //Ngon ngu
  182. require_once ( NV_ROOTDIR . '/includes/language.php' );
  183. require_once ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/global.php" );
  184. $global_config['cookie_path'] = $nv_Request->cookie_path; //vd: /ten_thu_muc_chua_site/
  185. $global_config['cookie_domain'] = $nv_Request->cookie_domain; //vd: .mydomain1.com
  186. $global_config['site_url'] = $nv_Request->site_url; //vd: http://mydomain1.com/ten_thu_muc_chua_site
  187. $global_config['my_domains'] = $nv_Request->my_domains; //vd: "mydomain1.com,mydomain2.com"
  188. $sys_info['register_globals'] = $nv_Request->is_register_globals; //0 = khong, 1 = bat
  189. $sys_info['magic_quotes_gpc'] = $nv_Request->is_magic_quotes_gpc; // 0 = khong, 1 = co
  190. $sys_info['sessionpath'] = $nv_Request->session_save_path; //vd: D:/AppServ/www/ten_thu_muc_chua_site/sess/
  191. $client_info['session_id'] = $nv_Request->session_id; //ten cua session
  192. $client_info['referer'] = $nv_Request->referer; //referer
  193. $client_info['is_myreferer'] = $nv_Request->referer_key; //0 = referer tu ben ngoai site, 1 = referer noi bo, 2 = khong co referer
  194. $client_info['selfurl'] = $nv_Request->my_current_domain . $nv_Request->request_uri; //trang dang xem
  195. $client_info['agent'] = $nv_Request->user_agent; //HTTP_USER_AGENT
  196. if ( preg_match( "/^[0-9]{10,}$/", $nv_Request->get_string( 'nocache', 'get', '' ) ) and //Xac dinh co phai AJAX hay khong
  197. $client_info['is_myreferer'] === 1 ) define( 'NV_IS_AJAX', true );
  198. //Chan truy cap neu HTTP_USER_AGENT == 'none'
  199. if ( NV_USER_AGENT == "none" )
  200. {
  201. 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 );
  202. }
  203. //xac dinh co phai User_Agent cua NukeViet hay khong
  204. if ( NV_USER_AGENT == 'NUKEVIET CMS ' . $global_config['version'] . '. Developed by VINADES. Url: http://nukeviet.vn. Code: ' . md5( $global_config['sitekey'] ) )
  205. {
  206. define( 'NV_IS_MY_USER_AGENT', true );
  207. }
  208. //Xac dinh co phai la bot hay khong
  209. $client_info['bot_info'] = nv_check_bot();
  210. $client_info['is_bot'] = ( ! empty( $client_info['bot_info'] ) ) ? 1 : 0;
  211. //Neu la bot va bot bi cam truy cap
  212. if ( $client_info['is_bot'] and empty( $client_info['bot_info']['allowed'] ) ) trigger_error( 'Sorry! Website does not support the bot', 256 );
  213. //Xac dinh co phai truy cap bang mobile hay khong
  214. $client_info['is_mobile'] = nv_checkmobile();
  215. //Chan hoac chuyen huong neu truy cap tu mobile
  216. //if ($client_info['is_mobile'])
  217. // trigger_error('Sorry! Website does not support the browser your mobile', 256);
  218. //Ket noi voi class chong flood
  219. if ( defined( 'NV_IS_FLOOD_BLOCKER' ) and NV_IS_FLOOD_BLOCKER == 1 and ! $nv_Request->isset_request( 'admin', 'session' ) and //
  220. ( ! $nv_Request->isset_request( 'second', 'get' ) or ( $nv_Request->isset_request( 'second', 'get' ) and $client_info['is_myreferer'] != 1 ) ) )
  221. {
  222. require_once ( NV_ROOTDIR . '/includes/core/flood_blocker.php' );
  223. }
  224. //Xac dinh borwser cua client
  225. $client_info['browser'] = $client_info['is_bot'] ? array( 'key' => "Unknown", 'name' => 'Unknown' ) : array_combine( array( 'key', 'name' ), explode( "|", nv_getBrowser( NV_USER_AGENT, NV_ROOTDIR . '/includes/ini/br.ini' ) ) );
  226. //Xac dinh OS cua client
  227. $client_info['client_os'] = $client_info['is_bot'] ? array( 'key' => "Robot", 'name' => $client_info['bot_info']['name'] ) : array_combine( array( 'key', 'name' ), explode( "|", nv_getOs( NV_USER_AGENT, NV_ROOTDIR . '/includes/ini/os.ini' ) ) );
  228. //Captcha
  229. if ( $nv_Request->isset_request( 'scaptcha', 'get' ) )
  230. {
  231. include_once ( NV_ROOTDIR . "/includes/core/captcha.php" );
  232. }
  233. //Bat dau phien lam viec cua MySQL
  234. require_once ( NV_ROOTDIR . '/includes/class/mysql.class.php' );
  235. $db_config['new_link'] = NV_MYSQL_NEW_LINK;
  236. $db_config['persistency'] = NV_MYSQL_PERSISTENCY;
  237. $db = new sql_db( $db_config );
  238. if ( ! empty( $db->error ) )
  239. {
  240. $die = ! empty( $db->error['user_message'] ) ? $db->error['user_message'] : $db->error['message'];
  241. $die .= ! empty( $db->error['code'] ) ? ' (Code: ' . $db->error['code'] . ')' : '';
  242. trigger_error( $die, 256 );
  243. }
  244. unset( $db_config['dbpass'] );
  245. //Ten cac table cua CSDL dung chung cho he thong
  246. define( 'NV_AUTHORS_GLOBALTABLE', $db_config['prefix'] . '_authors' );
  247. define( 'NV_GROUPS_GLOBALTABLE', $db_config['prefix'] . '_groups' );
  248. define( 'NV_USERS_GLOBALTABLE', $db_config['prefix'] . '_users' );
  249. define( 'NV_SESSIONS_GLOBALTABLE', $db_config['prefix'] . '_sessions' );
  250. define( 'NV_LANGUAGE_GLOBALTABLE', $db_config['prefix'] . '_language' );
  251. define( 'NV_BANNERS_CLIENTS_GLOBALTABLE', $db_config['prefix'] . '_banners_clients' );
  252. define( 'NV_BANNERS_PLANS_GLOBALTABLE', $db_config['prefix'] . '_banners_plans' );
  253. define( 'NV_BANNERS_ROWS_GLOBALTABLE', $db_config['prefix'] . '_banners_rows' );
  254. define( 'NV_BANNERS_CLICK_GLOBALTABLE', $db_config['prefix'] . '_banners_click' );
  255. define( 'NV_CONFIG_GLOBALTABLE', $db_config['prefix'] . '_config' );
  256. define( 'NV_CRONJOBS_GLOBALTABLE', $db_config['prefix'] . '_cronjobs' );
  257. define( 'NV_PREFIXLANG', $db_config['prefix'] . '_' . NV_LANG_DATA );
  258. define( 'NV_MODULES_TABLE', NV_PREFIXLANG . '_modules' );
  259. define( 'NV_BLOCKS_TABLE', NV_PREFIXLANG . '_blocks' );
  260. define( 'NV_MODFUNCS_TABLE', NV_PREFIXLANG . '_modfuncs' );
  261. define( 'NV_COUNTER_TABLE', NV_PREFIXLANG . '_counter' );
  262. define( 'NV_SEARCHKEYS_TABLE', NV_PREFIXLANG . '_searchkeys' );
  263. define( 'NV_REFSTAT_TABLE', NV_PREFIXLANG . '_referer_stats' );
  264. $sql = "SELECT `module`, `config_name`, `config_value` FROM `" . NV_CONFIG_GLOBALTABLE . "` WHERE `lang`='" . NV_LANG_DATA . "' ORDER BY `module` ASC";
  265. $list = nv_db_cache( $sql, '', 'settings' );
  266. foreach ( $list as $row )
  267. {
  268. if ( $row['module'] == "global" )
  269. {
  270. $global_config[$row['config_name']] = $row['config_value'];
  271. }
  272. else
  273. {
  274. $module_config[$row['module']][$row['config_name']] = $row['config_value'];
  275. }
  276. }
  277. if ( ! isset( $global_config['upload_checking_mode'] ) or ! in_array( $global_config['upload_checking_mode'], array( "mild", "lite", "none" ) ) )
  278. {
  279. $global_config['upload_checking_mode'] = "strong";
  280. }
  281. define( 'UPLOAD_CHECKING_MODE', $global_config['upload_checking_mode'] );
  282. if ( $global_config['is_url_rewrite'] )
  283. {
  284. $check_rewrite_file = nv_check_rewrite_file();
  285. if ( $check_rewrite_file )
  286. {
  287. require ( NV_ROOTDIR . "/includes/rewrite.php" );
  288. }
  289. else
  290. {
  291. require ( NV_ROOTDIR . "/includes/rewrite_index.php" );
  292. }
  293. if ( preg_match( "/^" . nv_preg_quote( NV_BASE_SITEURL . "index.php?" ) . "/i", $_SERVER['REQUEST_URI'] ) )
  294. {
  295. $url_rewrite = nv_url_rewrite( $_SERVER['REQUEST_URI'], true );
  296. if ( $url_rewrite != $_SERVER['REQUEST_URI'] )
  297. {
  298. Header( "Location: " . $url_rewrite );
  299. die();
  300. }
  301. }
  302. elseif ( $global_config['rewrite_optional'] && preg_match( "/^" . nv_preg_quote( NV_BASE_SITEURL . NV_LANG_DATA . "/" ) . "/i", $_SERVER['REQUEST_URI']) )
  303. {
  304. $url_rewrite = preg_replace( "/^" . nv_preg_quote( NV_BASE_SITEURL . NV_LANG_DATA . "/" ) . "(.*)$/", NV_BASE_SITEURL . "\\1", $_SERVER['REQUEST_URI'] );
  305. Header( "Location: " . $url_rewrite );
  306. die();
  307. }
  308. elseif ( $global_config['rewrite_optional'] && preg_match( "/^" . nv_preg_quote( NV_BASE_SITEURL . "index.php/" . NV_LANG_DATA . "/" ) . "/i", $_SERVER['REQUEST_URI']) )
  309. {
  310. $url_rewrite = preg_replace( "/^" . nv_preg_quote( NV_BASE_SITEURL . "index.php/" . NV_LANG_DATA . "/" ) . "(.*)$/", NV_BASE_SITEURL . "\\1", $_SERVER['REQUEST_URI'] );
  311. Header( "Location: " . $url_rewrite );
  312. die();
  313. }
  314. }
  315. elseif ( empty( $global_config['lang_multi'] ) and $global_config['rewrite_optional'] )
  316. {
  317. require ( NV_ROOTDIR . "/includes/rewrite_language.php" );
  318. if ( preg_match( "/^" . nv_preg_quote( NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA ) . "/i", $_SERVER['REQUEST_URI'] ) )
  319. {
  320. $url_rewrite = nv_url_rewrite( $_SERVER['REQUEST_URI'], true );
  321. if ( $url_rewrite != $_SERVER['REQUEST_URI'] )
  322. {
  323. Header( "Location: " . $url_rewrite );
  324. die();
  325. }
  326. }
  327. }
  328. if ( defined( 'NV_ADMIN' ) )
  329. {
  330. if ( ! in_array( NV_LANG_DATA, $global_config['allow_adminlangs'] ) )
  331. {
  332. if ( $global_config['lang_multi'] )
  333. {
  334. $nv_Request->set_Cookie( 'data_lang', $global_config['site_lang'], NV_LIVE_COOKIE_TIME );
  335. }
  336. Header( "Location: " . NV_BASE_ADMINURL );
  337. exit();
  338. }
  339. if ( ! in_array( NV_LANG_INTERFACE, $global_config['allow_adminlangs'] ) )
  340. {
  341. if ( $global_config['lang_multi'] )
  342. {
  343. $nv_Request->set_Cookie( 'int_lang', $global_config['site_lang'], NV_LIVE_COOKIE_TIME );
  344. }
  345. Header( "Location: " . NV_BASE_ADMINURL );
  346. exit();
  347. }
  348. }
  349. //Class ma hoa du lieu $crypt->hash($data)
  350. require_once ( NV_ROOTDIR . '/includes/class/crypt.class.php' );
  351. $crypt = new nv_Crypt( $global_config['sitekey'], NV_CRYPT_SHA1 == 1 ? 'sha1' : 'md5' );
  352. if ( ! $crypt->_otk ) trigger_error( "sitekey not declared", 256 );
  353. //cronjobs
  354. if ( $nv_Request->isset_request( 'second', 'get' ) and $nv_Request->get_string( 'second', 'get' ) == "cronjobs" )
  355. {
  356. include_once ( NV_ROOTDIR . "/includes/core/cronjobs.php" );
  357. }
  358. //Kiem tra tu cach admin
  359. if ( defined( 'NV_IS_ADMIN' ) || defined( 'NV_IS_SPADMIN' ) )
  360. {
  361. trigger_error( "Hacking attempt", 256 );
  362. }
  363. define( 'ADMIN_LOGIN_MODE', ( empty( $global_config['closed_site'] ) ) ? 3 : $global_config['closed_site'] );
  364. $admin_cookie = $nv_Request->get_bool( 'admin', 'session', false );
  365. if ( ! empty( $admin_cookie ) )
  366. {
  367. require_once ( NV_ROOTDIR . "/includes/core/admin_access.php" );
  368. require_once ( NV_ROOTDIR . "/includes/core/is_admin.php" );
  369. }
  370. if ( defined( "NV_IS_ADMIN" ) )
  371. {
  372. //Buoc admin khai bao lai pass neu khong online trong khoang thoi gian nhat dinh
  373. if ( empty( $admin_info['checkpass'] ) )
  374. {
  375. if ( $nv_Request->isset_request( NV_ADMINRELOGIN_VARIABLE, 'get' ) and $nv_Request->get_int( NV_ADMINRELOGIN_VARIABLE, 'get' ) == 1 )
  376. {
  377. require_once ( NV_ROOTDIR . "/includes/core/admin_relogin.php" );
  378. exit();
  379. }
  380. }
  381. }
  382. elseif ( ! in_array( NV_LANG_DATA, $global_config['allow_sitelangs'] ) )
  383. {
  384. $global_config['closed_site'] = 1;
  385. }
  386. //Dinh chi hoat dong cua site
  387. if ( ! defined( 'NV_ADMIN' ) and ! defined( "NV_IS_ADMIN" ) )
  388. {
  389. if ( ! empty( $global_config['closed_site'] ) )
  390. {
  391. $disable_site_content = ( isset( $global_config['disable_site_content'] ) and ! empty( $global_config['disable_site_content'] ) ) ? $global_config['disable_site_content'] : $lang_global['disable_site_content'];
  392. nv_info_die( $global_config['site_description'], $global_config['disable_site_title'], $disable_site_content );
  393. }
  394. elseif ( ! in_array( NV_LANG_DATA, $global_config['allow_sitelangs'] ) )
  395. {
  396. Header( "Location: " . NV_BASE_SITEURL );
  397. exit();
  398. }
  399. elseif ( empty( $global_config['lang_multi'] ) and NV_LANG_DATA != $global_config['site_lang'] )
  400. {
  401. Header( "Location: " . NV_BASE_SITEURL );
  402. exit();
  403. }
  404. }
  405. define( 'PCLZIP_TEMPORARY_DIR', NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' );
  406. ?>