1998-09-16 01:49:26 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (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.
|
|
|
|
#
|
1998-09-16 01:49:26 +04:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1998-09-16 01:49:26 +04:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1998-09-16 01:49:26 +04:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
1999-12-03 02:21:42 +03:00
|
|
|
# Dan Mosedale <dmose@mozilla.org>
|
2000-09-15 22:35:18 +04:00
|
|
|
# Joe Robins <jmrobins@tgix.com>
|
2001-06-08 00:26:40 +04:00
|
|
|
# Dave Miller <justdave@syndicomm.com>
|
2001-08-26 22:51:45 +04:00
|
|
|
# Christopher Aillon <christopher@aillon.com>
|
2001-09-11 01:26:05 +04:00
|
|
|
# Gervase Markham <gerv@gerv.net>
|
2001-10-11 03:36:29 +04:00
|
|
|
# Christian Reis <kiko@async.com.br>
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
# Contains some global routines used throughout the CGI scripts of Bugzilla.
|
|
|
|
|
|
|
|
use diagnostics;
|
|
|
|
use strict;
|
2001-11-19 01:23:31 +03:00
|
|
|
use lib ".";
|
|
|
|
|
2000-03-10 20:45:09 +03:00
|
|
|
# use Carp; # for confess
|
2000-10-24 04:44:21 +04:00
|
|
|
|
|
|
|
# commented out the following snippet of code. this tosses errors into the
|
|
|
|
# CGI if you are perl 5.6, and doesn't if you have perl 5.003.
|
2000-09-15 22:35:18 +04:00
|
|
|
# We want to check for the existence of the LDAP modules here.
|
2000-10-24 04:44:21 +04:00
|
|
|
# eval "use Mozilla::LDAP::Conn";
|
|
|
|
# my $have_ldap = $@ ? 0 : 1;
|
|
|
|
|
2001-11-18 06:54:54 +03:00
|
|
|
# Shut up misguided -w warnings about "used only once". For some reason,
|
|
|
|
# "use vars" chokes on me when I try it here.
|
1999-10-19 03:57:58 +04:00
|
|
|
|
1999-10-19 04:04:59 +04:00
|
|
|
sub CGI_pl_sillyness {
|
1999-10-19 03:57:58 +04:00
|
|
|
my $zz;
|
2000-03-10 20:45:09 +03:00
|
|
|
$zz = %::MFORM;
|
2000-01-21 00:36:20 +03:00
|
|
|
$zz = %::dontchange;
|
1999-10-19 03:57:58 +04:00
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
use CGI::Carp qw(fatalsToBrowser);
|
|
|
|
|
|
|
|
require 'globals.pl';
|
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
use vars qw($template $vars);
|
|
|
|
|
2002-02-03 12:28:48 +03:00
|
|
|
# If Bugzilla is shut down, do not go any further, just display a message
|
|
|
|
# to the user about the downtime. (do)editparams.cgi is exempted from
|
|
|
|
# this message, of course, since it needs to be available in order for
|
|
|
|
# the administrator to open Bugzilla back up.
|
|
|
|
if (Param("shutdownhtml") && $0 !~ m:[\\/](do)?editparams.cgi$:) {
|
|
|
|
# The shut down message we are going to display to the user.
|
|
|
|
$::vars->{'title'} = "Bugzilla is Down";
|
|
|
|
$::vars->{'h1'} = "Bugzilla is Down";
|
|
|
|
$::vars->{'message'} = Param("shutdownhtml");
|
|
|
|
|
|
|
|
# Return the appropriate HTTP response headers.
|
|
|
|
print "Content-Type: text/html\n\n";
|
|
|
|
|
|
|
|
# Generate and return an HTML message about the downtime.
|
|
|
|
$::template->process("global/message.html.tmpl", $::vars)
|
2002-04-24 11:24:50 +04:00
|
|
|
|| ThrowTemplateError($::template->error());
|
2002-02-03 12:28:48 +03:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
# Implementations of several of the below were blatently stolen from CGI.pm,
|
|
|
|
# by Lincoln D. Stein.
|
|
|
|
|
|
|
|
# Get rid of all the %xx encoding and the like from the given URL.
|
|
|
|
sub url_decode {
|
|
|
|
my ($todecode) = (@_);
|
|
|
|
$todecode =~ tr/+/ /; # pluses become spaces
|
|
|
|
$todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
|
|
|
|
return $todecode;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Quotify a string, suitable for putting into a URL.
|
|
|
|
sub url_quote {
|
|
|
|
my($toencode) = (@_);
|
|
|
|
$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
|
|
|
|
return $toencode;
|
|
|
|
}
|
|
|
|
|
2000-01-28 04:01:40 +03:00
|
|
|
sub ParseUrlString {
|
2002-01-20 04:44:52 +03:00
|
|
|
# We don't want to detaint the user supplied data...
|
|
|
|
use re 'taint';
|
|
|
|
|
2000-01-28 04:01:40 +03:00
|
|
|
my ($buffer, $f, $m) = (@_);
|
|
|
|
undef %$f;
|
|
|
|
undef %$m;
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
my %isnull;
|
|
|
|
my $remaining = $buffer;
|
|
|
|
while ($remaining ne "") {
|
2001-10-13 05:36:17 +04:00
|
|
|
my $item;
|
|
|
|
if ($remaining =~ /^([^&]*)&(.*)$/) {
|
|
|
|
$item = $1;
|
|
|
|
$remaining = $2;
|
|
|
|
} else {
|
|
|
|
$item = $remaining;
|
|
|
|
$remaining = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $name;
|
|
|
|
my $value;
|
|
|
|
if ($item =~ /^([^=]*)=(.*)$/) {
|
|
|
|
$name = $1;
|
|
|
|
$value = url_decode($2);
|
|
|
|
} else {
|
|
|
|
$name = $item;
|
|
|
|
$value = "";
|
|
|
|
}
|
2002-01-20 04:44:52 +03:00
|
|
|
|
2001-10-13 05:36:17 +04:00
|
|
|
if ($value ne "") {
|
|
|
|
if (defined $f->{$name}) {
|
|
|
|
$f->{$name} .= $value;
|
|
|
|
my $ref = $m->{$name};
|
|
|
|
push @$ref, $value;
|
|
|
|
} else {
|
|
|
|
$f->{$name} = $value;
|
|
|
|
$m->{$name} = [$value];
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
} else {
|
|
|
|
$isnull{$name} = 1;
|
|
|
|
}
|
|
|
|
}
|
2000-08-21 23:50:41 +04:00
|
|
|
if (%isnull) {
|
1998-09-16 01:49:26 +04:00
|
|
|
foreach my $name (keys(%isnull)) {
|
2000-01-28 04:01:40 +03:00
|
|
|
if (!defined $f->{$name}) {
|
|
|
|
$f->{$name} = "";
|
|
|
|
$m->{$name} = [];
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-28 04:01:40 +03:00
|
|
|
sub ProcessFormFields {
|
|
|
|
my ($buffer) = (@_);
|
|
|
|
return ParseUrlString($buffer, \%::FORM, \%::MFORM);
|
|
|
|
}
|
|
|
|
|
1999-04-08 18:40:46 +04:00
|
|
|
sub ProcessMultipartFormFields {
|
2001-10-31 02:42:22 +03:00
|
|
|
my ($boundary) = @_;
|
|
|
|
|
|
|
|
# Initialize variables that store whether or not we are parsing a header,
|
|
|
|
# the name of the part we are parsing, and its value (which is incomplete
|
|
|
|
# until we finish parsing the part).
|
1999-04-08 18:40:46 +04:00
|
|
|
my $inheader = 1;
|
2001-10-31 02:42:22 +03:00
|
|
|
my $fieldname = "";
|
|
|
|
my $fieldvalue = "";
|
|
|
|
|
|
|
|
# Read the input stream line by line and parse it into a series of parts,
|
|
|
|
# each one containing a single form field and its value and each one
|
|
|
|
# separated from the next by the value of $boundary.
|
|
|
|
my $remaining = $ENV{"CONTENT_LENGTH"};
|
1999-04-08 18:40:46 +04:00
|
|
|
while ($remaining > 0 && ($_ = <STDIN>)) {
|
|
|
|
$remaining -= length($_);
|
2001-10-31 02:42:22 +03:00
|
|
|
|
|
|
|
# If the current input line is a boundary line, save the previous
|
|
|
|
# form value and reset the storage variables.
|
2002-04-20 20:17:54 +04:00
|
|
|
if ($_ =~ m/^-*\Q$boundary\E/) {
|
2001-10-31 02:42:22 +03:00
|
|
|
if ( $fieldname ) {
|
|
|
|
chomp($fieldvalue);
|
|
|
|
$fieldvalue =~ s/\r$//;
|
|
|
|
if ( defined $::FORM{$fieldname} ) {
|
|
|
|
$::FORM{$fieldname} .= $fieldvalue;
|
2001-10-31 03:21:28 +03:00
|
|
|
push @{$::MFORM{$fieldname}}, $fieldvalue;
|
2001-10-31 02:42:22 +03:00
|
|
|
} else {
|
|
|
|
$::FORM{$fieldname} = $fieldvalue;
|
|
|
|
$::MFORM{$fieldname} = [$fieldvalue];
|
|
|
|
}
|
|
|
|
}
|
1999-04-08 18:40:46 +04:00
|
|
|
|
2001-10-31 02:42:22 +03:00
|
|
|
$inheader = 1;
|
|
|
|
$fieldname = "";
|
|
|
|
$fieldvalue = "";
|
|
|
|
|
|
|
|
# If the current input line is a header line, look for a blank line
|
|
|
|
# (meaning the end of the headers), a Content-Disposition header
|
|
|
|
# (containing the field name and, for uploaded file parts, the file
|
|
|
|
# name), or a Content-Type header (containing the content type for
|
|
|
|
# file parts).
|
|
|
|
} elsif ( $inheader ) {
|
1999-04-08 18:40:46 +04:00
|
|
|
if (m/^\s*$/) {
|
|
|
|
$inheader = 0;
|
2001-10-31 02:42:22 +03:00
|
|
|
} elsif (m/^Content-Disposition:\s*form-data\s*;\s*name\s*=\s*"([^\"]+)"/i) {
|
|
|
|
$fieldname = $1;
|
1999-04-08 18:40:46 +04:00
|
|
|
if (m/;\s*filename\s*=\s*"([^\"]+)"/i) {
|
2001-10-31 02:42:22 +03:00
|
|
|
$::FILE{$fieldname}->{'filename'} = $1;
|
1999-04-08 18:40:46 +04:00
|
|
|
}
|
2001-10-31 02:42:22 +03:00
|
|
|
} elsif ( m|^Content-Type:\s*([^/]+/[^\s;]+)|i ) {
|
|
|
|
$::FILE{$fieldname}->{'contenttype'} = $1;
|
1999-04-08 18:40:46 +04:00
|
|
|
}
|
2001-10-31 02:42:22 +03:00
|
|
|
|
|
|
|
# If the current input line is neither a boundary line nor a header,
|
|
|
|
# it must be part of the field value, so append it to the value.
|
|
|
|
} else {
|
|
|
|
$fieldvalue .= $_;
|
1999-04-08 18:40:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-03 02:21:42 +03:00
|
|
|
# check and see if a given field exists, is non-empty, and is set to a
|
|
|
|
# legal value. assume a browser bug and abort appropriately if not.
|
|
|
|
# if $legalsRef is not passed, just check to make sure the value exists and
|
|
|
|
# is non-NULL
|
|
|
|
sub CheckFormField (\%$;\@) {
|
|
|
|
my ($formRef, # a reference to the form to check (a hash)
|
|
|
|
$fieldname, # the fieldname to check
|
|
|
|
$legalsRef # (optional) ref to a list of legal values
|
|
|
|
) = @_;
|
|
|
|
|
|
|
|
if ( !defined $formRef->{$fieldname} ||
|
|
|
|
trim($formRef->{$fieldname}) eq "" ||
|
|
|
|
(defined($legalsRef) &&
|
|
|
|
lsearch($legalsRef, $formRef->{$fieldname})<0) ){
|
|
|
|
|
2001-10-20 04:50:27 +04:00
|
|
|
SendSQL("SELECT description FROM fielddefs WHERE name=" . SqlQuote($fieldname));
|
|
|
|
my $result = FetchOneColumn();
|
|
|
|
if ($result) {
|
2002-04-26 10:13:41 +04:00
|
|
|
ThrowCodeError("A legal $result was not set.", undef, "abort");
|
2001-10-20 04:50:27 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-04-26 10:13:41 +04:00
|
|
|
ThrowCodeError("A legal $fieldname was not set.", undef, "abort");
|
2001-10-20 04:50:27 +04:00
|
|
|
}
|
1999-12-03 02:21:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# check and see if a given field is defined, and abort if not
|
|
|
|
sub CheckFormFieldDefined (\%$) {
|
|
|
|
my ($formRef, # a reference to the form to check (a hash)
|
|
|
|
$fieldname, # the fieldname to check
|
|
|
|
) = @_;
|
|
|
|
|
2002-04-29 01:57:10 +04:00
|
|
|
if (!defined $formRef->{$fieldname}) {
|
|
|
|
ThrowCodeError("$fieldname was not defined; " .
|
|
|
|
Param("browserbugmessage"));
|
1999-12-03 02:21:42 +03:00
|
|
|
}
|
|
|
|
}
|
1999-04-08 18:40:46 +04:00
|
|
|
|
2001-05-31 19:52:25 +04:00
|
|
|
sub ValidateBugID {
|
2001-06-03 02:02:02 +04:00
|
|
|
# Validates and verifies a bug ID, making sure the number is a
|
|
|
|
# positive integer, that it represents an existing bug in the
|
|
|
|
# database, and that the user is authorized to access that bug.
|
2002-01-20 04:44:52 +03:00
|
|
|
# We detaint the number here, too
|
2001-06-03 02:02:02 +04:00
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
$_[0] = trim($_[0]); # Allow whitespace arround the number
|
|
|
|
detaint_natural($_[0])
|
2001-10-13 00:54:26 +04:00
|
|
|
|| DisplayError("The bug number is invalid. If you are trying to use " .
|
|
|
|
"QuickSearch, you need to enable JavaScript in your " .
|
|
|
|
"browser. To help us fix this limitation, look " .
|
|
|
|
"<a href=\"http://bugzilla.mozilla.org/show_bug.cgi?id=70907\">here</a>.")
|
2001-06-03 02:02:02 +04:00
|
|
|
&& exit;
|
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
my ($id) = @_;
|
|
|
|
|
2001-06-03 02:02:02 +04:00
|
|
|
# Get the values of the usergroupset and userid global variables
|
|
|
|
# and write them to local variables for use within this function,
|
|
|
|
# setting those local variables to the default value of zero if
|
|
|
|
# the global variables are undefined.
|
|
|
|
|
2001-10-23 19:44:53 +04:00
|
|
|
# First check that the bug exists
|
|
|
|
SendSQL("SELECT bug_id FROM bugs WHERE bug_id = $id");
|
2001-08-13 04:46:20 +04:00
|
|
|
|
2001-10-23 19:44:53 +04:00
|
|
|
FetchOneColumn()
|
|
|
|
|| DisplayError("Bug #$id does not exist.")
|
|
|
|
&& exit;
|
2001-08-26 22:51:45 +04:00
|
|
|
|
2001-10-23 19:44:53 +04:00
|
|
|
return if CanSeeBug($id, $::userid, $::usergroupset);
|
2001-08-13 04:46:20 +04:00
|
|
|
|
|
|
|
# The user did not pass any of the authorization tests, which means they
|
|
|
|
# are not authorized to see the bug. Display an error and stop execution.
|
|
|
|
# The error the user sees depends on whether or not they are logged in
|
2001-10-23 19:44:53 +04:00
|
|
|
# (i.e. $::userid contains the user's positive integer ID).
|
|
|
|
if ($::userid) {
|
2001-08-13 04:46:20 +04:00
|
|
|
DisplayError("You are not authorized to access bug #$id.");
|
|
|
|
} else {
|
|
|
|
DisplayError(
|
|
|
|
qq|You are not authorized to access bug #$id. To see this bug, you
|
2001-10-11 03:36:29 +04:00
|
|
|
must first <a href="show_bug.cgi?id=$id&GoAheadAndLogIn=1">log in
|
2001-08-13 04:46:20 +04:00
|
|
|
to an account</a> with the appropriate permissions.|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
|
2001-05-31 19:52:25 +04:00
|
|
|
}
|
|
|
|
|
2002-03-11 10:33:03 +03:00
|
|
|
sub ValidateComment {
|
|
|
|
# Make sure a comment is not too large (greater than 64K).
|
|
|
|
|
|
|
|
my ($comment) = @_;
|
|
|
|
|
|
|
|
if (defined($comment) && length($comment) > 65535) {
|
|
|
|
DisplayError("Comments cannot be longer than 65,535 characters.");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
sub html_quote {
|
|
|
|
my ($var) = (@_);
|
|
|
|
$var =~ s/\&/\&/g;
|
|
|
|
$var =~ s/</\</g;
|
|
|
|
$var =~ s/>/\>/g;
|
2002-03-27 11:13:35 +03:00
|
|
|
$var =~ s/"/\"/g;
|
1998-09-16 01:49:26 +04:00
|
|
|
return $var;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub value_quote {
|
|
|
|
my ($var) = (@_);
|
|
|
|
$var =~ s/\&/\&/g;
|
|
|
|
$var =~ s/</\</g;
|
|
|
|
$var =~ s/>/\>/g;
|
|
|
|
$var =~ s/"/\"/g;
|
2000-06-02 03:09:14 +04:00
|
|
|
# See bug http://bugzilla.mozilla.org/show_bug.cgi?id=4928 for
|
|
|
|
# explanaion of why bugzilla does this linebreak substitution.
|
|
|
|
# This caused form submission problems in mozilla (bug 22983, 32000).
|
2001-01-17 00:09:33 +03:00
|
|
|
$var =~ s/\r\n/\
/g;
|
|
|
|
$var =~ s/\n\r/\
/g;
|
1999-04-10 21:42:24 +04:00
|
|
|
$var =~ s/\r/\
/g;
|
2001-01-17 00:09:33 +03:00
|
|
|
$var =~ s/\n/\
/g;
|
1998-09-16 01:49:26 +04:00
|
|
|
return $var;
|
|
|
|
}
|
|
|
|
|
2001-09-11 01:26:05 +04:00
|
|
|
# Adds <link> elements for bug lists. These can be inserted into the header by
|
|
|
|
# (ab)using the "jscript" parameter to PutHeader, which inserts an arbitrary
|
2002-04-25 23:43:50 +04:00
|
|
|
# string into the header. This is currently used only in
|
|
|
|
# template/en/default/bug/edit.html.tmpl.
|
2001-09-11 01:26:05 +04:00
|
|
|
sub navigation_links($) {
|
|
|
|
my ($buglist) = @_;
|
|
|
|
|
|
|
|
my $retval = "";
|
|
|
|
|
|
|
|
# We need to be able to pass in a buglist because when you sort on a column
|
|
|
|
# the bugs in the cookie you are given will still be in the old order.
|
|
|
|
# If a buglist isn't passed, we just use the cookie.
|
|
|
|
$buglist ||= $::COOKIE{"BUGLIST"};
|
|
|
|
|
|
|
|
if (defined $buglist && $buglist ne "") {
|
|
|
|
my @bugs = split(/:/, $buglist);
|
|
|
|
|
|
|
|
if (defined $::FORM{'id'}) {
|
|
|
|
# We are on an individual bug
|
|
|
|
my $cur = lsearch(\@bugs, $::FORM{"id"});
|
|
|
|
|
|
|
|
if ($cur > 0) {
|
|
|
|
$retval .= "<link rel=\"First\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
|
|
|
|
$retval .= "<link rel=\"Prev\" href=\"show_bug.cgi?id=$bugs[$cur - 1]\" />\n";
|
|
|
|
}
|
|
|
|
if ($cur < $#bugs) {
|
|
|
|
$retval .= "<link rel=\"Next\" href=\"show_bug.cgi?id=$bugs[$cur + 1]\" />\n";
|
|
|
|
$retval .= "<link rel=\"Last\" href=\"show_bug.cgi?id=$bugs[$#bugs]\" />\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$retval .= "<link rel=\"Up\" href=\"buglist.cgi?regetlastlist=1\" />\n";
|
|
|
|
$retval .= "<link rel=\"Contents\" href=\"buglist.cgi?regetlastlist=1\" />\n";
|
|
|
|
} else {
|
|
|
|
# We are on a bug list
|
|
|
|
$retval .= "<link rel=\"First\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
|
|
|
|
$retval .= "<link rel=\"Next\" href=\"show_bug.cgi?id=$bugs[0]\" />\n";
|
|
|
|
$retval .= "<link rel=\"Last\" href=\"show_bug.cgi?id=$bugs[$#bugs]\" />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
|
|
|
|
1999-12-06 20:09:54 +03:00
|
|
|
$::CheckOptionValues = 1;
|
|
|
|
|
2002-04-25 23:43:50 +04:00
|
|
|
# This sub is still used in reports.cgi.
|
1998-09-16 01:49:26 +04:00
|
|
|
sub make_options {
|
|
|
|
my ($src,$default,$isregexp) = (@_);
|
|
|
|
my $last = "";
|
|
|
|
my $popup = "";
|
|
|
|
my $found = 0;
|
1999-06-11 21:39:19 +04:00
|
|
|
$default = "" if !defined $default;
|
1999-04-27 21:17:49 +04:00
|
|
|
|
|
|
|
if ($src) {
|
|
|
|
foreach my $item (@$src) {
|
|
|
|
if ($item eq "-blank-" || $item ne $last) {
|
|
|
|
if ($item eq "-blank-") {
|
|
|
|
$item = "";
|
|
|
|
}
|
|
|
|
$last = $item;
|
|
|
|
if ($isregexp ? $item =~ $default : $default eq $item) {
|
2001-10-10 08:52:09 +04:00
|
|
|
$popup .= "<OPTION SELECTED VALUE=\"$item\">$item\n";
|
1999-04-27 21:17:49 +04:00
|
|
|
$found = 1;
|
|
|
|
} else {
|
2001-10-10 08:52:09 +04:00
|
|
|
$popup .= "<OPTION VALUE=\"$item\">$item\n";
|
1999-04-27 21:17:49 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$found && $default ne "") {
|
2002-02-05 03:20:09 +03:00
|
|
|
if ( $::CheckOptionValues &&
|
1999-12-03 02:56:07 +03:00
|
|
|
($default ne $::dontchange) && ($default ne "-All-") &&
|
|
|
|
($default ne "DUPLICATE") ) {
|
1999-12-03 02:21:42 +03:00
|
|
|
print "Possible bug database corruption has been detected. " .
|
|
|
|
"Please send mail to " . Param("maintainer") . " with " .
|
|
|
|
"details of what you were doing when this message " .
|
|
|
|
"appeared. Thank you.\n";
|
2000-03-23 21:20:34 +03:00
|
|
|
if (!$src) {
|
|
|
|
$src = ["???null???"];
|
|
|
|
}
|
|
|
|
print "<pre>src = " . value_quote(join(' ', @$src)) . "\n";
|
|
|
|
print "default = " . value_quote($default) . "</pre>";
|
2000-04-28 03:12:44 +04:00
|
|
|
PutFooter();
|
2000-03-10 20:45:09 +03:00
|
|
|
# confess "Gulp.";
|
1999-12-03 02:21:42 +03:00
|
|
|
exit 0;
|
|
|
|
|
|
|
|
} else {
|
2001-10-13 05:36:17 +04:00
|
|
|
$popup .= "<OPTION SELECTED>$default\n";
|
1999-12-03 02:21:42 +03:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
return $popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub PasswordForLogin {
|
|
|
|
my ($login) = (@_);
|
|
|
|
SendSQL("select cryptpassword from profiles where login_name = " .
|
2001-10-13 05:36:17 +04:00
|
|
|
SqlQuote($login));
|
1998-10-13 22:15:37 +04:00
|
|
|
my $result = FetchOneColumn();
|
|
|
|
if (!defined $result) {
|
|
|
|
$result = "";
|
|
|
|
}
|
|
|
|
return $result;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
1999-03-11 19:30:54 +03:00
|
|
|
sub quietly_check_login() {
|
|
|
|
$::usergroupset = '0';
|
|
|
|
my $loginok = 0;
|
2000-01-19 01:41:26 +03:00
|
|
|
$::disabledreason = '';
|
2000-02-17 08:15:23 +03:00
|
|
|
$::userid = 0;
|
1999-03-11 19:30:54 +03:00
|
|
|
if (defined $::COOKIE{"Bugzilla_login"} &&
|
2001-10-13 05:36:17 +04:00
|
|
|
defined $::COOKIE{"Bugzilla_logincookie"}) {
|
1999-03-11 19:30:54 +03:00
|
|
|
ConnectToDatabase();
|
2000-02-17 08:15:23 +03:00
|
|
|
SendSQL("SELECT profiles.userid, profiles.groupset, " .
|
|
|
|
"profiles.login_name, " .
|
1999-05-24 23:42:28 +04:00
|
|
|
"profiles.login_name = " .
|
2001-10-13 05:36:17 +04:00
|
|
|
SqlQuote($::COOKIE{"Bugzilla_login"}) .
|
2002-03-16 09:03:09 +03:00
|
|
|
" AND logincookies.ipaddr = " .
|
|
|
|
SqlQuote($ENV{"REMOTE_ADDR"}) .
|
2000-01-19 01:41:26 +03:00
|
|
|
", profiles.disabledtext " .
|
2001-10-13 05:36:17 +04:00
|
|
|
" FROM profiles, logincookies WHERE logincookies.cookie = " .
|
|
|
|
SqlQuote($::COOKIE{"Bugzilla_logincookie"}) .
|
|
|
|
" AND profiles.userid = logincookies.userid");
|
1999-03-11 19:30:54 +03:00
|
|
|
my @row;
|
|
|
|
if (@row = FetchSQLData()) {
|
2000-02-17 08:15:23 +03:00
|
|
|
my ($userid, $groupset, $loginname, $ok, $disabledtext) = (@row);
|
2000-01-19 01:41:26 +03:00
|
|
|
if ($ok) {
|
|
|
|
if ($disabledtext eq '') {
|
|
|
|
$loginok = 1;
|
2000-02-17 08:15:23 +03:00
|
|
|
$::userid = $userid;
|
2000-01-19 01:41:26 +03:00
|
|
|
$::usergroupset = $groupset;
|
|
|
|
$::COOKIE{"Bugzilla_login"} = $loginname; # Makes sure case
|
|
|
|
# is in
|
|
|
|
# canonical form.
|
2002-01-20 04:44:52 +03:00
|
|
|
# We've just verified that this is ok
|
|
|
|
detaint_natural($::COOKIE{"Bugzilla_logincookie"});
|
2000-01-19 01:41:26 +03:00
|
|
|
} else {
|
|
|
|
$::disabledreason = $disabledtext;
|
|
|
|
}
|
1999-03-11 19:30:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-08 22:12:28 +04:00
|
|
|
# if 'who' is passed in, verify that it's a good value
|
|
|
|
if ($::FORM{'who'}) {
|
|
|
|
my $whoid = DBname_to_id($::FORM{'who'});
|
|
|
|
delete $::FORM{'who'} unless $whoid;
|
|
|
|
}
|
1999-04-27 21:17:49 +04:00
|
|
|
if (!$loginok) {
|
|
|
|
delete $::COOKIE{"Bugzilla_login"};
|
|
|
|
}
|
1999-03-11 19:30:54 +03:00
|
|
|
return $loginok;
|
|
|
|
}
|
|
|
|
|
1999-03-27 05:28:51 +03:00
|
|
|
sub CheckEmailSyntax {
|
|
|
|
my ($addr) = (@_);
|
1999-06-14 21:33:52 +04:00
|
|
|
my $match = Param('emailregexp');
|
2001-07-04 11:06:00 +04:00
|
|
|
if ($addr !~ /$match/ || $addr =~ /[\\\(\)<>&,;:"\[\] \t\r\n]/) {
|
2002-04-29 01:57:10 +04:00
|
|
|
ThrowUserError("The e-mail address you entered(<b>" .
|
|
|
|
html_quote($addr) . "</b>) didn't pass our syntax checking
|
|
|
|
for a legal email address. " . Param('emailregexpdesc') .
|
|
|
|
' It must also not contain any of these special characters:
|
|
|
|
<tt>\ ( ) & < > , ; : " [ ]</tt>, or any whitespace.',
|
|
|
|
"Check e-mail address syntax");
|
1999-03-27 05:28:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-08 02:07:21 +04:00
|
|
|
sub MailPassword {
|
|
|
|
my ($login, $password) = (@_);
|
|
|
|
my $urlbase = Param("urlbase");
|
2000-02-08 01:11:55 +03:00
|
|
|
my $template = Param("passwordmail");
|
|
|
|
my $msg = PerformSubsts($template,
|
|
|
|
{"mailaddress" => $login . Param('emailsuffix'),
|
|
|
|
"login" => $login,
|
|
|
|
"password" => $password});
|
1999-05-08 02:07:21 +04:00
|
|
|
|
2002-02-17 11:22:31 +03:00
|
|
|
open SENDMAIL, "|/usr/lib/sendmail -t -i";
|
1999-05-08 02:07:21 +04:00
|
|
|
print SENDMAIL $msg;
|
|
|
|
close SENDMAIL;
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
sub confirm_login {
|
|
|
|
my ($nexturl) = (@_);
|
|
|
|
|
|
|
|
# Uncommenting the next line can help debugging...
|
|
|
|
# print "Content-type: text/plain\n\n";
|
|
|
|
|
|
|
|
ConnectToDatabase();
|
2000-09-15 22:35:18 +04:00
|
|
|
# I'm going to reorganize some of this stuff a bit. Since we're adding
|
|
|
|
# a second possible validation method (LDAP), we need to move some of this
|
|
|
|
# to a later section. -Joe Robins, 8/3/00
|
|
|
|
my $enteredlogin = "";
|
|
|
|
my $realcryptpwd = "";
|
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
# If the form contains Bugzilla login and password fields, use Bugzilla's
|
|
|
|
# built-in authentication to authenticate the user (otherwise use LDAP below).
|
|
|
|
if (defined $::FORM{"Bugzilla_login"} && defined $::FORM{"Bugzilla_password"}) {
|
|
|
|
# Make sure the user's login name is a valid email address.
|
|
|
|
$enteredlogin = $::FORM{"Bugzilla_login"};
|
|
|
|
CheckEmailSyntax($enteredlogin);
|
|
|
|
|
|
|
|
# Retrieve the user's ID and crypted password from the database.
|
|
|
|
my $userid;
|
|
|
|
SendSQL("SELECT userid, cryptpassword FROM profiles
|
|
|
|
WHERE login_name = " . SqlQuote($enteredlogin));
|
|
|
|
($userid, $realcryptpwd) = FetchSQLData();
|
|
|
|
|
2001-07-16 23:38:34 +04:00
|
|
|
# Make sure the user exists or throw an error (but do not admit it was a username
|
|
|
|
# error to make it harder for a cracker to find account names by brute force).
|
|
|
|
$userid
|
|
|
|
|| DisplayError("The username or password you entered is not valid.")
|
|
|
|
&& exit;
|
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
# If this is a new user, generate a password, insert a record
|
|
|
|
# into the database, and email their password to them.
|
|
|
|
if ( defined $::FORM{"PleaseMailAPassword"} && !$userid ) {
|
2002-04-02 02:52:40 +04:00
|
|
|
# Ensure the new login is valid
|
|
|
|
if(!ValidateNewUser($enteredlogin)) {
|
2002-04-29 01:57:10 +04:00
|
|
|
ThrowUserError("That account already exists.");
|
2002-04-02 02:52:40 +04:00
|
|
|
}
|
|
|
|
|
2001-07-11 09:29:21 +04:00
|
|
|
my $password = InsertNewUser($enteredlogin, "");
|
|
|
|
MailPassword($enteredlogin, $password);
|
2002-04-29 01:57:10 +04:00
|
|
|
|
|
|
|
$vars->{'login'} = $enteredlogin;
|
|
|
|
|
|
|
|
print "Content-Type: text/html\n\n";
|
|
|
|
$template->process("account/created.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2001-07-11 09:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Otherwise, authenticate the user.
|
|
|
|
else {
|
|
|
|
# Get the salt from the user's crypted password.
|
|
|
|
my $salt = $realcryptpwd;
|
|
|
|
|
|
|
|
# Using the salt, crypt the password the user entered.
|
|
|
|
my $enteredCryptedPassword = crypt( $::FORM{"Bugzilla_password"} , $salt );
|
|
|
|
|
|
|
|
# Make sure the passwords match or throw an error.
|
|
|
|
($enteredCryptedPassword eq $realcryptpwd)
|
|
|
|
|| DisplayError("The username or password you entered is not valid.")
|
|
|
|
&& exit;
|
|
|
|
|
|
|
|
# If the user has successfully logged in, delete any password tokens
|
|
|
|
# lying around in the system for them.
|
|
|
|
use Token;
|
|
|
|
my $token = Token::HasPasswordToken($userid);
|
|
|
|
while ( $token ) {
|
|
|
|
Token::Cancel($token, "user logged in");
|
|
|
|
$token = Token::HasPasswordToken($userid);
|
|
|
|
}
|
|
|
|
}
|
2000-09-15 22:35:18 +04:00
|
|
|
|
|
|
|
} elsif (Param("useLDAP") &&
|
|
|
|
defined $::FORM{"LDAP_login"} &&
|
|
|
|
defined $::FORM{"LDAP_password"}) {
|
|
|
|
# If we're using LDAP for login, we've got an entirely different
|
|
|
|
# set of things to check.
|
2000-10-24 04:44:21 +04:00
|
|
|
|
|
|
|
# see comment at top of file near eval
|
2000-09-15 22:35:18 +04:00
|
|
|
# First, if we don't have the LDAP modules available to us, we can't
|
|
|
|
# do this.
|
2000-10-24 04:44:21 +04:00
|
|
|
# if(!$have_ldap) {
|
|
|
|
# print "Content-type: text/html\n\n";
|
|
|
|
# PutHeader("LDAP not enabled");
|
|
|
|
# print "The necessary modules for LDAP login are not installed on ";
|
|
|
|
# print "this machine. Please send mail to ".Param("maintainer");
|
|
|
|
# print " and notify him of this problem.\n";
|
|
|
|
# PutFooter();
|
|
|
|
# exit;
|
|
|
|
# }
|
2000-09-15 22:35:18 +04:00
|
|
|
|
|
|
|
# Next, we need to bind anonymously to the LDAP server. This is
|
|
|
|
# because we need to get the Distinguished Name of the user trying
|
|
|
|
# to log in. Some servers (such as iPlanet) allow you to have unique
|
|
|
|
# uids spread out over a subtree of an area (such as "People"), so
|
|
|
|
# just appending the Base DN to the uid isn't sufficient to get the
|
|
|
|
# user's DN. For servers which don't work this way, there will still
|
|
|
|
# be no harm done.
|
|
|
|
my $LDAPserver = Param("LDAPserver");
|
|
|
|
if ($LDAPserver eq "") {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("LDAP server not defined");
|
|
|
|
print "The LDAP server for authentication has not been defined. ";
|
|
|
|
print "Please contact ".Param("maintainer")." ";
|
|
|
|
print "and notify him of this problem.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $LDAPport = "389"; #default LDAP port
|
|
|
|
if($LDAPserver =~ /:/) {
|
|
|
|
($LDAPserver, $LDAPport) = split(":",$LDAPserver);
|
|
|
|
}
|
|
|
|
my $LDAPconn = new Mozilla::LDAP::Conn($LDAPserver,$LDAPport);
|
|
|
|
if(!$LDAPconn) {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Unable to connect to LDAP server");
|
|
|
|
print "I was unable to connect to the LDAP server for user ";
|
|
|
|
print "authentication. Please contact ".Param("maintainer");
|
|
|
|
print " and notify him of this problem.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:56:23 +03:00
|
|
|
# if no password was provided, then fail the authentication
|
|
|
|
# while it may be valid to not have an LDAP password, when you
|
|
|
|
# bind without a password (regardless of the binddn value), you
|
|
|
|
# will get an anonymous bind. I do not know of a way to determine
|
|
|
|
# whether a bind is anonymous or not without making changes to the
|
|
|
|
# LDAP access control settings
|
|
|
|
if ( ! $::FORM{"LDAP_password"} ) {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Login Failed");
|
|
|
|
print "You did not provide a password.\n";
|
|
|
|
print "Please click <b>Back</b> and try again.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2000-09-15 22:35:18 +04:00
|
|
|
# We've got our anonymous bind; let's look up this user.
|
|
|
|
my $dnEntry = $LDAPconn->search(Param("LDAPBaseDN"),"subtree","uid=".$::FORM{"LDAP_login"});
|
|
|
|
if(!$dnEntry) {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Login Failed");
|
|
|
|
print "The username or password you entered is not valid.\n";
|
|
|
|
print "Please click <b>Back</b> and try again.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now we get the DN from this search. Once we've got that, we're
|
|
|
|
# done with the anonymous bind, so we close it.
|
|
|
|
my $userDN = $dnEntry->getDN;
|
|
|
|
$LDAPconn->close;
|
|
|
|
|
|
|
|
# Now we attempt to bind as the specified user.
|
|
|
|
$LDAPconn = new Mozilla::LDAP::Conn($LDAPserver,$LDAPport,$userDN,$::FORM{"LDAP_password"});
|
|
|
|
if(!$LDAPconn) {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Login Failed");
|
|
|
|
print "The username or password you entered is not valid.\n";
|
|
|
|
print "Please click <b>Back</b> and try again.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# And now we're going to repeat the search, so that we can get the
|
|
|
|
# mail attribute for this user.
|
|
|
|
my $userEntry = $LDAPconn->search(Param("LDAPBaseDN"),"subtree","uid=".$::FORM{"LDAP_login"});
|
|
|
|
if(!$userEntry->exists(Param("LDAPmailattribute"))) {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("LDAP authentication error");
|
|
|
|
print "I was unable to retrieve the ".Param("LDAPmailattribute");
|
|
|
|
print " attribute from the LDAP server. Please contact ";
|
|
|
|
print Param("maintainer")." and notify him of this error.\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Mozilla::LDAP::Entry->getValues returns an array for the attribute
|
|
|
|
# requested, even if there's only one entry.
|
|
|
|
$enteredlogin = ($userEntry->getValues(Param("LDAPmailattribute")))[0];
|
|
|
|
|
|
|
|
# We're going to need the cryptpwd for this user from the database
|
|
|
|
# so that we can set the cookie below, even though we're not going
|
|
|
|
# to use it for authentication.
|
|
|
|
$realcryptpwd = PasswordForLogin($enteredlogin);
|
|
|
|
|
|
|
|
# If we don't get a result, then we've got a user who isn't in
|
|
|
|
# Bugzilla's database yet, so we've got to add them.
|
|
|
|
if($realcryptpwd eq "") {
|
|
|
|
# We'll want the user's name for this.
|
|
|
|
my $userRealName = ($userEntry->getValues("displayName"))[0];
|
|
|
|
if($userRealName eq "") {
|
|
|
|
$userRealName = ($userEntry->getValues("cn"))[0];
|
|
|
|
}
|
|
|
|
InsertNewUser($enteredlogin, $userRealName);
|
|
|
|
$realcryptpwd = PasswordForLogin($enteredlogin);
|
|
|
|
}
|
|
|
|
} # end LDAP authentication
|
|
|
|
|
|
|
|
# And now, if we've logged in via either method, then we need to set
|
|
|
|
# the cookies.
|
|
|
|
if($enteredlogin ne "") {
|
|
|
|
$::COOKIE{"Bugzilla_login"} = $enteredlogin;
|
2002-03-16 09:03:09 +03:00
|
|
|
SendSQL("insert into logincookies (userid,ipaddr) values (@{[DBNameToIdAndCheck($enteredlogin)]}, @{[SqlQuote($ENV{'REMOTE_ADDR'})]})");
|
2000-09-15 22:35:18 +04:00
|
|
|
SendSQL("select LAST_INSERT_ID()");
|
|
|
|
my $logincookie = FetchOneColumn();
|
|
|
|
|
|
|
|
$::COOKIE{"Bugzilla_logincookie"} = $logincookie;
|
2001-10-13 04:40:41 +04:00
|
|
|
my $cookiepath = Param("cookiepath");
|
|
|
|
print "Set-Cookie: Bugzilla_login=$enteredlogin ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
|
|
|
|
print "Set-Cookie: Bugzilla_logincookie=$logincookie ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
1999-03-11 19:30:54 +03:00
|
|
|
my $loginok = quietly_check_login();
|
1998-09-16 01:49:26 +04:00
|
|
|
|
1999-03-11 19:30:54 +03:00
|
|
|
if ($loginok != 1) {
|
2000-01-19 01:41:26 +03:00
|
|
|
if ($::disabledreason) {
|
2001-10-13 04:40:41 +04:00
|
|
|
my $cookiepath = Param("cookiepath");
|
|
|
|
print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT
|
|
|
|
Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT
|
2000-01-19 01:41:26 +03:00
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
";
|
2002-04-29 01:57:10 +04:00
|
|
|
ThrowUserError($::disabledreason . "<hr>" .
|
|
|
|
"If you believe your account should be restored, please " .
|
|
|
|
"send email to " . Param("maintainer") . " explaining why.",
|
|
|
|
"Your account has been disabled");
|
2000-01-19 01:41:26 +03:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
print "Content-type: text/html\n\n";
|
2001-08-13 23:11:35 +04:00
|
|
|
PutHeader("Login");
|
2000-09-15 22:35:18 +04:00
|
|
|
if(Param("useLDAP")) {
|
|
|
|
print "I need a legitimate LDAP username and password to continue.\n";
|
|
|
|
} else {
|
|
|
|
print "I need a legitimate e-mail address and password to continue.\n";
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
if (!defined $nexturl || $nexturl eq "") {
|
2001-10-13 05:36:17 +04:00
|
|
|
# Sets nexturl to be argv0, stripping everything up to and
|
|
|
|
# including the last slash (or backslash on Windows).
|
|
|
|
$0 =~ m:[^/\\]*$:;
|
|
|
|
$nexturl = $&;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
my $method = "POST";
|
2001-06-08 00:26:40 +04:00
|
|
|
# We always want to use POST here, because we're submitting a password and don't
|
|
|
|
# want to see it in the location bar in the browser in case a co-worker is looking
|
|
|
|
# over your shoulder. If you have cookies off and need to bookmark the query, you
|
|
|
|
# can bookmark it from the screen asking for your password, and it should still
|
|
|
|
# work. See http://bugzilla.mozilla.org/show_bug.cgi?id=15980
|
|
|
|
# if (defined $ENV{"REQUEST_METHOD"} && length($::buffer) > 1) {
|
|
|
|
# $method = $ENV{"REQUEST_METHOD"};
|
|
|
|
# }
|
1998-09-16 01:49:26 +04:00
|
|
|
print "
|
|
|
|
<FORM action=$nexturl method=$method>
|
|
|
|
<table>
|
2000-09-15 22:35:18 +04:00
|
|
|
<tr>";
|
|
|
|
if(Param("useLDAP")) {
|
|
|
|
print "
|
|
|
|
<td align=right><b>Username:</b></td>
|
|
|
|
<td><input size=10 name=LDAP_login></td>
|
|
|
|
</tr>
|
1998-09-16 01:49:26 +04:00
|
|
|
<tr>
|
2000-09-15 22:35:18 +04:00
|
|
|
<td align=right><b>Password:</b></td>
|
|
|
|
<td><input type=password size=10 name=LDAP_password></td>";
|
|
|
|
} else {
|
|
|
|
print "
|
1998-09-16 01:49:26 +04:00
|
|
|
<td align=right><b>E-mail address:</b></td>
|
|
|
|
<td><input size=35 name=Bugzilla_login></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right><b>Password:</b></td>
|
2000-09-15 22:35:18 +04:00
|
|
|
<td><input type=password size=35 name=Bugzilla_password></td>";
|
|
|
|
}
|
|
|
|
print "
|
1998-09-16 01:49:26 +04:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
";
|
2001-07-11 09:29:21 +04:00
|
|
|
# Add all the form fields into the form as hidden fields
|
|
|
|
# (except for Bugzilla_login and Bugzilla_password which we
|
|
|
|
# already added as text fields above).
|
|
|
|
foreach my $i ( grep( $_ !~ /^Bugzilla_/ , keys %::FORM ) ) {
|
2002-01-23 01:23:21 +03:00
|
|
|
if (defined $::MFORM{$i} && scalar(@{$::MFORM{$i}}) > 1) {
|
2001-10-13 01:33:21 +04:00
|
|
|
# This field has multiple values; add each one separately.
|
|
|
|
foreach my $val (@{$::MFORM{$i}}) {
|
|
|
|
print qq|<input type="hidden" name="$i" value="@{[value_quote($val)]}">\n|;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# This field has a single value; add it.
|
2001-07-11 09:29:21 +04:00
|
|
|
print qq|<input type="hidden" name="$i" value="@{[value_quote($::FORM{$i})]}">\n|;
|
2001-10-13 01:33:21 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
2001-07-11 09:29:21 +04:00
|
|
|
|
|
|
|
print qq|
|
|
|
|
<input type="submit" name="GoAheadAndLogIn" value="Login">
|
|
|
|
</form>
|
|
|
|
|;
|
|
|
|
|
|
|
|
# Allow the user to request a token to change their password (unless
|
|
|
|
# we are using LDAP, in which case the user must use LDAP to change it).
|
|
|
|
unless( Param("useLDAP") ) {
|
|
|
|
print qq|
|
|
|
|
<hr>
|
2001-10-15 07:59:19 +04:00
|
|
|
<p>If you don't have a Bugzilla account, you can
|
|
|
|
<a href="createaccount.cgi">create a new account</a>.</p>
|
2001-07-11 09:29:21 +04:00
|
|
|
<form method="get" action="token.cgi">
|
|
|
|
<input type="hidden" name="a" value="reqpw">
|
2001-10-15 07:59:19 +04:00
|
|
|
If you have an account, but have forgotten your password,
|
2001-07-11 09:29:21 +04:00
|
|
|
enter your login name below and submit a request
|
|
|
|
to change your password.<br>
|
|
|
|
<input size="35" name="loginname">
|
|
|
|
<input type="submit" value="Submit Request">
|
|
|
|
</form>
|
2001-08-16 10:43:21 +04:00
|
|
|
<hr>
|
2001-07-11 09:29:21 +04:00
|
|
|
|;
|
2000-09-15 22:35:18 +04:00
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
# This seems like as good as time as any to get rid of old
|
|
|
|
# crufty junk in the logincookies table. Get rid of any entry
|
|
|
|
# that hasn't been used in a month.
|
2000-02-18 00:41:39 +03:00
|
|
|
if ($::dbwritesallowed) {
|
|
|
|
SendSQL("DELETE FROM logincookies " .
|
|
|
|
"WHERE TO_DAYS(NOW()) - TO_DAYS(lastused) > 30");
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
|
|
|
|
|
2000-01-15 01:35:49 +03:00
|
|
|
PutFooter();
|
1998-09-16 01:49:26 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Update the timestamp on our logincookie, so it'll keep on working.
|
2000-02-18 00:41:39 +03:00
|
|
|
if ($::dbwritesallowed) {
|
|
|
|
SendSQL("UPDATE logincookies SET lastused = null " .
|
|
|
|
"WHERE cookie = $::COOKIE{'Bugzilla_logincookie'}");
|
|
|
|
}
|
2000-02-17 08:15:23 +03:00
|
|
|
return $::userid;
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub PutHeader {
|
2002-04-29 01:57:10 +04:00
|
|
|
($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'},
|
|
|
|
$vars->{'extra'}, $vars->{'jscript'}) = (@_);
|
|
|
|
|
|
|
|
$::template->process("global/header.html.tmpl", $::vars)
|
|
|
|
|| ThrowTemplateError($::template->error());
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
|
2000-01-15 01:35:49 +03:00
|
|
|
sub PutFooter {
|
2002-04-29 01:57:10 +04:00
|
|
|
$::template->process("global/footer.html.tmpl", $::vars)
|
|
|
|
|| ThrowTemplateError($::template->error());
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
###############################################################################
|
|
|
|
# Error handling
|
|
|
|
#
|
|
|
|
# If you are doing incremental output, set $vars->{'header_done'} once you've
|
|
|
|
# done the header.
|
|
|
|
###############################################################################
|
|
|
|
|
2002-04-06 00:03:09 +04:00
|
|
|
# DisplayError is deprecated. Use ThrowCodeError, ThrowUserError or
|
|
|
|
# ThrowTemplateError instead.
|
2001-05-10 06:53:22 +04:00
|
|
|
sub DisplayError {
|
2002-04-04 03:00:29 +04:00
|
|
|
($vars->{'error'}, $vars->{'title'}) = (@_);
|
|
|
|
$vars->{'title'} ||= "Error";
|
|
|
|
|
|
|
|
print "Content-type: text/html\n\n" if !$vars->{'header_done'};
|
|
|
|
$template->process("global/user-error.html.tmpl", $vars)
|
2002-04-06 00:03:09 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-04 03:00:29 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# For "this shouldn't happen"-type places in the code.
|
|
|
|
# $vars->{'variables'} is a reference to a hash of useful debugging info.
|
2002-04-06 00:03:09 +04:00
|
|
|
sub ThrowCodeError {
|
2002-04-26 10:13:41 +04:00
|
|
|
($vars->{'error'}, $vars->{'variables'}, my $unlock_tables) = (@_);
|
2002-04-04 03:00:29 +04:00
|
|
|
$vars->{'title'} = "Code Error";
|
|
|
|
|
2002-04-26 10:13:41 +04:00
|
|
|
SendSQL("UNLOCK TABLES") if $unlock_tables;
|
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
# We may optionally log something to file here.
|
2002-03-12 16:55:07 +03:00
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
print "Content-type: text/html\n\n" if !$vars->{'header_done'};
|
|
|
|
$template->process("global/code-error.html.tmpl", $vars)
|
2002-04-06 00:03:09 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-04 03:00:29 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
2001-05-10 06:53:22 +04:00
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
# For errors made by the user.
|
2002-04-06 00:03:09 +04:00
|
|
|
sub ThrowUserError {
|
2002-04-04 03:00:29 +04:00
|
|
|
($vars->{'error'}, $vars->{'title'}, my $unlock_tables) = (@_);
|
|
|
|
$vars->{'title'} ||= "Error";
|
2001-05-10 06:53:22 +04:00
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
SendSQL("UNLOCK TABLES") if $unlock_tables;
|
|
|
|
|
|
|
|
print "Content-type: text/html\n\n" if !$vars->{'header_done'};
|
|
|
|
$template->process("global/user-error.html.tmpl", $vars)
|
2002-04-06 00:03:09 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
2002-04-04 03:00:29 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
2001-05-10 06:53:22 +04:00
|
|
|
|
2002-04-06 00:03:09 +04:00
|
|
|
# If the template system isn't working, we can't use a template.
|
|
|
|
# This should only be called if a template->process() fails.
|
2002-04-04 03:00:29 +04:00
|
|
|
# The Content-Type will already have been printed.
|
2002-04-06 00:03:09 +04:00
|
|
|
sub ThrowTemplateError {
|
2002-04-04 03:00:29 +04:00
|
|
|
my ($error) = html_quote((@_));
|
2002-04-06 00:03:09 +04:00
|
|
|
my $maintainer = Param('maintainer');
|
2002-04-04 03:00:29 +04:00
|
|
|
|
2002-04-06 00:03:09 +04:00
|
|
|
print <<END;
|
|
|
|
<tt>
|
|
|
|
<p>
|
|
|
|
Bugzilla has suffered an internal error. Please save this page and send
|
|
|
|
it to $maintainer with details of what you were doing at the time this
|
|
|
|
message appeared.
|
|
|
|
</p>
|
|
|
|
<script> <!--
|
|
|
|
document.write("<p>URL: " + document.location + "</p>");
|
|
|
|
// -->
|
|
|
|
</script>
|
|
|
|
<p>Template->process() failed: $error</p>
|
|
|
|
</tt>
|
|
|
|
END
|
|
|
|
|
2002-04-04 03:00:29 +04:00
|
|
|
exit;
|
2001-05-10 06:53:22 +04:00
|
|
|
}
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
sub CheckIfVotedConfirmed {
|
|
|
|
my ($id, $who) = (@_);
|
|
|
|
SendSQL("SELECT bugs.votes, bugs.bug_status, products.votestoconfirm, " .
|
|
|
|
" bugs.everconfirmed " .
|
|
|
|
"FROM bugs, products " .
|
|
|
|
"WHERE bugs.bug_id = $id AND products.product = bugs.product");
|
|
|
|
my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData());
|
|
|
|
if ($votes >= $votestoconfirm && $status eq $::unconfirmedstate) {
|
|
|
|
SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " .
|
|
|
|
"WHERE bug_id = $id");
|
|
|
|
my $fieldid = GetFieldID("bug_status");
|
|
|
|
SendSQL("INSERT INTO bugs_activity " .
|
2001-07-20 19:18:30 +04:00
|
|
|
"(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
|
2000-02-17 08:15:23 +03:00
|
|
|
"($id,$who,now(),$fieldid,'$::unconfirmedstate','NEW')");
|
|
|
|
if (!$everconfirmed) {
|
|
|
|
$fieldid = GetFieldID("everconfirmed");
|
|
|
|
SendSQL("INSERT INTO bugs_activity " .
|
2001-07-20 19:18:30 +04:00
|
|
|
"(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
|
2000-02-17 08:15:23 +03:00
|
|
|
"($id,$who,now(),$fieldid,'0','1')");
|
|
|
|
}
|
2002-04-29 01:57:10 +04:00
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
AppendComment($id, DBID_to_name($who),
|
|
|
|
"*** This bug has been confirmed by popular vote. ***");
|
2002-04-29 01:57:10 +04:00
|
|
|
|
|
|
|
$vars->{'type'} = "votes";
|
|
|
|
$vars->{'id'} = $id;
|
|
|
|
$vars->{'mail'} = "";
|
|
|
|
open(PMAIL, "-|") or exec('./processmail', $id);
|
|
|
|
$vars->{'mail'} .= $_ while <PMAIL>;
|
|
|
|
close(PMAIL);
|
|
|
|
|
|
|
|
$template->process("bug/process/results.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:54:18 +04:00
|
|
|
sub GetBugActivity {
|
1999-05-25 23:22:31 +04:00
|
|
|
my ($id, $starttime) = (@_);
|
|
|
|
my $datepart = "";
|
2000-03-07 21:23:00 +03:00
|
|
|
|
|
|
|
die "Invalid id: $id" unless $id=~/^\s*\d+\s*$/;
|
|
|
|
|
1999-05-25 23:22:31 +04:00
|
|
|
if (defined $starttime) {
|
2001-11-27 18:04:52 +03:00
|
|
|
$datepart = "and bugs_activity.bug_when > " . SqlQuote($starttime);
|
1999-05-25 23:22:31 +04:00
|
|
|
}
|
2002-04-03 22:54:18 +04:00
|
|
|
|
1999-05-25 23:22:31 +04:00
|
|
|
my $query = "
|
2001-08-31 07:54:37 +04:00
|
|
|
SELECT IFNULL(fielddefs.description, bugs_activity.fieldid),
|
|
|
|
bugs_activity.attach_id,
|
2000-01-23 00:43:30 +03:00
|
|
|
bugs_activity.bug_when,
|
2001-07-20 19:18:30 +04:00
|
|
|
bugs_activity.removed, bugs_activity.added,
|
1999-05-25 23:22:31 +04:00
|
|
|
profiles.login_name
|
2000-01-23 00:43:30 +03:00
|
|
|
FROM bugs_activity LEFT JOIN fielddefs ON
|
|
|
|
bugs_activity.fieldid = fielddefs.fieldid,
|
|
|
|
profiles
|
2000-01-22 07:24:42 +03:00
|
|
|
WHERE bugs_activity.bug_id = $id $datepart
|
|
|
|
AND profiles.userid = bugs_activity.who
|
|
|
|
ORDER BY bugs_activity.bug_when";
|
1999-05-25 23:22:31 +04:00
|
|
|
|
|
|
|
SendSQL($query);
|
|
|
|
|
2002-04-03 22:54:18 +04:00
|
|
|
my @operations;
|
|
|
|
my $operation = {};
|
|
|
|
my $changes = [];
|
2001-08-09 10:12:18 +04:00
|
|
|
my $incomplete_data = 0;
|
2002-04-03 22:54:18 +04:00
|
|
|
|
|
|
|
while (my ($field, $attachid, $when, $removed, $added, $who)
|
|
|
|
= FetchSQLData())
|
|
|
|
{
|
|
|
|
my %change;
|
|
|
|
|
|
|
|
# This gets replaced with a hyperlink in the template.
|
|
|
|
$field =~ s/^Attachment// if $attachid;
|
|
|
|
|
|
|
|
# Check for the results of an old Bugzilla data corruption bug
|
|
|
|
$incomplete_data = 1 if ($added =~ /^\?/ || $removed =~ /^\?/);
|
|
|
|
|
|
|
|
# An operation, done by 'who' at time 'when', has a number of
|
|
|
|
# 'changes' associated with it.
|
|
|
|
# If this is the start of a new operation, store the data from the
|
|
|
|
# previous one, and set up the new one.
|
|
|
|
if ($operation->{'who'}
|
|
|
|
&& ($who ne $operation->{'who'}
|
|
|
|
|| $when ne $operation->{'when'}))
|
|
|
|
{
|
|
|
|
$operation->{'changes'} = $changes;
|
|
|
|
push (@operations, $operation);
|
|
|
|
|
|
|
|
# Create new empty anonymous data structures.
|
|
|
|
$operation = {};
|
|
|
|
$changes = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$operation->{'who'} = $who;
|
|
|
|
$operation->{'when'} = $when;
|
|
|
|
|
|
|
|
$change{'field'} = $field;
|
|
|
|
$change{'attachid'} = $attachid;
|
|
|
|
$change{'removed'} = $removed;
|
|
|
|
$change{'added'} = $added;
|
|
|
|
push (@$changes, \%change);
|
2001-08-09 10:12:18 +04:00
|
|
|
}
|
2002-04-03 22:54:18 +04:00
|
|
|
|
|
|
|
if ($operation->{'who'}) {
|
|
|
|
$operation->{'changes'} = $changes;
|
|
|
|
push (@operations, $operation);
|
1999-05-25 23:22:31 +04:00
|
|
|
}
|
2002-04-03 22:54:18 +04:00
|
|
|
|
|
|
|
return(\@operations, $incomplete_data);
|
1999-05-25 23:22:31 +04:00
|
|
|
}
|
|
|
|
|
2000-01-15 01:35:49 +03:00
|
|
|
sub GetCommandMenu {
|
|
|
|
my $loggedin = quietly_check_login();
|
2001-09-28 23:17:27 +04:00
|
|
|
if (!defined $::anyvotesallowed) {
|
|
|
|
GetVersionTable();
|
|
|
|
}
|
2001-10-11 03:36:29 +04:00
|
|
|
my $html = qq {
|
|
|
|
<FORM METHOD="GET" ACTION="show_bug.cgi">
|
2001-03-11 01:06:57 +03:00
|
|
|
<TABLE width="100%"><TR><TD>
|
2001-02-22 05:20:58 +03:00
|
|
|
Actions:
|
2001-03-11 01:06:57 +03:00
|
|
|
</TD><TD VALIGN="middle" NOWRAP>
|
2001-10-11 03:36:29 +04:00
|
|
|
<a href="enter_bug.cgi">New</a> |
|
|
|
|
<a href="query.cgi">Query</a> |
|
|
|
|
};
|
2001-02-22 05:20:58 +03:00
|
|
|
|
2000-01-15 01:35:49 +03:00
|
|
|
if (-e "query2.cgi") {
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= "[<a href=\"query2.cgi\">beta</a>]";
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
|
|
|
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= qq{
|
|
|
|
<INPUT TYPE="SUBMIT" VALUE="Find"> bug \#
|
|
|
|
<INPUT NAME="id" SIZE="6">
|
|
|
|
| <a href="reports.cgi">Reports</a>
|
|
|
|
};
|
2001-03-10 08:52:54 +03:00
|
|
|
if ($loggedin) {
|
|
|
|
if ($::anyvotesallowed) {
|
2002-04-06 02:42:26 +04:00
|
|
|
$html .= " | <A HREF=\"votes.cgi?action=show_user\">My votes</A>\n";
|
2001-03-10 08:52:54 +03:00
|
|
|
}
|
2001-03-11 01:06:57 +03:00
|
|
|
}
|
2000-01-15 01:35:49 +03:00
|
|
|
if ($loggedin) {
|
2001-10-13 05:36:17 +04:00
|
|
|
#a little mandatory SQL, used later on
|
2000-02-17 18:52:12 +03:00
|
|
|
SendSQL("SELECT mybugslink, userid, blessgroupset FROM profiles " .
|
|
|
|
"WHERE login_name = " . SqlQuote($::COOKIE{'Bugzilla_login'}));
|
|
|
|
my ($mybugslink, $userid, $blessgroupset) = (FetchSQLData());
|
2001-02-22 05:20:58 +03:00
|
|
|
|
|
|
|
#Begin settings
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= qq{
|
|
|
|
</TD><TD>
|
|
|
|
|
|
|
|
</TD><TD VALIGN="middle">
|
|
|
|
Edit <a href="userprefs.cgi">prefs</a>
|
|
|
|
};
|
2000-01-15 01:35:49 +03:00
|
|
|
if (UserInGroup("tweakparams")) {
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= ", <a href=\"editparams.cgi\">parameters</a>\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
2000-02-17 18:52:12 +03:00
|
|
|
if (UserInGroup("editusers") || $blessgroupset) {
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= ", <a href=\"editusers.cgi\">users</a>\n";
|
2000-01-18 21:34:01 +03:00
|
|
|
}
|
2000-01-15 01:35:49 +03:00
|
|
|
if (UserInGroup("editcomponents")) {
|
2001-11-18 06:22:50 +03:00
|
|
|
$html .= ", <a href=\"editproducts.cgi\">products</a>\n";
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= ", <a href=\"editattachstatuses.cgi\">
|
2002-01-30 17:14:12 +03:00
|
|
|
attachment statuses</a>\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
2000-04-26 23:35:51 +04:00
|
|
|
if (UserInGroup("creategroups")) {
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= ", <a href=\"editgroups.cgi\">groups</a>\n";
|
2000-04-26 23:35:51 +04:00
|
|
|
}
|
2000-01-15 01:35:49 +03:00
|
|
|
if (UserInGroup("editkeywords")) {
|
2001-10-11 23:07:00 +04:00
|
|
|
$html .= ", <a href=\"editkeywords.cgi\">keywords</a>\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
2001-09-06 06:19:04 +04:00
|
|
|
if (UserInGroup("tweakparams")) {
|
2001-10-26 22:49:33 +04:00
|
|
|
$html .= "| <a href=\"sanitycheck.cgi\">Sanity check</a>\n";
|
2001-09-06 06:19:04 +04:00
|
|
|
}
|
|
|
|
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= qq{
|
|
|
|
| <a href="relogin.cgi">Log out</a> $::COOKIE{'Bugzilla_login'}
|
|
|
|
</TD></TR>
|
|
|
|
};
|
2001-02-22 05:20:58 +03:00
|
|
|
|
2001-10-13 05:36:17 +04:00
|
|
|
#begin preset queries
|
2001-02-22 05:20:58 +03:00
|
|
|
my $mybugstemplate = Param("mybugstemplate");
|
|
|
|
my %substs;
|
|
|
|
$substs{'userid'} = url_quote($::COOKIE{"Bugzilla_login"});
|
2001-10-06 04:03:00 +04:00
|
|
|
$html .= "<TR>";
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= "<TD>Preset Queries: </TD>";
|
2001-03-11 01:06:57 +03:00
|
|
|
$html .= "<TD colspan=3>\n";
|
2001-02-22 05:20:58 +03:00
|
|
|
if ($mybugslink) {
|
|
|
|
my $mybugsurl = PerformSubsts($mybugstemplate, \%substs);
|
2001-10-11 03:36:29 +04:00
|
|
|
$html = $html . "<A HREF=\"$mybugsurl\">My bugs</A>\n";
|
2001-02-22 05:20:58 +03:00
|
|
|
}
|
|
|
|
SendSQL("SELECT name FROM namedqueries " .
|
|
|
|
"WHERE userid = $userid AND linkinfooter");
|
2001-03-11 01:06:57 +03:00
|
|
|
my $anynamedqueries = 0;
|
2001-02-22 05:20:58 +03:00
|
|
|
while (MoreSQLData()) {
|
|
|
|
my ($name) = (FetchSQLData());
|
2001-10-11 23:51:33 +04:00
|
|
|
my $disp_name = $name;
|
|
|
|
$disp_name =~ s/ / /g;
|
2001-03-11 01:06:57 +03:00
|
|
|
if ($anynamedqueries || $mybugslink) { $html .= " | " }
|
|
|
|
$anynamedqueries = 1;
|
2001-10-11 03:36:29 +04:00
|
|
|
$html .= "<A HREF=\"buglist.cgi?cmdtype=runnamed&namedcmd=" .
|
2001-10-11 23:51:33 +04:00
|
|
|
url_quote($name) . "\">$disp_name</A>\n";
|
2001-02-22 05:20:58 +03:00
|
|
|
}
|
2001-10-06 04:03:00 +04:00
|
|
|
$html .= "</TD></TR>\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
} else {
|
2001-10-11 23:07:00 +04:00
|
|
|
$html .= "</TD><TD> </TD><TD valign=\"middle\" align=\"right\">\n";
|
2000-01-25 10:54:57 +03:00
|
|
|
$html .=
|
2001-10-11 03:36:29 +04:00
|
|
|
" <a href=\"createaccount.cgi\">New account</a>\n";
|
2000-01-25 10:54:57 +03:00
|
|
|
$html .=
|
2001-10-11 03:36:29 +04:00
|
|
|
" | <a href=\"query.cgi?GoAheadAndLogIn=1\">Log in</a>";
|
2001-02-22 05:20:58 +03:00
|
|
|
$html .= "</TD></TR>";
|
2000-01-15 01:35:49 +03:00
|
|
|
}
|
2001-02-22 05:20:58 +03:00
|
|
|
$html .= "</TABLE>";
|
2001-10-06 04:03:00 +04:00
|
|
|
$html .= "</FORM>\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
############# Live code below here (that is, not subroutine defs) #############
|
|
|
|
|
|
|
|
$| = 1;
|
|
|
|
|
|
|
|
# Uncommenting this next line can help debugging.
|
|
|
|
# print "Content-type: text/html\n\nHello mom\n";
|
|
|
|
|
|
|
|
# foreach my $k (sort(keys %ENV)) {
|
|
|
|
# print "$k $ENV{$k}<br>\n";
|
|
|
|
# }
|
|
|
|
|
|
|
|
if (defined $ENV{"REQUEST_METHOD"}) {
|
|
|
|
if ($ENV{"REQUEST_METHOD"} eq "GET") {
|
|
|
|
if (defined $ENV{"QUERY_STRING"}) {
|
|
|
|
$::buffer = $ENV{"QUERY_STRING"};
|
|
|
|
} else {
|
|
|
|
$::buffer = "";
|
|
|
|
}
|
1999-04-08 18:40:46 +04:00
|
|
|
ProcessFormFields $::buffer;
|
1998-09-16 01:49:26 +04:00
|
|
|
} else {
|
2000-03-31 03:56:36 +04:00
|
|
|
if (exists($ENV{"CONTENT_TYPE"}) && $ENV{"CONTENT_TYPE"} =~
|
1999-04-08 18:40:46 +04:00
|
|
|
m@multipart/form-data; boundary=\s*([^; ]+)@) {
|
|
|
|
ProcessMultipartFormFields($1);
|
|
|
|
$::buffer = "";
|
|
|
|
} else {
|
|
|
|
read STDIN, $::buffer, $ENV{"CONTENT_LENGTH"} ||
|
|
|
|
die "Couldn't get form data";
|
|
|
|
ProcessFormFields $::buffer;
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined $ENV{"HTTP_COOKIE"}) {
|
2002-01-20 04:44:52 +03:00
|
|
|
# Don't trust anything which came in as a cookie
|
|
|
|
use re 'taint';
|
1998-09-16 01:49:26 +04:00
|
|
|
foreach my $pair (split(/;/, $ENV{"HTTP_COOKIE"})) {
|
2001-10-13 05:36:17 +04:00
|
|
|
$pair = trim($pair);
|
|
|
|
if ($pair =~ /^([^=]*)=(.*)$/) {
|
|
|
|
$::COOKIE{$1} = $2;
|
|
|
|
} else {
|
|
|
|
$::COOKIE{$pair} = "";
|
|
|
|
}
|
1998-09-16 01:49:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|