From 7b9956f225cd885c861db0cb145b16b3b8441ca7 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 11 Jul 2004 17:04:32 +0000 Subject: cleaned up physical scripts --- web/README.txt | 30 ++--- web/html/packages.php | 349 +++++++++++++++++++++++++++++++++++++++++++++++++ web/html/pkgsearch.php | 349 ------------------------------------------------- web/html/pkgvote.php | 16 --- web/lang/vote_po.inc | 19 --- web/lib/aur.inc | 16 +-- web/lib/pkgfuncs.inc | 8 +- 7 files changed, 367 insertions(+), 420 deletions(-) create mode 100644 web/html/packages.php delete mode 100644 web/html/pkgsearch.php delete mode 100644 web/html/pkgvote.php delete mode 100644 web/lang/vote_po.inc (limited to 'web') diff --git a/web/README.txt b/web/README.txt index 5adbe474..dcebc40e 100644 --- a/web/README.txt +++ b/web/README.txt @@ -93,35 +93,21 @@ Scripts: packages are orphaned (the Users.ID field in the UnsupportedPackages table is set to Null). -- html/pkgsearch.php +- html/packages.php PHP script to search the package database. It should support searching by location ("unsupported", "AUR", "extra"), name, category, maintainer, popularity, etc. It should resemble the packages.php script on archlinux.org. A checkbox should be included next to each package to allow users to flag a package - out of date. - -- html/pkgvote.php - The PHP script that handles voting for packages. It works like - the search script above to provide a list of packages (maybe by - location only?) with a checkbox for the user to register their - 'yes' vote. It should probably only list 50-ish packages per page - and allow the user to vote a page at a time. Each page contains a - 'Continue' button to advance to the next list of packages. At the - final page, a summary is presented with a 'Cast Vote' button. Once - the vote is cast, the PackageVotes table is first cleared for that - User and then all new entries are added for the new vote (this will - be easier than trying to figure out if the vote has changed for a - particular package). + out of date, adopt it, and vote for it (and reverse operations). - html/pkgmgmnt.php - The PHP script for managing packages. It provides a list of - packages under the management of the logged in user (normal or - TU). The user can edit the package information stored in the - database such as the description, url, category, and location - (a TU can move it to/from "unsupported" and the "AUR"). This - is where TUs can adopt packages that are in the "unsupported" - area. + This script is not accessed directly, but is invoked when a + visitor clicks the 'manage' link from the 'packages.php' script. + The user can edit the package information stored in the database + such as the description, url, category, and location (a TU can move + it to/from "unsupported" and the "AUR"). This is where TUs can + adopt packages that are in the "unsupported" area. - html/pkgsubmit.php This is the PHP script that allows users to upload a new package. diff --git a/web/html/packages.php b/web/html/packages.php new file mode 100644 index 00000000..546ed2b5 --- /dev/null +++ b/web/html/packages.php @@ -0,0 +1,349 @@ +\n"; + print_r($_REQUEST); + print "\n"; +} + +# get login privileges +# +if (isset($_COOKIE["AURSID"])) { + # Only logged in users can do stuff + # + $atype = account_from_sid($_COOKIE["AURSID"]); +} else { + $atype = ""; +} + +# grab the list of Package IDs to be operated on +# +isset($_REQUEST["IDs"]) ? $ids = $_REQUEST["IDs"] : $ids = array(); +#isset($_REQUEST["All_IDs"]) ? +# $all_ids = explode(":", $_REQUEST["All_IDs"]) : +# $all_ids = array(); + + +# 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 { + + if (!empty($ids)) { + $dbh = db_connect(); + + # Flag the packages in $ids array + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if ($first) { + $first = 0; + $flag = $pid; + } else { + $flag .= ", ".$pid; + } + } + $q = "UPDATE Packages SET OutOfDate = 1 "; + $q.= "WHERE ID IN (" . $flag . ")"; + db_query($q, $dbh); + + print "

\n"; + print __("The selected packages have been flagged out-of-date."); + print "

\n"; + } else { + print "

\n"; + print __("You did not select any packages to flag."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + +} elseif (isset($_REQUEST["do_UnFlag"])) { + if (!$atype) { + print __("You must be logged in before you can unflag packages."); + print "
\n"; + + } else { + + if (!empty($ids)) { + $dbh = db_connect(); + + # Un-Flag the packages in $ids array + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if ($first) { + $first = 0; + $unflag = $pid; + } else { + $unflag .= ", ".$pid; + } + } + $q = "UPDATE Packages SET OutOfDate = 0 "; + $q.= "WHERE ID IN (" . $unflag . ")"; + db_query($q, $dbh); + + print "

