diff options
Diffstat (limited to 'src/usr/local/www/system_firmware_settings.php')
-rw-r--r-- | src/usr/local/www/system_firmware_settings.php | 358 |
1 files changed, 150 insertions, 208 deletions
diff --git a/src/usr/local/www/system_firmware_settings.php b/src/usr/local/www/system_firmware_settings.php index 9f6c5e0..e43ca1c 100644 --- a/src/usr/local/www/system_firmware_settings.php +++ b/src/usr/local/www/system_firmware_settings.php @@ -30,7 +30,7 @@ */ /* pfSense_BUILDER_BINARIES: /usr/bin/fetch - pfSense_MODULE: firmware + pfSense_MODULE: firmware */ ##|+PRIV @@ -89,230 +89,172 @@ $gitcfg = $config['system']['gitsync']; $pgtitle = array(gettext("System"), gettext("Firmware"), gettext("Settings")); $closehead = false; -include("head.inc"); exec("/usr/bin/fetch -q -o {$g['tmp_path']}/manifest \"{$g['update_manifest']}\""); if (file_exists("{$g['tmp_path']}/manifest")) { $preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest")); } -?> -<script type="text/javascript"> -//<![CDATA[ +include("head.inc"); + +if ($input_errors) + print_input_errors($input_errors); + +if ($savemsg) + print_info_box($savemsg, 'success'); + +$tab_array = array(); +$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php"); +$tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php"); +$tab_array[] = array(gettext("Updater Settings"), true, "system_firmware_settings.php"); + +if($g['hidedownloadbackup'] == false) + $tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php"); + +display_top_tabs($tab_array); +require('classes/Form.class.php'); -function enable_altfirmwareurl(enable_over) { - if (document.iform.alturlenable.checked || enable_over) { - document.iform.firmwareurl.disabled = 0; - } else { - document.iform.firmwareurl.disabled = 1; - document.iform.firmwareurl.value = ''; +$form = new Form(); + +$section = new Form_Section('Firmware Branch'); + +if(is_array($preset_urls_split)) { + $urllist = array(); + + foreach($preset_urls_split as $pus) { + $pus_text = explode("\t", $pus); + if (empty($pus_text[0])) + continue; + if (stristr($pus_text[0], php_uname("m")) !== false) { + $yourarch = " (Current architecture)"; + $choice = $pus_text[1]; + } else { + $yourarch = ""; + } + + $urllist[$pus_text[1]] = $pus_text[0] . $yourarch; } + + $section->addInput(new Form_Select( + 'preseturls', + 'Default Auto Update URLs', + $choice, + $urllist + ))->setHelp('Entries denoted by "Current architecture" match the architecture of your current installation, ' . + 'such as %s. Changing architectures during an upgrade is not recommended, and may require a manual reboot after the update completes.', [php_uname("m")]); + + $form->add($section); } -//]]> -</script> -</head> +$section = new Form_Section('Firmware Auto Update URL'); -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc");?> -<?php if ($input_errors) print_input_errors($input_errors); ?> +$section->addInput(new Form_Checkbox( + 'alturlenable', + 'Unofficial', + 'Allow the use of an "unofficial" server for firmware upgrades', + isset($curcfg['alturl']['enable']) + )); -<form action="system_firmware_settings.php" method="post" name="iform" id="iform"> -<?php if ($savemsg) print_info_box($savemsg); ?> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware settings"> - <tr> - <td> -<?php - $tab_array = array(); - $tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php"); - $tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php"); - $tab_array[] = array(gettext("Updater Settings"), true, "system_firmware_settings.php"); - if ($g['hidedownloadbackup'] == false) { - $tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php"); +$section->addInput(new Form_Input( + 'firmwareurl', + 'Base URL', + 'text' + ))->setHelp('This is where %s will check for newer firmware versions when the <a href="system_firmware_check.php">' . + 'System: Firmware: Auto Update</a> page is viewed', [$g['product_name']]); + +$form->add($section); + +$section = new Form_Section('Updates'); + +$section->addInput(new Form_Checkbox( + 'allowinvalidsig', + 'Unsigned images', + 'Allow auto-update firmware images with a missing or invalid digital signature to be used', + isset($curcfg['allowinvalidsig']) + )); + +$section->addInput(new Form_Checkbox( + 'disablecheck', + 'Dashboard check', + 'Disable the automatic dashboard auto-update check', + isset($curcfg['disablecheck']) + )); + +$form->add($section); + +if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense") { + $section = new Form_Section('GitSync'); + + $section->addInput(new Form_Checkbox( + 'synconupgrade', + 'Auto sync on update', + 'After updating, sync with the following repository/branch before reboot', + isset($gitcfg['synconupgrade']) + ))->setHelp('After updating, sync with the following repository/branch before reboot'); + + if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) { + exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str); + if(is_array($output_str) && !empty($output_str[0])) + $lastrepositoryurl = $output_str[0]; + unset($output_str); } - display_top_tabs($tab_array); -?> - </td> - </tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area"> - <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></td> - </tr> -<?php if (is_array($preset_urls_split)): ?> - <tr> - <td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td> - <td class="vtable"> - <select name='preseturls' id='preseturls' onchange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; jQuery('#preseturls').parent().effect('highlight');"> - <option></option> - <?php - foreach ($preset_urls_split as $pus) { - $pus_text = explode("\t", $pus); - if (empty($pus_text[0])) { - continue; - } - if (stristr($pus_text[0], php_uname("m")) !== false) { - $style = " style=\"font-weight: bold\""; - $yourarch = " (Current architecture)"; - } else { - $style = ""; - $yourarch = ""; - } - echo "<option value='{$pus_text[1]}'{$style}>{$pus_text[0]}{$yourarch}</option>"; - } - ?> - </select> - <br /><br /><?php echo sprintf(gettext("Entries denoted by \"Current architecture\" match the architecture of your current installation, such as %s. Changing architectures during an upgrade is not recommended, and may require a manual reboot after the update completes."), php_uname("m")); ?> - </td> - </tr> -<?php endif; ?> - <tr> - <td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td> - <td class="vtable"> - <input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onclick="enable_altfirmwareurl()" <?php if (isset($curcfg['alturl']['enable'])) echo "checked=\"checked\""; ?> /> <?=gettext("Use an unofficial server for firmware upgrades") ?><br /> - <table summary="alternative Base URL"> - <tr> - <td> - <?=gettext("Base URL:"); ?> - </td> - <td> - <input name="firmwareurl" type="text" class="formfld url" id="firmwareurl" size="64" value="<?php if ($curcfg['alturl']['firmwareurl']) echo htmlspecialchars($curcfg['alturl']['firmwareurl']); else echo $g['']; ?>" /> - </td> - </tr> - </table> - <span class="vexpl"> - <?=gettext("This is where"); ?> <?php echo $g['product_name'] ?> <?=gettext("will check for newer firmware versions when the"); ?> <a href="system_firmware_check.php"><?=gettext("System: Firmware: Auto Update"); ?></a> <?=gettext("page is viewed."); ?> - <br /> - <b><?=gettext("NOTE:"); ?></b> <?php printf(gettext("When a custom URL is configured, the system will not verify the image has an official digital signature")); ?> - </span> - </td> - </tr> - <tr> - <td colspan="2" class="list" height="12"> </td> - </tr> - <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Unsigned images"); ?></td> - <td width="78%" class="vtable"> - <input name="allowinvalidsig" type="checkbox" id="allowinvalidsig" value="yes" <?php if (isset($curcfg['allowinvalidsig'])) echo "checked=\"checked\""; ?> /> - <br /> - <?=gettext("Allow auto-update firmware images with a missing or invalid digital signature to be used."); ?> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Dashboard check"); ?></td> - <td width="78%" class="vtable"> - <input name="disablecheck" type="checkbox" id="disablecheck" value="yes" <?php if (isset($curcfg['disablecheck'])) echo "checked=\"checked\""; ?> /> - <br /> - <?=gettext("Disable the automatic dashboard auto-update check."); ?> - </td> - </tr> -<?php - if (file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): -?> - <tr> - <td colspan="2" class="list" height="12"> </td> - </tr> - <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td> - <td width="78%" class="vtable"> - <input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked=\"checked\""; ?> /> - <br /> - <?=gettext("After updating, sync with the following repository/branch before reboot."); ?> - </td> - </tr> -<?php - if (is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) { - exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str); - if (is_array($output_str) && !empty($output_str[0])) { - $lastrepositoryurl = $output_str[0]; - } - unset($output_str); - } -?> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td> - <td width="78%" class="vtable"> - <input name="repositoryurl" type="text" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo htmlspecialchars($gitcfg['repositoryurl']); ?>" /> -<?php - if ($lastrepositoryurl): -?> - <br /> - <?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?> - <br /> - <?=gettext("This will be used if the field is left blank."); ?> -<?php - endif; -?> - </td> - </tr> -<?php - if (is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) { - exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str); - if (is_array($output_str)) { - foreach ($output_str as $output_line) { - if (strstr($output_line, '* ')) { - $lastbranch = substr($output_line, 2); - break; - } + + $section->addInput(new Form_Input( + 'repositoryurl', + 'Repository URL', + 'text', + ($gitcfg['repositoryurl'] ? $gitcfg['repositoryurl'] : '') + ))->setHelp('The most recently used repository was %s. This repository will be used if the field is left blank.', [$lastrepositoryurl]); + + if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) { + exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str); + if(is_array($output_str)) { + foreach($output_str as $output_line) { + if(strstr($output_line, '* ')) { + $lastbranch = substr($output_line, 2); + break; } } unset($output_str); } + unset($output_str); + } + + $section->addInput(new Form_Input( + 'branch', + 'Branch name', + 'text', + ($gitcfg['branch'] ? $gitcfg['branch'] : '') + ))->setHelp('The most recently used branch was "%s". (Usually the branch name is master)' . + '<br />Note: Sync will not be performed if a branch is not specified', [$lastbranch]); + + $form->add($section); +} // e-o-if(file_exista() + +print($form); ?> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td> - <td width="78%" class="vtable"> - <input name="branch" type="text" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo htmlspecialchars($gitcfg['branch']); ?>" /> -<?php - if ($lastbranch): -?> - <br /> - <?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?> -<?php - else: -?> - <br /> - <?=gettext("Usually the branch name is master"); ?> -<?php - endif; -?> - <br /> - <?=gettext("Note: Sync will not be performed if a branch is not specified."); ?> - </td> - </tr> + +<script> +// Update firmwareurl from preseturls +function update_firmwareurl() { + var pre = document.getElementById("preseturls"); + var preVal = pre.options[pre.selectedIndex].value; + var firm = document.getElementById("firmwareurl"); + firm.value = preVal; +} + +// Call it when preseturls changes +events.push(function(){ + $('#preseturls').on('change', function(){ + update_firmwareurl(); + }) +}); + +// And call it on page load +update_firmwareurl(); + +</script> <?php - endif; -?> - <tr> - <td> - <script type="text/javascript"> - //<![CDATA[ - enable_altfirmwareurl(); - //]]> - </script> - </td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> - </td> - </tr> - </table> - </div> - </td> - </tr> -</table> -</form> -<?php include("fend.inc"); ?> -</body> -</html> + +include("foot.inc");
\ No newline at end of file |