extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH, PCLZIP_OPT_REMOVE_PATH, $_GET['autoupdate'], PCLZIP_OPT_REPLACE_NEWER)) { 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); } } } autoupdate_deltree($conf['local_data_dir'].'/autoupdate'); redirect('admin.php?autoupdate=success'); } else { autoupdate_deltree($conf['local_data_dir'].'/autoupdate'); array_push($page['errors'], l10n('autoupdate_fail')); } } else { array_push($page['errors'], l10n('autoupdate_fail')); } } elseif (preg_match('/\d+\.\d+\.\d+/', PHPWG_VERSION) and fetchRemote(PHPWG_URL.'/download/latest_version', $result)) { $lines = @explode("\r\n", $result); $new_version = trim($lines[1]); $new_branch = substr($new_version, 0, 3); $actual_branch = substr(PHPWG_VERSION, 0, 3); $actual_version = $actual_branch . '.x'; if (version_compare(PHPWG_VERSION, $new_version) < 0 and $actual_branch == $new_branch) { $path = $conf['local_data_dir'].'/autoupdate/'; $filename = $path.$actual_version.'_to_'.$new_version.'.zip'; mkgetdir($path); if (!file_exists($filename) or !filesize($filename)) { $zip = @fopen($filename, 'w+'); @fetchRemote(PHPWG_URL.'/download/dlcounter.php?code='.str_replace('.', '', $actual_version).'to'.str_replace('.', '', $new_version), $zip); @fclose($zip); } if (file_exists($filename) and filesize($filename)) { array_push($header_notes, l10n('A new version of Piwigo is available.').'
', ''.l10n('Click here to upgrade automatically').'' ); } } } ?>