user may choose upgrade. 2 = upgrade on same branch 3 = upgrade on different branch */ $step = isset($_GET['step']) ? $_GET['step'] : 0; $upgrade_to = isset($_GET['to']) ? $_GET['to'] : ''; // +-----------------------------------------------------------------------+ // | Step 0 | // +-----------------------------------------------------------------------+ if ($step == 0) { $template->assign(array( 'CHECK_VERSION' => false, 'DEV_VERSION' => false, ) ); if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches)) { if (@fetchRemote(PHPWG_URL.'/download/all_versions.php', $result) and $all_versions = @explode("\n", $result) and is_array($all_versions)) { $template->assign('CHECK_VERSION', true); $last_version = trim($all_versions[0]); $upgrade_to = $last_version; if (version_compare(PHPWG_VERSION, $last_version, '<')) { $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $last_version); $actual_branch = $matches[1]; if ($new_branch == $actual_branch) { $step = 2; } else { $step = 3; // Check if new version exists in same branch foreach ($all_versions as $version) { $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $version); if ($new_branch == $actual_branch) { if (version_compare(PHPWG_VERSION, $version, '<')) { $step = 1; } break; } } } } } } else { $template->assign('DEV_VERSION', true); } } // +-----------------------------------------------------------------------+ // | Step 1 | // +-----------------------------------------------------------------------+ if ($step == 1) { $template->assign(array( 'MINOR_VERSION' => $version, 'MAJOR_VERSION' => $last_version, ) ); } // +-----------------------------------------------------------------------+ // | Step 2 | // +-----------------------------------------------------------------------+ if ($step == 2) { if (isset($_POST['submit']) and isset($_POST['upgrade_to'])) { autoupdate_upgrade_to($_POST['upgrade_to'], $step); } } // +-----------------------------------------------------------------------+ // | Step 3 | // +-----------------------------------------------------------------------+ if ($step == 3) { if (isset($_POST['saveTemplate'])) { autoupdate_save_template_dir(); } if (isset($_POST['dumpDatabase'])) { autoupdate_dump_database(); } if (isset($_POST['submit']) and isset($_POST['upgrade_to'])) { autoupdate_upgrade_to($_POST['upgrade_to'], $step); } } // +-----------------------------------------------------------------------+ // | Process template | // +-----------------------------------------------------------------------+ $template->assign(array( 'STEP' => $step, 'AU_URL' => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'), 'UPGRADE_TO' => $upgrade_to, 'RELEASE_URL' => PHPWG_URL.'/releases/'.$upgrade_to, ) ); $template->set_filename('plugin_admin_content', realpath(AUTOUPDATE_PATH.'template/autoupdate.tpl')); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); ?>