From 74d81b288dda5b0f7fa3dd3790b641883a092854 Mon Sep 17 00:00:00 2001
From: eric
Date: Fri, 10 Sep 2004 12:47:37 +0000
Subject: continuing with pkgsubmit, added vim instructions to php files
---
web/html/account.php | 2 +-
web/html/hacker.php | 1 +
web/html/index.php | 1 +
web/html/logout.php | 1 +
web/html/packages.php | 1 +
web/html/pkgmgmnt.php | 1 +
web/html/pkgsubmit.php | 77 ++++++++++++++++++++++++++++++++++----------------
web/html/template.php | 2 ++
web/html/testpo.php | 1 +
web/html/timeout.php | 1 +
10 files changed, 62 insertions(+), 26 deletions(-)
(limited to 'web')
diff --git a/web/html/account.php b/web/html/account.php
index 0975ab7..09849da 100644
--- a/web/html/account.php
+++ b/web/html/account.php
@@ -126,5 +126,5 @@ if (isset($_COOKIE["AURSID"])) {
}
html_footer("\$Id$");
-# vim: ts=2 sw=2 noet ft=php
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/hacker.php b/web/html/hacker.php
index 5d51834..630d466 100644
--- a/web/html/hacker.php
+++ b/web/html/hacker.php
@@ -10,4 +10,5 @@ print __("If this problem persists, please contact the site administrator.");
print "
\n";
html_footer("\$Id$");
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/index.php b/web/html/index.php
index 7b2213a..5814fec 100644
--- a/web/html/index.php
+++ b/web/html/index.php
@@ -117,4 +117,5 @@ print "\n";
html_footer("\$Id$");
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/logout.php b/web/html/logout.php
index 26d6166..885bf3d 100644
--- a/web/html/logout.php
+++ b/web/html/logout.php
@@ -20,4 +20,5 @@ print __("You have been successfully logged out.")."
\n";
html_footer("\$Id$");
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/packages.php b/web/html/packages.php
index 546ed2b..07123a9 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -346,4 +346,5 @@ if (isset($_REQUEST["do_Flag"])) {
}
html_footer("\$Id$");
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/pkgmgmnt.php b/web/html/pkgmgmnt.php
index 98c8400..a2e28c2 100644
--- a/web/html/pkgmgmnt.php
+++ b/web/html/pkgmgmnt.php
@@ -15,4 +15,5 @@ print __("Manage package ID: %s", array($_REQUEST["ID"])) . "
\n";
html_footer("\$Id$");
+# vim: ts=2 sw=2 et ft=php
?>
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index ad917bd..bd0f9be 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -18,23 +18,36 @@ if ($_COOKIE["AURSID"]) {
$error = "";
if ($_REQUEST["pkgsubmit"]) {
+ # If this var is set, then the visitor is uploading a file...
+ #
+ if (!$_REQUEST["pkgname"]) {
+ $error = __("You did not specify a package name.");
+ } else {
+ $pkg_name = escapeshellarg($_REQUEST["pkgname"]);
+ $presult = preg_match("/[^a-z_]/", $pkg_name);
+ if ($presult == FALSE || $presult > 0) {
+ # error processing regex, or invalid characters
+ #
+ $error = __("Invalid name: only lowercase letters are allowed.");
+ }
+ }
- $pkg_name = escapeshellarg($_FILES["pfile"]["name"]);
-
- # first, see if this package already exists, and if it can be overwritten
- #
- $pkg_exists = package_exists($pkg_name);
- if ($pkg_exists) {
- # ok, it exists - should it be overwritten, and does the user have
- # the permissions to do so?
- #
- if (can_overwrite_pkg($pkg_name, $_COOKIE["AURSID"])) {
- if (!$_REQUEST["overwrite"]) {
- $error = __("You did not tag the 'overwrite' checkbox.");
+ if (!$error) {
+ # first, see if this package already exists, and if it can be overwritten
+ #
+ $pkg_exists = package_exists($pkg_name);
+ if ($pkg_exists) {
+ # ok, it exists - should it be overwritten, and does the user have
+ # the permissions to do so?
+ #
+ if (can_overwrite_pkg($pkg_name, $_COOKIE["AURSID"])) {
+ if (!$_REQUEST["overwrite"]) {
+ $error = __("You did not tag the 'overwrite' checkbox.");
+ }
+ } else {
+ $error = __("You are not allowed to overwrite the %h%s%h package.",
+ array("", $pkg_name, ""));
}
- } else {
- $error = __("You are not allowed to overwrite the %h%s%h package.",
- array("", $pkg_name, ""));
}
}
@@ -87,9 +100,9 @@ if ($_COOKIE["AURSID"]) {
# At this point, if no error exists, the package has been extracted
# There should be a $INCOMING_DIR.$pkg_name."/".$pkg_name directory
- # if the user packaged it correctly. However, the final sub-directory
- # may not exist, in which case, the files will live in,
- # $INCOMING_DIR.$pkg_name.
+ # if the user packaged it correctly. However, if the file was
+ # packaged without the $pkg_name subdirectory, try and create it
+ # and move the package contents into the new sub-directory.
#
if (is_dir($INCOMING_DIR.$pkg_name."/".$pkg_name) &&
is_file($INCOMING_DIR.$pkg_name."/".$pkg_name."/PKGBUILD")) {
@@ -101,7 +114,9 @@ if ($_COOKIE["AURSID"]) {
}
$pkg_dir = $INCOMING_DIR.$pkg_name."/".$pkg_name;
} elseif (is_file($INCOMING_DIR.$pkg_name."/PKGBUILD")) {
- # not packaged correctly, but recovery is possible
+ # not packaged correctly, but recovery may be possible.
+ # try and create $INCOMING_DIR.$pkg_name."/".$pkg_name and
+ # move package contents into the new dir
#
if (!mkdir($INCOMING_DIR.$pkg_name."/".$pkg_name)) {
$error = __("Could not create directory %s.",
@@ -141,7 +156,7 @@ if ($_COOKIE["AURSID"]) {
#
$pkgbuild = array();
$fp = fopen($pkg_dir."/PKGBUILD", "r");
- $seen_build = 0;
+ $seen_build_function = 0;
while (!feof($fp)) {
$line = trim(fgets($fp));
$lparts = explode("=", $line);
@@ -153,16 +168,16 @@ if ($_COOKIE["AURSID"]) {
# either a comment, blank line, or build function
#
if (substr($lparts[0], 0, 5) == "build") {
- $seen_build = 1;
+ $seen_build_function = 1;
}
}
- if ($seen_build) {break;}
+ if ($seen_build_function) {break;}
}
fclose($fp);
# some error checking on PKGBUILD contents
#
- if (!$seen_build) {
+ if (!$seen_build_function) {
$error = __("Missing build function in PKGBUILD.");
}
if (!array_key_exists("md5sums", $pkgbuild)) {
@@ -188,13 +203,16 @@ if ($_COOKIE["AURSID"]) {
}
}
-
# update the backend database if there are no errors
#
if (!$error) {
$dbh = db_connect();
if ($pkg_exists) {
+ # TODO add some kind of package history table - for who
+ # was the last person to upload, a timestamp, and maybe a
+ # comment about it too
+
# this is an overwrite of an existing package, the database ID
# needs to be preserved so that any votes are retained. However,
# PackageDepends, PackageSources, and PackageContents can be
@@ -236,6 +254,7 @@ if ($_COOKIE["AURSID"]) {
if (!$_REQUEST["pkgsubmit"] || $error) {
+ # User is not uploading, or there were errors uploading - then
# give the visitor the default upload form
#
if (ini_get("file_uploads")) {
@@ -251,7 +270,14 @@ if ($_COOKIE["AURSID"]) {
print "