if ($_POST['disablecheck'] == "yes") {
        $config['system']['firmware']['disablecheck'] = true;
    } elseif (isset($config['system']['firmware']['disablecheck'])) {
        unset($config['system']['firmware']['disablecheck']);
    }
    if ($_POST['synconupgrade'] == "yes") {
        $config['system']['gitsync']['synconupgrade'] = true;
    } elseif (isset($config['system']['gitsync']['synconupgrade'])) {
        unset($config['system']['gitsync']['synconupgrade']);
    }
    $config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
    $config['system']['gitsync']['branch'] = $_POST['branch'];
    foreach ($repos as $repo) {
        if ($repo['name'] == $_POST['fwbranch']) {
            $config['system']['pkg_repo_conf_path'] = $repo['path'];
            pkg_switch_repo($repo['path']);
            break;
        }
    }
    write_config();
    $savemsg = gettext("Changes have been saved successfully");
}
$curcfg = $config['system']['firmware'];
$gitcfg = $config['system']['gitsync'];
$pgtitle = array(gettext("System"), gettext("Update"), gettext("Update Settings"));
// Create an array of repo names and descriptions to populate the "Branch" selector
function build_repo_list()
{
    global $repos;
    $list = array();
    foreach ($repos as $repo) {
require "guiconfig.inc";
require "pkg-utils.inc";
if ($_POST) {
    unset($input_errors);
    /* input validation */
    if ($_POST['alturlenable'] == "yes" && empty($_POST['firmwareurl'])) {
        $input_errors[] = gettext("A Firmware Auto Update Base URL must be specified when \"Use an unofficial server for firmware upgrades\" is enabled.");
    }
    if (!$input_errors) {
        // Set the firmware branch, but only if we are not using it already
        if ($_POST['fwbranch']) {
            if ($_POST['fwbranch'] == "development" && is_pkg_installed($g['product_name'] . "-repo")) {
                pkg_switch_repo(true);
            } else {
                if ($_POST['fwbranch'] == "stable" && is_pkg_installed($g['product_name'] . "-repo-devel")) {
                    pkg_switch_repo(false);
                }
            }
        }
        if ($_POST['disablecheck'] == "yes") {
            $config['system']['firmware']['disablecheck'] = true;
        } else {
            unset($config['system']['firmware']['disablecheck']);
        }
        if ($_POST['synconupgrade'] == "yes") {
            $config['system']['gitsync']['synconupgrade'] = true;
        } else {
            unset($config['system']['gitsync']['synconupgrade']);
        }
        $config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
        $config['system']['gitsync']['branch'] = $_POST['branch'];