mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Revamped pkg_search_page()
- Reduced database hits - Improved speed - Improved sanity (slightly) - Fixed searches,buttons,gizmos Signed-off-by: Simo Leone <simo@archlinux.org>
This commit is contained in:
parent
da3b397ac9
commit
99e65b28d8
3 changed files with 499 additions and 551 deletions
|
@ -18,8 +18,6 @@ if (isset($_GET['ID'])) {
|
||||||
}
|
}
|
||||||
} else if (!empty($_GET['K'])) {
|
} else if (!empty($_GET['K'])) {
|
||||||
$title = "Search: " . $_GET['K'];
|
$title = "Search: " . $_GET['K'];
|
||||||
} else if (!empty($_GET['do_MyPackages'])) {
|
|
||||||
$title = __("My Packages");
|
|
||||||
} else {
|
} else {
|
||||||
$title = __("Packages");
|
$title = __("Packages");
|
||||||
}
|
}
|
||||||
|
@ -520,7 +518,7 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# do_More/do_Less/do_Search/do_MyPackages - just do a search
|
# just do a search
|
||||||
#
|
#
|
||||||
pkg_search_page($_COOKIE["AURSID"]);
|
pkg_search_page($_COOKIE["AURSID"]);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ include_once("config.inc");
|
||||||
|
|
||||||
# define variables used during pkgsearch
|
# define variables used during pkgsearch
|
||||||
#
|
#
|
||||||
$pkgsearch_vars = array("O", "L", "C", "K", "SB", "SO", "PP", "do_MyPackages", "do_Orphans", "SeB");
|
$pkgsearch_vars = array("O", "L", "C", "K", "SB", "SO", "PP", "do_Orphans", "SeB");
|
||||||
|
|
||||||
# Make sure this visitor can delete the requested package comment
|
# Make sure this visitor can delete the requested package comment
|
||||||
# They can delete if they were the comment submitter, or if they are a TU/Dev
|
# They can delete if they were the comment submitter, or if they are a TU/Dev
|
||||||
|
@ -374,7 +374,7 @@ function package_details($id=0, $SID="") {
|
||||||
while (list($k, $darr) = each($deps)) {
|
while (list($k, $darr) = each($deps)) {
|
||||||
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
||||||
while(list($k, $var) = each($pkgsearch_vars)) {
|
while(list($k, $var) = each($pkgsearch_vars)) {
|
||||||
if (($var == "do_MyPackages" || $var == "do_Orphans") && $_REQUEST[$var]) {
|
if (($var == "do_Orphans") && $_REQUEST[$var]) {
|
||||||
$url .= "&".$var."=1";
|
$url .= "&".$var."=1";
|
||||||
} else {
|
} else {
|
||||||
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
||||||
|
@ -404,7 +404,7 @@ function package_details($id=0, $SID="") {
|
||||||
while (list($k, $darr) = each($deps)) {
|
while (list($k, $darr) = each($deps)) {
|
||||||
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
|
||||||
while(list($k, $var) = each($pkgsearch_vars)) {
|
while(list($k, $var) = each($pkgsearch_vars)) {
|
||||||
if (($var == "do_MyPackages" || $var == "do_Orphans") && $_REQUEST[$var]) {
|
if (($var == "do_Orphans") && $_REQUEST[$var]) {
|
||||||
$url .= "&".$var."=1";
|
$url .= "&".$var."=1";
|
||||||
} else {
|
} else {
|
||||||
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
|
||||||
|
@ -591,70 +591,91 @@ function package_details($id=0, $SID="") {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# display the search form in a boxSoft style
|
/* pkg_search_page(SID)
|
||||||
#
|
* outputs the body of search/search results page
|
||||||
|
*
|
||||||
|
* parameters:
|
||||||
|
* SID - current Session ID
|
||||||
|
* preconditions:
|
||||||
|
* package search page has been accessed
|
||||||
|
* request variables have not been sanitized
|
||||||
|
*
|
||||||
|
* request vars:
|
||||||
|
* O - starting result number
|
||||||
|
* PP - number of search hits per page
|
||||||
|
* L - package location ID number
|
||||||
|
* C - package category ID number
|
||||||
|
* K - package search string
|
||||||
|
* SO - search hit sort order:
|
||||||
|
* values: a - ascending
|
||||||
|
* d - descending
|
||||||
|
* SB - sort search hits by:
|
||||||
|
* values: l - package location
|
||||||
|
* c - package category
|
||||||
|
* n - package name
|
||||||
|
* v - number of votes
|
||||||
|
* m - maintainer username
|
||||||
|
* SeB- property that search string (K) represents
|
||||||
|
* values: nd - package name&description
|
||||||
|
* m - package maintainer's username
|
||||||
|
* s - package submitter's username
|
||||||
|
* do_Orphans - boolean. whether to search packages
|
||||||
|
* without a maintainer
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* These two are actually handled in packages.php.
|
||||||
|
*
|
||||||
|
* IDs- integer array of ticked packages' IDs
|
||||||
|
* action - action to be taken on ticked packages
|
||||||
|
* values: do_Flag - Flag out-of-date
|
||||||
|
* do_UnFlag - Remove out-of-date flag
|
||||||
|
* do_Adopt - Adopt
|
||||||
|
* do_Disown - Disown
|
||||||
|
* do_Delete - Delete
|
||||||
|
* do_Notify - Toggle notification
|
||||||
|
*/
|
||||||
function pkg_search_page($SID="") {
|
function pkg_search_page($SID="") {
|
||||||
global $_REQUEST;
|
// establish a db connection
|
||||||
global $pkgsearch_vars;
|
|
||||||
# SID: session id cookie
|
|
||||||
|
|
||||||
$locs = pkgLocations();
|
|
||||||
$cats = pkgCategories();
|
|
||||||
$devs = getDevelopers();
|
|
||||||
$tus = getTrustedUsers();
|
|
||||||
$users = getUsers();
|
|
||||||
$dbh = db_connect();
|
$dbh = db_connect();
|
||||||
|
|
||||||
|
// get commonly used variables...
|
||||||
|
// TODO: REDUCE DB HITS.
|
||||||
|
// grab info for user if they're logged in
|
||||||
|
if ($SID)
|
||||||
|
$myuid = uid_from_sid($SID);
|
||||||
|
// get a list of package locations
|
||||||
|
$locs = pkgLocations();
|
||||||
|
// get a list of package categories
|
||||||
|
$cats = pkgCategories(); //meow
|
||||||
|
|
||||||
# determine paging variables
|
// sanitize paging variables
|
||||||
#
|
//
|
||||||
if (intval($_GET['O'])) {
|
if (isset($_REQUEST['O'])) {
|
||||||
$O = $_GET['O'];
|
$O = intval($_REQUEST['O']);
|
||||||
|
if ($O < 0)
|
||||||
|
$O = 0;
|
||||||
} else {
|
} else {
|
||||||
$O = 0;
|
$O = 0;
|
||||||
}
|
}
|
||||||
$_REQUEST["PP"] ? $PP = intval($_REQUEST["PP"]) : $PP = 25;
|
|
||||||
if ($PP < 25) {$PP = 25;}
|
|
||||||
if ($PP > 100) {$PP = 100;}
|
|
||||||
|
|
||||||
if ($_REQUEST["do_Search"] && $_REQUEST["do_Search"] != 1) {
|
if (isset($_REQUEST["PP"])) {
|
||||||
# reset the offset to zero if they hit Go
|
$PP = intval($_REQUEST["PP"]);
|
||||||
#
|
if ($PP < 25)
|
||||||
$_REQUEST["do_MyPackages"] = 0;
|
$PP = 25;
|
||||||
$_REQUEST["do_Orphans"] = 0;
|
else if ($PP > 100)
|
||||||
$O = 0;
|
$PP = 100;
|
||||||
}
|
} else {
|
||||||
if ($_REQUEST["do_MyPackages"] && $_REQUEST["do_MyPackages"] != 1) {
|
$PP = 25;
|
||||||
# reset the offset to zero if they hit My Packages
|
|
||||||
#
|
|
||||||
$_REQUEST["do_Search"] = 0;
|
|
||||||
$_REQUEST["do_Orphans"] = 0;
|
|
||||||
$O = 0;
|
|
||||||
}
|
|
||||||
if (!empty($_REQUEST['do_Orphans']) && $_REQUEST['do_Orphans'] != 1) {
|
|
||||||
# reset the offset to zero if they hit Orphans
|
|
||||||
#
|
|
||||||
$_REQUEST["do_Search"] = 0;
|
|
||||||
$_REQUEST["do_MyPackages"] = 0;
|
|
||||||
$O = 0;
|
|
||||||
}
|
|
||||||
$_REQUEST["O"] = $O; # so that pkg_search_results() works
|
|
||||||
|
|
||||||
|
|
||||||
# grab info for user if they're logged in
|
|
||||||
#
|
|
||||||
if ($SID) {
|
|
||||||
$myuid = uid_from_sid($SID);
|
|
||||||
$acct = account_from_sid($SID);
|
|
||||||
$my_votes = pkgvotes_from_sid($SID);
|
|
||||||
$my_notify = pkgnotify_from_sid($SID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# The search form
|
// The search form - XXX: split into own function?
|
||||||
#
|
//
|
||||||
print "<form action='/packages.php' method='post'>\n";
|
// FIXME: highly fugly. whoever makes this use
|
||||||
#print "<form action='/packages.php' method='get'>\n";
|
// less print statements gets a cookie
|
||||||
print "<input type='hidden' name='O' value='".$O."'>\n";
|
// FIXME: ugly html. whoever un-tables this gets
|
||||||
|
// another cookie
|
||||||
|
print "<form action='/packages.php' method='get'>\n";
|
||||||
|
print "<input type='hidden' name='O' value='0'>\n";
|
||||||
|
|
||||||
print "<center>\n";
|
print "<center>\n";
|
||||||
print "<table cellspacing='3' class='boxSoft'>\n";
|
print "<table cellspacing='3' class='boxSoft'>\n";
|
||||||
|
@ -703,9 +724,7 @@ function pkg_search_page($SID="") {
|
||||||
print "</span></span><br />\n";
|
print "</span></span><br />\n";
|
||||||
print " <input type='text' name='K' size='20'";
|
print " <input type='text' name='K' size='20'";
|
||||||
|
|
||||||
# Added to trim() to avoid the problem described in #6191
|
$K = trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES));
|
||||||
$K = trim(str_replace("\"", "", $_REQUEST["K"])); # TODO better testing for SQL trickery...
|
|
||||||
|
|
||||||
print " value=\"".stripslashes($K)."\" maxlength='35'>\n";
|
print " value=\"".stripslashes($K)."\" maxlength='35'>\n";
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
|
@ -744,7 +763,7 @@ function pkg_search_page($SID="") {
|
||||||
print " </select>\n";
|
print " </select>\n";
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
# Added to break put the buttons in a new line
|
// Added to break put the buttons in a new line
|
||||||
print"</tr></table><center><table><tr>";
|
print"</tr></table><center><table><tr>";
|
||||||
|
|
||||||
print "<td align='right' valign='bottom'> \n";
|
print "<td align='right' valign='bottom'> \n";
|
||||||
|
@ -764,89 +783,67 @@ function pkg_search_page($SID="") {
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print "</center>\n";
|
print "</center>\n";
|
||||||
|
print "</form>\n";
|
||||||
print "<br />\n";
|
print "<br />\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 Users RIGHT JOIN Packages ";
|
|
||||||
$q.= "ON (Users.ID = Packages.MaintainerUID) ";
|
|
||||||
$q.= "WHERE DummyPkg != 1 ";
|
|
||||||
$has_where = 1;
|
|
||||||
|
|
||||||
if (intval($_REQUEST["L"])) {
|
// FIXME: pull out DB-related code. all of it.
|
||||||
if (!$has_where) {
|
// this one's worth a choco-chip cookie,
|
||||||
$q.= "WHERE LocationID = ".intval($_REQUEST["L"])." ";
|
// one of those nice big soft ones
|
||||||
} else {
|
|
||||||
$q .= "AND LocationID = ".intval($_REQUEST["L"])." ";
|
// build the package search query
|
||||||
|
//
|
||||||
|
$q = "SELECT SQL_CALC_FOUND_ROWS ";
|
||||||
|
if ($SID) {
|
||||||
|
$q .= "CommentNotify.UserID AS Notify,
|
||||||
|
PackageVotes.UsersID AS Voted, ";
|
||||||
}
|
}
|
||||||
$has_where = 1;
|
$q .= "Users.Username AS Maintainer,
|
||||||
|
PackageCategories.Category,
|
||||||
|
PackageLocations.Location,
|
||||||
|
Packages.Name, Packages.Version, Packages.Description, Packages.NumVotes,
|
||||||
|
Packages.ID, Packages.OutOfDate
|
||||||
|
|
||||||
|
FROM PackageCategories, PackageLocations, Packages
|
||||||
|
LEFT JOIN Users ON (Packages.MaintainerUID = Users.ID) ";
|
||||||
|
if ($SID) {
|
||||||
|
$q .= "LEFT JOIN PackageVotes
|
||||||
|
ON (Packages.ID = PackageVotes.PackageID AND PackageVotes.UsersID = ".$myuid.")
|
||||||
|
LEFT JOIN CommentNotify
|
||||||
|
ON (Packages.ID = CommentNotify.PkgID AND CommentNotify.UserID = ".$myuid.") ";
|
||||||
|
}
|
||||||
|
$q .= "WHERE
|
||||||
|
Packages.CategoryID = PackageCategories.ID
|
||||||
|
AND Packages.LocationID = PackageLocations.ID
|
||||||
|
AND Packages.DummyPkg = 0 ";
|
||||||
|
|
||||||
|
// TODO: possibly do string matching on category and
|
||||||
|
// location to make request variable values more sensible
|
||||||
|
if (intval($_REQUEST["L"])) {
|
||||||
|
$q .= "AND Packages.LocationID = ".intval($_REQUEST["L"])." ";
|
||||||
}
|
}
|
||||||
if (intval($_REQUEST["C"])) {
|
if (intval($_REQUEST["C"])) {
|
||||||
if (!$has_where) {
|
$q.= "AND Packages.CategoryID = ".intval($_REQUEST["C"])." ";
|
||||||
$q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." ";
|
|
||||||
$has_where = 1;
|
|
||||||
} else {
|
|
||||||
$q.= "AND CategoryID = ".intval($_REQUEST["C"])." ";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($K) {
|
if ($_REQUEST['K']) {
|
||||||
#search by maintainer
|
$K = mysql_real_escape_string(trim($_REQUEST['K']));
|
||||||
|
//search by maintainer
|
||||||
if ($_REQUEST["SeB"] == "m"){
|
if ($_REQUEST["SeB"] == "m"){
|
||||||
if (!$has_where) {
|
$q.= "AND Users.Username = '".$K."' ";
|
||||||
$q.= "WHERE Username = '".mysql_real_escape_string($K)."' ";
|
|
||||||
$has_where = 1;
|
|
||||||
} else {
|
|
||||||
$q.= "AND Username = '".mysql_real_escape_string($K)."' ";
|
|
||||||
}
|
|
||||||
} elseif ($_REQUEST["SeB"] == "s") {
|
} elseif ($_REQUEST["SeB"] == "s") {
|
||||||
if (!$has_where) {
|
// FIXME: this shouldn't be making 2 queries
|
||||||
$q.= "WHERE SubmitterUID = ".uid_from_username($K)." ";
|
// kill the call to uid_from_username
|
||||||
$has_where = 1;
|
$q.= "AND SubmitterUID = ".uid_from_username($_REQUEST['K'])." ";
|
||||||
|
// the default behavior, query the name/description
|
||||||
} else {
|
} else {
|
||||||
$q.= "AND SubmitterUID = ".uid_from_username($K)." ";
|
$q.= "AND (Name LIKE '%".$K."%' OR ";
|
||||||
}
|
$q.= "Description LIKE '%".$K."%') ";
|
||||||
# the default behaivior, query the name/description
|
|
||||||
} else {
|
|
||||||
if (!$has_where) {
|
|
||||||
$q.= "WHERE (Name LIKE '%".mysql_real_escape_string($K)."%' OR ";
|
|
||||||
$q.= "Description LIKE '%".mysql_real_escape_string($K)."%') ";
|
|
||||||
$has_where = 1;
|
|
||||||
} else {
|
|
||||||
$q.= "AND (Name LIKE '%".mysql_real_escape_string($K)."%' OR ";
|
|
||||||
$q.= "Description LIKE '%".mysql_real_escape_string($K)."%') ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_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 ";
|
|
||||||
$has_where = 1;
|
|
||||||
} else {
|
|
||||||
$q.= "AND (AURMaintainerUID = ".$myuid." OR ";
|
|
||||||
}
|
|
||||||
//$q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") ";
|
|
||||||
$q.= "MaintainerUID = ".$myuid.") ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($_REQUEST["do_Orphans"]) {
|
if ($_REQUEST["do_Orphans"]) {
|
||||||
# List packages that have neither a Maintainer nor AURMaintainer
|
$q.= "AND MaintainerUID = 0 ";
|
||||||
#
|
|
||||||
if (!$has_where) {
|
|
||||||
$q.= "WHERE (AURMaintainerUID = 0 AND ";
|
|
||||||
$q.= "MaintainerUID = 0) ";
|
|
||||||
$has_where = 1;
|
|
||||||
} else {
|
|
||||||
$q.= "AND (AURMaintainerUID = 0 AND ";
|
|
||||||
$q.= "MaintainerUID = 0) ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
|
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
|
||||||
|
@ -865,7 +862,7 @@ function pkg_search_page($SID="") {
|
||||||
$SB = 'v';
|
$SB = 'v';
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
$q.= "ORDER BY Username ".$order.", Name ASC, LocationID ASC ";
|
$q.= "ORDER BY Maintainer ".$order.", Name ASC, LocationID ASC ";
|
||||||
$SB = 'm';
|
$SB = 'm';
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -877,13 +874,12 @@ function pkg_search_page($SID="") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allresults = mysql_num_rows(db_query($q, $dbh));
|
|
||||||
|
|
||||||
$qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth
|
|
||||||
$q.= "LIMIT ".$O.", ".$PP;
|
$q.= "LIMIT ".$O.", ".$PP;
|
||||||
|
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
|
$total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0);
|
||||||
|
|
||||||
|
print "<form action='/packages.php' method='post'>\n";
|
||||||
print "<center>\n";
|
print "<center>\n";
|
||||||
print "<table cellspacing='3' class='boxSoft'>\n";
|
print "<table cellspacing='3' class='boxSoft'>\n";
|
||||||
print "<tr>\n";
|
print "<tr>\n";
|
||||||
|
@ -899,15 +895,15 @@ function pkg_search_page($SID="") {
|
||||||
print "<div class='pgboxbody'>";
|
print "<div class='pgboxbody'>";
|
||||||
print __("Error retrieving package list.");
|
print __("Error retrieving package list.");
|
||||||
print "</div>";
|
print "</div>";
|
||||||
} elseif (!mysql_num_rows($result)) {
|
} elseif ($total == 0) {
|
||||||
print "<div class='pgboxbody'>";
|
print "<div class='pgboxbody'>";
|
||||||
print __("No packages matched your search criteria.");
|
print __("No packages matched your search criteria.");
|
||||||
print "</div>";
|
print "</div>";
|
||||||
} else {
|
} else {
|
||||||
# print out package search results
|
// print out package search results
|
||||||
#
|
//
|
||||||
|
|
||||||
# SO_next used to change sort order on header click
|
// SO_next used to change sort order on header click
|
||||||
if ($_REQUEST["SO"] == "d"){
|
if ($_REQUEST["SO"] == "d"){
|
||||||
$SO_next="a";
|
$SO_next="a";
|
||||||
$SO = 'd';
|
$SO = 'd';
|
||||||
|
@ -922,19 +918,19 @@ function pkg_search_page($SID="") {
|
||||||
}
|
}
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
print " bottom'><span class='f2'>";
|
print " bottom'><span class='f2'>";
|
||||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>";
|
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>";
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
print " bottom'><span class='f2'>";
|
print " bottom'><span class='f2'>";
|
||||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>";
|
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>";
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
print " bottom'><span class='f2'>";
|
print " bottom'><span class='f2'>";
|
||||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>";
|
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>";
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
print " bottom'><span class='f2'>";
|
print " bottom'><span class='f2'>";
|
||||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>";
|
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>";
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
if ($SID) {
|
if ($SID) {
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
|
@ -949,13 +945,8 @@ function pkg_search_page($SID="") {
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
||||||
print " bottom'><span class='f2'>";
|
print " bottom'><span class='f2'>";
|
||||||
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>";
|
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>";
|
||||||
print "</span></th>\n";
|
print "</span></th>\n";
|
||||||
# REMOVED LINK TO 'pkgmgmnt.php'
|
|
||||||
# if ($SID) {
|
|
||||||
# print " <th style='border-bottom: #666 1px solid; vertical-align:";
|
|
||||||
# print " bottom'><span class='f2'>".__("Manage")."</span></th>\n";
|
|
||||||
# }
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
|
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
|
||||||
|
@ -967,20 +958,15 @@ function pkg_search_page($SID="") {
|
||||||
}
|
}
|
||||||
print " <td class='".$c."'>";
|
print " <td class='".$c."'>";
|
||||||
print "<input type='checkbox' name='IDs[".$row["ID"]."]' value='1'>";
|
print "<input type='checkbox' name='IDs[".$row["ID"]."]' value='1'>";
|
||||||
# if ($i == 0) {
|
|
||||||
# $all_ids = $row["ID"];
|
|
||||||
# } else {
|
|
||||||
# $all_ids .= ":".$row["ID"];
|
|
||||||
# }
|
|
||||||
if ($row["OutOfDate"]) {
|
if ($row["OutOfDate"]) {
|
||||||
print "</span>";
|
print "</span>";
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||||
print $locs[$row["LocationID"]]."</span></span></td>\n";
|
print $row["Location"]."</span></span></td>\n";
|
||||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||||
print $cats[$row["CategoryID"]]."</span></span></td>\n";
|
print $row["Category"]."</span></span></td>\n";
|
||||||
print " <td class='".$c."'><span class='f4'>";
|
print " <td class='".$c."'><span class='f4'>";
|
||||||
$url = "<a href='/packages.php?";
|
$url = "<a href='/packages.php?";
|
||||||
$url .= "ID=";
|
$url .= "ID=";
|
||||||
|
@ -994,15 +980,13 @@ function pkg_search_page($SID="") {
|
||||||
print " ".$row["NumVotes"]."</span></span></td>\n";
|
print " ".$row["NumVotes"]."</span></span></td>\n";
|
||||||
if ($SID) {
|
if ($SID) {
|
||||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||||
if (isset($my_votes[$row["ID"]])) {
|
if (isset($row["Voted"])) {
|
||||||
print " ".__("Yes")."</span></td>\n";
|
print " ".__("Yes")."</span></td>\n";
|
||||||
} else {
|
} else {
|
||||||
print " </span></td>\n";
|
print " </span></td>\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($SID) {
|
|
||||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||||
if (isset($my_notify[$row["ID"]])) {
|
if (isset($row["Notify"])) {
|
||||||
print " ".__("Yes")."</span></td>\n";
|
print " ".__("Yes")."</span></td>\n";
|
||||||
} else {
|
} else {
|
||||||
print " </span></td>\n";
|
print " </span></td>\n";
|
||||||
|
@ -1012,40 +996,14 @@ function pkg_search_page($SID="") {
|
||||||
print $row["Description"]."</span></span></td>\n";
|
print $row["Description"]."</span></span></td>\n";
|
||||||
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
print " <td class='".$c."'><span class='f5'><span class='blue'>";
|
||||||
|
|
||||||
# print the package manager, also determine if it is managed
|
if (isset($row["Maintainer"])) {
|
||||||
#
|
print "<a href='packages.php?K=".$row['Maintainer']."&SeB=m'>".$row['Maintainer']."</a>";
|
||||||
$managed = 1;
|
|
||||||
# if (isset($devs[$row["AURMaintainerUID"]])) {
|
|
||||||
# print $devs[$row["AURMaintainerUID"]]["Username"];
|
|
||||||
# } else
|
|
||||||
# if (isset($tus[$row["MaintainerUID"]])) {
|
|
||||||
# print $tus[$row["MaintainerUID"]]["Username"];
|
|
||||||
if (isset($users[$row["MaintainerUID"]])) {
|
|
||||||
# Add a link to the user packages, e.g, if you click on the Solve the sorting problem, so we can force the
|
|
||||||
# maintainer name, you will be redirected to a page with the user packages.
|
|
||||||
$user = $users[$row["MaintainerUID"]]["Username"];
|
|
||||||
print "<a href='packages.php?K=".$user."&SeB=m'>".$users[$row["MaintainerUID"]]["Username"]."</a>";
|
|
||||||
} else {
|
} else {
|
||||||
print "<span style='color: blue; font-style: italic;'>";
|
print "<span style='color: blue; font-style: italic;'>";
|
||||||
print __("orphan");
|
print __("orphan");
|
||||||
print "</span>";
|
print "</span>";
|
||||||
$managed = 0;
|
|
||||||
}
|
}
|
||||||
print "</span></span></td>\n";
|
print "</span></span></td>\n";
|
||||||
|
|
||||||
# REMOVED LINK TO 'pkgmgmnt.php'
|
|
||||||
# # print the managed link if applicable
|
|
||||||
# #
|
|
||||||
# if (canManagePackage($myuid, $row["AURMaintainerUID"],
|
|
||||||
# $row["MaintainerUID"], $row["SubmitterUID"], $managed)) {
|
|
||||||
# $manage_url = "<a href='/pkgmgmnt.php?ID=";
|
|
||||||
# $manage_url.= $row["ID"]."'><span class='black'>Manage</span></a>";
|
|
||||||
# print " <td class='".$c."'><span class='f4'>";
|
|
||||||
# print $manage_url."</span></td>\n";
|
|
||||||
# } else {
|
|
||||||
# print "<td class='".$c."'><span class='f4'> </span></td>\n";
|
|
||||||
# }
|
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1053,17 +1011,10 @@ function pkg_search_page($SID="") {
|
||||||
print " </td>\n";
|
print " </td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
# print "<input type='hidden' name='All_IDs' value='".$all_ids."'>\n";
|
|
||||||
if ($_REQUEST["do_MyPackages"]) {
|
|
||||||
print "<input type='hidden' name='do_MyPackages' value='1'>\n";
|
|
||||||
}
|
|
||||||
if ($_REQUEST["do_Orphans"]) {
|
|
||||||
print "<input type='hidden' name='do_Orphans' value='1'>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($SID) {
|
if ($SID) {
|
||||||
# The 'Actions' box
|
// The 'Actions' box
|
||||||
#
|
//
|
||||||
print "<div style='text-align: right; padding: 5px 5% 5px 0'>";
|
print "<div style='text-align: right; padding: 5px 5% 5px 0'>";
|
||||||
print "<select name='action'>";
|
print "<select name='action'>";
|
||||||
print "<option>" . __("Actions") . "</option>";
|
print "<option>" . __("Actions") . "</option>";
|
||||||
|
@ -1084,23 +1035,23 @@ function pkg_search_page($SID="") {
|
||||||
print " <table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
|
print " <table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
|
||||||
print " <tr>\n";
|
print " <tr>\n";
|
||||||
|
|
||||||
# figure out the results to use
|
// figure out the results to use
|
||||||
$first = $O + 1;
|
$first = $O + 1;
|
||||||
|
|
||||||
if (($PP+$O) > $allresults) {
|
if (($PP+$O) > $total) {
|
||||||
$last = $allresults;
|
$last = $total;
|
||||||
} else {
|
} else {
|
||||||
$last = $PP + $O;
|
$last = $PP + $O;
|
||||||
}
|
}
|
||||||
|
|
||||||
# print number of results
|
// print number of results
|
||||||
# ok this styling sucks
|
// ok this styling sucks
|
||||||
# patches welcome!
|
// patches welcome!
|
||||||
print "<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>";
|
print "<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>";
|
||||||
print __("Showing results %s - %s of %s", array($first, $last, $allresults));
|
print __("Showing results %s - %s of %s", array($first, $last, $total));
|
||||||
print "</span></span></td></tr>";
|
print "</span></span></td></tr>";
|
||||||
|
|
||||||
# first print the legend
|
// first print the legend
|
||||||
print " <td colspan='2' align='center'>";
|
print " <td colspan='2' align='center'>";
|
||||||
print " <span class='f5'>\n";
|
print " <span class='f5'>\n";
|
||||||
if ($SID) {
|
if ($SID) {
|
||||||
|
@ -1110,24 +1061,23 @@ function pkg_search_page($SID="") {
|
||||||
print " </tr>";
|
print " </tr>";
|
||||||
|
|
||||||
|
|
||||||
# now print the forward and back buttons on the bottom
|
// now print the forward and back buttons on the bottom
|
||||||
# LEFT
|
// LEFT
|
||||||
print " <tr>";
|
print " <tr>";
|
||||||
print " <td align='left'>";
|
print " <td align='left'>";
|
||||||
if (($O-$PP) >= 0) {
|
if (($O-$PP) >= 0) {
|
||||||
print "<a href='/packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
print "<a href='/packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||||
} else if ($O<$PP && $O>0) {
|
} else if ($O<$PP && $O>0) {
|
||||||
print "<a href='/packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_MyPackages=".$_REQUEST["do_MyPackages"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
print "<a href='/packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
|
||||||
}
|
}
|
||||||
print " </td>";
|
print " </td>";
|
||||||
# RIGHT
|
// RIGHT
|
||||||
print " <td align='right'>";
|
print " <td align='right'>";
|
||||||
if (mysql_num_rows(db_query($qnext, $dbh))) {
|
if ($total - $PP - $O > 0) {
|
||||||
print "<a href='/packages.php?O=" . ($O + $PP) .
|
print "<a href='/packages.php?O=" . ($O + $PP) .
|
||||||
"&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"]) .
|
"&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"]) .
|
||||||
"&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"] .
|
"&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"] .
|
||||||
"&do_MyPackages=".$_REQUEST["do_MyPackages"] .
|
"&do_Orphans=".$_REQUEST["do_Orphans"]."'>" .
|
||||||
"&do_Orphans=".isset($_REQUEST["do_Orphans"])."'>" .
|
|
||||||
__("More") . "</a>";
|
__("More") . "</a>";
|
||||||
}
|
}
|
||||||
print " </td>\n";
|
print " </td>\n";
|
||||||
|
@ -1143,5 +1093,5 @@ function pkg_search_page($SID="") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim: ts=2 sw=2 noet ft=php
|
# vim: ts=4 sw=4 et ft=php
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -48,7 +48,7 @@ if (isset($_COOKIE["AURSID"])) {
|
||||||
?>
|
?>
|
||||||
<li><a href="/logout.php"><?php print __("Logout"); ?></a></li>
|
<li><a href="/logout.php"><?php print __("Logout"); ?></a></li>
|
||||||
<li><a href="/pkgsubmit.php"><?php print __("Submit"); ?></a></li>
|
<li><a href="/pkgsubmit.php"><?php print __("Submit"); ?></a></li>
|
||||||
<li><a href="/packages.php?do_MyPackages=1"><?php print __("My Packages"); ?></a></li>
|
<li><a href="/packages.php?SeB=m&K=<?php print username_from_sid($_COOKIE["AURSID"]); ?>"><?php print __("My Packages"); ?></a></li>
|
||||||
<?php
|
<?php
|
||||||
if (account_from_sid($_COOKIE["AURSID"]) == "Trusted User"
|
if (account_from_sid($_COOKIE["AURSID"]) == "Trusted User"
|
||||||
|| account_from_sid($_COOKIE["AURSID"]) == "Developer") {
|
|| account_from_sid($_COOKIE["AURSID"]) == "Developer") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue