Lines Matching defs:CGI
1 package CGI;
19 # http://search.cpan.org/dist/CGI.pm
22 $CGI::revision = '$Id: CGI.pm,v 1.266 2009/07/30 16:32:34 lstein Exp $';
23 $CGI::VERSION='3.52';
28 use CGI::Util qw(rearrange rearrange_header make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic);
65 # 1) use CGI '-nosticky';
66 # 2) $CGI::NOSTICKY = 1;
71 # 1) use CGI qw(-nph)
72 # 2) CGI::nph(1)
83 # 1) use CGI qw(:private_tempfiles)
84 # 2) CGI::private_tempfiles(1);
93 # 1) use CGI qw(:close_upload_files)
94 # 2) $CGI::close_upload_files(1);
110 # use CGI qw(-no_undef_params);
171 # This is the default class for the CGI object to use when all else fails.
172 $DefaultClass = 'CGI' unless defined $CGI::DefaultClass;
175 $AutoloadClass = $DefaultClass unless defined $CGI::AutoloadClass;
190 $PERLEX++ if defined($ENV{'GATEWAY_INTERFACE'}) && $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-PerlEx/;
195 # mod_perl handlers may run system() on scripts using CGI.pm;
226 $CGI::DefaultClass->binmode(\*main::STDOUT);
227 $CGI::DefaultClass->binmode(\*main::STDIN);
228 $CGI::DefaultClass->binmode(\*main::STDERR);
361 $r->register_cleanup(\&CGI::_reset_globals);
370 $r->pool->cleanup_register(\&CGI::_reset_globals);
407 $CGI::Q = $self = $CGI::DefaultClass->new(@_);
479 return @_ if defined($_[0]) && (!ref($_[0])) &&($_[0] eq 'CGI');
481 (ref($_[0]) eq 'CGI' || UNIVERSAL::isa($_[0],'CGI')) # slightly optimized for common case
483 $Q = $CGI::DefaultClass->new unless defined($Q);
492 (substr(ref($_[0]),0,3) eq 'CGI'
493 || UNIVERSAL::isa($_[0],'CGI'))) {
618 if (UNIVERSAL::isa($initializer,'CGI')) {
857 print STDERR "CGI::AUTOLOAD for $AUTOLOAD\n" if $CGI::AUTOLOAD_DEBUG;
870 $pack = ${"$pack\:\:AutoloadClass"} || $CGI::DefaultClass
891 $code = $CGI::DefaultClass->_make_tag_func($func_name);
952 $routine =~ s/^.*::/CGI::/;
1140 tie(%in,CGI,$q);
1157 tie(%in,CGI);
1213 if (ref($arg) && UNIVERSAL::isa($arg,'CGI')) {
1232 return $_[0] if $_[1] eq 'CGI';
1441 # A way to restore CGI parameters from an initializer.
1446 $Q = $CGI::DefaultClass->new(@_);
1606 my $cs = UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string : $_;
2309 return $XHTML ? CGI::label($labelattributes,
2321 push @_,$_[0] if @_==1 && $_[0] eq 'CGI';
2322 my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_);
2357 push @_,$_[0] if @_==1 && $_[0] eq 'CGI';
2358 my ($self,$string) = CGI::self_or_default(@_);
2540 CGI::label($labelattributes,
2916 require CGI::Cookie;
2922 $self->{'.cookies'} = CGI::Cookie->fetch;
2943 return CGI::Cookie->new(@param);
3002 # This is all fine except that some bogus CGI scripts expect
3020 # avoid relying on the browser, proxy, server, and CGI.pm preserving the
3189 require CGI::Cookie;
3192 $self->{'.raw_cookies'} = CGI::Cookie->raw_fetch
3426 $CGI::NOSTICKY = $param if defined($param);
3427 return $CGI::NOSTICKY;
3437 $CGI::NPH = $param if defined($param);
3438 return $CGI::NPH;
3448 $CGI::PRIVATE_TEMPFILES = $param if defined($param);
3449 return $CGI::PRIVATE_TEMPFILES;
3458 $CGI::CLOSE_UPLOAD_FILES = $param if defined($param);
3459 return $CGI::CLOSE_UPLOAD_FILES;
3471 $CGI::DEFAULT_DTD = [ $param, $param2 ];
3473 $CGI::DEFAULT_DTD = $param;
3475 return $CGI::DEFAULT_DTD;
3483 push @_,$_[0] if @_==1 && $_[0] eq 'CGI';
3484 my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_);
3520 return $self->CGI::hidden('-name'=>'.cgifields',
3638 die "CGI.pm open of tmpfile $tmp/$filename failed: $!\n" unless defined $filehandle;
3639 $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode
3672 $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode;
3750 die "CGI open of tmpfile: $!\n" unless defined $filehandle;
3751 $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode
3774 $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode;
3852 $AUTOLOAD = "CGI::$_";
3876 *Fh::AUTOLOAD = \&CGI::AUTOLOAD;
3892 return $i.$CGI::TAINTED;
3952 $CRLF=$CGI::CRLF;
3955 *MultipartBuffer::AUTOLOAD = \&CGI::AUTOLOAD;
3971 $CGI::DefaultClass->binmode($IN); # if $CGI::needs_binmode; # just do it always
3989 $boundary = "--$boundary" unless CGI::user_agent('MSIE\s+3\.0[12];\s*Mac|DreamPassport');
4030 local($CRLF) = "\015\012" if $CGI::OS eq 'VMS' || $CGI::EBCDIC;
4048 if ($CGI::EBCDIC) {
4050 $header = CGI::Util::ascii2ebcdic($header);
4083 if ($CGI::EBCDIC) {
4085 $returnval = CGI::Util::ascii2ebcdic($returnval);
4106 my $boundary_start = $CGI::EBCDIC ? CGI::Util::ebcdic2ascii($self->{BOUNDARY}) : $self->{BOUNDARY};
4107 my $boundary_end = $CGI::EBCDIC ? CGI::Util::ebcdic2ascii($self->{BOUNDARY}.'--') : $self->{BOUNDARY}.'--';
4181 die "CGI.pm: Server closed socket during multipart read (client aborted?).\n"
4211 $SL = $CGI::SL;
4212 $MAC = $CGI::OS eq 'MACINTOSH';
4221 if( $CGI::OS eq 'WINDOWS' ){
4233 # unshift(@TEMP,(getpwuid($<))[7].'/tmp') if $CGI::OS eq 'UNIX';
4238 # unshift(@TEMP,(eval {(getpwuid($>))[7]}).'/tmp') if $CGI::OS eq 'UNIX' and $> != 0;
4253 *CGITempFile::AUTOLOAD = \&CGI::AUTOLOAD;
4299 package CGI;
4305 $CGI::CGI = '';
4306 $CGI::CGI=<<EOF;
4307 $CGI::VERSION;
4322 CGI - Handle Common Gateway Interface requests and responses
4326 use CGI;
4328 my $q = CGI->new;
4354 CGI.pm is a stable, complete and mature solution for processing and preparing
4360 CGI.pm performs very well in in a vanilla CGI.pm environment and also comes
4365 CGI.pm has been included in the Perl distribution since Perl 5.4, and has
4370 There are two styles of programming with CGI.pm, an object-oriented
4372 create one or more CGI objects and then use object methods to create
4373 the various elements of the page. Each CGI object starts out with the
4374 list of named parameters that were passed to your CGI script by the
4377 the CGI script, and because each object's parameter list is
4385 use CGI; # load CGI routines
4386 $q = CGI->new; # create new CGI object
4392 In the function-oriented style, there is one default CGI object that
4394 retrieve CGI parameters, create HTML tags, manage cookies, and so
4396 limits you to using one CGI object at a time. The following example
4400 need to create the CGI object.
4403 use CGI qw/:standard/; # load standard CGI routines
4411 function-oriented programming in CGI.pm
4413 =head2 CALLING CGI.PM ROUTINES
4415 Most CGI.pm routines accept several arguments, sometimes as many as 20
4424 dash. If a dash is present in the first argument, CGI.pm assumes
4439 For example, the param() routine is used to set a CGI parameter to a
4445 A large number of routines in CGI.pm actually aren't specifically
4451 attributes and contents, CGI.pm uses the convention of passing HTML
4465 Many newcomers to CGI.pm are puzzled by the difference between the
4476 If you use the B<-w> switch, you will be warned that some CGI.pm argument
4525 $query = CGI->new;
4535 $query = CGI->new(INPUTFILE);
4548 $query = CGI->new(\*STDIN);
4550 You can also initialize the CGI object with a FileHandle or IO::File
4554 initialize CGI state from a file handle, the way to do this is with
4556 default CGI object from the indicated file handle.
4565 $query = CGI->new( {'dinosaur'=>'barney',
4572 $query = CGI->new('dinosaur=barney&color=purple');
4574 or from a previously existing CGI object (currently this clones the
4578 $old_query = CGI->new;
4579 $new_query = CGI->new($old_query);
4583 $empty_query = CGI->new("");
4587 $empty_query = CGI->new({});
4675 the param() method instead to access CGI variables by name.
4696 This clears the CGI object completely. It might be useful to ensure
4716 only affects people trying to use CGI for XML processing and other
4741 use CGI ':cgi-lib';
4745 the keys are the names of the CGI parameters, and the values are the
4749 CGI parameter list. Called in a list context, it returns the
4753 When using this, the thing you must watch out for are multivalued CGI
4762 function calls (also see the section on CGI-LIB compatibility).
4781 Both name and value are URL escaped. Multi-valued CGI parameters are
4789 use CGI;
4794 my $q = CGI->new;
4803 my $q = CGI->new(\*IN);
4818 =head2 RETRIEVING CGI ERRORS
4821 processing uploaded files. When these errors occur, CGI will stop
4843 To use the function-oriented interface, you must specify which CGI.pm
4848 use CGI <list of methods>;
4851 call them directly without creating a CGI object first. This example
4855 use CGI 'param','header';
4869 Import all CGI-handling methods, such as B<param()>, B<path_info()>
4904 Import all the available methods. For the full list, see the CGI.pm
4909 If you import a function name that is not part of CGI.pm, the module
4915 machine reboots). You don't need to wait for a new version of CGI.pm
4918 use CGI qw/:standard :html3 gradient/;
4921 Note that in the interests of execution speed CGI.pm does B<not> use
4925 If you import any of the state-maintaining CGI or form-generating
4926 methods, a default CGI object will be created and initialized
4929 B<submit()> and the like. (If you need direct access to the CGI
4930 object, you can find it in the global variable B<$CGI::Q>). By
4931 importing CGI.pm methods, you can create visually elegant scripts:
4933 use CGI qw/:standard/;
4963 change the way that CGI.pm functions in various ways. Pragmas,
4969 use CGI qw/:standard -debug/;
4977 When you I<use CGI -any>, then any method that the query object
4982 use CGI qw(-any);
4983 $q=CGI->new;
4998 use CGI qw(-compile :standard :html3);
5002 use CGI qw(-compile :all);
5009 use CGI();
5010 CGI->compile();
5013 might want to precompile all CGI routines in a startup script, and
5018 By default the CGI module implements a state-preserving behavior
5037 This keeps CGI.pm from including undef params in the parameter list.
5041 By default, CGI.pm versions 2.69 and higher emit XHTML
5053 This makes CGI.pm treat all parameters as UTF-8 strings. Use this with
5063 This makes CGI.pm produce a header appropriate for an NPH (no
5070 Separate the name=value pairs in CGI parameter query strings with
5081 Separate the name=value pairs in CGI parameter query strings with
5087 that is not recognized is referred to CGI.pm for possible evaluation.
5088 This allows you to use all the CGI.pm functions without adding them to
5099 run a CGI.pm script from the command line to produce HTML, and you
5100 don't want it to read CGI parameters from the command line or STDIN,
5103 use CGI qw(-no_debug :standard);
5107 This turns on full debugging. In addition to reading CGI arguments
5108 from the command-line processing, CGI.pm will pause and try to read
5116 CGI.pm can process uploaded file. Ordinarily it spools the uploaded
5119 upload section. Another CGI script author could peek at this data
5128 To ensure that the temporary file cannot be read by other CGI scripts,
5129 use suEXEC or a CGI wrapper program to run your script. The temporary
5167 I<use CGI>. However, you can specify the tags you want to generate
5174 use CGI qw/:standard *table start_ul/;
5193 Most of CGI.pm's functions deal with creating documents on the fly.
5195 document itself. CGI.pm provides functions for generating HTTP
5205 Normally the first thing you will do in any CGI script is print out an
5240 to the CGI methods using named parameters. Recognized parameters are
5248 Most browsers will not cache the output from CGI scripts. Every time
5296 CGI.pm will accept valid multi-line headers when each line is separated with a
5302 are received, CGI.pm will always output them back as a single line, according to the
5422 will be replaced by the default DTD. If the public DTD contains 'XHTML', CGI.pm
5464 completely. CGI.pm attempts to format the script in such a way that
5474 $query = CGI->new;
5666 It is possible for a script to receive CGI parameters in the URL as
5677 interfere with similarly-named CGI parameters in POSTed forms. If you
5683 CGI.pm defines general HTML shortcut methods for many HTML tags. HTML shortcuts are named after a single
5708 use CGI ':standard';
5750 Prior to CGI.pm version 2.41, providing an empty ('') string as an
5805 CGI.pm puts the extra space there using array interpolation, which is
5866 be replaced by their numeric entities, since CGI.pm has no lookup
5899 pretty-printed output, please use L<CGI::Pretty>, a subclass
5934 autoEscape() method with a false value immediately after creating the CGI object:
5936 $query = CGI->new;
5940 CGI.pm HTML generation functions handle escaping. Calling escapeHTML()
6006 This is the older type of encoding. It is compatible with many CGI scripts and is
6008 convenience, CGI.pm stores the name of this encoding
6009 type in B<&CGI::URL_ENCODED>.
6017 your convenience, CGI.pm stores the name of this encoding type
6018 in B<&CGI::MULTIPART>
6021 by CGI scripts unless they use CGI.pm or another library designed
6190 by calling B<start_form()> with an encoding type of B<&CGI::MULTIPART>,
6262 that CGI.pm creates during upload spooling (see below).
6283 When processing an uploaded file, CGI.pm creates a temporary file on your hard
6285 file handle, CGI.pm unlinks (deletes) the temporary file. If you need to you
6301 finished. In this case, CGI.pm will return undef for the name of the
6318 CGI.pm gives you low-level access to file upload management through
6327 $q = CGI->new(\&hook [,$data [,$use_tempfile]]);
6338 CGI.pm's use of a temporary disk-based file during file upload. If you
6343 If using the function-oriented interface, call the CGI::upload_hook()
6344 method before calling param() or any other CGI functions:
6346 CGI::upload_hook(\&hook [,$data [,$use_tempfile]]);
6349 explicitly if you wish to use it without the CGI:: prefix.
6353 If you are using CGI.pm on a Windows platform and find that binary
6361 ( This section is here for completeness. if you are building a new application with CGI.pm, you can skip it. )
6363 The original way to process file uploads with CGI.pm was to use param(). The
7019 within a browser session. CGI.pm has several methods that support
7022 A cookie is a name=value pair much like the named parameters in a CGI
7023 query string. CGI scripts create one or more cookies and send
7026 to the CGI script during subsequent interactions.
7062 causes the cookie to be sent to any CGI script on your site.
7067 script if the CGI request is occurring on a secure channel, such as SSL.
7089 alphanumeric characters, CGI.pm removes this restriction by escaping
7128 use CGI ':standard';
7143 use CGI;
7144 $query = CGI->new;
7152 The cookie and CGI namespaces are separate. If you have a parameter
7155 simple to turn a CGI parameter into a cookie, and vice-versa:
7157 # turn a CGI parameter into a cookie
7172 It's possible for CGI.pm scripts to write into several browser panels
7186 in CGI.pm, but the HTML is very simple to write.
7203 CGI.pm it looks like this:
7334 CGI method. For example, to have your validateAge() JavaScript code
7341 function by incorporating it into a <SCRIPT> block. The CGI.pm
7355 CGI.pm has limited support for HTML3's cascading style sheets (css).
7392 use CGI qw/:standard :html3/;
7410 print start_html( -title=>'CGI with Style',
7414 print h1('CGI with Style'),
7533 As a shortcut, you can interpolate the entire CGI object into a string
7536 $query=CGI->new;
7569 method from the CGI::Cookie module.
7591 path information in CGI scripts destined for use with IIS.
7702 Servers use a variety of conventions for designating CGI scripts as
7709 CGI.pm supports NPH scripts with a special NPH mode. When in this
7710 mode, CGI.pm will output the necessary extra header information when
7715 version 2.30, CGI.pm will automatically detect when the script is
7723 Non-Parsed Headers Stripped From CGI Applications That Have nph-
7733 use CGI qw(:standard -nph)
7737 Call B<nph()> with a non-zero parameter at any point after using CGI.pm in your program.
7739 CGI->nph(1)
7751 CGI.pm provides four simple functions for producing multipart
7761 use CGI qw/:push -nph/;
7791 If not provided, CGI.pm chooses a reasonable boundary for you.
7818 at the CGI::Push module.
7822 A potential problem with CGI.pm is that, by default, it attempts to
7824 could attack your site by sending a CGI script a huge POST of many
7825 megabytes. CGI.pm will attempt to read the entire POST into a
7830 Another possible attack is for the remote user to force CGI.pm to
7831 accept a huge file upload. CGI.pm will accept the upload and store it
7833 an uploaded file. CGI.pm will delete the file automatically when it
7838 of memory, CPU time and disk space that CGI scripts can use. Some Web
7841 commands to put ceilings on CGI resource usage.
7844 CGI.pm also has some simple built-in protections against denial of
7846 These take the form of two global variables in the CGI name space:
7850 =item B<$CGI::POST_MAX>
7853 on the size of POSTings, in bytes. If CGI.pm detects a POST
7860 =item B<$CGI::DISABLE_UPLOADS>
7875 use CGI qw/:standard/;
7876 use CGI::Carp 'fatalsToBrowser';
7877 $CGI::POST_MAX=1024 * 100; # max 100K posts
7878 $CGI::DISABLE_UPLOADS = 1; # no uploads
7882 Open up CGI.pm, find the definitions for $POST_MAX and
7890 I<param()> to return an empty CGI parameter list. You can test for
7891 this event by checking I<cgi_error()>, either after you create the CGI
7897 designed to be returned to the browser as the CGI script's status
7910 =head1 COMPATIBILITY WITH CGI-LIB.PL
7923 use CGI;
7924 CGI::ReadParse();
7927 CGI.pm's ReadParse() routine creates a tied variable named %in,
7936 $q = $in{CGI};
7941 of CGI.pm without rewriting your old scripts from scratch.
7943 An even simpler way to mix cgi-lib calls with CGI.pm calls is to import both the
7946 use CGI qw(:cgi-lib :standard);
7951 =head2 Cgi-lib functions that are available in CGI.pm
7964 =head2 Cgi-lib functions that are not available in CGI.pm
7971 This function is not available. Use CGI.pm's url() method instead.
7974 This function is not available. Use CGI.pm's self_url() method
7978 These functions are not supported. Look at CGI::Carp for the way I
7983 just print out the CGI object:
7985 use CGI qw(:standard);
7986 $q = CGI->new;
7994 The CGI.pm distribution is copyright 1995-2007, Lincoln D. Stein. It is
7998 bug reports, please provide the version of CGI.pm, the version of
8061 use CGI ':standard';
8064 print start_html("Example CGI.pm Form");
8065 print "<h1> Example CGI.pm Form</h1>\n";
8142 L<CGI::Carp> - provides a L<Carp> implementation tailored to the CGI environment.
8144 L<CGI::Fast> - supports running CGI applications under FastCGI
8146 L<CGI::Pretty> - pretty prints HTML generated by CGI.pm (with a performance penalty)