summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2015-05-30 09:57:09 -0300
committerRenato Botelho <garga@FreeBSD.org>2015-05-30 09:57:09 -0300
commit5d15bda8a30dc5bff4e530163b0f130d1c5fa21b (patch)
treeeb5aa9800b451c62662088418414e835cb12b902 /usr/local/www
parenta90bc47aac1d985457fc6bbf5c2d93e0fd60ab48 (diff)
parent0e88de0c3bd7736f6dd949063270b18ef84b5274 (diff)
downloadpfsense-5d15bda8a30dc5bff4e530163b0f130d1c5fa21b.zip
pfsense-5d15bda8a30dc5bff4e530163b0f130d1c5fa21b.tar.gz
Merge pull request #1698 from phil-davis/system-firmware
Diffstat (limited to 'usr/local/www')
-rw-r--r--usr/local/www/system_firmware.php222
-rwxr-xr-xusr/local/www/system_firmware_auto.php52
-rw-r--r--usr/local/www/system_firmware_check.php31
-rw-r--r--usr/local/www/system_firmware_restorefullbackup.php32
-rw-r--r--usr/local/www/system_firmware_settings.php337
5 files changed, 379 insertions, 295 deletions
diff --git a/usr/local/www/system_firmware.php b/usr/local/www/system_firmware.php
index 2eb0589..b3564c0 100644
--- a/usr/local/www/system_firmware.php
+++ b/usr/local/www/system_firmware.php
@@ -59,16 +59,18 @@ ini_set('max_input_time', '9999');
function file_is_for_platform($filename, $ul_name) {
global $g;
- if($g['platform'] == "nanobsd") {
- if(stristr($ul_name, "nanobsd"))
+ if ($g['platform'] == "nanobsd") {
+ if (stristr($ul_name, "nanobsd")) {
return true;
- else
+ } else {
return false;
+ }
}
$_gb = exec("/usr/bin/tar xzf $filename -C /tmp/ etc/platform");
unset($_gb);
- if(!file_exists("/tmp/etc/platform"))
+ if (!file_exists("/tmp/etc/platform")) {
return false;
+ }
$upgrade_is_for_platform = trim(file_get_contents("/tmp/etc/platform", " \n\t\r"));
if ($g['platform'] == $upgrade_is_for_platform) {
@unlink("/tmp/etc/platform");
@@ -79,28 +81,28 @@ function file_is_for_platform($filename, $ul_name) {
function file_upload_error_message($error_code) {
switch ($error_code) {
- case UPLOAD_ERR_INI_SIZE:
- return gettext('The uploaded file exceeds the upload_max_filesize directive in php.ini');
- case UPLOAD_ERR_FORM_SIZE:
- return gettext('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form');
- case UPLOAD_ERR_PARTIAL:
- return gettext('The uploaded file was only partially uploaded');
- case UPLOAD_ERR_NO_FILE:
- return gettext('No file was uploaded');
- case UPLOAD_ERR_NO_TMP_DIR:
- return gettext('Missing a temporary folder');
- case UPLOAD_ERR_CANT_WRITE:
- return gettext('Failed to write file to disk');
- case UPLOAD_ERR_EXTENSION:
- return gettext('File upload stopped by extension');
- default:
- return gettext('Unknown upload error');
+ case UPLOAD_ERR_INI_SIZE:
+ return gettext('The uploaded file exceeds the upload_max_filesize directive in php.ini');
+ case UPLOAD_ERR_FORM_SIZE:
+ return gettext('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form');
+ case UPLOAD_ERR_PARTIAL:
+ return gettext('The uploaded file was only partially uploaded');
+ case UPLOAD_ERR_NO_FILE:
+ return gettext('No file was uploaded');
+ case UPLOAD_ERR_NO_TMP_DIR:
+ return gettext('Missing a temporary folder');
+ case UPLOAD_ERR_CANT_WRITE:
+ return gettext('Failed to write file to disk');
+ case UPLOAD_ERR_EXTENSION:
+ return gettext('File upload stopped by extension');
+ default:
+ return gettext('Unknown upload error');
}
}
/* if upgrade in progress, alert user */
-if(is_subsystem_dirty('firmwarelock')) {
- $pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Manual Update"));
+if (is_subsystem_dirty('firmwarelock')) {
+ $pgtitle = array(gettext("System"), gettext("Firmware"), gettext("Manual Update"));
include("head.inc");
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
include("fbegin.inc");
@@ -113,8 +115,9 @@ if(is_subsystem_dirty('firmwarelock')) {
exit;
}
-if($_POST['backupbeforeupgrade'])
+if ($_POST['backupbeforeupgrade']) {
touch("/tmp/perform_full_backup.txt");
+}
/* Handle manual upgrade */
if ($_POST && !is_subsystem_dirty('firmwarelock')) {
@@ -122,15 +125,16 @@ if ($_POST && !is_subsystem_dirty('firmwarelock')) {
unset($input_errors);
unset($sig_warning);
- if (stristr($_POST['Submit'], gettext("Enable")))
+ if (stristr($_POST['Submit'], gettext("Enable"))) {
$mode = "enable";
- else if (stristr($_POST['Submit'], gettext("Disable")))
+ } else if (stristr($_POST['Submit'], gettext("Disable"))) {
$mode = "disable";
- else if (stristr($_POST['Submit'], gettext("Upgrade")) || $_POST['sig_override'])
+ } else if (stristr($_POST['Submit'], gettext("Upgrade")) || $_POST['sig_override']) {
$mode = "upgrade";
- else if ($_POST['sig_no']) {
- if(file_exists("{$g['upload_path']}/firmware.tgz"))
- unlink("{$g['upload_path']}/firmware.tgz");
+ } else if ($_POST['sig_no']) {
+ if (file_exists("{$g['upload_path']}/firmware.tgz")) {
+ unlink("{$g['upload_path']}/firmware.tgz");
+ }
}
if ($mode) {
if ($mode == "enable") {
@@ -140,13 +144,14 @@ if ($_POST && !is_subsystem_dirty('firmwarelock')) {
conf_mount_ro();
clear_subsystem_dirty('firmware');
} else if ($mode == "upgrade") {
- if ($_FILES['ulfile']['error'])
+ if ($_FILES['ulfile']['error']) {
$errortext = "(" . file_upload_error_message($_FILES['ulfile']['error']) . ")";
+ }
if (is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
/* verify firmware image(s) */
- if (file_is_for_platform($_FILES['ulfile']['tmp_name'], $_FILES['ulfile']['name']) == false && !$_POST['sig_override'])
+ if (file_is_for_platform($_FILES['ulfile']['tmp_name'], $_FILES['ulfile']['name']) == false && !$_POST['sig_override']) {
$input_errors[] = gettext("The uploaded image file is not for this platform.");
- else if (!file_exists($_FILES['ulfile']['tmp_name'])) {
+ } else if (!file_exists($_FILES['ulfile']['tmp_name'])) {
/* probably out of memory for the MFS */
$input_errors[] = gettext("Image upload failed (out of memory?)");
mwexec("/etc/rc.firmware disable");
@@ -158,12 +163,13 @@ if ($_POST && !is_subsystem_dirty('firmwarelock')) {
/* check digital signature */
$sigchk = verify_digital_signature("{$g['upload_path']}/firmware.tgz");
- if ($sigchk == 1)
+ if ($sigchk == 1) {
$sig_warning = gettext("The digital signature on this image is invalid.");
- else if ($sigchk == 2 && !isset($config['system']['firmware']['allowinvalidsig']))
+ } else if ($sigchk == 2 && !isset($config['system']['firmware']['allowinvalidsig'])) {
$sig_warning = gettext("This image is not digitally signed.");
- else if (($sigchk >= 3))
+ } else if (($sigchk >= 3)) {
$sig_warning = gettext("There has been an error verifying the signature on this image.");
+ }
if (!verify_gzip_file("{$g['upload_path']}/firmware.tgz")) {
$input_errors[] = gettext("The image file is corrupt.");
@@ -180,26 +186,28 @@ if ($_POST && !is_subsystem_dirty('firmwarelock')) {
/* fire up the update script in the background */
mark_subsystem_dirty('firmwarelock');
$savemsg = gettext("The firmware is now being updated. The firewall will reboot automatically.");
- if (stristr($_FILES['ulfile']['name'],"nanobsd") or $_POST['isnano'] == "yes")
+ if (stristr($_FILES['ulfile']['name'], "nanobsd") or $_POST['isnano'] == "yes") {
mwexec_bg("/etc/rc.firmware pfSenseNanoBSDupgrade {$g['upload_path']}/firmware.tgz");
- else if(stristr($_FILES['ulfile']['name'],"bdiff"))
+ } else if (stristr($_FILES['ulfile']['name'], "bdiff")) {
mwexec_bg("/etc/rc.firmware delta_update {$g['upload_path']}/firmware.tgz");
- else {
- if($g['platform'] == "nanobsd")
+ } else {
+ if ($g['platform'] == "nanobsd") {
$whichone = "pfSenseNanoBSDupgrade";
- else
+ } else {
$whichone = "pfSenseupgrade";
+ }
mwexec_bg("/etc/rc.firmware {$whichone} {$g['upload_path']}/firmware.tgz");
unset($whichone);
}
- } else
- $savemsg = sprintf(gettext("Firmware image missing or other error, please try again %s."),$errortext);
+ } else {
+ $savemsg = sprintf(gettext("Firmware image missing or other error, please try again %s."), $errortext);
+ }
}
}
}
}
-$pgtitle = array(gettext("System"),gettext("Firmware"));
+$pgtitle = array(gettext("System"), gettext("Firmware"));
include("head.inc");
?>
@@ -207,73 +215,83 @@ include("head.inc");
<form action="system_firmware.php" method="post" enctype="multipart/form-data">
<?php
/* Construct an upload_id for this session */
- if (!session_id())
+ if (!session_id()) {
$upload_id = uniqid();
- else
+ } else {
$upload_id = session_id();
+ }
?>
<input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $upload_id;?>" />
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if ($fwinfo <> "") print_info_box($fwinfo); ?>
-<?php if ($sig_warning && !$input_errors): ?>
<?php
- $sig_warning = "<strong>" . $sig_warning . "</strong><br />" . gettext("This means that the image you uploaded " .
- "is not an official/supported image and may lead to unexpected behavior or security " .
- "compromises. Only install images that come from sources that you trust, and make sure ".
- "that the image has not been tampered with.") . "<br /><br />".
- gettext("Do you want to install this image anyway (on your own risk)?");
-print_info_box($sig_warning);
-if(stristr($_FILES['ulfile']['name'],"nanobsd"))
- echo "<input type='hidden' name='isnano' id='isnano' value='yes' />\n";
+ if ($sig_warning && !$input_errors):
+ $sig_warning = "<strong>" . $sig_warning . "</strong><br />" . gettext("This means that the image you uploaded " .
+ "is not an official/supported image and may lead to unexpected behavior or security " .
+ "compromises. Only install images that come from sources that you trust, and make sure " .
+ "that the image has not been tampered with.") . "<br /><br />" .
+ gettext("Do you want to install this image anyway (on your own risk)?");
+ print_info_box($sig_warning);
+ if (stristr($_FILES['ulfile']['name'], "nanobsd")) {
+ echo "<input type='hidden' name='isnano' id='isnano' value='yes' />\n";
+ }
?>
<input name="sig_override" type="submit" class="formbtn" id="sig_override" value=" <?=gettext("Yes");?> " />
<input name="sig_no" type="submit" class="formbtn" id="sig_no" value=" <?=gettext("No"); ?> " />
-<?php else: ?>
-<?php if (!is_subsystem_dirty('firmwarelock')): ?>
+<?php
+ else:
+ if (!is_subsystem_dirty('firmwarelock')):
+?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware">
<tr>
<td>
<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Manual Update"), true, "system_firmware.php");
- $tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php");
- $tab_array[] = array(gettext("Updater Settings"), false, "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);
+ $tab_array = array();
+ $tab_array[] = array(gettext("Manual Update"), true, "system_firmware.php");
+ $tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php");
+ $tab_array[] = array(gettext("Updater Settings"), false, "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);
?>
</td>
</tr>
<tr>
<td>
<div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
<tr>
<td colspan="2" class="listtopic"><?=gettext("Invoke") ." ". $g['product_name'] ." ". gettext("Manual Upgrade"); ?></td>
</tr>
<tr>
<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
<td width="78%" class="vtable">
- <?php if (!is_subsystem_dirty('rebootreq')): ?>
- <?php if (!is_subsystem_dirty('firmware')): ?>
- <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Enable firmware upload");?>" />
- <br />
- <?php printf(gettext('Click "Enable firmware upload" to begin.'),$g['firmware_update_text']);?>
- <br />
- <?php else: ?>
+<?php
+ if (!is_subsystem_dirty('rebootreq')):
+ if (!is_subsystem_dirty('firmware')):
+?>
+ <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Enable firmware upload");?>" />
+ <br />
+ <?php printf(gettext('Click "Enable firmware upload" to begin.'), $g['firmware_update_text']);?>
+ <br />
+<?php
+ else:
+?>
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Disable firmware upload");?>" />
- </td>
+ </td>
</tr>
<tr>
<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
<td width="78%" class="vtable">
<?php
- if ($g['platform'] == "nanobsd")
+ if ($g['platform'] == "nanobsd") {
$type = "*.img.gz";
- else
+ } else {
$type = "*.tgz";
+ }
?>
<strong><?=gettext("Firmware image file ($type):");?> </strong>
<input name="ulfile" type="file" class="formfld" />
@@ -284,33 +302,43 @@ if(stristr($_FILES['ulfile']['name'],"nanobsd"))
<?php endif; ?>
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Upgrade firmware");?>" />
<?=gettext('Click "Upgrade firmware" to start the upgrade process.');?>
- <?php endif; else: ?>
+<?php
+ endif;
+ else:
+?>
<strong><?=gettext("You must reboot the system before you can upgrade the firmware.");?></strong>
- <?php endif; ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
+<?php
+ endif;
+?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
<?php if (is_subsystem_dirty('firmware')): ?>
- <span class="vexpl">
- <span class="red">
- <strong>
- <?=gettext("Warning:");?><br />
- </strong>
- </span>
- <?=gettext("DO NOT abort the firmware upgrade once it " .
- "has started. The firewall will reboot automatically after " .
- "storing the new firmware. The configuration will be maintained.");?>
- </span>
+ <span class="vexpl">
+ <span class="red">
+ <strong>
+ <?=gettext("Warning:");?><br />
+ </strong>
+ </span>
+ <?=gettext("DO NOT abort the firmware upgrade once it " .
+ "has started. The firewall will reboot automatically after " .
+ "storing the new firmware. The configuration will be maintained.");?>
+ </span>
<?php endif; ?>
- </td></tr>
- </table>
- </div>
- </td></tr>
-</table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
-<?php endif; endif; ?>
+<?php
+ endif;
+ endif;
+?>
<?php include("fend.inc"); ?>
</form>
</body>
diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php
index 6e0ead5..9c15ae3 100755
--- a/usr/local/www/system_firmware_auto.php
+++ b/usr/local/www/system_firmware_auto.php
@@ -50,16 +50,18 @@ require_once("pfsense-utils.inc");
$curcfg = $config['system']['firmware'];
-if(isset($curcfg['alturl']['enable']))
+if (isset($curcfg['alturl']['enable'])) {
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
-else
+} else {
$updater_url = $g['update_url'];
+}
-if($_POST['backupbeforeupgrade'])
+if ($_POST['backupbeforeupgrade']) {
touch("/tmp/perform_full_backup.txt");
+}
$closehead = false;
-$pgtitle = array(gettext("Diagnostics"),gettext("Firmware"),gettext("Auto Update"));
+$pgtitle = array(gettext("Diagnostics"), gettext("Firmware"), gettext("Auto Update"));
include("head.inc");
?>
@@ -81,8 +83,9 @@ include("head.inc");
$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
$tab_array[] = array(gettext("Auto Update"), true, "system_firmware_check.php");
$tab_array[] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
- if($g['hidedownloadbackup'] == false)
+ if ($g['hidedownloadbackup'] == false) {
$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
+ }
display_top_tabs($tab_array);
?>
</td>
@@ -96,15 +99,16 @@ include("head.inc");
<tr>
<td align="center">
<table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images">
-
<tr>
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_left.gif')" height="15" width="5"> </td>
<td>
- <table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="">
- <tr><td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
- <img src="./themes/<?=$g['theme'];?>/images/misc/bar_blue.gif" width="0" height="15" name="progressbar" id="progressbar" alt="" />
- </td></tr>
- </table>
+ <table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="">
+ <tr>
+ <td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
+ <img src="./themes/<?=$g['theme'];?>/images/misc/bar_blue.gif" width="0" height="15" name="progressbar" id="progressbar" alt="" />
+ </td>
+ </tr>
+ </table>
</td>
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5"></td>
</tr>
@@ -112,7 +116,7 @@ include("head.inc");
<br />
<script type="text/javascript">
//<![CDATA[
- window.onload=function(){
+ window.onload=function() {
document.getElementById("status").wrap='hard';
document.getElementById("output").wrap='hard';
}
@@ -141,10 +145,11 @@ include("head.inc");
update_status(gettext("Downloading current version information") . "...");
$nanosize = "";
if ($g['platform'] == "nanobsd") {
- if (file_exists("/etc/nano_use_vga.txt"))
+ if (file_exists("/etc/nano_use_vga.txt")) {
$nanosize = "-nanobsd-vga-";
- else
+ } else {
$nanosize = "-nanobsd-";
+ }
$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
}
@@ -152,7 +157,7 @@ if ($g['platform'] == "nanobsd") {
@unlink("/tmp/{$g['product_name']}_version");
download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version");
$latest_version = str_replace("\n", "", @file_get_contents("/tmp/{$g['product_name']}_version"));
-if(!$latest_version) {
+if (!$latest_version) {
update_output_window(gettext("Unable to check for updates."));
require("fend.inc");
exit;
@@ -161,7 +166,7 @@ if(!$latest_version) {
$current_installed_version = trim(file_get_contents("/etc/version"));
$latest_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
$latest_version_pfsense = strtotime($latest_version);
- if(!$latest_version) {
+ if (!$latest_version) {
update_output_window(gettext("Unable to check for updates."));
require("fend.inc");
exit;
@@ -189,10 +194,11 @@ if(!$latest_version) {
/* launch external upgrade helper */
$external_upgrade_helper_text = "/etc/rc.firmware ";
-if($g['platform'] == "nanobsd")
+if ($g['platform'] == "nanobsd") {
$external_upgrade_helper_text .= "pfSenseNanoBSDupgrade ";
-else
+} else {
$external_upgrade_helper_text .= "pfSenseupgrade ";
+}
$external_upgrade_helper_text .= "{$g['upload_path']}/latest.tgz";
@@ -201,8 +207,9 @@ $upgrade_latest_tgz_sha256 = str_replace("\n", "", `/bin/cat {$g['upload_path']}
$sigchk = 0;
-if(!isset($curcfg['alturl']['enable']))
+if (!isset($curcfg['alturl']['enable'])) {
$sigchk = verify_digital_signature("{$g['upload_path']}/latest.tgz");
+}
$exitstatus = 0;
if ($sigchk == 1) {
@@ -210,8 +217,9 @@ if ($sigchk == 1) {
$exitstatus = 1;
} else if ($sigchk == 2) {
$sig_warning = gettext("This image is not digitally signed.");
- if (!isset($config['system']['firmware']['allowinvalidsig']))
+ if (!isset($config['system']['firmware']['allowinvalidsig'])) {
$exitstatus = 1;
+ }
} else if (($sigchk >= 3)) {
$sig_warning = gettext("There has been an error verifying the signature on this image.");
$exitstatus = 1;
@@ -239,7 +247,7 @@ if (!verify_gzip_file("{$g['upload_path']}/latest.tgz")) {
exit;
}
-if($downloaded_latest_tgz_sha256 <> $upgrade_latest_tgz_sha256) {
+if ($downloaded_latest_tgz_sha256 <> $upgrade_latest_tgz_sha256) {
update_status(gettext("Downloading complete but sha256 does not match."));
update_output_window(gettext("Auto upgrade aborted.") . " \n\n" . gettext("Downloaded SHA256") . ": " . $downloaded_latest_tgz_sha256 . "\n\n" . gettext("Needed SHA256") . ": " . $upgrade_latest_tgz_sha256);
} else {
@@ -274,7 +282,7 @@ function read_body_firmware($ch, $string) {
$text .= " " . gettext("Percent") . " : {$c}%\\n";
$text .= "----------------------------------------------------\\n";
$counter++;
- if($counter > 150) {
+ if ($counter > 150) {
update_output_window($text);
update_progress_bar($downloadProgress);
$counter = 0;
diff --git a/usr/local/www/system_firmware_check.php b/usr/local/www/system_firmware_check.php
index f38a5c2..458e071 100644
--- a/usr/local/www/system_firmware_check.php
+++ b/usr/local/www/system_firmware_check.php
@@ -65,8 +65,9 @@ include("head.inc");
$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
$tab_array[] = array(gettext("Auto Update"), true, "system_firmware_check.php");
$tab_array[] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
- if($g['hidedownloadbackup'] == false)
+ if ($g['hidedownloadbackup'] == false) {
$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
+ }
display_top_tabs($tab_array);
?>
</td>
@@ -83,9 +84,11 @@ include("head.inc");
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_left.gif')" height="15" width="5"></td>
<td>
<table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="">
- <tr><td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
- <img src="./themes/<?=$g['theme'];?>/images/misc/bar_blue.gif" width="0" height="15" name="progressbar" id="progressbar" alt="" />
- </td></tr>
+ <tr>
+ <td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
+ <img src="./themes/<?=$g['theme'];?>/images/misc/bar_blue.gif" width="0" height="15" name="progressbar" id="progressbar" alt="" />
+ </td>
+ </tr>
</table>
</td>
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5"></td>
@@ -95,7 +98,7 @@ include("head.inc");
<!-- command output box -->
<script type="text/javascript">
//<![CDATA[
- window.onload=function(){
+ window.onload=function() {
document.getElementById("output").wrap='hard';
}
//]]>
@@ -119,32 +122,36 @@ include("head.inc");
<?php
/* Define necessary variables. */
-if(isset($curcfg['alturl']['enable']))
+if (isset($curcfg['alturl']['enable'])) {
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
-else
+} else {
$updater_url = $g['update_url'];
+}
$needs_system_upgrade = false;
$static_text .= gettext("Downloading new version information...");
$nanosize = "";
if ($g['platform'] == "nanobsd") {
- if (file_exists("/etc/nano_use_vga.txt"))
+ if (file_exists("/etc/nano_use_vga.txt")) {
$nanosize = "-nanobsd-vga-";
- else
+ } else {
$nanosize = "-nanobsd-";
+ }
$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
}
-if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
+if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true) {
$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
+}
$static_text .= gettext("done") . "\\n";
if (!$remote_version) {
$static_text .= gettext("Unable to check for updates.") . "\\n";
- if(isset($curcfg['alturl']['enable']))
+ if (isset($curcfg['alturl']['enable'])) {
$static_text .= gettext("Could not contact custom update server.") . "\\n";
- else
+ } else {
$static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
+ }
} else {
$static_text .= gettext("Obtaining current version information...");
update_output_window($static_text);
diff --git a/usr/local/www/system_firmware_restorefullbackup.php b/usr/local/www/system_firmware_restorefullbackup.php
index 0f63634..fb571af 100644
--- a/usr/local/www/system_firmware_restorefullbackup.php
+++ b/usr/local/www/system_firmware_restorefullbackup.php
@@ -53,16 +53,18 @@ require("guiconfig.inc");
require_once("filter.inc");
require_once("shaper.inc");
-if($_POST['overwriteconfigxml'])
+if ($_POST['overwriteconfigxml']) {
touch("/tmp/do_not_restore_config.xml");
+}
-if($_GET['backupnow'])
+if ($_GET['backupnow']) {
mwexec_bg("/etc/rc.create_full_backup");
+}
-if($_GET['downloadbackup']) {
+if ($_GET['downloadbackup']) {
$filename = basename($_GET['downloadbackup']);
$path = "/root/{$filename}";
- if(file_exists($path)) {
+ if (file_exists($path)) {
session_write_close();
ob_end_clean();
session_cache_limiter('public');
@@ -71,11 +73,11 @@ if($_GET['downloadbackup']) {
header("Cache-Control: ");
header("Pragma: ");
header("Content-Type: application/octet-stream");
- header("Content-Length: " .(string)(filesize($path)) );
+ header("Content-Length: " .(string)(filesize($path)));
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");
- if($file = fopen("/root/{$filename}", 'rb')){
- while( (!feof($file)) && (connection_status()==0) ){
+ if ($file = fopen("/root/{$filename}", 'rb')) {
+ while ((!feof($file)) && (connection_status() == 0)) {
print(fread($file, 1024*8));
flush();
}
@@ -88,7 +90,7 @@ if($_GET['downloadbackup']) {
if ($_GET['deletefile']) {
$filename = basename($_GET['deletefile']);
- if(file_exists("/root/{$filename}") && (preg_match("/pfSense-full-backup-\d+-\d+\.tgz/", $filename) == 1)) {
+ if (file_exists("/root/{$filename}") && (preg_match("/pfSense-full-backup-\d+-\d+\.tgz/", $filename) == 1)) {
unlink("/root/" . $filename);
$savemsg = htmlspecialchars($filename) . " " . gettext("has been deleted.");
} else {
@@ -98,7 +100,7 @@ if ($_GET['deletefile']) {
if ($_POST['restorefile']) {
$filename = basename($_POST['restorefile']);
- if(file_exists("/root/{$filename}") && (preg_match("/pfSense-full-backup-\d+-\d+\.tgz/", $filename) == 1)) {
+ if (file_exists("/root/{$filename}") && (preg_match("/pfSense-full-backup-\d+-\d+\.tgz/", $filename) == 1)) {
mwexec_bg("/etc/rc.restore_full_backup /root/" . escapeshellcmd($filename));
$savemsg = gettext("The firewall is currently restoring") . " " . htmlspecialchars($filename);
} else {
@@ -106,7 +108,7 @@ if ($_POST['restorefile']) {
}
}
-$pgtitle = array(gettext("Diagnostics"),gettext("Restore full backup"));
+$pgtitle = array(gettext("Diagnostics"), gettext("Restore full backup"));
include("head.inc");
?>
@@ -132,8 +134,9 @@ include("head.inc");
$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"), false, "system_firmware_settings.php");
- if($g['hidedownloadbackup'] == false)
+ if ($g['hidedownloadbackup'] == false) {
$tab_array[] = array(gettext("Restore Full Backup"), true, "system_firmware_restorefullbackup.php");
+ }
display_top_tabs($tab_array);
?>
</td>
@@ -152,7 +155,7 @@ include("head.inc");
chdir("/root");
$available_restore_files = glob("pfSense-full-backup-*");
$counter = 0;
- foreach($available_restore_files as $arf) {
+ foreach ($available_restore_files as $arf) {
$counter++;
$size = exec("gzip -l /root/$arf | grep -v compressed | awk '{ print $2 }'");
echo "<tr>";
@@ -175,7 +178,7 @@ include("head.inc");
echo "</td>";
echo "</tr>";
}
- if($counter == 0) {
+ if ($counter == 0) {
echo "<tr>";
echo "<td class='listlr' width='100%' colspan='4' align='center'>";
echo gettext("Could not locate any previous backups.");
@@ -210,7 +213,8 @@ decrypt_change();
</html>
<?php
-if (is_subsystem_dirty('restore'))
+if (is_subsystem_dirty('restore')) {
system_reboot();
+}
?>
diff --git a/usr/local/www/system_firmware_settings.php b/usr/local/www/system_firmware_settings.php
index ec48469..f2232d6 100644
--- a/usr/local/www/system_firmware_settings.php
+++ b/usr/local/www/system_firmware_settings.php
@@ -46,12 +46,12 @@ if ($_POST) {
unset($input_errors);
/* input validation */
- if(($_POST['alturlenable'] == "yes") && (empty($_POST['firmwareurl']))) {
+ 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) {
- if($_POST['alturlenable'] == "yes") {
+ if ($_POST['alturlenable'] == "yes") {
$config['system']['firmware']['alturl']['enable'] = true;
$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
} else {
@@ -60,20 +60,23 @@ if ($_POST) {
unset($config['system']['firmware']['alturl']);
unset($config['system']['firmware']);
}
- if($_POST['allowinvalidsig'] == "yes")
+ if ($_POST['allowinvalidsig'] == "yes") {
$config['system']['firmware']['allowinvalidsig'] = true;
- else
+ } else {
unset($config['system']['firmware']['allowinvalidsig']);
+ }
- if($_POST['disablecheck'] == "yes")
+ if ($_POST['disablecheck'] == "yes") {
$config['system']['firmware']['disablecheck'] = true;
- else
+ } else {
unset($config['system']['firmware']['disablecheck']);
+ }
- if($_POST['synconupgrade'] == "yes")
+ if ($_POST['synconupgrade'] == "yes") {
$config['system']['gitsync']['synconupgrade'] = true;
- else
+ } else {
unset($config['system']['gitsync']['synconupgrade']);
+ }
$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
$config['system']['gitsync']['branch'] = $_POST['branch'];
@@ -84,12 +87,12 @@ if ($_POST) {
$curcfg = $config['system']['firmware'];
$gitcfg = $config['system']['gitsync'];
-$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
+$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")) {
+if (file_exists("{$g['tmp_path']}/manifest")) {
$preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest"));
}
@@ -98,13 +101,13 @@ if(file_exists("{$g['tmp_path']}/manifest")) {
//<![CDATA[
-function enable_altfirmwareurl(enable_over) {
- if (document.iform.alturlenable.checked || enable_over) {
- document.iform.firmwareurl.disabled = 0;
- } else {
+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 = '';
- }
+ }
}
//]]>
@@ -116,8 +119,8 @@ function enable_altfirmwareurl(enable_over) {
<?php if ($input_errors) print_input_errors($input_errors); ?>
<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">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware settings">
<tr>
<td>
<?php
@@ -125,156 +128,190 @@ function enable_altfirmwareurl(enable_over) {
$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)
+ if ($g['hidedownloadbackup'] == false) {
$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
+ }
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>
+ <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 $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">&nbsp;</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">&nbsp;</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>
+ <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 $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">&nbsp;</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(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);
- }
+ if (file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"):
?>
- <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 $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>
+ <tr>
+ <td colspan="2" class="list" height="12">&nbsp;</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 $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
- 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;
+ 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;
+ }
}
}
+ unset($output_str);
}
- unset($output_str);
- }
?>
- <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 $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>
-<?php endif; ?>
- <tr><td><script type="text/javascript">
+ <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 $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>
+<?php
+ endif;
+?>
+ <tr>
+ <td>
+ <script type="text/javascript">
//<![CDATA[
enable_altfirmwareurl();
//]]>
- </script></td></tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
- </td>
- </tr>
- </table></div></td></tr></table>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</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>
OpenPOWER on IntegriCloud