Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
bcfde177
Commit
bcfde177
authored
Jul 14, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 283989: CGI.pl global init code should be moved to Bugzilla::CGI
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wurblzap, a=justdave
parent
bf0a551f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
26 deletions
+104
-26
Bugzilla.pm
Bugzilla.pm
+53
-0
CGI.pm
Bugzilla/CGI.pm
+9
-0
Util.pm
Bugzilla/Util.pm
+16
-0
CGI.pl
CGI.pl
+0
-26
message.txt.tmpl
template/en/default/global/message.txt.tmpl
+26
-0
No files found.
Bugzilla.pm
View file @
bcfde177
...
...
@@ -33,6 +33,59 @@ use Bugzilla::Constants;
use
Bugzilla::
DB
;
use
Bugzilla::
Template
;
use
Bugzilla::
User
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
use
File::
Basename
;
#####################################################################
# Constants
#####################################################################
# Scripts that are not stopped by shutdownhtml being in effect.
use
constant
SHUTDOWNHTML_EXEMPT
=>
[
'doeditparams.cgi'
,
'editparams.cgi'
,
'checksetup.pl'
,
];
#####################################################################
# Global Code
#####################################################################
# If Bugzilla is shut down, do not allow anything to run, just display a
# message to the user about the downtime. Scripts listed in
# SHUTDOWNHTML_EXEMPT are exempt from this message.
#
# This code must go here. It cannot go anywhere in Bugzilla::CGI, because
# it uses Template, and that causes various dependency loops.
if
(
Param
(
"shutdownhtml"
)
&&
lsearch
(
SHUTDOWNHTML_EXEMPT
,
basename
(
$0
))
==
-
1
)
{
my
$template
=
Bugzilla
->
template
;
my
$vars
=
{};
$vars
->
{
'message'
}
=
'shutdown'
;
# Generate and return a message about the downtime, appropriately
# for if we're a command-line script or a CGI sript.
my
$extension
;
if
(
i_am_cgi
()
&&
(
!
Bugzilla
->
cgi
->
param
(
'format'
)
||
Bugzilla
->
cgi
->
param
(
'format'
)
eq
'html'
))
{
$extension
=
'html'
;
}
else
{
$extension
=
'txt'
;
}
print
Bugzilla
->
cgi
->
header
()
if
i_am_cgi
();
my
$t_output
;
$template
->
process
(
"global/message.$extension.tmpl"
,
$vars
,
\
$t_output
)
||
ThrowTemplateError
(
$template
->
error
);
print
$t_output
.
"\n"
;
exit
;
}
#####################################################################
# Subroutines and Methods
#####################################################################
my
$_template
;
sub
template
{
...
...
Bugzilla/CGI.pm
View file @
bcfde177
...
...
@@ -25,9 +25,18 @@ use strict;
package
Bugzilla::
CGI
;
BEGIN
{
if
(
$^O
=~
/MSWin32/i
)
{
# Help CGI find the correct temp directory as the default list
# isn't Windows friendly (Bug 248988)
$ENV
{
'TMPDIR'
}
=
$ENV
{
'TEMP'
}
||
$ENV
{
'TMP'
}
||
"$ENV{'WINDIR'}\\TEMP"
;
}
}
use
CGI
qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers SERVER_PUSH)
;
use
base
qw(CGI)
;
use
CGI::
Carp
qw(fatalsToBrowser)
;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
...
...
Bugzilla/Util.pm
View file @
bcfde177
...
...
@@ -33,6 +33,7 @@ use base qw(Exporter);
detaint_signed
html_quote url_quote value_quote xml_quote
css_class_quote
i_am_cgi
lsearch max min
diff_arrays diff_strings
trim wrap_comment find_wrap_point
...
...
@@ -130,6 +131,12 @@ sub xml_quote {
return
$var
;
}
sub
i_am_cgi
()
{
# I use SERVER_SOFTWARE because it's required to be
# defined for all requests in the CGI spec.
return
exists
$ENV
{
'SERVER_SOFTWARE'
}
?
1
:
0
;
}
sub
lsearch
{
my
(
$list
,
$item
)
=
(
@_
);
my
$count
=
0
;
...
...
@@ -376,6 +383,9 @@ Bugzilla::Util - Generic utility functions for bugzilla
value_quote($var);
xml_quote($var);
# Functions that tell you about your environment
my $is_cgi = i_am_cgi();
# Functions for searching
$loc = lsearch(\@arr, $val);
$val = max($a, $b, $c);
...
...
@@ -480,6 +490,12 @@ This is similar to C<html_quote>, except that ' is escaped to '. This
is kept separate from html_quote partly for compatibility with previous code
(for ') and partly for future handling of non-ASCII characters.
=item C<i_am_cgi()>
Tells you whether or not you are being run as a CGI script in a web
server. For example, it would return false if the caller is running
in a command-line script.
=back
=head2 Searching
...
...
CGI.pl
View file @
bcfde177
...
...
@@ -32,14 +32,6 @@ use lib ".";
# use Carp; # for confess
BEGIN
{
if
(
$^O
=~
/MSWin32/i
)
{
# Help CGI find the correct temp directory as the default list
# isn't Windows friendly (Bug 248988)
$ENV
{
'TMPDIR'
}
=
$ENV
{
'TEMP'
}
||
$ENV
{
'TMP'
}
||
"$ENV{'WINDIR'}\\TEMP"
;
}
}
use
Bugzilla::
Util
;
use
Bugzilla::
Config
;
use
Bugzilla::
Constants
;
...
...
@@ -60,28 +52,10 @@ sub CGI_pl_sillyness {
$zz
=
$::buffer
;
}
use
CGI::
Carp
qw(fatalsToBrowser)
;
require
'globals.pl'
;
use
vars
qw($template $vars)
;
# 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$:
)
{
$::vars
->
{
'message'
}
=
"shutdown"
;
# Return the appropriate HTTP response headers.
print
Bugzilla
->
cgi
->
header
();
# Generate and return an HTML message about the downtime.
$::template
->
process
(
"global/message.html.tmpl"
,
$::vars
)
||
ThrowTemplateError
(
$::template
->
error
());
exit
;
}
# Implementations of several of the below were blatently stolen from CGI.pm,
# by Lincoln D. Stein.
...
...
template/en/default/global/message.txt.tmpl
0 → 100644
View file @
bcfde177
[%# 1.0@bugzilla.org %]
[%# 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.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Max Kanat-Alexander.
# Portions created by Max Kanat-Alexander are Copyright (C) 2005
# Max Kanat-Alexander. All Rights Reserved.
#
# Contributor(s): Max Kanat-Alexander <mkanat@kerio.com>
#%]
[% PROCESS global/variables.none.tmpl %]
[%# Yes, this may show some HTML. But it's the best we
# can do at the moment. %]
[% PROCESS global/messages.html.tmpl %]
[% message %]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment