summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/html/pkgsubmit.php125
-rw-r--r--web/lang/submit_po.inc40
-rw-r--r--web/lib/aur.inc19
3 files changed, 165 insertions, 19 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index 02f3c050..fa8f3c75 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -5,33 +5,120 @@ 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
+print "<center>\n";
+
# this is the directory that new packages will be uploaded to
#
-$UPLOAD_DIR = "/tmp/aur/temp";
+$UPLOAD_DIR = "/tmp/aur/temp/";
+$INCOMING_DIR = "/tmp/aur/incoming/";
-if ($_REQUEST["upload"]) {
- # try and process the upload
+if ($_COOKIE["AURSID"]) {
+ # track upload errors
#
+ $error = "";
+
+ if ($_REQUEST["pkgsubmit"]) {
+
+ # first, see if this package already exists, and if it can be overwritten
+ #
+ if (package_exists($_FILES["pfile"]["name"])) { # TODO write function
+ # ok, it exists - should it be overwritten, and does the user have
+ # the permissions to do so?
+ #
+ # TODO write 'can_overwrite_pkg' function
+ if (can_overwrite_pkg($_FILES["pfile"]["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("<b>", $_FILES["pfile"]["name"], "</b>"));
+ }
+ }
+
+ if (!$error)) {
+ # no errors checking upload permissions, go ahead and try to process
+ # the uploaded package file.
+ #
+
+ $upload_file = $UPLOAD_DIR . $_FILES["pfile"]["name"];
+ if (move_uploaded_file($_FILES["pfile"]["tmp_name"], $upload_file)) {
+ # ok, we can proceed
+ #
+ if (file_exists($INCOMING_DIR . $_FILES["pfile"]["name"])) {
+ # blow away the existing file/dir and contents
+ #
+ rm_rf($INCOMING_DIR . $_FILES["pfile"]["name"]);
+ }
+
+ } else {
+ # errors uploading file...
+ #
+ $error = __("Error trying to upload file - please try again.");
+ }
+ }
+
+ }
+
+
+ if (!$_REQUEST["pkgsubmit"] || !$error)) {
+ # give the visitor the default upload form
+ #
+ if (ini_get("file_uploads")) {
+ if (!$error) {
+ print "<span class='error'>".$error."</span><br />\n";
+ print "<br />&nbsp;<br />\n";
+ }
+ print "<form action='/pkgsubmit.php' method='post'";
+ print " enctype='multipart/form-data'>\n";
+ print "<input type='hidden' name='pkgsubmit' value='1' />\n";
+ print "<input type='hidden' name='MAX_FILE_SIZE' value='";
+ print initeger(ini_get("upload_max_filesize"))."' />\n";
+ print "<table border='0' cellspacing='5'>\n";
+ print "<tr>\n";
+ print " <td span='f4' align='right'>";
+ print __("Upload package").":</td>\n";
+ print " <td span='f4' align='left'>";
+ print "<input type='file' name='pfile' size='30' />\n";
+ print " </td>\n";
+ print "</tr>\n";
+ print "<tr>\n";
+ print " <td span='f4' align='right'>";
+ print __("Overwrite existing package?");
+ print " </td>\n";
+ print " <td span='f4' align='left'>";
+ print "<input type='checkbox' name='overwrite' value='1'> ".__("Yes");
+ print "&nbsp;&nbsp;&nbsp;";
+ print "<input type='checkbox' name='overwrite' value='0' checked> ";
+ print __("No");
+ print " </td>\n";
+ print "</tr>\n";
+ print "<tr>\n";
+ print " <td align='center' colspan='2'>&nbsp;</td>\n";
+ print "</tr>\n";
+
+ print "<tr>\n";
+ print " <td align='right'>";
+ print "<input class='button' type='submit' value='".__("Upload")."' />\n";
+ print "</td>\n";
+ print " <td>&nbsp;</td>\n";
+ print "</tr>\n";
+ print "</table>\n";
+
+ print "</form>\n";
+ } else {
+ print __("Sorry, uploads are not permitted by this server.");
+ print "<br />\n";
+ }
+ }
} else {
- # give the visitor the default upload page
+ # visitor is not logged in
#
- print "<center>\n";
- if (ini_get("file_uploads")) {
- print "<form action='/pkgsubmit.php' method='post'";
- print " enctype='multipart/form-data'>\n";
- print "<input type='hidden' name='MAX_FILE_SIZE' value='";
- print initeger(ini_get("upload_max_filesize"))."' />\n";
- print "Upload package: ";
- print "<input type='file' name='pfile' size='30' />\n";
- print "&nbsp;&nbsp;&nbsp;&nbsp;";
- print "<input class='button' type='submit' value='Upload' />\n";
- print "</form>\n";
- } else {
- print "Sorry, uploads are not permitted by this server.\n<br />\n";
- }
- print "</center>\n";
+ print __("You must create an account before you can upload packages.");
+ print "<br />\n";
}
+print "</center>\n";
html_footer("\$Id$");
?>
diff --git a/web/lang/submit_po.inc b/web/lang/submit_po.inc
index 438f50df..fcab03c8 100644
--- a/web/lang/submit_po.inc
+++ b/web/lang/submit_po.inc
@@ -16,4 +16,44 @@ $_t["en"]["Under construction..."] = "Under construction...";
# $_t["fr"]["Under construction..."] = "--> Traduction française ici. <--";
# $_t["de"]["Under construction..."] = "--> Deutsche Übersetzung hier. <--";
+$_t["en"]["Sorry, uploads are not permitted by this server."] = "Sorry, uploads are not permitted by this server.";
+# $_t["es"]["Sorry, uploads are not permitted by this server."] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Sorry, uploads are not permitted by this server."] = "--> Traduction française ici. <--";
+# $_t["de"]["Sorry, uploads are not permitted by this server."] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["You must create an account before you can upload packages."] = "You must create an account before you can upload packages.";
+# $_t["es"]["You must create an account before you can upload packages."] = "--> Traducción española aquí. <--";
+# $_t["fr"]["You must create an account before you can upload packages."] = "--> Traduction française ici. <--";
+# $_t["de"]["You must create an account before you can upload packages."] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["Upload package"] = "Upload package";
+# $_t["es"]["Upload package"] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Upload package"] = "--> Traduction française ici. <--";
+# $_t["de"]["Upload package"] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["Upload"] = "Upload";
+# $_t["es"]["Upload"] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Upload"] = "--> Traduction française ici. <--";
+# $_t["de"]["Upload"] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["No"] = "No";
+# $_t["es"]["No"] = "--> Traducción española aquí. <--";
+# $_t["fr"]["No"] = "--> Traduction française ici. <--";
+# $_t["de"]["No"] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["Error trying to upload file - please try again."] = "Error trying to upload file - please try again.";
+# $_t["es"]["Error trying to upload file - please try again."] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Error trying to upload file - please try again."] = "--> Traduction française ici. <--";
+# $_t["de"]["Error trying to upload file - please try again."] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["Yes"] = "Yes";
+# $_t["es"]["Yes"] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Yes"] = "--> Traduction française ici. <--";
+# $_t["de"]["Yes"] = "--> Deutsche Übersetzung hier. <--";
+
+$_t["en"]["Overwrite existing package?"] = "Overwrite existing package?";
+# $_t["es"]["Overwrite existing package?"] = "--> Traducción española aquí. <--";
+# $_t["fr"]["Overwrite existing package?"] = "--> Traduction française ici. <--";
+# $_t["de"]["Overwrite existing package?"] = "--> Deutsche Übersetzung hier. <--";
+
?> \ No newline at end of file
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index 686154f5..0db5c126 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -467,5 +467,24 @@ function initeger($inival="0", $isbytes=1) {
return intval($inival) * $multiplier;
}
+# recursive delete directory
+#
+function rm_rf($dirname="") {
+ $d = dir($dirname);
+ while ($f = $d->read()) {
+ if ($f != "." && $f != "..") {
+ if (is_dir($dirname.$f)) {
+ rm_rf($dirname.$f."/");
+ }
+ if (is_file($dirname.$f) || is_link($dirname.$f)) {
+ unlink($dirname.$f);
+ }
+ }
+ }
+ $d->close();
+ rmdir($dirname);
+ return;
+}
+
# vim: ts=2 sw=2 noet ft=php
?>