1 ##--------------------------------------------------------------------------##
3 ## $Id: CGI.pm,v 1.2 2002/09/18 17:23:29 ehood Exp $
6 ##--------------------------------------------------------------------------##
7 ## Copyright (C) 2002 Earl Hood <earl@earlhood.com>
9 ## This program is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 2 of the License, or
12 ## (at your option) any later version.
14 ## This program is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License
20 ## along with this program; if not, write to the Free Software
21 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 ##--------------------------------------------------------------------------##
37 &print_not_found_error
41 ##--------------------------------------------------------------------------##
47 ##--------------------------------------------------------------------------##
50 my($method) = ($ENV{"REQUEST_METHOD"}) || 'GET';
52 if ($method eq "GET") {
53 $data = $ENV{"QUERY_STRING"} || "";
54 } elsif ($method eq "POST") {
55 read(STDIN
, $data, $ENV{"CONTENT_LENGTH"});
57 warn qq/Unknown method: $method/;
61 my(@pairs, $name, $value);
66 @pairs = split(/&/, $data);
68 ($name, $value) = split(/=/);
69 $name = expandstr
($name);
70 $value = expandstr
($value);
71 $form->{$name} = $value;
78 print STDOUT
'Status: 403 Forbidden', "\r\n";
79 print_content_type
('text/plain');
80 print STDOUT
"Access Denied\n";
83 sub print_input_error
{
84 print STDOUT
'Status: 400 Bad Request', "\r\n";
85 print_content_type
('text/plain');
86 print STDOUT
"Input Error\n";
90 print_content_type
('text/plain');
91 print STDOUT
"Script Error\n";
94 sub print_not_found_error
{
95 print STDOUT
'Status: 404 Not Found', "\r\n";
96 print_content_type
('text/plain');
97 print STDOUT
"Not Found\n";
101 print STDOUT
'Location: ', $_[0], "\r\n\r\n";
104 sub print_content_type
{
106 print STDOUT
"Content-type: $type\r\n\r\n";
112 $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ge;
116 ##--------------------------------------------------------------------------##
122 MHArc::CGI - General CGI-related utilities for mail archiving system.
130 This module contains a collection of CGI-related utility routines used
131 by the various mharc CGI programs.
135 The following module variables can be set to affect the behavior
136 of the utility routines:
142 If set to a true value, routines will print out debugging information,
149 By default, no routines are exported into the calling namespace.
150 Routines in this module can be imported by explicitly listing the
151 routines to import in the C<use> declaration:
153 use MHArc::CGI qw( parse_input );
155 The following routines are availale:
165 C<$Id: CGI.pm,v 1.2 2002/09/18 17:23:29 ehood Exp $>
169 Earl Hood, earl@earlhood.com
171 This module is part of the mharc archiving system and comes with
172 ABSOLUTELY NO WARRANTY and may be copied only under the terms of
173 the GNU General Public License, which may be found in the MHArc