From 9a9f8b8a87439dcbc6d0a31ba33f9600991ecf29 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 12 Apr 2018 14:21:35 +0200 Subject: packages/index.php: search-page ready (?) --- packages/index.php | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 363 insertions(+) create mode 100644 packages/index.php diff --git a/packages/index.php b/packages/index.php new file mode 100644 index 0000000..1ae251c --- /dev/null +++ b/packages/index.php @@ -0,0 +1,363 @@ + + + + + + + + Arch Linux 32 - Package Search + + + + + +
+ + +
+
+ + + + + +
+ + array( + "title" => "architecture", + "label" => "Arch", + "mysql" => "`architectures`.`name`" + ), + "repo" => array( + "title" => "repository", + "label" => "Repo", + "mysql" => "`repositories`.`name`" + ), + "pkgname" => array( + "title" => "package name", + "label" => "Name", + "mysql" => "`binary_packages`.`pkgname`" + ), + "pkgver" => array( + "title" => "package version", + "label" => "Version", + "mysql" => "CONCAT(`binary_packages`.`epoch`,\":\",`binary_packages`.`pkgver`,\"-\",`binary_packages`.`pkgrel`,\".\",`binary_packages`.`sub_pkgrel`)" + ), + "bugs" => array( + "title" => "bug status", + "label" => "Bugs", + "mysql" => "NOT `binary_packages`.`has_issues`" + ) + ); + + +$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 . + " ORDER BY "; + +if (isset($_GET["sort"])) { + if (isset($sorts[$_GET["sort"]]["mysql"])) + $query .= $sorts[$_GET["sort"]]["mysql"] . ","; + elseif (isset($sorts[substr($_GET["sort"],1)]["mysql"])) + $query .= $sorts[substr($_GET["sort"],1)]["mysql"] . " DESC,"; +} + +$query .= "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`"; + +if (! $result = $mysql -> query( + "SELECT COUNT(1)" . $query + )) + die ($mysql -> error); + + $num_results = implode($result -> fetch_assoc()); + + $pages = max(ceil($num_results / 100), 1); + if (isset($_GET["page"])) + $page = max(min($_GET["page"]+0, $pages),1); + else + $page = 1; + +if (! $result = $mysql -> 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 . + " LIMIT " . (($page-1)*100) . ", 100" + )) + die ($mysql -> error); + + + function header_and_footer() { + + global $page, $pages, $num_results; + + print "
\n"; + + print "

" . $num_results . " matching package"; + if ($num_results != 1) + print "s"; + print " found.\n"; + + if ($pages != 1) { + print "Page " . $page . " of " . $pages . ".

\n"; + + print "
\n"; + print "\n"; + + if ($page > 1) { + print ""; + }; + print "< Prev"; + if ($page > 1) + print ""; + print "\n"; + print "\n"; + + if ($page < $pages) { + print ""; + }; + print "Next >"; + if ($page < $pages) + print ""; + print "\n"; + print "
\n"; + }; + print "
\n"; + + }; + + header_and_footer(); + +?> + + + + + $sort) { + print "\n"; + } +?> + + + + fetch_assoc()) { + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + if ($oddity == "odd" ) + $oddity = "even"; + else + $oddity = "odd"; + } + +?> + +
".$sort["label"]."
" . $row["arch"] . "" . $row["repo"] . "" . $row["pkgname"] ."" . $row["version"] . ""; + if ($row["has_issues"]) + print "bugs"; + else + print " "; + print "
+ + + +
+

Can't find what you are looking for? Try searching again + using different criteria, or try + searching the AUR + to see if the package can be found there.

+ +

You are browsing the Arch Linux 32 package database. From here you can find + detailed information about packages located in the 32 bit repositories.

+
+ + +
+ + + + -- cgit v1.2.3