Changeset 4007 for extensions/autoupdate/autoupdate.php
- Timestamp:
- Oct 9, 2009, 5:05:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/autoupdate/autoupdate.php
r3898 r4007 83 83 include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 84 84 $zip = new PclZip($file); 85 if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], PCLZIP_OPT_REPLACE_NEWER)) 85 if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, 86 PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], 87 PCLZIP_OPT_SET_CHMOD, 0755, 88 PCLZIP_OPT_REPLACE_NEWER)) 86 89 { 87 if (file_exists(PHPWG_ROOT_PATH.'obsolete.list')88 and $old_files = file(PHPWG_ROOT_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES)89 and !empty($old_files))90 //Check if all files were extracted 91 $error = ''; 92 foreach($result as $extract) 90 93 { 91 array_push($old_files, 'obsolete.list'); 92 foreach($old_files as $old_file) 94 if (!in_array($extract['status'], array('ok', 'filtered', 'already_a_directory'))) 93 95 { 94 $path = PHPWG_ROOT_PATH.$old_file; 95 if (is_file($path)) 96 // Try to change chmod and extract 97 if (@chmod(PHPWG_ROOT_PATH.$extract['filename'], 0777) 98 and ($res = $zip->extract(PCLZIP_OPT_BY_NAME, $_GET['autoupdate'].'/'.$extract['filename'], 99 PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, 100 PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], 101 PCLZIP_OPT_SET_CHMOD, 0755, 102 PCLZIP_OPT_REPLACE_NEWER)) 103 and isset($res[0]['status']) 104 and $res[0]['status'] == 'ok') 96 105 { 97 @unlink($path);106 continue; 98 107 } 99 else if (is_dir($path))108 else 100 109 { 101 autoupdate_deltree($path);110 $error .= $extract['filename'].': '.$extract['status']."\n"; 102 111 } 103 112 } 104 113 } 105 if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches)) 114 115 if (empty($error)) 106 116 { 107 check_version_for_autoupdate($matches[1]); 117 if (file_exists(PHPWG_ROOT_PATH.'obsolete.list') 118 and $old_files = file(PHPWG_ROOT_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) 119 and !empty($old_files)) 120 { 121 array_push($old_files, 'obsolete.list'); 122 foreach($old_files as $old_file) 123 { 124 $path = PHPWG_ROOT_PATH.$old_file; 125 if (is_file($path)) 126 { 127 @unlink($path); 128 } 129 elseif (is_dir($path)) 130 { 131 autoupdate_deltree($path); 132 } 133 } 134 } 135 if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches)) 136 { 137 check_version_for_autoupdate($matches[1]); 138 } 139 autoupdate_deltree($conf['local_data_dir'].'/autoupdate'); 140 invalidate_user_cache(true); 141 $template->delete_compiled_templates(); 142 redirect('admin.php?autoupdate=success'); 108 143 } 109 autoupdate_deltree($conf['local_data_dir'].'/autoupdate'); 110 invalidate_user_cache(true); 111 $template->delete_compiled_templates(); 112 redirect('admin.php?autoupdate=success'); 144 else 145 { 146 file_put_contents($conf['local_data_dir'].'/autoupdate/log_error.txt', $error); 147 $relative_path = trim(str_replace(dirname(dirname(dirname(__FILE__))), '', $conf['local_data_dir']), '/\\'); 148 array_push($page['errors'], sprintf(l10n('autoupdate_extract_fail'), PHPWG_ROOT_PATH.$relative_path.'/autoupdate/log_error.txt')); 149 } 113 150 } 114 151 else
Note: See TracChangeset
for help on using the changeset viewer.