From 56effc6ae4737f955c972177bf3cc0d7a5e320be Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 13 Jul 2004 00:48:21 +0000 Subject: a little bit more... --- web/html/pkgsubmit.php | 125 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 106 insertions(+), 19 deletions(-) (limited to 'web/html/pkgsubmit.php') 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 "
\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("", $_FILES["pfile"]["name"], "")); + } + } + + 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 "".$error."
\n"; + print "
 
\n"; + } + print "
\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print "\n"; + print "\n"; + print " \n"; + print "\n"; + + print "\n"; + print " \n"; + print " \n"; + print "\n"; + print "
"; + print __("Upload package").":"; + print "\n"; + print "
"; + print __("Overwrite existing package?"); + print " "; + print " ".__("Yes"); + print "   "; + print " "; + print __("No"); + print "
 
"; + print "\n"; + print " 
\n"; + + print "
\n"; + } else { + print __("Sorry, uploads are not permitted by this server."); + print "
\n"; + } + } } else { - # give the visitor the default upload page + # visitor is not logged in # - print "
\n"; - if (ini_get("file_uploads")) { - print "
\n"; - print "\n"; - print "Upload package: "; - print "\n"; - print "    "; - print "\n"; - print "
\n"; - } else { - print "Sorry, uploads are not permitted by this server.\n
\n"; - } - print "
\n"; + print __("You must create an account before you can upload packages."); + print "
\n"; } +print "
\n"; html_footer("\$Id$"); ?> -- cgit v1.2.3-24-g4f1b