diff options
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/interfaces_assign.php | 6 | ||||
-rw-r--r-- | src/usr/local/www/pkg_mgr.php | 2 | ||||
-rw-r--r-- | src/usr/local/www/pkg_mgr_install.php | 279 |
3 files changed, 154 insertions, 133 deletions
diff --git a/src/usr/local/www/interfaces_assign.php b/src/usr/local/www/interfaces_assign.php index 240fb92..68d2d32 100644 --- a/src/usr/local/www/interfaces_assign.php +++ b/src/usr/local/www/interfaces_assign.php @@ -500,11 +500,11 @@ if (file_exists("/var/run/interface_mismatch_reboot_needed")) { $savemsg = gettext("The system is now rebooting. Please wait."); $class = "success"; } else { - $savemsg = gettext("Reboot is needed. Please apply the settings in order to reboot."); + $applymsg = gettext("Reboot is needed. Please apply the settings in order to reboot."); $class = "warning"; } } else { - $savemsg = gettext("Interface mismatch detected. Please resolve the mismatch and click 'Apply Changes'. The firewall will reboot afterwards."); + $applymsg = gettext("Interface mismatch detected. Please resolve the mismatch and click 'Apply Changes'. The firewall will reboot afterwards."); $class = "warning"; } } @@ -513,6 +513,8 @@ if (file_exists("/tmp/reload_interfaces")) { echo "<p>\n"; print_apply_box(gettext("The interface configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect.")); echo "<br /></p>\n"; +} elseif ($applymsg) { + print_apply_box($applymsg); } elseif ($savemsg) { print_info_box($savemsg, $class); } diff --git a/src/usr/local/www/pkg_mgr.php b/src/usr/local/www/pkg_mgr.php index 7ce9821..6eb6bc8 100644 --- a/src/usr/local/www/pkg_mgr.php +++ b/src/usr/local/www/pkg_mgr.php @@ -144,7 +144,7 @@ function get_pkg_table() { $pkgtbl .= '</td>' . "\n"; $pkgtbl .= '<td>' . "\n"; - $pkgtbl .= '<a title="' . gettext("Click to install") . '" href="pkg_mgr_install.php?id=' . $index['name'] . '" class="btn btn-success btn-sm"><i class="fa fa-plus icon-embed-btn"></i>Install</a>' . "\n"; + $pkgtbl .= '<a title="' . gettext("Click to install") . '" href="pkg_mgr_install.php?pkg=' . $index['name'] . '" class="btn btn-success btn-sm"><i class="fa fa-plus icon-embed-btn"></i>Install</a>' . "\n"; if (!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']) { $pkgtbl .= '<a target="_blank" title="' . gettext("View more information") . '" href="' . htmlspecialchars($index['pkginfolink']) . '" class="btn btn-default btn-sm">info</a>' . "\n"; diff --git a/src/usr/local/www/pkg_mgr_install.php b/src/usr/local/www/pkg_mgr_install.php index 134608e..fe683b5 100644 --- a/src/usr/local/www/pkg_mgr_install.php +++ b/src/usr/local/www/pkg_mgr_install.php @@ -10,29 +10,29 @@ * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgment: - * "This product includes software developed by the pfSense Project - * for use in the pfSense software distribution. (http://www.pfsense.org/). + * must display the following acknowledgment: + * "This product includes software developed by the pfSense Project + * for use in the pfSense software distribution. (http://www.pfsense.org/). * * 4. The names "pfSense" and "pfSense Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * coreteam@pfsense.org. + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * coreteam@pfsense.org. * * 5. Products derived from this software may not be called "pfSense" - * nor may "pfSense" appear in their names without prior written - * permission of the Electric Sheep Fencing, LLC. + * nor may "pfSense" appear in their names without prior written + * permission of the Electric Sheep Fencing, LLC. * * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: + * acknowledgment: * * "This product includes software developed by the pfSense Project * for use in the pfSense software distribution (http://www.pfsense.org/). @@ -177,7 +177,7 @@ if ($_REQUEST['ajax']) { if ($JSONfile != FALSE) { while (($logline = fgets($JSONfile)) !== false) { - if (!feof($JSONfile) && (strpos($logline, 'INFO_PROGRESS_TICK') !== false)) { + if (!feof($JSONfile) && (strpos($logline, 'INFO_PROGRESS_TICK') !== false)) { if (strpos($logline, '}}') !== false) { $progress = $logline; } @@ -220,30 +220,50 @@ function waitfor_string_in_file($filename, $string, $timeout) { return(false); } -if ($_POST) { - if (empty($_POST['id']) && $_POST['mode'] != 'reinstallall') { +$pkgmode = ''; +if (!empty($_REQUEST['mode'])) { + $valid_modes = array( + 'reinstallall', + 'reinstallpkg', + 'delete', + 'installed' + ); + + if (!in_array($_REQUEST['mode'], $valid_modes)) { header("Location: pkg_mgr_installed.php"); return; } - if (isset($_POST['pkgcancel']) || (empty($_POST['id']) && $_POST['mode'] != 'reinstallall')) { + $pkgmode = $_REQUEST['mode']; +} + +$confirmed = isset($_POST['confirmed']) && $_POST['confirmed'] == 'true'; +$completed = isset($_POST['completed']) && $_POST['completed'] == 'true'; + +if (!empty($_REQUEST['id'])) { + if ($_REQUEST['id'] != "firmware") { header("Location: pkg_mgr_installed.php"); return; } -} else if ($_GET && !$_GET['id']) { - if (empty($_GET['pkg']) && ($_GET['mode'] != 'reinstallall')) { + $firmwareupdate = true; +} elseif (!$completed && empty($_REQUEST['pkg']) && $pkgmode != 'reinstallall') { + header("Location: pkg_mgr_installed.php"); + return; +} + +$pkgname = ''; +if (!empty($_REQUEST['pkg'])) { + $pkgname = $_REQUEST['pkg']; + + if (!pkg_valid_name($pkgname)) { header("Location: pkg_mgr_installed.php"); return; } } -if ($_GET && $_GET['id'] == "firmware") { - $firmwareupdate = true; -} - $tab_array = array(); -if ($firmwareupdate || ($_POST['id'] == "firmware")) { +if ($firmwareupdate) { $pgtitle = array(gettext("System"), gettext("Update"), gettext("System Update")); $tab_array[] = array(gettext("System Update"), true, ""); $tab_array[] = array(gettext("Update Settings"), false, "system_update_settings.php"); @@ -255,12 +275,11 @@ if ($firmwareupdate || ($_POST['id'] == "firmware")) { } include("head.inc"); +?> + +<div id="final" class="alert" role="alert" style="display: none;"></div> -if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall") { - ?> - <div id="final" class="alert" role="alert" style="display: none;"></div> <?php -} display_top_tabs($tab_array); if ($input_errors) { @@ -269,17 +288,10 @@ if ($input_errors) { ?> <form action="pkg_mgr_install.php" method="post" class="form-horizontal"> -<?php if (($POST['complete'] != "true") && (empty($_GET['mode']) && $_GET['id']) || (!empty($_GET['mode']) && (!empty($_GET['pkg']) || $_GET['mode'] == 'reinstallall'))): - if (empty($_GET['mode']) && $_GET['id']) { - $pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['id'], ENT_QUOTES | ENT_HTML401)); - $pkgmode = 'installed'; - } else if (!empty($_GET['mode']) && !empty($_GET['pkg'])) { - $pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['pkg'], ENT_QUOTES | ENT_HTML401)); - $pkgmode = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['mode'], ENT_QUOTES | ENT_HTML401)); - } else if ($_GET['mode'] == 'reinstallall') { - $pkgmode = 'reinstallall'; - } +<?php +if (!$confirmed && !$completed && + ($firmwareupdate || $pkgmode == 'reinstallall' || !empty($pkgname))): switch ($pkgmode) { case 'reinstallpkg': $pkgtxt = sprintf(gettext('Confirmation Required to reinstall package %s.'), $pkgname); @@ -297,77 +309,79 @@ if ($input_errors) { <div class="panel-heading"> <h2 class="panel-title"> <?php - if ($pkgmode == 'reinstallall') { + if ($pkgmode == 'reinstallall'): ?> <?=gettext("Confirmation Required to reinstall all packages.");?> <?php - } else if ($_GET['from'] && $_GET['to']) { + elseif ($_GET['from'] && $_GET['to']): ?> <?=sprintf(gettext('Confirmation Required to upgrade package %1$s from %2$s to %3$s.'), $pkgname, $_GET['from'], $_GET['to'])?> <?php - } else if ($firmwareupdate) { + elseif ($firmwareupdate): ?> <?=sprintf(gettext('Confirmation Required to update %s system.'), $g['product_name'])?> <?php - } else { + else: ?> <?=$pkgtxt;?> <?php - } + endif; ?> </h2> </div> <div class="panel-body"> <div class="content"> - <input type="hidden" name="mode" value="<?=$pkgmode;?>" /> + <input type="hidden" name="mode" value="<?=$pkgmode;?>" /> <?php - if ($firmwareupdate) { + if ($firmwareupdate): ?> - <div class="form-group"> - <label class="col-sm-2 control-label"> - <?=gettext("Current Base System")?> - </label> - <div class="col-sm-10" id="installed_version"> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label"> - <?=gettext("Latest Base System")?> - </label> - <div class="col-sm-10" id="version"> - </div> - </div> - - <div class="form-group" id="confirm"> - <label class="col-sm-2 control-label" id="confirmlabel"> - <?=gettext("Retrieving")?> - </label> - <div class="col-sm-10"> - <input type="hidden" name="id" value="firmware" /> - <button type="submit" class="btn btn-success" name="pkgconfirm" id="pkgconfirm" value="<?=gettext("Confirm")?>" style="display: none"> + <div class="form-group"> + <label class="col-sm-2 control-label"> + <?=gettext("Current Base System")?> + </label> + <div class="col-sm-10" id="installed_version"> + </div> + </div> + + <div class="form-group"> + <label class="col-sm-2 control-label"> + <?=gettext("Latest Base System")?> + </label> + <div class="col-sm-10" id="version"> + </div> + </div> + + <div class="form-group" id="confirm"> + <label class="col-sm-2 control-label" id="confirmlabel"> + <?=gettext("Retrieving")?> + </label> + <div class="col-sm-10"> + <input type="hidden" name="id" value="firmware" /> + <input type="hidden" name="confirmed" value="true" /> + <button type="submit" class="btn btn-success" name="pkgconfirm" id="pkgconfirm" value="<?=gettext("Confirm")?>" style="display: none"> + <i class="fa fa-check icon-embed-btn"></i> + <?=gettext("Confirm")?> + </button> + <span id="uptodate"><i class="fa fa-cog fa-spin fa-lg text-warning"></i></span> + </div> + </div> +<?php + else: +?> + <input type="hidden" name="pkg" value="<?=$pkgname;?>" /> + <input type="hidden" name="confirmed" value="true" /> + <button type="submit" class="btn btn-success" name="pkgconfirm" id="pkgconfirm" value="<?=gettext("Confirm")?>"> <i class="fa fa-check icon-embed-btn"></i> <?=gettext("Confirm")?> </button> - <span id="uptodate"><i class="fa fa-cog fa-spin fa-lg text-warning"></i></span> - </div> - </div> <?php - } else { + endif; ?> - <input type="hidden" name="id" value="<?=$pkgname;?>" /> - <button type="submit" class="btn btn-success" name="pkgconfirm" id="pkgconfirm" value="<?=gettext("Confirm")?>"> - <i class="fa fa-check icon-embed-btn"></i> - <?=gettext("Confirm")?> - </button> -<?php - } - ?> </div> </div> </div> -<?php endif; - +<?php +endif; ?> <div id="unable" style="display: none"> <?=print_info_box(gettext("Unable to retrieve system versions."), 'danger')?> @@ -375,42 +389,47 @@ if ($input_errors) { <?php if ($_POST) { - $pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401)); - if ($pkgid == "firmware") { + if ($firmwareupdate) { $logfilename = $g['cf_conf_path'] . '/upgrade_log'; } else { - $logfilename = $g['cf_conf_path'] . '/pkg_log_' . $pkgid; + $logfilename = $g['cf_conf_path'] . '/pkg_log_' . $pkgname; } } -if ($_POST['mode'] == 'delete') { +if ($pkgmode == 'delete') { $panel_heading_txt = gettext("Package Removal"); - $pkg_success_txt = sprintf(gettext('<b>%1$s</b> removal successfully completed.'), $pkgid); - $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> removal failed!'), $pkgid); - $pkg_wait_txt = sprintf(gettext('Please wait while the removal of <b>%1$s</b> completes.'), $pkgid); -} else if (($_POST['mode'] == 'reinstallpkg') || ($_POST['mode'] == 'reinstallall')) { + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> removal successfully completed.'), $pkgname); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> removal failed!'), $pkgname); + $pkg_wait_txt = sprintf(gettext('Please wait while the removal of <b>%1$s</b> completes.'), $pkgname); +} else if ($pkgmode == 'reinstallall') { + $panel_heading_txt = gettext("Packages Reinstallation"); + $pkg_success_txt = gettext('All packages reinstallation successfully completed.'); + $pkg_fail_txt = gettext('All packages reinstallation failed!'); + $pkg_wait_txt = gettext('Please wait while the reinstallation of all packages completes.'); +} else if ($pkgmode == 'reinstallpkg') { $panel_heading_txt = gettext("Package Reinstallation"); - $pkg_success_txt = sprintf(gettext('<b>%1$s</b> reinstallation successfully completed.'), $pkgid); - $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> reinstallation failed!'), $pkgid); - $pkg_wait_txt = sprintf(gettext('Please wait while the reinstallation of <b>%1$s</b> completes.'), $pkgid); + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> reinstallation successfully completed.'), $pkgname); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> reinstallation failed!'), $pkgname); + $pkg_wait_txt = sprintf(gettext('Please wait while the reinstallation of <b>%1$s</b> completes.'), $pkgname); } else { $panel_heading_txt = gettext("Package Installation"); - $pkg_success_txt = sprintf(gettext('<b>%1$s</b> installation successfully completed.'), $pkgid); - $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> installation failed!'), $pkgid); - $pkg_wait_txt = sprintf(gettext('Please wait while the installation of <b>%1$s</b> completes.'), $pkgid); + $pkg_success_txt = sprintf(gettext('<b>%1$s</b> installation successfully completed.'), $pkgname); + $pkg_fail_txt = sprintf(gettext('<b>%1$s</b> installation failed!'), $pkgname); + $pkg_wait_txt = sprintf(gettext('Please wait while the installation of <b>%1$s</b> completes.'), $pkgname); } -if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): - // What if the user navigates away from this page and then comes back via his/her "Back" button? +if ($confirmed): + // XXX: What if the user navigates away from this page and then comes back via his/her "Back" button? $pidfile = $g['varrun_path'] . '/' . $g['product_name'] . '-upgrade.pid'; if (isvalidpid($pidfile)) { $start_polling = true; } ?> - <input type="hidden" name="id" value="<?=htmlspecialchars($_POST['id'])?>" /> - <input type="hidden" name="mode" value="<?=htmlspecialchars($_POST['mode'])?>" /> + <input type="hidden" name="id" value="<?=$_REQUEST['id']?>" /> + <input type="hidden" name="mode" value="<?=$pkgmode?>" /> <input type="hidden" name="completed" value="true" /> + <input type="hidden" name="confirmed" value="true" /> <input type="hidden" id="reboot_needed" name="reboot_needed" value="no" /> <div id="countdown" class="text-center"></div> @@ -421,36 +440,42 @@ if (!empty($_POST['id']) || $_POST['mode'] == "reinstallall"): <br /> <div class="panel panel-default"> <div class="panel-heading"> -<?php if ($firmwareupdate) { +<?php + if ($firmwareupdate): ?> <h2 class="panel-title" id="status"><?=gettext("Updating System")?></h2> -<?php } else { +<?php + else: ?> <h2 class="panel-title" id="status"><?=$panel_heading_txt?></h2> - <?php } ?> +<?php + endif; +?> </div> <div class="panel-body"> <textarea rows="15" class="form-control" id="output" name="output"><?=$_POST['output']?></textarea> </div> </div> -<?php endif?> +<?php +endif; +?> </form> <?php ob_flush(); -if ($_POST && ($_POST['completed'] != "true")) { +if ($confirmed && !$completed) { /* Write out configuration to create a backup prior to pkg install. */ write_config(gettext("Creating restore point before package installation.")); $progbar = true; $upgrade_script = "/usr/local/sbin/{$g['product_name']}-upgrade -y -l {$logfilename}.txt -p {$g['tmp_path']}/{$g['product_name']}-upgrade.sock"; - switch ($_POST['mode']) { + switch ($pkgmode) { case 'delete': - mwexec_bg("{$upgrade_script} -r {$pkgid}"); + mwexec_bg("{$upgrade_script} -r {$pkgname}"); $start_polling = true; break; @@ -463,16 +488,16 @@ if ($_POST && ($_POST['completed'] != "true")) { break; case 'reinstallpkg': - mwexec_bg("{$upgrade_script} -i {$pkgid} -f"); + mwexec_bg("{$upgrade_script} -i {$pkgname} -f"); $start_polling = true; break; case 'installed': default: - if ($pkgid == 'firmware') { + if ($firmwareupdate) { mwexec_bg("{$upgrade_script}"); } else { - mwexec_bg("{$upgrade_script} -i {$pkgid}"); + mwexec_bg("{$upgrade_script} -i {$pkgname}"); } $start_polling = true; break; @@ -483,11 +508,11 @@ $uptodatemsg = gettext("Up to date."); $confirmlabel = gettext("Confirm Update"); $sysmessage = gettext("Status"); -// $_POST['completed'] just means that we are refreshing the page to update any new menu items +// $completed just means that we are refreshing the page to update any new menu items // that were installed -if ($_POST && $_POST['completed'] == "true"): +if ($completed): unlink_if_exists($logfilename . ".json"); - if (($pkgid == 'firmware') && ($_POST['reboot_needed'] == "yes")): + if (($firmwareupdate) && ($_POST['reboot_needed'] == "yes")): ?> <script> @@ -520,8 +545,8 @@ function setProgress(barName, percent, transition) { // Display a success banner function show_success() { $('#final').removeClass("alert-info").addClass("alert-success"); - if ("<?=$_POST['mode']?>" != "reinstallall") { - if ("<?=$pkgid?>" == "firmware") { + if ("<?=$pkgmode?>" != "reinstallall") { + if ("<?=$firmwareupdate?>") { $('#final').html("<?=gettext('System update successfully completed.')?>"); } else { $('#final').html("<?=$pkg_success_txt?>"); @@ -537,7 +562,7 @@ function show_success() { function show_failure() { $('#final').removeClass("alert-info"); $('#final').addClass("alert-danger"); - if ("<?=$_POST['mode']?>" != "reinstallall") { + if ("<?=$pkgmode?>" != "reinstallall") { $('#final').html("<?=$pkg_fail_txt?>"); } else { $('#final').html("<?=gettext('Reinstallation of all packages failed.')?>"); @@ -548,7 +573,7 @@ function show_failure() { // Ask the user to wait a bit function show_info() { $('#final').addClass("alert-info"); - if ("<?=$_POST['mode']?>" != "reinstallall") { + if ("<?=$pkgmode?>" != "reinstallall") { $('#final').html("<p><?=$pkg_wait_txt?>" + "</p><p>" + "<?=gettext("This may take several minutes!")?>" + "</p>"); } else { @@ -569,7 +594,7 @@ function get_firmware_versions() data: { ajax: "ajax", getversion: "yes" - } + } }); // Deal with the results of the above ajax call @@ -608,7 +633,7 @@ function getLogsStatus() { data: { ajax: "ajax", logfilename: "<?=$logfilename?>", next_log_line: "0" - } + } }); // Deal with the results of the above ajax call @@ -655,7 +680,10 @@ function getLogsStatus() { $('#reboot_needed').val("yes"); } - $('form').submit(); + setProgress('progressbar', 100, false); + $('#progressbar').addClass("progress-bar-success"); + show_success(); + setTimeout(scrollToBottom, 200); } if ((json.pid == "stopped") && ((progress != 0) || (json.exitstatus != 0))) { @@ -679,7 +707,7 @@ var time = 0; function checkonline() { $.ajax({ - url : "/index.php", // or other resource + url : "/index.php", // or other resource type : "HEAD" }) .done(function() { @@ -712,15 +740,6 @@ events.push(function() { show_info(); } - // If we are just re-drawing the page after a successful install/remove/reinstall, - // we only need to re-populate the progress indicator and the status banner - if ("<?=$_POST['completed']?>" == "true") { - setProgress('progressbar', 100, false); - $('#progressbar').addClass("progress-bar-success"); - show_success(); - setTimeout(scrollToBottom, 200); - } - if ("<?=$firmwareupdate?>") { get_firmware_versions(); } |