extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], PCLZIP_OPT_SET_CHMOD, 0755, PCLZIP_OPT_REPLACE_NEWER)) { //Check if all files were extracted $error = ''; foreach($result as $extract) { if (!in_array($extract['status'], array('ok', 'filtered', 'already_a_directory'))) { // Try to change chmod and extract if (@chmod(PHPWG_ROOT_PATH.$extract['filename'], 0777) and ($res = $zip->extract(PCLZIP_OPT_BY_NAME, $_GET['autoupdate'].'/'.$extract['filename'], PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], PCLZIP_OPT_SET_CHMOD, 0755, PCLZIP_OPT_REPLACE_NEWER)) and isset($res[0]['status']) and $res[0]['status'] == 'ok') { continue; } else { $error .= $extract['filename'].': '.$extract['status']."\n"; } } } if (empty($error)) { if (file_exists(PHPWG_ROOT_PATH.'obsolete.list') and $old_files = file(PHPWG_ROOT_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) and !empty($old_files)) { array_push($old_files, 'obsolete.list'); foreach($old_files as $old_file) { $path = PHPWG_ROOT_PATH.$old_file; if (is_file($path)) { @unlink($path); } elseif (is_dir($path)) { $autoupdate->deltree($path); } } } if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches)) { unset($_SESSION['need_update']); $autoupdate->check_version($matches[1]); } $autoupdate->deltree($conf['local_data_dir'].'/autoupdate'); invalidate_user_cache(true); $template->delete_compiled_templates(); redirect('admin.php?autoupdate=success'); } else { file_put_contents($conf['local_data_dir'].'/autoupdate/log_error.txt', $error); $relative_path = trim(str_replace(dirname(dirname(dirname(__FILE__))), '', $conf['local_data_dir']), '/\\'); array_push($page['errors'], sprintf(l10n('autoupdate_extract_fail'), PHPWG_ROOT_PATH.$relative_path.'/autoupdate/log_error.txt')); } } else { $autoupdate->deltree($conf['local_data_dir'].'/autoupdate'); array_push($page['errors'], l10n('autoupdate_fail')); } } else { @unlink($file); array_push($page['errors'], l10n('autoupdate_fail')); } } if (!isset($_SESSION['need_update']) or !isset($_SESSION['plugins_need_update']) or $_SESSION['need_update'] !== false or $_SESSION['plugins_need_update'] !== array()) { $template->set_filename('autoupdate_head', realpath(dirname(__FILE__).'/head.tpl')); array_push($header_notes, $template->parse('autoupdate_head', true)); } ?>