From 5b0f1f39dba251e5ae29df432587da7ce0098c87 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 6 May 2012 12:38:59 +0200 Subject: web/html/packages.php: Remove duplicate code Retrieve the package ID early and merge the if-branches calling package_details(). Signed-off-by: Lukas Fleischer --- web/html/packages.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index 8f3b143..aa1d04c 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -89,28 +89,24 @@ html_header($title); \n"; - } else { - if (isset($_COOKIE["AURSID"])) { - package_details($_GET['ID'], $_COOKIE["AURSID"]); - } - else { - package_details($_GET['ID'], null); - } - } + $pkgid = intval($_GET['ID']); } else if (isset($_GET['N'])) { + $pkgid = pkgid_from_name($_GET['N']); +} else { + unset($pkgid); +} + +if (isset($pkgid)) { include('pkg_search_form.php'); - if (!$pkgid = pkgid_from_name($_GET['N'])) { - print __("Error trying to retrieve package details.")."
\n"; - } else { + if ($pkgid) { if (isset($_COOKIE["AURSID"])) { package_details($pkgid, $_COOKIE["AURSID"]); } else { package_details($pkgid, null); } + } else { + print __("Error trying to retrieve package details.")."
\n"; } } else { if (!isset($_GET['K']) && !isset($_GET['SB'])) { -- cgit v1.2.3-54-g00ecf