require "include/bittorrent.php"; dbconn(); loggedinorreturn(); $maxfilesize = 256 * 1024; if( get_user_class() < UC_MODERATOR) stderr( _("Error"), _("Permission denied.")); if ($_SERVER["REQUEST_METHOD"] == "POST") { $file = $_FILES["file"]; if (!isset($file) || $file["size"] < 1) stderr("Upload failed", "Nothing received!"); if ($file["size"] > $maxfilesize) stderr("Upload failed", "Sorry, that file is too large for the bit-bucket."); $filename = $file["name"]; if (strpos($filename, "..") !== false || strpos($filename, "/") !== false) stderr("Upload failed", "Bad file name."); $tgtfile = "bitbucket/$filename"; if (file_exists($tgtfile)) stderr("Upload failed", "Sorry, a file with the name " . htmlspecialchars($filename) . " already exists in the bit-bucket."); $i = strrpos($filename, "."); if ($i !== false) { $ext = strtolower(substr($filename, $i)); if (($it == IMAGETYPE_GIF && $ext != ".gif") || ($it == IMAGETYPE_JPEG && $ext != ".jpg") || ($it == IMAGETYPE_PNG && $ext != ".png")) stderr( _("Error"), "Invalid file name extension: ".htmlspecialchars($ext).""); } else stderr( _("Error"), "File name needs an extension."); move_uploaded_file($file["tmp_name"], $tgtfile); $url = str_replace(" ", "%20", htmlspecialchars($GLOBALS['DEFAULTBASEURL']."/bitbucket/$filename")); stderr("Success", "Use the following URL to access the file: $url
Upload another file."); } stdhead("Bit-bucket upload"); ?>
Bit-bucket upload
|