\n"; + print __("The selected packages have been unflagged."); + print "

\n"; + } else { + print "

\n"; + print __("You did not select any packages to unflag."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + +} elseif (isset($_REQUEST["do_Disown"])) { + if (!$atype) { + print __("You must be logged in before you can disown packages."); + print "
\n"; + + } else { + # Disown the packages in $ids array + # + if (!empty($ids)) { + $dbh = db_connect(); + + # Disown the packages in $ids array + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if ($first) { + $first = 0; + $disown = $pid; + } else { + $disown .= ", ".$pid; + } + } + $atype = account_from_sid($_COOKIE["AURSID"]); + if ($atype == "Trusted User" || $atype == "Developer") { + $field = "AURMaintainerUID"; + } elseif ($atype == "User") { + $field = "MaintainerUID"; + } else { + $field = ""; + } + + if ($field) { + $q = "UPDATE Packages "; + $q.= "SET ".$field." = 0 "; + $q.= "WHERE ID IN (" . $disown . ") "; + $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]); + db_query($q, $dbh); + } + + print "

\n"; + print __("The selected packages have been disowned."); + print "

\n"; + } else { + print "

\n"; + print __("You did not select any packages to disowned."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + + +} elseif (isset($_REQUEST["do_Adopt"])) { + if (!$atype) { + print __("You must be logged in before you can adopt packages."); + print "
\n"; + + } else { + # Adopt the packages in $ids array + # + if (!empty($ids)) { + $dbh = db_connect(); + + # Adopt the packages in $ids array + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if ($first) { + $first = 0; + $adopt = $pid; + } else { + $adopt .= ", ".$pid; + } + } + $atype = account_from_sid($_COOKIE["AURSID"]); + if ($atype == "Trusted User" || $atype == "Developer") { + $field = "AURMaintainerUID"; + } elseif ($atype == "User") { + $field = "MaintainerUID"; + } else { + $field = ""; + } + + if ($field) { + $q = "UPDATE Packages "; + $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; + $q.= "WHERE ID IN (" . $adopt . ") "; + $q.= "AND ".$field." = 0"; + db_query($q, $dbh); + } + + print "

\n"; + print __("The selected packages have been adopted."); + print "

\n"; + } else { + print "

\n"; + print __("You did not select any packages to adopt."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + + +} 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. + # + if (!empty($ids)) { + $dbh = db_connect(); + $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); + $uid = uid_from_sid($_COOKIE["AURSID"]); + # $vote_ids will contain the string of Package.IDs that + # the visitor hasn't voted for already + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if (!isset($my_votes[$pid])) { + # cast a vote for this package + # + if ($first) { + $first = 0; + $vote_ids = $pid; + $vote_clauses = "(".$uid.", ".$pid.")"; + } else { + $vote_ids .= ", ".$pid; + $vote_clauses .= ", (".$uid.", ".$pid.")"; + } + } + } + # only vote for packages the user hasn't already voted for + # + $q = "UPDATE Packages SET NumVotes = NumVotes + 1 "; + $q.= "WHERE ID IN (".$vote_ids.")"; + db_query($q, $dbh); + + $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES "; + $q.= $vote_clauses; + db_query($q, $dbh); + + print "

\n"; + print __("Your votes have been cast for the selected packages."); + print "

\n"; + + } else { + print "

\n"; + print __("You did not select any packages to vote for."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + + +} elseif (isset($_REQUEST["do_UnVote"])) { + if (!$atype) { + print __("You must be logged in before you can un-vote for packages."); + print "
\n"; + + } else { + # un-vote on the packages in $ids array. + # + if (!empty($ids)) { + $dbh = db_connect(); + $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); + $uid = uid_from_sid($_COOKIE["AURSID"]); + # $unvote_ids will contain the string of Package.IDs that + # the visitor has voted for and wants to unvote. + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if (isset($my_votes[$pid])) { + # cast a un-vote for this package + # + if ($first) { + $first = 0; + $unvote_ids = $pid; + } else { + $unvote_ids .= ", ".$pid; + } + } + } + # only un-vote for packages the user has already voted for + # + $q = "UPDATE Packages SET NumVotes = NumVotes - 1 "; + $q.= "WHERE ID IN (".$unvote_ids.")"; + db_query($q, $dbh); + + $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." "; + $q.= "AND PackageID IN (".$unvote_ids.")"; + db_query($q, $dbh); + + print "

