From c07c5261370e8a6c7660603b28da088bafe238d1 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 12 Apr 2018 14:58:36 +0200 Subject: packages/index.php: show exact matches, too --- packages/index.php | 157 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 44 deletions(-) (limited to 'packages/index.php') diff --git a/packages/index.php b/packages/index.php index ba783f9..ba9c25c 100644 --- a/packages/index.php +++ b/packages/index.php @@ -112,7 +112,118 @@ if (isset($_GET["q"])) + query( + "SELECT " . + "`binary_packages`.`pkgname`," . + "`repositories`.`name` AS `repo`," . + "`architectures`.`name` AS `arch`," . + "CONCAT(IF(`binary_packages`.`epoch`=\"0\",\"\",CONCAT(`binary_packages`.`epoch`,\":\"))," . + "`binary_packages`.`pkgver`,\"-\"," . + "`binary_packages`.`pkgrel`,\".\"," . + "`binary_packages`.`sub_pkgrel`) AS `version`," . + "IF(`binary_packages`.`has_issues`,1,0) AS `has_issues`" . + $query + )) + die ($mysql -> error); + + function print_results() { + global $result; + + $oddity="odd"; + while ($row = $result -> fetch_assoc()) { + print "\n"; + print "" . $row["arch"] . "\n"; + print "" . $row["repo"] . "\n"; + print "" . $row["pkgname"] ."\n"; + print "" . $row["version"] . "\n"; + print ""; + if ($row["has_issues"]) + print "has open bug reports"; + else + print " "; + print "\n"; + print "\n"; + if ($oddity == "odd" ) + $oddity = "even"; + else + $oddity = "odd"; + } + } +if ($result -> num_rows > 0) { +?> +
+
+

num_rows; ?> exact match num_rows != 1) print "es"; ?> found.

+
+ + + + + + + + + + + + + +
ArchRepoNameVersionBugs
+
+
@@ -146,34 +257,11 @@ if (isset($_GET["q"])) ) ); - -$filter = " WHERE 1"; -if (isset($_GET["arch"])) { - $filter .= " AND `architectures`.`name` IN ("; - foreach ($archs as $arch) - if (strpos("&".$_SERVER["QUERY_STRING"]."&", "&arch=".$arch."&") !== false) - $filter .= "\"" . $arch . "\","; - $filter .= "\"\")"; -} -if (isset($_GET["repo"])) { - $filter .= " AND `repositories`.`name` IN ("; - foreach ($repos as $repo) - if (strpos("&".$_SERVER["QUERY_STRING"]."&", "&repo=".$repo."&") !== false) - $filter .= "\"" . $repo . "\","; - $filter .= "\"\")"; -} -if (isset($_GET["q"])) - $filter .= " AND `binary_packages`.`pkgname` LIKE from_base64(\"".base64_encode("%".$_GET["q"]."%")."\")"; -if ($_GET["bugs"] == "Bugs") - $filter .= " AND `binary_packages`.`has_issues`"; -if ($_GET["bugs"] == "No Bugs") - $filter .= " AND NOT `binary_packages`.`has_issues`"; - $query = " FROM `binary_packages`" . " JOIN `architectures` ON `architectures`.`id`=`binary_packages`.`architecture`" . " JOIN `repositories` ON `repositories`.`id`=`binary_packages`.`repository`" . " AND `repositories`.`is_on_master_mirror`" . - $filter . + $filter . $fuzzy_filter . " ORDER BY "; if (isset($_GET["sort"])) { @@ -292,26 +380,7 @@ if (! $result = $mysql -> query( fetch_assoc()) { - print "\n"; - print "" . $row["arch"] . "\n"; - print "" . $row["repo"] . "\n"; - print "" . $row["pkgname"] ."\n"; - print "" . $row["version"] . "\n"; - print ""; - if ($row["has_issues"]) - print "has open bug reports"; - else - print " "; - print "\n"; - print "\n"; - if ($oddity == "odd" ) - $oddity = "even"; - else - $oddity = "odd"; - } + print_results(); ?> -- cgit v1.2.3-70-g09d2