diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index 9c5d920a..876cf285 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -110,6 +110,7 @@ CREATE TABLE Packages (
URL CHAR(255) NOT NULL DEFAULT "http://www.archlinux.org",
Source CHAR(255) NOT NULL DEFAULT "/dev/null",
LocationID TINYINT UNSIGNED NOT NULL,
+ NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0,
OutOfDate TINYINT UNSIGNED DEFAULT 0,
SubmittedTS BIGINT UNSIGNED NOT NULL,
SubmitterUID INTEGER UNSIGNED NOT NULL DEFAULT 0,
@@ -119,6 +120,7 @@ CREATE TABLE Packages (
INDEX (CategoryID),
INDEX (LocationID),
INDEX (OutOfDate),
+ INDEX (NumVotes),
INDEX (SubmitterUID),
INDEX (MaintainerUID),
FOREIGN KEY (CategoryID) REFERENCES PackageCategories(ID) ON DELETE NO ACTION,
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index 06513efe..7365296e 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -15,12 +15,12 @@ DB_USER = "aur"
DB_PASS = "aur"
USER_ID = 5 # Users.ID of first user
PKG_ID = 1 # Packages.ID of first package
-MAX_USERS = 200 # how many users to 'register'
+MAX_USERS = 1000 # how many users to 'register'
MAX_DEVS = .1 # what percentage of MAX_USERS are Developers
MAX_TUS = .2 # what percentage of MAX_USERS are Trusted Users
MAX_PKGS = 2500 # how many packages to load
PKG_FILES = (8, 30) # min/max number of files in a package
-VOTING = (.3, .8) # percentage range for package voting
+VOTING = (.1, .4) # percentage range for package voting
RANDOM_PATHS = [ # random path locations for package files
"/usr/bin", "/usr/lib", "/etc", "/etc/rc.d", "/usr/share", "/lib",
"/var/spool", "/var/log", "/usr/sbin", "/opt", "/usr/X11R6/bin",
@@ -299,22 +299,32 @@ if DBUG: print "."
# Cast votes
#
+track_votes = {}
if DBUG: print "Casting votes for packages.",
count = 0
for u in user_keys:
- num_votes = random.randrange(len(seen_pkgs)*VOTING[0],
- len(seen_pkgs)*VOTING[1])
+ num_votes = random.randrange(int(len(seen_pkgs)*VOTING[0]),
+ int(len(seen_pkgs)*VOTING[1]))
pkgvote = {}
for v in range(num_votes):
pkg = random.randrange(0, len(seen_pkgs))
if not pkgvote.has_key(pkg):
s = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES (%d, %d);\n" % (seen_users[u], pkg)
pkgvote[pkg] = 1
+ if not track_votes.has_key(pkg):
+ track_votes[pkg] = 0
+ track_votes[pkg] += 1
out.write(s)
if count % 100 == 0:
if DBUG: print ".",
count += 1
+# Update statements for package votes
+#
+for p in track_votes.keys():
+ s = "UPDATE Packages SET NumVotes = %d WHERE ID = %d;\n" % (track_votes[p], p)
+ out.write(s)
+
# close output file
#
out.write("\n")
diff --git a/web/html/index.php b/web/html/index.php
index 67ff657d..64a1c2f7 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -25,11 +25,14 @@ if (isset($_REQUEST["user"]) || isset($_REQUEST["pass"])) {
$q.= "AND Passwd = '" . mysql_escape_string($_REQUEST["pass"]) . "'";
$result = db_query($q, $dbh);
if (!$result) {
- $login_error = __("Incorrect password for username, %s.",
+ $login_error = __("Error looking up username, %s.",
array($_REQUEST["user"]));
} else {
$row = mysql_fetch_row($result);
- if ($row[1]) {
+ if (empty($row)) {
+ $login_error = __("Incorrect password for username, %s.",
+ array($_REQUEST["user"]));
+ } elseif ($row[1]) {
$login_error = __("Your account has been suspended.");
}
}
diff --git a/web/html/pkgmgmnt.php b/web/html/pkgmgmnt.php
index 5544016f..98c84006 100644
--- a/web/html/pkgmgmnt.php
+++ b/web/html/pkgmgmnt.php
@@ -6,10 +6,12 @@ check_sid(); # see if they're still logged in
html_header(); # print out the HTML header
-# Any text you print out to the visitor, use the __() function
-# for i18n support. See 'testpo.php' for more details.
+# vistor has requested package management for a specific package
+#
+print __("Manage package ID: %s", array($_REQUEST["ID"])) . "
\n";
+
+# NOTE: managing an orphaned package will automatically force adoption
#
-print __("Under construction...")."
\n";
html_footer("\$Id$");
diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php
index 9d4521ce..64d229bc 100644
--- a/web/html/pkgsearch.php
+++ b/web/html/pkgsearch.php
@@ -6,14 +6,6 @@ set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in
html_header(); # print out the HTML header
-# TODO Maybe pkgsearch, pkgvote can be consolidated? This script can
-# provide a search form. In the results, it can contain a checkbox
-# for 'flag out of date', 'vote', 'details' link, and a link to 'pkgmgmnt'.
-#
-# the results page should have columns for,
-# pkg name/ver, location, maintainer, description, O-O-D, Vote, details, mgmnt
-#
-
# get login privileges
#
@@ -25,30 +17,110 @@ if (isset($_COOKIE["AURSID"])) {
$atype = "";
}
+# grab the list of Package IDs to be operated on
+#
+isset($_REQUEST["IDs"]) ? $ids = $_REQUEST["IDs"] : $ids = array();
-if ($atype && $_REQUEST["Action"] == "Something") {
- # do something based on what the user specifies
+
+# determine what button the visitor clicked
+#
+if (isset($_REQUEST["do_Flag"])) {
+ if (!$atype) {
+ print __("You must be logged in before you can flag packages.");
+ print "
\n";
+
+ } else {
+ # Flag the packages in $ids array, and unflag any other
+ # packages listed in $_REQUEST["All_IDs"]
+ #
+ print "flagging
\n";
+
+ # After flagging, show the search page again (or maybe print out
+ # a message and give the user a link to resume where they were
+ # in the search
+ #
+ pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
+ $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
+ $_REQUEST["PP"]);
+ }
+
+
+} elseif (isset($_REQUEST["do_Disown"])) {
+ if ($atype != "User" && $atype != "") {
+ print __("You do not have access to disown packages.");
+ print "
\n";
+
+ } else {
+ # Disown the packages in $ids array
+ #
+ print "disowning
\n";
+
+ # After disowning, show the search page again (or maybe print out
+ # a message and give the user a link to resume where they were
+ # in the search
+ #
+ pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
+ $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
+ $_REQUEST["PP"]);
+ }
+
+
+} elseif (isset($_REQUEST["do_Adopt"])) {
+ if ($atype != "User" && $atype != "") {
+ print __("You do not have access to adopt packages.");
+ print "
\n";
+
+ } else {
+ # Adopt the packages in $ids array
+ #
+ print "adopting
\n";
+
+ # After adopting, show the search page again (or maybe print out
+ # a message and give the user a link to resume where they were
+ # in the search
+ #
+ pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
+ $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
+ $_REQUEST["PP"]);
+ }
+
+
+} elseif (isset($_REQUEST["do_Vote"])) {
+ if (!$atype) {
+ print __("You must be logged in before you can vote for packages.");
+ print "
\n";
+
+ } else {
+ # vote on the packages in $ids array. 'unvote' for any packages
+ # listed in the $_REQUEST["All_IDs"] array.
+ #
+ print "adopting
\n";
+
+ # After voting, show the search page again (or maybe print out
+ # a message and give the user a link to resume where they were
+ # in the search
+ #
+ pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
+ $_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
+ $_REQUEST["PP"]);
+ }
+
+
+} elseif (isset($_REQUEST["do_Details"])) {
+ # give a link to 'manage', and another to return to search
+ # results.
#
+ print "details for package
\n";
-} elseif ($atype && $_REQUEST["Action"] == "SomethingElse") {
- # do something else based on what the user specifies
- #
-} elseif ($_REQUEST["Action"] == "SearchPkgs") {
- # the visitor has requested search options and/or hit the less/more button
+} else {
+ # do_More/do_Less/do_Search/do_MyPackages - just do a search
#
pkg_search_page($_COOKIE["AURSID"], $_REQUEST["L"], $_REQUEST["C"],
$_REQUEST["K"], $_REQUEST["SB"], $_REQUEST["M"], $_REQUEST["O"],
$_REQUEST["PP"]);
-} else {
- # do the default thing - give the user a search form that they
- # can specify: location, category, maintainer, name, 'my pkgs'
- # and display a list of packages based on no search options.
- #
- pkg_search_page($_COOKIE["AURSID"]);
}
-
html_footer("\$Id$");
?>
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index fd923c7d..f97a1312 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -296,6 +296,7 @@ function set_lang() {
$row = mysql_fetch_array($result);
$LANG = $row[0];
}
+ $update_cookie = 1;
} else {
$LANG = "en";
}
diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc
index b4c47885..9fd70cbf 100644
--- a/web/lib/pkgs.inc
+++ b/web/lib/pkgs.inc
@@ -35,7 +35,8 @@ function pkgLocations() {
# display the search form in a boxSoft style
#
-function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) {
+function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25,
+ $D="") {
# SID: session id cookie
# L: PackageLocations.ID
# C: PackageCategories.ID
@@ -44,12 +45,15 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) {
# M: search "my packages"
# O: Row offset
# PP: Per page
+ # D: Direction to advance (Less/More)
$locs = pkgLocations();
$cats = pkgCategories();
$devs = getDevelopers();
$tus = getTrustedUsers();
$dbh = db_connect();
+
+ if (!$PP) {$PP = 25;}
if ($O) {
$OFFSET = intval($O);
} else {
@@ -68,6 +72,17 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) {
# The search form
#
+ print "SID=$SID, L=$L, C=$C, K=$K, SB=$SB, M=$M, O=$O, PP=$PP
\n";
+
+ print "