PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/NukeViet3.2/admin/modules/webtools/autoupdate.php

http://nuke-viet.googlecode.com/
PHP | 552 lines | 515 code | 19 blank | 18 comment | 29 complexity | 7fb42026f2e0f0fb79b5484118521e3a 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 9/9/2010, 6:38
  7. */
  8. if ( ! defined( 'NV_IS_FILE_WEBTOOLS' ) ) die( 'Stop!!!' );
  9. if ( $sys_info['allowed_set_time_limit'] )
  10. {
  11. set_time_limit( 0 );
  12. }
  13. $nv_sites_update = array( //
  14. 'update.nukeviet.vn', //
  15. 'update2.nukeviet.vn', //
  16. 'update.nukeviet.info', //
  17. 'update2.nukeviet.info' );
  18. $temp_extract_dir = 'install/update';
  19. $ftp_check_login = 0;
  20. if ( $sys_info['ftp_support'] and intval( $global_config['ftp_check_login'] ) == 1 )
  21. {
  22. $ftp_server = nv_unhtmlspecialchars( $global_config['ftp_server'] );
  23. $ftp_port = intval( $global_config['ftp_port'] );
  24. $ftp_user_name = nv_unhtmlspecialchars( $global_config['ftp_user_name'] );
  25. $ftp_user_pass = nv_unhtmlspecialchars( $global_config['ftp_user_pass'] );
  26. $ftp_path = nv_unhtmlspecialchars( $global_config['ftp_path'] );
  27. // set up basic connection
  28. $conn_id = ftp_connect( $ftp_server, $ftp_port, 10 );
  29. // login with username and password
  30. $login_result = ftp_login( $conn_id, $ftp_user_name, $ftp_user_pass );
  31. if ( ( ! $conn_id ) || ( ! $login_result ) )
  32. {
  33. $ftp_check_login = 3;
  34. }
  35. elseif ( ftp_chdir( $conn_id, $ftp_path ) )
  36. {
  37. $ftp_check_login = 1;
  38. }
  39. else
  40. {
  41. $ftp_check_login = 2;
  42. }
  43. }
  44. function nv_site_path_update ( $path )
  45. {
  46. if ( preg_match( "/^uploads\/banners\/(.*)$/i", $path, $matches ) )
  47. {
  48. //Thu muc uploads banner
  49. return NV_UPLOADS_DIR . '/' . NV_BANNER_DIR . '/' . $matches[1];
  50. }
  51. elseif ( preg_match( "/^admin\/editors\/(.*)$/i", $path, $matches ) )
  52. {
  53. //Ten thu muc editors
  54. return NV_EDITORSDIR . '/' . $matches[1];
  55. }
  56. elseif ( preg_match( "/^admin\/(.*)$/i", $path, $matches ) )
  57. {
  58. return NV_ADMINDIR . '/' . $matches[1];
  59. }
  60. elseif ( preg_match( "/^uploads\/(.*)$/i", $path, $matches ) )
  61. {
  62. //Thu muc uploads
  63. return NV_UPLOADS_DIR . '/' . $matches[1];
  64. }
  65. elseif ( preg_match( "/^files\/(.*)$/i", $path, $matches ) )
  66. {
  67. //Thu muc files
  68. return NV_FILES_DIR . '/' . $matches[1];
  69. }
  70. elseif ( preg_match( "/^data\/(.*)$/i", $path, $matches ) )
  71. {
  72. //Ten thu muc luu data
  73. return NV_DATADIR . '/' . $matches[1];
  74. }
  75. elseif ( preg_match( "/^files\/(.*)$/i", $path, $matches ) )
  76. {
  77. return NV_FILES_DIR . '/' . $matches[1];
  78. }
  79. elseif ( preg_match( "/^sess\/(.*)$/i", $path, $matches ) )
  80. {
  81. //Thu muc chua sessions
  82. return NV_SESSION_SAVE_PATH . '/' . $matches[1];
  83. }
  84. elseif ( preg_match( "/^tmp\/(.*)$/i", $path, $matches ) )
  85. {
  86. //Thu muc chua cac file tam thoi
  87. return NV_TEMP_DIR . '/' . $matches[1];
  88. }
  89. elseif ( preg_match( "/^cache\/(.*)$/i", $path, $matches ) )
  90. {
  91. //Ten thu muc cache
  92. return NV_CACHEDIR . '/' . $matches[1];
  93. }
  94. return $path;
  95. }
  96. $page_title = "autoupdate";
  97. $revision = isset( $global_config['revision'] ) ? intval( $global_config['revision'] ) : 0;
  98. $version = $global_config['version'];
  99. $step = ( isset( $_GET['step'] ) ) ? intval( $_GET['step'] ) : 0;
  100. $checkss = ( isset( $_GET['checkss'] ) ) ? trim( $_GET['checkss'] ) : '';
  101. if ( empty( $step ) )
  102. {
  103. if ( file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/update.php' ) )
  104. {
  105. $step = 3;
  106. }
  107. else
  108. {
  109. $step = 1;
  110. }
  111. }
  112. $nextstep = $step + 1;
  113. if ( $step == 1 )
  114. {
  115. $filedownload = "";
  116. $domain_update = $global_config['site_url'];
  117. srand( ( float )microtime() * 10000000 );
  118. $rand = array_rand( $nv_sites_update );
  119. $nv_site = $nv_sites_update[$rand];
  120. $contents = '<center><br /><br /><br /><b>' . $lang_module['autoupdate_get_error'] . '</b><br /></center>';
  121. require_once NV_ROOTDIR . '/includes/class/geturl.class.php';
  122. $getContent = new UrlGetContents( $global_config );
  123. $xml = $getContent->get( "http://" . $nv_site . "/autoupdate.php?revision=" . $revision . "&version=" . $version . "&lang=" . NV_LANG_INTERFACE );
  124. if ( ! empty( $xml ) )
  125. {
  126. $new_version = simplexml_load_string( $xml );
  127. if ( $new_version !== false )
  128. {
  129. $update = ( int )$new_version->update;
  130. $contents = ( string )$new_version->note;
  131. if ( $update )
  132. {
  133. $filedownload = ( string )$new_version->filedownload;
  134. $nv_Request->set_Session( 'autoupdate_filedownload', $filedownload );
  135. $lang_waiting = sprintf( $lang_module['autoupdate_download_waiting'], $filedownload, $filedownload );
  136. $contents .= '<div id="message" style="display:none;text-align:center;color:red"><img src="' . NV_BASE_SITEURL . 'images/load_bar.gif"/><br /><br />' . $lang_waiting . '</div>';
  137. $contents .= '<div id="step1" ><center><br /><input style="margin-top:10px;font-size:15px" type="button" name="install_content_overwrite" value="' . $lang_module['autoupdate_download'] . '"/><center></div>';
  138. $contents .= '<script type="text/javascript">
  139. $(function(){
  140. $("input[name=install_content_overwrite]").click(function(){
  141. $("#message").show();
  142. $("#step1").html("");
  143. $("#step1").load("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&step=' . $nextstep . '&checkss=' . md5( $nextstep . $global_config['sitekey'] . session_id() ) . '",function(){
  144. $("#message").hide();
  145. });
  146. });
  147. });
  148. </script>';
  149. }
  150. }
  151. }
  152. include ( NV_ROOTDIR . "/includes/header.php" );
  153. echo nv_admin_theme( $contents );
  154. include ( NV_ROOTDIR . "/includes/footer.php" );
  155. }
  156. elseif ( $step == 2 and md5( $step . $global_config['sitekey'] . session_id() ) )
  157. {
  158. $filedownload = $nv_Request->get_string( 'autoupdate_filedownload', 'session', '' );
  159. if ( ! empty( $filedownload ) )
  160. {
  161. //downlod file
  162. require_once NV_ROOTDIR . '/includes/class/upload.class.php';
  163. $allow_files_type = array( 'archives' );
  164. $upload = new upload( $allow_files_type, $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT );
  165. $upload_info = $upload->save_urlfile( $filedownload, NV_ROOTDIR . '/' . NV_TEMP_DIR, false );
  166. if ( ! empty( $upload_info['error'] ) )
  167. {
  168. $contents = 'error filedownload: ' . $filedownload;
  169. }
  170. else
  171. {
  172. //extract Zip file
  173. require_once NV_ROOTDIR . '/includes/class/pclzip.class.php';
  174. $zip = new PclZip( $upload_info['name'] );
  175. $status = $zip->properties();
  176. if ( $status['status'] == 'ok' )
  177. {
  178. $ziplistContent = $zip->listContent();
  179. if ( NV_ROOTDIR . '/' . $temp_extract_dir )
  180. {
  181. nv_deletefile( NV_ROOTDIR . '/' . $temp_extract_dir, true );
  182. }
  183. if ( $ftp_check_login == 1 )
  184. {
  185. ftp_mkdir( $conn_id, $temp_extract_dir );
  186. if ( substr( $sys_info['os'], 0, 3 ) != 'WIN' ) ftp_chmod( $conn_id, 0777, $temp_extract_dir );
  187. foreach ( $ziplistContent as $array_file )
  188. {
  189. if ( ! empty( $array_file['folder'] ) and ! file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/' . $array_file['filename'] ) )
  190. {
  191. $cp = "";
  192. $e = explode( "/", $array_file['filename'] );
  193. foreach ( $e as $p )
  194. {
  195. if ( ! empty( $p ) and ! is_dir( NV_ROOTDIR . '/' . $temp_extract_dir . '/' . $cp . $p ) )
  196. {
  197. ftp_mkdir( $conn_id, $temp_extract_dir . '/' . $cp . $p );
  198. if ( substr( $sys_info['os'], 0, 3 ) != 'WIN' ) ftp_chmod( $conn_id, 0777, $temp_extract_dir . '/' . $cp . $p );
  199. }
  200. $cp .= $p . '/';
  201. }
  202. }
  203. }
  204. }
  205. $no_extract = array();
  206. $extract = $zip->extract( PCLZIP_OPT_PATH, NV_ROOTDIR . '/' . $temp_extract_dir );
  207. foreach ( $extract as $extract_i )
  208. {
  209. $filename_i = str_replace( NV_ROOTDIR, "", str_replace( '\\', '/', $extract_i['filename'] ) );
  210. if ( $extract_i['status'] != 'ok' and $extract_i['status'] != 'already_a_directory' )
  211. {
  212. $no_extract[] = $filename_i;
  213. }
  214. }
  215. nv_deletefile( $upload_info['name'] );
  216. if ( ! file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/index.html' ) )
  217. {
  218. nv_copyfile( NV_ROOTDIR . '/language/index.html', NV_ROOTDIR . '/' . $temp_extract_dir . '/index.html' );
  219. }
  220. if ( ! file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/.htaccess' ) )
  221. {
  222. nv_copyfile( NV_ROOTDIR . '/language/.htaccess', NV_ROOTDIR . '/' . $temp_extract_dir . '/.htaccess' );
  223. }
  224. if ( empty( $no_extract ) )
  225. {
  226. $contents = '<br />';
  227. $contents .= '<div id="message_31" style="display:none;text-align:center;color:red"><img src="' . NV_BASE_SITEURL . 'images/load_bar.gif"/></div>';
  228. $contents .= '<div id="step_31" >' . $lang_module['autoupdate_download_complete'];
  229. $contents .= '<center><br /><input style="margin-top:10px;font-size:15px" type="button" name="install_content_overwrite" value="' . $lang_module['autoupdate_check_file'] . ' "/><center></div>';
  230. $contents .= '<script type="text/javascript">
  231. $(function(){
  232. $("input[name=install_content_overwrite]").click(function(){
  233. $("#message_31").show();
  234. $("#step_31").html("");
  235. $("#step_31").load("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&step=' . $nextstep . '&checkss=' . md5( $nextstep . $global_config['sitekey'] . session_id() ) . '",function(){
  236. $("#message_31").hide();
  237. });
  238. });
  239. });
  240. </script>';
  241. }
  242. else
  243. {
  244. $contents = '<div id="message" style="text-align:center;color:red"><br /><br />' . sprintf( $lang_module['autoupdate_download_error'], $filedownload, $filedownload ) . '</div>';
  245. }
  246. }
  247. else
  248. {
  249. $contents = '<div id="message" style="text-align:center;color:red"><br /><br />' . $lang_module['autoupdate_invalidfile'] . '</div>';
  250. }
  251. }
  252. }
  253. else
  254. {
  255. $contents = 'error filedownload';
  256. }
  257. include ( NV_ROOTDIR . "/includes/header.php" );
  258. echo $contents;
  259. include ( NV_ROOTDIR . "/includes/footer.php" );
  260. }
  261. elseif ( $step == 3 and file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/update.php' ) )
  262. {
  263. if ( ! file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/index.html' ) )
  264. {
  265. nv_copyfile( NV_ROOTDIR . '/language/index.html', NV_ROOTDIR . '/' . $temp_extract_dir . '/index.html' );
  266. }
  267. if ( ! file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/.htaccess' ) )
  268. {
  269. nv_copyfile( NV_ROOTDIR . '/language/.htaccess', NV_ROOTDIR . '/' . $temp_extract_dir . '/.htaccess' );
  270. }
  271. define( 'NV_AUTOUPDATE', true );
  272. $update_info = array();
  273. $add_files = array();
  274. $edit_files = array();
  275. $delete_files = array();
  276. require_once ( NV_ROOTDIR . '/' . $temp_extract_dir . '/update.php' );
  277. if ( $checkss != md5( $step . $global_config['sitekey'] . session_id() ) )
  278. {
  279. $contents = '<br />';
  280. $contents .= '<div id="message_31" style="display:none;text-align:center;color:red"><img src="' . NV_BASE_SITEURL . 'images/load_bar.gif"/></div>';
  281. $contents .= '<div id="step_31" >' . $lang_module['autoupdate_form_upload'];
  282. $contents .= '<center><br /><input style="margin-top:10px;font-size:15px" type="button" name="install_content_overwrite" value="' . $lang_module['autoupdate_check_file'] . '"/><center></div>';
  283. $contents .= '<script type="text/javascript">
  284. $(function(){
  285. $("input[name=install_content_overwrite]").click(function(){
  286. $("#message_31").show();
  287. $("#step_31").html("");
  288. $("#step_31").load("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&step=' . $step . '&checkss=' . md5( $step . $global_config['sitekey'] . session_id() ) . '",function(){
  289. $("#message_31").hide();
  290. });
  291. });
  292. });
  293. </script>';
  294. include ( NV_ROOTDIR . "/includes/header.php" );
  295. echo nv_admin_theme( $contents );
  296. include ( NV_ROOTDIR . "/includes/footer.php" );
  297. }
  298. else
  299. {
  300. $user_edit_file = array();
  301. $check_files = array_merge( $edit_files, $delete_files );
  302. if ( ! empty( $check_files ) )
  303. {
  304. asort( $check_files );
  305. foreach ( $check_files as $file )
  306. {
  307. $file_p = nv_site_path_update( $file );
  308. $cur_file = NV_ROOTDIR . '/' . $file_p;
  309. $old_file = NV_ROOTDIR . '/' . $temp_extract_dir . '/old/' . $file;
  310. if ( ! file_exists( $cur_file ) or ! file_exists( $old_file ) )
  311. {
  312. $user_edit_file[] = $file_p;
  313. }
  314. elseif ( md5_file( $cur_file ) != md5_file( $old_file ) )
  315. {
  316. $user_edit_file[] = $file_p;
  317. }
  318. }
  319. }
  320. if ( ! empty( $user_edit_file ) )
  321. {
  322. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_change'] . ':</b>';
  323. $contents .= '<br /> ' . implode( "<br />", $user_edit_file );
  324. $contents .= '<br /><br />' . $lang_module['autoupdate_overwrite'];
  325. }
  326. else
  327. {
  328. $contents .= '<br />' . $lang_module['autoupdate_click_update'];
  329. }
  330. $contents .= '<br /><br />' . $lang_module['autoupdate_backupfile'] . ': <br /><br /><b>' . NV_LOGS_DIR . '/data_logs/backup_update_' . date( 'Y_m_d' ) . '_' . md5( $global_config['sitekey'] . session_id() ) . '.zip</b>';
  331. $contents .= '<br /><br />';
  332. $contents .= '<div id="message_32" style="display:none;text-align:center;color:red"><img src="' . NV_BASE_SITEURL . 'images/load_bar.gif"/></div>';
  333. $contents .= '<br /><div id="step_32" ><center><br /><input style="margin-top:10px;font-size:15px" type="button" name="install_content_overwrite" value="' . $lang_module['autoupdate'] . '"/><center></div>';
  334. $contents .= '<script type="text/javascript">
  335. $(function(){
  336. $("input[name=install_content_overwrite]").click(function(){
  337. if(confirm("' . $lang_module['autoupdate_confirm'] . '")){
  338. $("#message_32").show();
  339. $("#step_32").html("");
  340. $("#step_32").load("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&step=' . $nextstep . '&checkss=' . md5( $nextstep . $global_config['sitekey'] . session_id() ) . '",function(){
  341. $("#message_32").hide();
  342. });
  343. }
  344. });
  345. });
  346. </script>';
  347. include ( NV_ROOTDIR . "/includes/header.php" );
  348. echo $contents;
  349. include ( NV_ROOTDIR . "/includes/footer.php" );
  350. }
  351. }
  352. elseif ( $step == 4 and md5( $step . $global_config['sitekey'] . session_id() ) and file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/update.php' ) and file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/old/' ) and file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/new/' ) )
  353. {
  354. define( 'NV_AUTOUPDATE', true );
  355. $update_info = array();
  356. $add_files = array();
  357. $edit_files = array();
  358. $delete_files = array();
  359. require_once ( NV_ROOTDIR . '/' . $temp_extract_dir . '/update.php' );
  360. // backup file
  361. $error_backup = false;
  362. $backup_files = array_merge( $edit_files, $delete_files );
  363. if ( ! empty( $backup_files ) )
  364. {
  365. $zip_file_backup = array();
  366. foreach ( $backup_files as $file_i )
  367. {
  368. $file_p = nv_site_path_update( $file_i );
  369. if ( is_file( NV_ROOTDIR . '/' . $file_p ) )
  370. {
  371. $zip_file_backup[] = NV_ROOTDIR . '/' . $file_p;
  372. }
  373. }
  374. if ( ! empty( $zip_file_backup ) )
  375. {
  376. $file_src = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/backup_update_' . date( 'Y_m_d' ) . '_' . md5( $global_config['sitekey'] . session_id() ) . '.zip';
  377. require_once NV_ROOTDIR . '/includes/class/pclzip.class.php';
  378. $zip = new PclZip( $file_src );
  379. $return = $zip->add( $zip_file_backup, PCLZIP_OPT_REMOVE_PATH, NV_ROOTDIR );
  380. if ( empty( $return ) )
  381. {
  382. $check_backup = true;
  383. }
  384. }
  385. }
  386. if ( $error_backup )
  387. {
  388. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_backupfile_error'] . ':' . NV_LOGS_DIR . '/data_logs</b>';
  389. }
  390. else
  391. {
  392. $move_files = array_merge( $add_files, $edit_files );
  393. if ( ! empty( $move_files ) )
  394. {
  395. // create new folder
  396. $error_create_folder = array();
  397. foreach ( $move_files as $file_i )
  398. {
  399. $file_p = nv_site_path_update( $file_i );
  400. $cp = "";
  401. $e = explode( "/", $file_p );
  402. foreach ( $e as $p )
  403. {
  404. if ( ! empty( $p ) and is_dir( NV_ROOTDIR . '/' . $temp_extract_dir . '/new/' . $cp . $p ) and ! is_dir( NV_ROOTDIR . '/' . $cp . $p ) )
  405. {
  406. if ( ! ( $ftp_check_login == 1 and ftp_mkdir( $conn_id, $cp . $p ) ) )
  407. {
  408. @mkdir( NV_ROOTDIR . '/' . $cp . $p );
  409. }
  410. if ( ! is_dir( NV_ROOTDIR . '/' . $cp . $p ) )
  411. {
  412. $error_create_folder[] = $cp . $p;
  413. }
  414. }
  415. $cp .= $p . '/';
  416. }
  417. }
  418. if ( ! empty( $error_create_folder ) )
  419. {
  420. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_error_create_folder'] . ':</b>';
  421. $contents .= '<br /> ' . implode( "<br />", $error_create_folder );
  422. if ( $sys_info['ftp_support'] and intval( $global_config['ftp_check_login'] ) != 1 )
  423. {
  424. $contents .= '<br /><br />' . $lang_module['revision_config_ftp'];
  425. }
  426. }
  427. else
  428. {
  429. //Move file";
  430. $error_move_folder = array();
  431. foreach ( $move_files as $file_i )
  432. {
  433. if ( is_file( NV_ROOTDIR . '/' . $temp_extract_dir . '/new/' . $file_i ) )
  434. {
  435. $file_p = nv_site_path_update( $file_i );
  436. if ( file_exists( NV_ROOTDIR . '/' . $file_p ) )
  437. {
  438. if ( ! ( $ftp_check_login == 1 and ftp_delete( $conn_id, $file_p ) ) )
  439. {
  440. nv_deletefile( NV_ROOTDIR . '/' . $file_p );
  441. }
  442. }
  443. if ( ! ( $ftp_check_login == 1 and ftp_rename( $conn_id, $temp_extract_dir . '/new/' . $file_i, $file_p ) ) )
  444. {
  445. @rename( NV_ROOTDIR . '/' . $temp_extract_dir . '/new/' . $file_i, NV_ROOTDIR . '/' . $file_p );
  446. }
  447. if ( file_exists( NV_ROOTDIR . '/' . $temp_extract_dir . '/new/' . $file_i ) )
  448. {
  449. $error_move_folder[] = $file_i;
  450. }
  451. }
  452. }
  453. if ( ! empty( $error_move_folder ) )
  454. {
  455. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_error_move_file'] . ':</b>';
  456. $contents .= '<br /> ' . implode( "<br />", $error_move_folder );
  457. if ( $sys_info['ftp_support'] and intval( $global_config['ftp_check_login'] ) != 1 )
  458. {
  459. $contents .= '<br /><br />' . $lang_module['revision_config_ftp'];
  460. }
  461. }
  462. else
  463. {
  464. global $error_contents;
  465. $error_contents = array();
  466. $update_data = true;
  467. if ( nv_function_exists( 'nv_func_update_data' ) )
  468. {
  469. $update_data = nv_func_update_data();
  470. }
  471. if ( $update_data )
  472. {
  473. if ( isset( $update_info['version']['to'] ) )
  474. {
  475. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_config` SET `config_value` = " . $db->dbescape_string( $update_info['version']['to'] ) . " WHERE `lang` = 'sys' AND `module` = 'global' AND `config_name` = 'version'" );
  476. }
  477. if ( isset( $update_info['revision']['to'] ) )
  478. {
  479. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_config` SET `config_value` = '" . intval( $update_info['revision']['to'] ) . "' WHERE `lang` = 'sys' AND `module` = 'global' AND `config_name` = 'revision'" );
  480. }
  481. nv_save_file_config_global();
  482. $del = nv_deletefile( NV_ROOTDIR . '/' . $temp_extract_dir, true );
  483. foreach ( $delete_files as $file_i )
  484. {
  485. $file_p = nv_site_path_update( $file_i );
  486. if ( file_exists( NV_ROOTDIR . '/' . $file_p ) )
  487. {
  488. nv_deletefile( NV_ROOTDIR . '/' . $file_p );
  489. }
  490. }
  491. if ( $del[0] == 1 )
  492. {
  493. $msg = $lang_module['autoupdate_complete'];
  494. }
  495. else
  496. {
  497. $msg = $lang_module['autoupdate_complete_error_del_file'];
  498. }
  499. $contents .= '<br /><br /><b>' . $msg . '</b>';
  500. }
  501. else
  502. {
  503. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_complete_file'] . '.</b>';
  504. $contents .= '<br /><br /><b>' . $lang_module['autoupdate_error_data'] . ':</b><br />' . implode( "<br />", $error_contents );
  505. }
  506. }
  507. }
  508. }
  509. }
  510. include ( NV_ROOTDIR . "/includes/header.php" );
  511. echo $contents;
  512. include ( NV_ROOTDIR . "/includes/footer.php" );
  513. }
  514. elseif ( $step > 2 )
  515. {
  516. include ( NV_ROOTDIR . "/includes/header.php" );
  517. echo '<div style="text-align:center;color:red">' . $lang_module['autoupdate_error_dir_update'] . '</div>';
  518. include ( NV_ROOTDIR . "/includes/footer.php" );
  519. }
  520. else
  521. {
  522. Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name );
  523. exit();
  524. }
  525. ?>