\n"; + print __("Your votes have been removed from the selected packages."); + print "

\n"; + + } else { + print "

\n"; + print __("You did not select any packages to un-vote for."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + + +} elseif (isset($_REQUEST["do_Details"])) { + + if (!isset($_REQUEST["ID"]) || !intval($_REQUEST["ID"])) { + print __("Error trying to retrieve package details.")."
\n"; + + } else { + package_details($_REQUEST["ID"]); + } + + print "
\n"; + pkgsearch_results_link(); + + +} else { + # do_More/do_Less/do_Search/do_MyPackages - just do a search + # + pkg_search_page($_COOKIE["AURSID"]); + +} + +html_footer("\$Id$"); +?> diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php deleted file mode 100644 index 546ed2b5..00000000 --- a/web/html/pkgsearch.php +++ /dev/null @@ -1,349 +0,0 @@ -\n"; - print_r($_REQUEST); - print "\n"; -} - -# get login privileges -# -if (isset($_COOKIE["AURSID"])) { - # Only logged in users can do stuff - # - $atype = account_from_sid($_COOKIE["AURSID"]); -} else { - $atype = ""; -} - -# grab the list of Package IDs to be operated on -# -isset($_REQUEST["IDs"]) ? $ids = $_REQUEST["IDs"] : $ids = array(); -#isset($_REQUEST["All_IDs"]) ? -# $all_ids = explode(":", $_REQUEST["All_IDs"]) : -# $all_ids = array(); - - -# 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 { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $flag = $pid; - } else { - $flag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 1 "; - $q.= "WHERE ID IN (" . $flag . ")"; - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been flagged out-of-date."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to flag."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - -} elseif (isset($_REQUEST["do_UnFlag"])) { - if (!$atype) { - print __("You must be logged in before you can unflag packages."); - print "
\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Un-Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $unflag = $pid; - } else { - $unflag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 0 "; - $q.= "WHERE ID IN (" . $unflag . ")"; - db_query($q, $dbh); - - print "

\n"; - print __("The selected packages have been unflagged."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to unflag."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - -} elseif (isset($_REQUEST["do_Disown"])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "
\n"; - - } else { - # Disown the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Disown the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $disown = $pid; - } else { - $disown .= ", ".$pid; - } - } - $atype = account_from_sid($_COOKIE["AURSID"]); - if ($atype == "Trusted User" || $atype == "Developer") { - $field = "AURMaintainerUID"; - } elseif ($atype == "User") { - $field = "MaintainerUID"; - } else { - $field = ""; - } - - if ($field) { - $q = "UPDATE Packages "; - $q.= "SET ".$field." = 0 "; - $q.= "WHERE ID IN (" . $disown . ") "; - $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]); - db_query($q, $dbh); - } - - print "

\n"; - print __("The selected packages have been disowned."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to disowned."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - - -} elseif (isset($_REQUEST["do_Adopt"])) { - if (!$atype) { - print __("You must be logged in before you can adopt packages."); - print "
\n"; - - } else { - # Adopt the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Adopt the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $adopt = $pid; - } else { - $adopt .= ", ".$pid; - } - } - $atype = account_from_sid($_COOKIE["AURSID"]); - if ($atype == "Trusted User" || $atype == "Developer") { - $field = "AURMaintainerUID"; - } elseif ($atype == "User") { - $field = "MaintainerUID"; - } else { - $field = ""; - } - - if ($field) { - $q = "UPDATE Packages "; - $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; - $q.= "WHERE ID IN (" . $adopt . ") "; - $q.= "AND ".$field." = 0"; - db_query($q, $dbh); - } - - print "

\n"; - print __("The selected packages have been adopted."); - print "

\n"; - } else { - print "

\n"; - print __("You did not select any packages to adopt."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - - -} 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. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $vote_ids will contain the string of Package.IDs that - # the visitor hasn't voted for already - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (!isset($my_votes[$pid])) { - # cast a vote for this package - # - if ($first) { - $first = 0; - $vote_ids = $pid; - $vote_clauses = "(".$uid.", ".$pid.")"; - } else { - $vote_ids .= ", ".$pid; - $vote_clauses .= ", (".$uid.", ".$pid.")"; - } - } - } - # only vote for packages the user hasn't already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes + 1 "; - $q.= "WHERE ID IN (".$vote_ids.")"; - db_query($q, $dbh); - - $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES "; - $q.= $vote_clauses; - db_query($q, $dbh); - - print "

\n"; - print __("Your votes have been cast for the selected packages."); - print "

\n"; - - } else { - print "

\n"; - print __("You did not select any packages to vote for."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - - -} elseif (isset($_REQUEST["do_UnVote"])) { - if (!$atype) { - print __("You must be logged in before you can un-vote for packages."); - print "
\n"; - - } else { - # un-vote on the packages in $ids array. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $unvote_ids will contain the string of Package.IDs that - # the visitor has voted for and wants to unvote. - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (isset($my_votes[$pid])) { - # cast a un-vote for this package - # - if ($first) { - $first = 0; - $unvote_ids = $pid; - } else { - $unvote_ids .= ", ".$pid; - } - } - } - # only un-vote for packages the user has already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes - 1 "; - $q.= "WHERE ID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." "; - $q.= "AND PackageID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - print "

\n"; - print __("Your votes have been removed from the selected packages."); - print "

\n"; - - } else { - print "

\n"; - print __("You did not select any packages to un-vote for."); - print "

\n"; - } - - pkgsearch_results_link(); - - } - - -} elseif (isset($_REQUEST["do_Details"])) { - - if (!isset($_REQUEST["ID"]) || !intval($_REQUEST["ID"])) { - print __("Error trying to retrieve package details.")."
\n"; - - } else { - package_details($_REQUEST["ID"]); - } - - print "
\n"; - pkgsearch_results_link(); - - -} else { - # do_More/do_Less/do_Search/do_MyPackages - just do a search - # - pkg_search_page($_COOKIE["AURSID"]); - -} - -html_footer("\$Id$"); -?> diff --git a/web/html/pkgvote.php b/web/html/pkgvote.php deleted file mode 100644 index eed4a357..00000000 --- a/web/html/pkgvote.php +++ /dev/null @@ -1,16 +0,0 @@ -\n"; - - -html_footer("\$Id$"); -?> diff --git a/web/lang/vote_po.inc b/web/lang/vote_po.inc deleted file mode 100644 index 438f50df..00000000 --- a/web/lang/vote_po.inc +++ /dev/null @@ -1,19 +0,0 @@ - Traducción española aquí. <--"; -# $_t["fr"]["Under construction..."] = "--> Traduction française ici. <--"; -# $_t["de"]["Under construction..."] = "--> Deutsche Übersetzung hier. <--"; - -?> \ No newline at end of file diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 005c5642..7ea1e965 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -62,7 +62,7 @@ function check_sid() { global $_COOKIE; global $LOGIN_TIMEOUT; - if (isset($_COOKIE["AURSID"])) { + if ($_COOKIE["AURSID"]) { $failed = 0; # the visitor is logged in, try and update the session # @@ -290,18 +290,18 @@ function set_lang() { global $SUPPORTED_LANGS; $update_cookie = 0; - if (isset($_REQUEST['setlang'])) { + if ($_REQUEST['setlang']) { # visitor is requesting a language change # $LANG = $_REQUEST['setlang']; $update_cookie = 1; - } elseif (isset($_COOKIE['AURLANG'])) { + } elseif ($_COOKIE['AURLANG']) { # If a cookie is set, use that # $LANG = $_COOKIE['AURLANG']; - } elseif (isset($_COOKIE["AURSID"])) { + } elseif ($_COOKIE["AURSID"]) { $dbh = db_connect(); $q = "SELECT LangPreference FROM Users, Sessions "; $q.= "WHERE Users.ID = Sessions.UsersID "; @@ -392,17 +392,13 @@ function html_header() { print " - "; print " ".__("Accounts")." "; print " - "; - print " ".__("Packages")." "; - if (isset($_COOKIE["AURSID"])) { + print " ".__("Packages")." "; + if ($_COOKIE["AURSID"]) { # Only display these items if the visitor is logged in. This should # be a safe check because check_sid() has been called prior to # html_header(). # print " - "; - print " ".__("Vote")." "; - print " - "; - print " ".__("Manage")." "; - print " - "; print " ".__("Submit")." "; print " - "; print " ".__("Logout")." "; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 0b7a0003..658dfbaa 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -12,7 +12,7 @@ function pkgsearch_results_link() { global $_REQUEST; global $pkgsearch_vars; - $url_data = ""; $deps = package_dependencies($row["ID"]); # $deps[0] = array('id','name'); while (list($k, $darr) = each($deps)) { - $url = "\n"; + print "
\n"; print "\n"; print "
\n"; @@ -588,7 +588,7 @@ function pkg_search_page($SID="") { print " "; print $cats[$row["CategoryID"]]."\n"; print " "; - $url = "