From 09a62e442b2d5665434ad87ff1f5198aad36d648 Mon Sep 17 00:00:00 2001 From: "terry%netscape.com" <> Date: Thu, 8 Apr 1999 21:40:45 +0000 Subject: Bugzilla now has the ability to store patches and other attachments with bugs. --- createattachment.cgi | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 createattachment.cgi (limited to 'createattachment.cgi') diff --git a/createattachment.cgi b/createattachment.cgi new file mode 100755 index 000000000..d87453eb7 --- /dev/null +++ b/createattachment.cgi @@ -0,0 +1,110 @@ +#!/usr/bonsaitools/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public License +# Version 1.0 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations +# under the License. +# +# The Original Code is the Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Netscape Communications +# Corporation. Portions created by Netscape are Copyright (C) 1998 +# Netscape Communications Corporation. All Rights Reserved. +# +# Contributor(s): Terry Weissman +# David Gardiner + +use diagnostics; +use strict; + +require "CGI.pl"; + +use vars %::COOKIE, %::FILENAME; + +sub Punt { + my ($str) = (@_); + print "$str

Please hit Back and try again.\n"; + exit; +} + + +confirm_login(); + +print "Content-type: text/html\n\n"; + +my $id = $::FORM{'id'}; + +PutHeader("Create an attachment", "Create attachment", "Bug $id"); + + +if (!defined($::FORM{'data'})) { + print qq{ +

+ +To attach a file to bug $id, place it in a +file on your local machine, and enter the path to that file here:
+ +

+Please also provide a one-line description of this attachment:
+ +
+What kind of file is this? +
Patch file (text/plain, diffs) +
Plain text (text/plain) +
HTML source (text/html) +
Binary file (application/octet-stream) +
Other (enter mime type: ) +

+ +

+

+}; +} else { + if ($::FORM{'data'} eq "" || !defined $::FILENAME{'data'}) { + Punt("No file was provided, or it was empty."); + } + my $desc = trim($::FORM{'description'}); + if ($desc eq "") { + Punt("You must provide a description of your attachment."); + } + my $ispatch = 0; + my $mimetype = $::FORM{'type'}; + if (!defined $mimetype) { + Punt("You must select which kind of file you have."); + } + $mimetype = trim($mimetype); + if ($mimetype eq "patch") { + $mimetype = "text/plain"; + $ispatch = 1; + } + if ($mimetype eq "other") { + $mimetype = $::FORM{'othertype'}; + } + if ($mimetype !~ m@^(\w|-)+/(\w|-)+$@) { + Punt("You must select a legal mime type. '$mimetype' simply will not do."); + } + SendSQL("insert into attachments (bug_id, filename, description, mimetype, ispatch, thedata) values ($id," . + SqlQuote($::FILENAME{'data'}) . ", " . SqlQuote($desc) . ", " . + SqlQuote($mimetype) . ", $ispatch, " . + SqlQuote($::FORM{'data'}) . ")"); + SendSQL("select LAST_INSERT_ID()"); + my $attachid = FetchOneColumn(); + AppendComment($id, $::COOKIE{"Bugzilla_login"}, + "Created an attachment (id=$attachid)\n$desc\n"); + print "Your attachment has been created."; + +} + + + +print qq{ +

+Go back to bug $id
+Go back to the query page
+}; -- cgit v1.2.3-24-g4f1b