diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-15 17:47:00 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-15 17:47:00 +0545 |
commit | f8ac4407a8817d9513ffb7fd491f929b6232f487 (patch) | |
tree | d5c0a88dbb08aa5b5e5b52648f8f5b55ab244acd /usr/local/www/pkg_mgr_install.php | |
parent | 83c380c3eb0ee38f591a455aabee40d0a543bb95 (diff) | |
download | pfsense-f8ac4407a8817d9513ffb7fd491f929b6232f487.zip pfsense-f8ac4407a8817d9513ffb7fd491f929b6232f487.tar.gz |
Code style WWW pkg
The syntax of these all seems good. Because the 2.3-DEVELOPMENT master
does not currently have get_pkg_info implemented, the available packages
tab always says "Unable to retrieve package info...".
But I don't think I broke any code.
This is integrated with the little changes for startdisplayingat var in
pkg.php
Diffstat (limited to 'usr/local/www/pkg_mgr_install.php')
-rw-r--r-- | usr/local/www/pkg_mgr_install.php | 144 |
1 files changed, 78 insertions, 66 deletions
diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php index 9c5b8b2..ceb4f75 100644 --- a/usr/local/www/pkg_mgr_install.php +++ b/usr/local/www/pkg_mgr_install.php @@ -5,7 +5,7 @@ part of pfSense (https://www.pfsense.org) Copyright (C) 2013-2015 Electric Sheep Fencing, LP Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com> - Copyright (C) 2005 Colin Smith + Copyright (C) 2005 Colin Smith All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,24 +65,24 @@ if ($_POST) { } } else if ($_GET) { switch ($_GET['mode']) { - case 'reinstallall': - case 'showlog': - break; - case 'installedinfo': - case 'reinstallxml': - case 'reinstallpkg': - case 'delete': - if (empty($_GET['pkg'])) { - header("Location: pkg_mgr_installed.php"); - return; - } - break; - default: - if (empty($_GET['id'])) { - header("Location: pkg_mgr_installed.php"); - return; - } - break; + case 'reinstallall': + case 'showlog': + break; + case 'installedinfo': + case 'reinstallxml': + case 'reinstallpkg': + case 'delete': + if (empty($_GET['pkg'])) { + header("Location: pkg_mgr_installed.php"); + return; + } + break; + default: + if (empty($_GET['id'])) { + header("Location: pkg_mgr_installed.php"); + return; + } + break; } } @@ -104,7 +104,8 @@ if ($_POST) { ?> </td> </tr> -<?php if ((empty($_GET['mode']) && $_GET['id']) || (!empty($_GET['mode']) && (!empty($_GET['pkg']) || $_GET['mode'] == 'reinstallall') && ($_GET['mode'] != 'installedinfo' && $_GET['mode'] != 'showlog'))): +<?php +if ((empty($_GET['mode']) && $_GET['id']) || (!empty($_GET['mode']) && (!empty($_GET['pkg']) || $_GET['mode'] == 'reinstallall') && ($_GET['mode'] != 'installedinfo' && $_GET['mode'] != 'showlog'))): if (empty($_GET['mode']) && $_GET['id']) { $pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['id'], ENT_QUOTES | ENT_HTML401)); $pkgmode = 'installed'; @@ -115,20 +116,20 @@ if ($_POST) { $pkgmode = 'reinstallall'; } switch ($pkgmode) { - case 'reinstallall': - $pkgname = 'All packages'; - $pkgtxt = 'reinstalled'; - break; - case 'reinstallxml': - case 'reinstallpkg': - $pkgtxt = 'reinstalled'; - break; - case 'delete': - $pkgtxt = 'deleted'; - break; - default: - $pkgtxt = $pkgmode; - break; + case 'reinstallall': + $pkgname = 'All packages'; + $pkgtxt = 'reinstalled'; + break; + case 'reinstallxml': + case 'reinstallpkg': + $pkgtxt = 'reinstalled'; + break; + case 'delete': + $pkgtxt = 'deleted'; + break; + default: + $pkgtxt = $pkgmode; + break; } ?> <tr> @@ -136,7 +137,7 @@ if ($_POST) { <table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images"> <tr> <td class="tabcont" align="center">Package: <b><?=$pkgname;?></b> will be <?=$pkgtxt;?>.<br/> - Please confirm the action.<br/> + Please confirm the action.<br/> </td> <td class="tabcont" align="center"> <input type="hidden" name="id" value="<?=$pkgname;?>" /> @@ -148,7 +149,10 @@ if ($_POST) { </table> </td> </tr> -<?php endif; if (!empty($_POST['id']) || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))): ?> +<?php +endif; +if (!empty($_POST['id']) || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))): +?> <tr> <td class="tabcont" align="center"> <table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images"> @@ -156,9 +160,11 @@ if ($_POST) { <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="progress bar"> - <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="progress bar" /> - </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="progress bar" /> + </td> + </tr> </table> </td> <td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5"> @@ -191,25 +197,27 @@ ob_flush(); if ($_GET) { $pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['pkg'], ENT_QUOTES | ENT_HTML401)); - switch($_GET['mode']) { - case 'showlog': - if (strpos($pkgname, ".")) { - update_output_window(gettext("Something is wrong on the request.")); - } else if (file_exists("/tmp/pkg_mgr_{$pkgname}.log")) - update_output_window(@file_get_contents("/tmp/pkg_mgr_{$pkgname}.log")); - else - update_output_window(gettext("Log was not retrievable.")); - break; - case 'installedinfo': - if (file_exists("/tmp/{$pkgname}.info")) { - $status = @file_get_contents("/tmp/{$pkgname}.info"); - update_status("{$pkgname} " . gettext("installation completed.")); - update_output_window($status); - } else - update_output_window(sprintf(gettext("Could not find %s."), $pkgname)); - break; - default: - break; + switch ($_GET['mode']) { + case 'showlog': + if (strpos($pkgname, ".")) { + update_output_window(gettext("Something is wrong on the request.")); + } else if (file_exists("/tmp/pkg_mgr_{$pkgname}.log")) { + update_output_window(@file_get_contents("/tmp/pkg_mgr_{$pkgname}.log")); + } else { + update_output_window(gettext("Log was not retrievable.")); + } + break; + case 'installedinfo': + if (file_exists("/tmp/{$pkgname}.info")) { + $status = @file_get_contents("/tmp/{$pkgname}.info"); + update_status("{$pkgname} " . gettext("installation completed.")); + update_output_window($status); + } else { + update_output_window(sprintf(gettext("Could not find %s."), $pkgname)); + } + break; + default: + break; } } else if ($_POST) { $pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401)); @@ -250,11 +258,12 @@ if ($_GET) { case 'reinstallall': if (is_array($config['installedpackages']) && is_array($config['installedpackages']['package'])) { $todo = array(); - foreach($config['installedpackages']['package'] as $package) + foreach ($config['installedpackages']['package'] as $package) { $todo[] = array('name' => $package['name'], 'version' => $package['version']); - foreach($todo as $pkgtodo) { + } + foreach ($todo as $pkgtodo) { $static_output = ""; - if($pkgtodo['name']) { + if ($pkgtodo['name']) { update_output_window($static_output); uninstall_package($pkgtodo['name']); install_package($pkgtodo['name'], '', true); @@ -265,13 +274,14 @@ if ($_GET) { update_output_window($static_output); filter_configure(); send_event("service restart packages"); - } else + } else { update_output_window(gettext("No packages are installed.")); + } break; case 'installed': default: $status = install_package($pkgid); - if($status == -1) { + if ($status == -1) { update_status(gettext("Installation of") . " {$pkgid} " . gettext("FAILED!")); $static_output .= "\n" . gettext("Installation halted."); update_output_window($static_output); @@ -279,10 +289,11 @@ if ($_GET) { $status_a = gettext(sprintf("Installation of %s completed.", $pkgid)); update_status($status_a); $status = get_after_install_info($pkgid); - if($status) + if ($status) { $static_output .= "\n" . gettext("Installation completed.") . "\n{$pkgid} " . gettext("setup instructions") . ":\n{$status}"; - else + } else { $static_output .= "\n" . gettext("Installation completed. Please check to make sure that the package is configured from the respective menu then start the package."); + } @file_put_contents("/tmp/{$pkgid}.info", $static_output); echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$pkgid}\";</script>"; @@ -296,8 +307,9 @@ if ($_GET) { rmdir_recursive("/var/tmp/instmp*"); // close log - if($fd_log) + if ($fd_log) { fclose($fd_log); + } /* Restore to read only fs */ conf_mount_ro(); |