\n"; } else { $row = mysql_fetch_assoc($results); if (empty($row)) { print __("Package details could not be found.")."
\n"; } else { # print out package details # print "
\n"; print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
"; print "Package Details
\n"; print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
NAME
\n"; print "
\n"; print "
\n"; } } return; } # display the search form in a boxSoft style # function pkg_search_page($SID="") { global $_REQUEST; global $pkgsearch_vars; # SID: session id cookie $locs = pkgLocations(); $cats = pkgCategories(); $devs = getDevelopers(); $tus = getTrustedUsers(); $dbh = db_connect(); # determine paging variables # isset($_REQUEST["PP"]) ? $PP = intval($_REQUEST["PP"]) : $PP = 25; if ($PP < 25) {$PP = 25;} if ($PP > 100) {$PP = 100;} isset($_REQUEST["O"]) ? $O = intval($_REQUEST["O"]) : $O = 0; if (isset($_REQUEST["do_More"])) { $O += $PP; } elseif (isset($_REQUEST["do_Less"])) { $O -= $PP; } if ($O < 0) { $O = 0; } if (isset($_REQUEST["do_Search"]) || isset($_REQUEST["do_MyPackages"])) { # reset the offset to zero if they hit Go/My Packages # $O = 0; } # grab info for user if they're logged in # if ($SID) { $myuid = uid_from_sid($SID); $acct = account_from_sid($SID); } # The search form # print "
\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
\n"; print " ".__("Search Criteria")."\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($SID) { print "\n"; } print "\n"; print "
\n"; print " ".__("Location"); print "
\n"; print " \n"; print "
\n"; print " ".__("Category"); print "
\n"; print " \n"; print "
\n"; print " ".__("Keywords"); print "
\n"; print " \n"; print "
\n"; print " ".__("Sort by"); print "
\n"; print " \n"; print "
\n"; print " ".__("Per page"); print "
\n"; print " \n"; print "
 \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; # query to pull out package info # # $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes "; # $q.= "FROM Packages LEFT JOIN PackageVotes "; # $q.= "ON Packages.ID = PackageVotes.PackageID "; $q = "SELECT * FROM Packages "; $has_where = 0; if (isset($_REQUEST["L"]) && intval($_REQUEST["L"])) { $q.= "WHERE LocationID = ".intval($_REQUEST["L"])." "; $has_where = 1; } if (isset($_REQUEST["C"]) && intval($_REQUEST["C"])) { if (!$has_where) { $q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." "; $has_where = 1; } else { $q.= "AND CategoryID = ".intval($_REQUEST["C"])." "; } } if ($K) { if (!$has_where) { $q.= "WHERE (Name LIKE '".mysql_escape_string($K)."%' OR "; $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; $has_where = 1; } else { $q.= "AND (Name LIKE '".mysql_escape_string($K)."%' OR "; $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; } } if (isset($_REQUEST["do_MyPackages"]) && $SID) { # list packages that the user is a AUR Maintainer of, or if it the # vistior is a registered user, if they are the Maintainer. # if ($myuid) { if (!$has_where) { $q.= "WHERE (AURMaintainerUID = ".$myuid." OR "; $q.= "MaintainerUID = " . $myuid.") "; $has_where = 1; } else { $q.= "AND (AURMaintainerUID = ".$myuid." OR "; $q.= "MaintainerUID = " . $myuid.") "; } } } switch ($_REQUEST["SB"]) { case 'c': $q.= "ORDER BY CategoryID DESC, Name ASC, LocationID ASC "; break; case 'l': $q.= "ORDER BY LocationID ASC, Name ASC, CategoryID DESC "; break; case 'v': $q.= "ORDER BY NumVotes DESC, Name ASC, CategoryID DESC "; break; default: $q.= "ORDER BY Name ASC, LocationID ASC, CategoryID DESC "; break; } $q.= "LIMIT ".$O.", ".$PP; print $q."
\n"; print "
\n";
	print_r($_REQUEST);
	print "
\n"; $result = db_query($q, $dbh); if (!$result) { print __("Error retrieving package list."); } elseif (!mysql_num_rows($result)) { print __("No packages matched your search criteria."); } else { if ($SID) { # The 'Actions' table # print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
\n"; print " ".__("Actions")."\n"; print "
\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "\n"; print "
"; print ""; print ""; print ""; print "
\n"; print "
\n"; print "
\n"; print "
\n"; } # print out package search results # print "
\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
\n"; print " Package Listing\n"; print "
\n"; print "\n"; print "\n"; if ($SID) { print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($SID) { print " \n"; } print "\n"; for ($i=0; $row = mysql_fetch_assoc($result); $i++) { (($i % 2) == 0) ? $c = "data1" : $c = "data2"; print "\n"; if ($SID) { print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($myuid == $row["AURMaintainerUID"] || $not_managed || ($myuid == $row["MaintainerUID"] && $not_managed)) { # Only allow TUs/Devs to manage packages, or if it is a regular # user and the package has not been adopted by a TU/Dev, then the # regular user (most likely the submitter) can manage it. # $manage_url = "Manage"; print " \n"; } else { print "\n"; } print "\n"; } print "
 ".__("Location")."".__("Category")."".__("Name")."".__("Votes")."".__("Description")."".__("Maintainer")."".__("Manage")."
"; if ($row["OutOfDate"]) { print ""; } print ""; if ($i == 0) { $all_ids = $row["ID"]; } else { $all_ids .= ":".$row["ID"]; } if ($row["OutOfDate"]) { print ""; } print ""; print $locs[$row["LocationID"]].""; print $cats[$row["CategoryID"]].""; $details_url = "".$row["Name"]; $details_url.= "-".$row["Version"].""; print $details_url.""; print "   ".$row["NumVotes"].""; print $row["Description"].""; $not_managed = 0; if (isset($devs[$row["AURMaintainerUID"]])) { print $devs[$row["AURMaintainerUID"]]["Username"]; } elseif (isset($tus[$row["AURMaintainerUID"]])) { print $tus[$row["AURMaintainerUID"]]["Username"]; } else { print "None"; $not_managed = 1; } print ""; print $manage_url." 
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print " \n"; print " "; print " \n"; print "
\n"; print "
\n"; print "
\n"; } print "
\n"; return; } # vim: ts=2 sw=2 noet ft=php ?>