baby steps

This commit is contained in:
eric 2004-07-02 12:47:16 +00:00
parent 2358929978
commit ae26c9ce2a
6 changed files with 123 additions and 45 deletions

View file

@ -12,6 +12,7 @@ if (isset($_COOKIE["AURSID"])) {
$dbh = db_connect(); $dbh = db_connect();
db_query($q, $dbh); db_query($q, $dbh);
setcookie("AURSID", "", time() - (60*60*24*30), "/"); setcookie("AURSID", "", time() - (60*60*24*30), "/");
setcookie("AURLANG", "", time() - (60*60*24*30), "/");
} }
html_header(); # print out the HTML header html_header(); # print out the HTML header

View file

@ -8,22 +8,9 @@ html_header(); # print out the HTML header
# define variables used during pkgsearch # define variables used during pkgsearch
# #
$pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP"); $pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP", "do_MyPackages");
function pkgsearch_results_link() {
global $pkgsearch_vars;
print "Go back to <a href='/pkgsearch.php?";
$url_data = "do_Search=1";
while (list($k, $var) = each($pkgsearch_vars)) {
$url_data.="&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
}
print $url_data . "'>search results</a>.<br />\n";
return;
}
# get login privileges # get login privileges
# #
if (isset($_COOKIE["AURSID"])) { if (isset($_COOKIE["AURSID"])) {

View file

@ -116,4 +116,29 @@ $_t["en"]["Vote"] = "Vote";
# $_t["fr"]["Vote"] = "--> Traduction française ici. <--"; # $_t["fr"]["Vote"] = "--> Traduction française ici. <--";
# $_t["de"]["Vote"] = "--> Deutsche Übersetzung hier. <--"; # $_t["de"]["Vote"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Error retrieving package details."] = "Error retrieving package details.";
# $_t["es"]["Error retrieving package details."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Error retrieving package details."] = "--> Traduction française ici. <--";
# $_t["de"]["Error retrieving package details."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Package details could not be found."] = "Package details could not be found.";
# $_t["es"]["Package details could not be found."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Package details could not be found."] = "--> Traduction française ici. <--";
# $_t["de"]["Package details could not be found."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Error retrieving package list."] = "Error retrieving package list.";
# $_t["es"]["Error retrieving package list."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Error retrieving package list."] = "--> Traduction française ici. <--";
# $_t["de"]["Error retrieving package list."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Go back to %hsearch results%h."] = "Go back to %hsearch results%h.";
# $_t["es"]["Go back to %hsearch results%h."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Go back to %hsearch results%h."] = "--> Traduction française ici. <--";
# $_t["de"]["Go back to %hsearch results%h."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Manage"] = "Manage";
# $_t["es"]["Manage"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Manage"] = "--> Traduction française ici. <--";
# $_t["de"]["Manage"] = "--> Deutsche Übersetzung hier. <--";
?> ?>

View file

@ -36,4 +36,19 @@ $_t["en"]["You do not have access to adopt packages."] = "You do not have access
# $_t["fr"]["You do not have access to adopt packages."] = "--> Traduction française ici. <--"; # $_t["fr"]["You do not have access to adopt packages."] = "--> Traduction française ici. <--";
# $_t["de"]["You do not have access to adopt packages."] = "--> Deutsche Übersetzung hier. <--"; # $_t["de"]["You do not have access to adopt packages."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You must be logged in before you can disown packages."] = "You must be logged in before you can disown packages.";
# $_t["es"]["You must be logged in before you can disown packages."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You must be logged in before you can disown packages."] = "--> Traduction française ici. <--";
# $_t["de"]["You must be logged in before you can disown packages."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Error trying to retrieve package details."] = "Error trying to retrieve package details.";
# $_t["es"]["Error trying to retrieve package details."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Error trying to retrieve package details."] = "--> Traduction française ici. <--";
# $_t["de"]["Error trying to retrieve package details."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You must be logged in before you can adopt packages."] = "You must be logged in before you can adopt packages.";
# $_t["es"]["You must be logged in before you can adopt packages."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You must be logged in before you can adopt packages."] = "--> Traduction française ici. <--";
# $_t["de"]["You must be logged in before you can adopt packages."] = "--> Deutsche Übersetzung hier. <--";
?> ?>

View file

@ -365,7 +365,8 @@ function html_header() {
# XXX Can I scale a PNG like this? # XXX Can I scale a PNG like this?
# #
print "<img src='/images/AUR-logo-80.png' width='85' height='45' border='0' /></a></td>\n"; print "<img src='/images/AUR-logo-80.png' width='85' height='45' ";
print "alt='AUR' border='0' /></a></td>\n";
print " <td class='headerDisplay' valign='top' align='right'>"; print " <td class='headerDisplay' valign='top' align='right'>";
print "<span class='preHeader'>ArchLinux User-community Repository</span><br />"; print "<span class='preHeader'>ArchLinux User-community Repository</span><br />";

View file

@ -1,6 +1,49 @@
<? <?
include_once("pkgfuncs_po.inc"); include_once("pkgfuncs_po.inc");
# print out the 'return to search results' link
#
function pkgsearch_results_link() {
global $pkgsearch_vars;
$url_data = "<a href='/pkgsearch.php?do_Search=1";
while (list($k, $var) = each($pkgsearch_vars)) {
if ($var == "do_MyPackages") {
$url_data.="&".$var."=1";
} else {
$url_data.="&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
}
}
$url_data .= "'>";
print __("Go back to %hsearch results%h.",
array($url_data, "</a>"));
return;
}
# see if this Users.ID can manage the package
#
function canManagePackage($uid=0,$AURMUID=0, $MUID=0, $SUID=0, $managed=0) {
if (!$uid) {return 0;}
# The uid of the TU/Dev that manages the package
#
if ($uid == $AURMUID) {return 1;}
# If the package isn't maintained by a TU/Dev, is this the user-maintainer?
#
if ($uid == $MUID && !$managed) {return 1;}
# If the package isn't maintained by a TU/Dev, is this the user-submitter?
#
if ($uid == $SUID && !$managed) {return 1;}
# otherwise, no right to manage this package
#
return 0;
}
# grab the current list of PackageCategories # grab the current list of PackageCategories
# #
function pkgCategories() { function pkgCategories() {
@ -197,21 +240,22 @@ function pkg_search_page($SID="") {
# determine paging variables # determine paging variables
# #
isset($_REQUEST["PP"]) ? $PP = intval($_REQUEST["PP"]) : $PP = 25; $_REQUEST["PP"] ? $PP = intval($_REQUEST["PP"]) : $PP = 25;
if ($PP < 25) {$PP = 25;} if ($PP < 25) {$PP = 25;}
if ($PP > 100) {$PP = 100;} if ($PP > 100) {$PP = 100;}
isset($_REQUEST["O"]) ? $O = intval($_REQUEST["O"]) : $O = 0; $_REQUEST["O"] ? $O = intval($_REQUEST["O"]) : $O = 0;
if (isset($_REQUEST["do_More"])) { if ($_REQUEST["do_More"]) {
$O += $PP; $O += $PP;
} elseif (isset($_REQUEST["do_Less"])) { } elseif ($_REQUEST["do_Less"]) {
$O -= $PP; $O -= $PP;
} }
if ($O < 0) { if ($O < 0) {
$O = 0; $O = 0;
} }
if (isset($_REQUEST["do_Search"]) || isset($_REQUEST["do_MyPackages"])) { if ($_REQUEST["do_Search"]) {
# reset the offset to zero if they hit Go/My Packages # reset the offset to zero if they hit Go/My Packages
# #
$_REQUEST["do_MyPackages"] = 0;
$O = 0; $O = 0;
} }
@ -341,11 +385,11 @@ function pkg_search_page($SID="") {
# $q.= "ON Packages.ID = PackageVotes.PackageID "; # $q.= "ON Packages.ID = PackageVotes.PackageID ";
$q = "SELECT * FROM Packages "; $q = "SELECT * FROM Packages ";
$has_where = 0; $has_where = 0;
if (isset($_REQUEST["L"]) && intval($_REQUEST["L"])) { if (intval($_REQUEST["L"])) {
$q.= "WHERE LocationID = ".intval($_REQUEST["L"])." "; $q.= "WHERE LocationID = ".intval($_REQUEST["L"])." ";
$has_where = 1; $has_where = 1;
} }
if (isset($_REQUEST["C"]) && intval($_REQUEST["C"])) { if (intval($_REQUEST["C"])) {
if (!$has_where) { if (!$has_where) {
$q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." "; $q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." ";
$has_where = 1; $has_where = 1;
@ -363,18 +407,18 @@ function pkg_search_page($SID="") {
$q.= "Description LIKE '%".mysql_escape_string($K)."%') "; $q.= "Description LIKE '%".mysql_escape_string($K)."%') ";
} }
} }
if (isset($_REQUEST["do_MyPackages"]) && $SID) { if ($_REQUEST["do_MyPackages"] && $SID) {
# list packages that the user is a AUR Maintainer of, or if it the # list packages that the user is a AUR Maintainer of, or if it the
# vistior is a registered user, if they are the Maintainer. # vistior is a registered user, if they are the Maintainer.
# #
if ($myuid) { if ($myuid) {
if (!$has_where) { if (!$has_where) {
$q.= "WHERE (AURMaintainerUID = ".$myuid." OR "; $q.= "WHERE (AURMaintainerUID = ".$myuid." OR ";
$q.= "MaintainerUID = " . $myuid.") "; $q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") ";
$has_where = 1; $has_where = 1;
} else { } else {
$q.= "AND (AURMaintainerUID = ".$myuid." OR "; $q.= "AND (AURMaintainerUID = ".$myuid." OR ";
$q.= "MaintainerUID = " . $myuid.") "; $q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") ";
} }
} }
} }
@ -394,10 +438,10 @@ function pkg_search_page($SID="") {
break; break;
} }
$q.= "LIMIT ".$O.", ".$PP; $q.= "LIMIT ".$O.", ".$PP;
#print $q."<br />\n"; print $q."<br />\n";
#print "<pre>\n"; print "<pre>\n";
#print_r($_REQUEST); print_r($_REQUEST);
#print "</pre>\n"; print "</pre>\n";
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
if (!$result) { if (!$result) {
@ -502,41 +546,43 @@ function pkg_search_page($SID="") {
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 $cats[$row["CategoryID"]]."</span></span></td>\n";
print " <td class='".$c."'><span class='f4'>"; print " <td class='".$c."'><span class='f4'>";
$details_url = "<a href='/pkgsearch.php?"; $url = "<a href='/pkgsearch.php?";
$url_data = "do_Details=1&ID="; $url .= "do_Details=1&ID=";
$url_data.= $row["ID"]; $url .= $row["ID"];
while (list($k, $var) = each($pkgsearch_vars)) { while (list($k, $var) = each($pkgsearch_vars)) {
# I'm never convinced how to do this encoding/decoding properly. # I'm never convinced how to do this encoding/decoding properly.
# php.net recommends htmlentities(urlencode(data)), but that # php.net recommends htmlentities(urlencode(data)), but that
# doesn't work! # doesn't work!
# #
$url_data .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var])); $url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
} }
$details_url.= $url_data; reset($pkgsearch_vars);
$details_url.= "'><span class='black'>".$row["Name"]; $url.= "'><span class='black'>".$row["Name"];
$details_url.= "-".$row["Version"]."</span></a>"; $url.= "-".$row["Version"]."</span></a>";
print $details_url."</span></td>\n"; print $url."</span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>"; print " <td class='".$c."'><span class='f5'><span class='blue'>";
print "&nbsp;&nbsp;&nbsp;".$row["NumVotes"]."</span></span></td>\n"; print "&nbsp;&nbsp;&nbsp;".$row["NumVotes"]."</span></span></td>\n";
print " <td class='".$c."'><span class='f4'><span class='blue'>"; print " <td class='".$c."'><span class='f4'><span class='blue'>";
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'>";
$not_managed = 0;
# print the package manager, also determine if it is managed
#
$managed = 1;
if (isset($devs[$row["AURMaintainerUID"]])) { if (isset($devs[$row["AURMaintainerUID"]])) {
print $devs[$row["AURMaintainerUID"]]["Username"]; print $devs[$row["AURMaintainerUID"]]["Username"];
} elseif (isset($tus[$row["AURMaintainerUID"]])) { } elseif (isset($tus[$row["AURMaintainerUID"]])) {
print $tus[$row["AURMaintainerUID"]]["Username"]; print $tus[$row["AURMaintainerUID"]]["Username"];
} else { } else {
print "None"; print "None";
$not_managed = 1; $managed = 0;
} }
print "</span></span></td>\n"; print "</span></span></td>\n";
if ($myuid == $row["AURMaintainerUID"] || $not_managed ||
($myuid == $row["MaintainerUID"] && $not_managed)) { # print the managed link if applicable
# 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 if (canManagePackage($myuid, $row["AURMaintainerUID"],
# regular user (most likely the submitter) can manage it. $row["MaintainerUID"], $row["SubmitterUID"], $managed)) {
#
$manage_url = "<a href='/pkgmgmnt.php?ID="; $manage_url = "<a href='/pkgmgmnt.php?ID=";
$manage_url.= $row["ID"]."'><span class='black'>Manage</span></a>"; $manage_url.= $row["ID"]."'><span class='black'>Manage</span></a>";
print " <td class='".$c."'><span class='f4'>"; print " <td class='".$c."'><span class='f4'>";
@ -553,6 +599,9 @@ function pkg_search_page($SID="") {
print "</tr>\n"; print "</tr>\n";
print "</table>\n"; print "</table>\n";
print "<input type='hidden' name='All_IDs' value='".$all_ids."'>\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";
}
print "<table width='90%' cellspacing='0' cellpadding='2'>\n"; print "<table width='90%' cellspacing='0' cellpadding='2'>\n";
print "<tr>\n"; print "<tr>\n";