From 4727e6c09f88e63f02e6c8f359862d0c0942ed36 Mon Sep 17 00:00:00 2001 From: "terry%netscape.com" <> Date: Wed, 16 Sep 1998 04:49:23 +0000 Subject: Everything has been ported to now run under Perl. --- post_bug.cgi | 148 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 67 insertions(+), 81 deletions(-) (limited to 'post_bug.cgi') diff --git a/post_bug.cgi b/post_bug.cgi index 94878d3bb..3ea3b070f 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -1,5 +1,5 @@ -#! /usr/bonsaitools/bin/mysqltcl -# -*- Mode: tcl; indent-tabs-mode: nil -*- +#!/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 @@ -20,118 +20,104 @@ # Contributor(s): Terry Weissman -source "CGI.tcl" -confirm_login +use diagnostics; +use strict; -puts "Set-Cookie: PLATFORM=$FORM(product) ; path=/ ; expires=Sun, 30-Jun-99 00:00:00 GMT" -puts "Set-Cookie: VERSION-$FORM(product)=$FORM(version) ; path=/ ; expires=Sun, 30-Jun-99 00:00:00 GMT" -puts "Content-type: text/html\n" +require "CGI.pl"; -if {[info exists FORM(maketemplate)]} { - puts "Bookmarks are your friend." - puts "

Template constructed.

" - - set url "enter_bug.cgi?$buffer" +# Shut up misguided -w warnings about "used only once". For some reason, +# "use vars" chokes on me when I try it here. - puts "If you put a bookmark to this link, it will" - puts "bring up the submit-a-new-bug page with the fields initialized" - puts "as you've requested." - exit -} +# use vars qw($::buffer); +my $zz = $::buffer; +$zz = $zz . $zz; -PutHeader "Posting Bug -- Please wait" "Posting Bug" "One moment please..." +confirm_login(); -flush stdout -umask 0 -ConnectToDatabase +print "Set-Cookie: PLATFORM=$::FORM{'product'} ; path=/ ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; +print "Set-Cookie: VERSION-$::FORM{'product'}=$::FORM{'version'} ; path=/ ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; +print "Content-type: text/html\n\n"; -if {![info exists FORM(component)] || [cequal $FORM(component) ""]} { - puts "You must choose a component that corresponds to this bug. If" - puts "necessary, just guess. But please hit the Back button and" - puts "choose a component." - exit 0 -} +if (defined $::FORM{'maketemplate'}) { + print "Bookmarks are your friend.\n"; + print "

Template constructed.

\n"; + my $url = "enter_bug.cgi?$::buffer"; -set forceAssignedOK 0 -if {[cequal "" $FORM(assigned_to)]} { - SendSQL "select initialowner from components -where program='[SqlQuote $FORM(product)]' -and value='[SqlQuote $FORM(component)]'" - set FORM(assigned_to) [lindex [FetchSQLData] 0] - set forceAssignedOK 1 + print "If you put a bookmark to this link, it will\n"; + print "bring up the submit-a-new-bug page with the fields initialized\n"; + print "as you've requested.\n"; + exit; } -set FORM(assigned_to) [DBNameToIdAndCheck $FORM(assigned_to) $forceAssignedOK] -set FORM(reporter) [DBNameToIdAndCheck $FORM(reporter)] +PutHeader("Posting Bug -- Please wait", "Posting Bug", "One moment please..."); +umask 0; +ConnectToDatabase(); -set bug_fields { reporter product version rep_platform bug_severity \ - priority op_sys assigned_to bug_status bug_file_loc \ - short_desc component } -set query "insert into bugs (\n" +if (!defined $::FORM{'component'} || $::FORM{'component'} eq "") { + print "You must choose a component that corresponds to this bug. If\n"; + print "necessary, just guess. But please hit the Back button\n"; + print "and choose a component.\n"; + exit 0 +} + -foreach field $bug_fields { - append query "$field,\n" +my $forceAssignedOK = 0; +if ($::FORM{'assigned_to'} eq "") { + SendSQL("select initialowner from components where program=" . + SqlQuote($::FORM{'product'}) . + " and value=" . SqlQuote($::FORM{'component'})); + $::FORM{'assigned_to'} = FetchOneColumn(); + $forceAssignedOK = 1; } -append query "creation_ts, long_desc )\nvalues (\n" +$::FORM{'assigned_to'} = DBNameToIdAndCheck($::FORM{'assigned_to'}, $forceAssignedOK); +$::FORM{'reporter'} = DBNameToIdAndCheck($::FORM{'reporter'}); -foreach field $bug_fields { - if {$field == "qa_assigned_to"} { +my @bug_fields = ("reporter", "product", "version", "rep_platform", + "bug_severity", "priority", "op_sys", "assigned_to", + "bug_status", "bug_file_loc", "short_desc", "component"); +my $query = "insert into bugs (\n" . join(",\n", @bug_fields) . ", +creation_ts, long_desc ) +values ( +"; - set valin [DBname_to_id $FORM($field)] - if {$valin == "__UNKNOWN__"} { - append query "null,\n" - } else { - append query "$valin,\n" - } - } else { - regsub -all "'" [FormData $field] "''" value - append query "'$value',\n" - } +foreach my $field (@bug_fields) { + $query .= SqlQuote($::FORM{$field}) . ",\n"; } -append query "now(), " -append query "'[SqlQuote [FormData comment]]' )\n" +$query .= "now(), " . SqlQuote($::FORM{'comment'}) . " )\n"; -set ccids(zz) 1 -unset ccids(zz) +my %ccids; -if {[info exists FORM(cc)]} { - foreach person [split $FORM(cc) " ,"] { - if {![cequal $person ""]} { - set ccids([DBNameToIdAndCheck $person]) 1 +if (defined $::FORM{'cc'}) { + foreach my $person (split(/[ ,]/, $::FORM{'cc'})) { + if ($person ne "") { + $ccids{DBNameToIdAndCheck($person)} = 1; } } } -# puts "
$query
" +# print "
$query
\n"; -SendSQL $query -while {[MoreSQLData]} { set ret [FetchSQLData] } +SendSQL($query); -SendSQL "select LAST_INSERT_ID()" -set id [FetchSQLData] +SendSQL("select LAST_INSERT_ID()"); +my $id = FetchOneColumn(); -foreach person [array names ccids] { - SendSQL "insert into cc (bug_id, who) values ($id, $person)" - while { [ MoreSQLData ] } { FetchSQLData } +foreach my $person (keys %ccids) { + SendSQL("insert into cc (bug_id, who) values ($id, $person)"); } -# Now make sure changes are written before we run processmail... -Disconnect - -puts "

Changes Submitted

" -puts "Show BUG# $id" -puts "
Back To Query Page" - -flush stdout +print "

Changes Submitted

\n"; +print "Show BUG# $id\n"; +print "
Back To Query Page\n"; -exec ./processmail $id < /dev/null > /dev/null 2> /dev/null & -exit +system("./processmail $id < /dev/null > /dev/null 2> /dev/null &"); +exit; -- cgit v1.2.3-24-g4f1b