CGI-Simple

 view release on metacpan or  search on metacpan

lib/CGI/Simple.pm  view on Meta::CPAN

sub _init_from_file {
  use Carp qw(confess);
  confess "INIT_FROM_FILE called, stupid fucker!";
  my ( $self, $fh ) = @_;
  local $/ = "\n";
  while ( my $pair = <$fh> ) {
    chomp $pair;
    return if $pair eq '=';
    $self->_parse_params( $pair );
  }
}

sub save {
  my ( $self, $fh ) = @_;
  local ( $,, $\ ) = ( '', '' );
  unless ( $fh and fileno $fh ) {
    $self->cgi_error( 'Invalid filehandle' );
    return undef;
  }
  for my $param ( $self->param ) {
    for my $value ( $self->param( $param ) ) {
      ;
      print $fh $self->url_encode( $param ), '=',
       $self->url_encode( $value ), "\n";
    }
  }
  print $fh "=\n";
}

sub save_parameters { save( @_ ) }    # CGI.pm alias for save

################ Miscellaneous Methods ################

sub parse_keywordlist {
  _parse_keywordlist( @_ );
}                                     # CGI.pm compatibility

sub escapeHTML {
  my ( $self, $escape, $newlinestoo ) = @_;
  require CGI::Simple::Util;
  $escape = CGI::Simple::Util::escapeHTML( $escape );
  $escape =~ s/([\012\015])/'&#'.(ord $1).';'/eg if $newlinestoo;
  return $escape;
}

sub unescapeHTML {
  require CGI::Simple::Util;
  return CGI::Simple::Util::unescapeHTML( $_[1] );
}

sub put {
  my $self = shift;
  $self->print( @_ );
}    # send output to browser

sub print {
  shift;
  CORE::print( @_ );
}    # print to standard output (for overriding in mod_perl)

################# Cookie Methods ################

sub cookie {
  my ( $self, @params ) = @_;
  require CGI::Simple::Cookie;
  require CGI::Simple::Util;
  my ( $name, $value, $path, $domain, $secure, $expires, $httponly, $samesite )
   = CGI::Simple::Util::rearrange(
    [
      'NAME', [ 'VALUE', 'VALUES' ],
      'PATH',   'DOMAIN',
      'SECURE', 'EXPIRES',
      'HTTPONLY', 'SAMESITE'
    ],
    @params
   );

  # retrieve the value of the cookie, if no value is supplied
  unless ( defined( $value ) ) {
    $self->{'.cookies'} = CGI::Simple::Cookie->fetch
     unless $self->{'.cookies'};
    return () unless $self->{'.cookies'};

   # if no name is supplied, then retrieve the names of all our cookies.
    return keys %{ $self->{'.cookies'} } unless $name;

    # return the value of the cookie
    return
     exists $self->{'.cookies'}->{$name}
     ? $self->{'.cookies'}->{$name}->value
     : ();
  }

  # If we get here, we're creating a new cookie
  return undef unless $name;    # this is an error
  @params = ();
  push @params, '-name'     => $name;
  push @params, '-value'    => $value;
  push @params, '-domain'   => $domain if $domain;
  push @params, '-path'     => $path if $path;
  push @params, '-expires'  => $expires if $expires;
  push @params, '-secure'   => $secure if $secure;
  push @params, '-httponly' => $httponly if $httponly;
  push @params, '-samesite' => $samesite if $samesite;
  return CGI::Simple::Cookie->new( @params );
}

sub raw_cookie {
  my ( $self, $key ) = @_;
  if ( defined $key ) {
    unless ( $self->{'.raw_cookies'} ) {
      require CGI::Simple::Cookie;
      $self->{'.raw_cookies'} = CGI::Simple::Cookie->raw_fetch;
    }
    return $self->{'.raw_cookies'}->{$key} || ();
  }
  return $ENV{'HTTP_COOKIE'} || $ENV{'COOKIE'} || '';
}

################# Header Methods ################

sub header {
  my ( $self, @params ) = @_;
  require CGI::Simple::Util;
  my @header;
  return undef
   if $self->{'.header_printed'}++
     and $self->{'.globals'}->{'HEADERS_ONCE'};
  my (
    $type, $status,  $cookie,     $target, $expires,
    $nph,  $charset, $attachment, $p3p,    @other
   )
   = CGI::Simple::Util::rearrange(
    [
      [ 'TYPE',   'CONTENT_TYPE', 'CONTENT-TYPE' ], 'STATUS',
      [ 'COOKIE', 'COOKIES',      'SET-COOKIE' ],   'TARGET',
      'EXPIRES', 'NPH',
      'CHARSET', 'ATTACHMENT',
      'P3P'
    ],
    @params
   );

  my $CRLF = $self->crlf;
  my $ALL_POSSIBLE_CRLF = qr/(?:\r\n|\n|\015\012)/;

  # CR escaping for values, per RFC 822
  for my $header (
    $type, $status,  $cookie,     $target, $expires,
    $nph,  $charset, $attachment, $p3p,    @other
   ) {
    if ( defined $header ) {
      # From RFC 822:
      # Unfolding  is  accomplished  by regarding   CRLF   immediately
      # followed  by  a  LWSP-char  as equivalent to the LWSP-char
      # (defined in the RFC as a space or a horizontal tab).
      $header =~ s/$ALL_POSSIBLE_CRLF([ \t])/$1/g;

      # All other uses of newlines are invalid input.
      if ( $header =~ m/$ALL_POSSIBLE_CRLF/ ) {
        # shorten very long values in the diagnostic
        $header = substr( $header, 0, 72 ) . '...'
         if ( length $header > 72 );
        die
         "Invalid header value contains a newline not followed by whitespace: $header";
      }
    }
  }

  $nph ||= $self->{'.globals'}->{'NPH'};
  $charset = $self->charset( $charset )
   ;    # get charset (and set new charset if supplied)
   # rearrange() was designed for the HTML portion, so we need to fix it up a little.

  for ( @other ) {

    # Don't use \s because of perl bug 21951
    next
     unless my ( $header, $value ) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/s;
    ( $_ = $header )
     =~ s/^(\w)(.*)/"\u$1\L$2" . ': '.$self->unescapeHTML($value)/e;
  }
  $type ||= 'text/html' unless defined $type;
  $type .= "; charset=$charset"
   if $type
     and $type =~ m!^text/!
     and $type !~ /\bcharset\b/;
  my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0';
  push @header, $protocol . ' ' . ( $status || '200 OK' ) if $nph;
  push @header, "Server: " . server_software() if $nph;
  push @header, "Status: $status"              if $status;
  push @header, "Window-Target: $target"       if $target;

  if ( $p3p ) {
    $p3p = join ' ', @$p3p if ref( $p3p ) eq 'ARRAY';
    push( @header, qq(P3P: policyref="/w3c/p3p.xml", CP="$p3p") );
  }

  # push all the cookies -- there may be several
  if ( $cookie ) {
    my @cookie = ref $cookie eq 'ARRAY' ? @{$cookie} : $cookie;
    for my $cookie ( @cookie ) {
      my $cs
       = ref $cookie eq 'CGI::Simple::Cookie'
       ? $cookie->as_string
       : $cookie;
      push @header, "Set-Cookie: $cs" if $cs;
    }
  }

# if the user indicates an expiration time, then we need both an Expires
# and a Date header (so that the browser is using OUR clock)
  $expires = 'now'
   if $self->no_cache;    # encourage no caching via expires now
  push @header,
   "Expires: " . CGI::Simple::Util::expires( $expires, 'http' )
   if $expires;
  push @header, "Date: " . CGI::Simple::Util::expires( 0, 'http' )
   if defined $expires || $cookie || $nph;
  push @header, "Pragma: no-cache" if $self->cache or $self->no_cache;
  push @header,
   "Content-Disposition: attachment; filename=\"$attachment\""
   if $attachment;
  push @header, @other;
  push @header, "Content-Type: $type" if $type;
  my $header = join $CRLF, @header;
  $header .= $CRLF . $CRLF;    # add the statutory two CRLFs

  if ( $self->{'.mod_perl'} and not $nph ) {
    my $r = $self->_mod_perl_request();
    $r->send_cgi_header( $header );
    return '';
  }
  return $header;
}

# Control whether header() will produce the no-cache Pragma directive.
sub cache {
  my ( $self, $value ) = @_;
  $self->{'.cache'} = $value if defined $value;
  return $self->{'.cache'};
}

# Control whether header() will produce expires now + the no-cache Pragma.
sub no_cache {
  my ( $self, $value ) = @_;
  $self->{'.no_cache'} = $value if defined $value;
  return $self->{'.no_cache'};
}

sub redirect {
  my ( $self, @params ) = @_;
  require CGI::Simple::Util;
  my ( $url, $target, $cookie, $nph, @other )
   = CGI::Simple::Util::rearrange(
    [
      [ 'LOCATION', 'URI',       'URL' ], 'TARGET',
      [ 'COOKIE',   'COOKIES' ], 'NPH'
    ],
    @params
   );
  $url ||= $self->self_url;
  my @o;
  for ( @other ) { tr/\"//d; push @o, split "=", $_, 2; }
  unshift @o,
   '-Status'   => '302 Found',
   '-Location' => $url,
   '-nph'      => $nph;
  unshift @o, '-Target' => $target if $target;
  unshift @o, '-Cookie' => $cookie if $cookie;
  unshift @o, '-Type'   => '';
  my @unescaped;
  unshift( @unescaped, '-Cookie' => $cookie ) if $cookie;
  return $self->header( ( map { $self->unescapeHTML( $_ ) } @o ),
    @unescaped );
}

################# Server Push Methods #################
# Return a Content-Type: style header for server-push
# This has to be NPH, and it is advisable to set $| = 1
# Credit to Ed Jordan <ed@fidalgo.net> and
# Andrew Benham <adsb@bigfoot.com> for this section

sub multipart_init {
  my ( $self, @p ) = @_;
  use CGI::Simple::Util qw(rearrange);
  my ( $boundary, @other ) = rearrange( ['BOUNDARY'], @p );
  if ( !$boundary ) {
    $boundary = '------- =_';
    my @chrs = ( '0' .. '9', 'A' .. 'Z', 'a' .. 'z' );
    for ( 1 .. 17 ) {
      $boundary .= $chrs[ rand( scalar @chrs ) ];
    }
  }

  my $CRLF = $self->crlf;    # get CRLF sequence
  my $warning
   = "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.";
  $self->{'.separator'}       = "$CRLF--$boundary$CRLF";
  $self->{'.final_separator'} = "$CRLF--$boundary--$CRLF$warning$CRLF";
  my $type = 'multipart/x-mixed-replace;boundary="' . $boundary . '"';
  return $self->header(
    -nph  => 1,
    -type => $type,
    map { split "=", $_, 2 } @other
   )
   . $warning
   . $self->multipart_end;
}

sub multipart_start {
  my ( $self, @p ) = @_;
  use CGI::Simple::Util qw(rearrange);
  my ( $type, @other ) = rearrange( ['TYPE'], @p );
  foreach ( @other ) {    # fix return from rearange
    next unless my ( $header, $value ) = /([^\s=]+)=\"?(.+?)\"?$/;
    $_ = ucfirst( lc $header ) . ': ' . unescapeHTML( 1, $value );
  }
  $type = $type || 'text/html';
  my @header = ( "Content-Type: $type" );
  push @header, @other;
  my $CRLF = $self->crlf;    # get CRLF sequence
  return ( join $CRLF, @header ) . $CRLF . $CRLF;
}

sub multipart_end { return $_[0]->{'.separator'} }

sub multipart_final { return $_[0]->{'.final_separator'} }

################# Debugging Methods ################

sub read_from_cmdline {
  my @words;

lib/CGI/Simple.pm  view on Meta::CPAN

    use CGI::Simple qw( -default ..... );

=head2 binmode() and Win32

If you are using CGI::Simple be sure to call B<binmode()> on any handle that
you create to write the uploaded file to disk. Calling B<binmode()> will do
no harm on other systems anyway.

=cut

################ Miscellaneous Methods ################

=head1 MISCELANEOUS METHODS

=head2 escapeHTML() Escaping HTML special characters

In HTML the < > " and & chars have special meaning and need to be
escaped to &lt; &gt; &quot; and &amp; respectively.

    $escaped = $q->escapeHTML( $string );

    $escaped = $q->escapeHTML( $string, 'new_lines_too' );

If the optional second argument is supplied then newlines will be escaped to.

=head2 unescapeHTML() Unescape HTML special characters

This performs the reverse of B<escapeHTML()>.

    $unescaped = $q->unescapeHTML( $HTML_escaped_string );

=head2 url_decode() Decode a URL encoded string

This method will correctly decode a url encoded string.

    $decoded = $q->url_decode( $encoded );

=head2 url_encode() URL encode a string

This method will correctly URL encode a string.

    $encoded = $q->url_encode( $string );

=head2 parse_keywordlist() Parse a supplied keyword list

    @keywords = $q->parse_keywordlist( $keyword_list );

This method returns a list of keywords, correctly URL escaped and split out
of the supplied string

=head2 put() Send output to browser

CGI.pm alias for print. $q->put('Hello World!') will print the usual

=head2 print() Send output to browser

CGI.pm alias for print. $q->print('Hello World!') will print the usual

=cut

################# Cookie Methods ################

=head1 HTTP COOKIES

CGI.pm has several methods that support cookies.

A cookie is a name=value pair much like the named parameters in a CGI
query string.  CGI scripts create one or more cookies and send
them to the browser in the HTTP header.  The browser maintains a list
of cookies that belong to a particular Web server, and returns them
to the CGI script during subsequent interactions.

In addition to the required name=value pair, each cookie has several
optional attributes:

=over 4

=item 1. an expiration time

This is a time/date string (in a special GMT format) that indicates
when a cookie expires.  The cookie will be saved and returned to your
script until this expiration date is reached if the user exits
the browser and restarts it.  If an expiration date isn't specified, the cookie
will remain active until the user quits the browser.

=item 2. a domain

This is a partial or complete domain name for which the cookie is
valid.  The browser will return the cookie to any host that matches
the partial domain name.  For example, if you specify a domain name
of ".capricorn.com", then the browser will return the cookie to
Web servers running on any of the machines "www.capricorn.com",
"www2.capricorn.com", "feckless.capricorn.com", etc.  Domain names
must contain at least two periods to prevent attempts to match
on top level domains like ".edu".  If no domain is specified, then
the browser will only return the cookie to servers on the host the
cookie originated from.

=item 3. a path

If you provide a cookie path attribute, the browser will check it
against your script's URL before returning the cookie.  For example,
if you specify the path "/cgi-bin", then the cookie will be returned
to each of the scripts "/cgi-bin/tally.pl", "/cgi-bin/order.pl",
and "/cgi-bin/customer_service/complain.pl", but not to the script
"/cgi-private/site_admin.pl".  By default, path is set to "/", which
causes the cookie to be sent to any CGI script on your site.

=item 4. a "secure" flag

If the "secure" attribute is set, the cookie will only be sent to your
script if the CGI request is occurring on a secure channel, such as SSL.

=back

=head2 cookie() A simple access method to cookies

The interface to HTTP cookies is the B<cookie()> method:

    $cookie = $q->cookie( -name      => 'sessionID',
                          -value     => 'xyzzy',

lib/CGI/Simple.pm  view on Meta::CPAN

Although browsers limit their cookie names to non-whitespace
alphanumeric characters, CGI.pm removes this restriction by escaping
and unescaping cookies behind the scenes.

=item B<-value>

The value of the cookie.  This can be any scalar value,
array reference, or even associative array reference.  For example,
you can store an entire associative array into a cookie this way:

    $cookie=$q->cookie( -name   => 'family information',
                        -value  => \%childrens_ages );

=item B<-path>

The optional partial path for which this cookie will be valid, as described
above.

=item B<-domain>

The optional partial domain for which this cookie will be valid, as described
above.

=item B<-expires>

The optional expiration date for this cookie.  The format is as described
in the section on the B<header()> method:

    "+1h"  one hour from now

=item B<-secure>

If set to true, this cookie will only be used within a secure
SSL session.

=back

The cookie created by B<cookie()> must be incorporated into the HTTP
header within the string returned by the B<header()> method:

    print $q->header(-cookie=>$my_cookie);

To create multiple cookies, give B<header()> an array reference:

    $cookie1 = $q->cookie( -name  => 'riddle_name',
                           -value => "The Sphynx's Question"
                         );
    $cookie2 = $q->cookie( -name  => 'answers',
                           -value => \%answers
                         );
    print $q->header( -cookie => [ $cookie1, $cookie2 ] );

To retrieve a cookie, request it by name by calling B<cookie()> method
without the B<-value> parameter:

    use CGI::Simple;
    $q = CGI::Simple->new;
    $riddle  = $q->cookie('riddle_name');
    %answers = $q->cookie('answers');

Cookies created with a single scalar value, such as the "riddle_name"
cookie, will be returned in that form.  Cookies with array and hash
values can also be retrieved.

The cookie and CGI::Simple  namespaces are separate.  If you have a parameter
named 'answers' and a cookie named 'answers', the values retrieved by
B<param()> and B<cookie()> are independent of each other.  However, it's
simple to turn a CGI parameter into a cookie, and vice-versa:

    # turn a CGI parameter into a cookie
    $c = $q->cookie( -name=>'answers', -value=>[$q->param('answers')] );
    # vice-versa
    $q->param( -name=>'answers', -value=>[$q->cookie('answers')] );

=head2 raw_cookie()

Returns the HTTP_COOKIE variable. Cookies have a special format, and
this method call just returns the raw form (?cookie dough). See
B<cookie()> for ways of setting and retrieving cooked cookies.

Called with no parameters, B<raw_cookie()> returns the packed cookie
structure.  You can separate it into individual cookies by splitting
on the character sequence "; ".  Called with the name of a cookie,
retrieves the B<unescaped> form of the cookie.  You can use the
regular B<cookie()> method to get the names, or use the raw_fetch()
method from the CGI::Simmple::Cookie module.

=cut

################# Header Methods ################

=head1 CREATING HTTP HEADERS

Normally the first thing you will do in any CGI script is print out an
HTTP header.  This tells the browser what type of document to expect,
and gives other optional information, such as the language, expiration
date, and whether to cache the document.  The header can also be
manipulated for special purposes, such as server push and pay per view
pages.

=head2 header() Create simple or complex HTTP headers

    print $q->header;

         -or-

    print $q->header('image/gif');

         -or-

    print $q->header('text/html','204 No response');

         -or-

    print $q->header( -type       => 'image/gif',
                      -nph        => 1,
                      -status     => '402 Payment required',
                      -expires    => '+3d',
                      -cookie     => $cookie,
                      -charset    => 'utf-7',
                      -attachment => 'foo.gif',
                      -Cost       => '$2.00'
                    );

B<header()> returns the Content-type: header.  You can provide your own
MIME type if you choose, otherwise it defaults to text/html.  An
optional second parameter specifies the status code and a human-readable
message.  For example, you can specify 204, "No response" to create a
script that tells the browser to do nothing at all.

The last example shows the named argument style for passing arguments
to the CGI methods using named parameters.  Recognized parameters are
B<-type>, B<-status>, B<-cookie>, B<-target>, B<-expires>, B<-nph>,
B<-charset> and B<-attachment>.  Any other named parameters will be
stripped of their initial hyphens and turned into header fields, allowing
you to specify any HTTP header you desire.

For example, you can produce non-standard HTTP header fields by providing
them as named arguments:

  print $q->header( -type            => 'text/html',
                    -nph             => 1,
                    -cost            => 'Three smackers',
                    -annoyance_level => 'high',
                    -complaints_to   => 'bit bucket'
                  );

lib/CGI/Simple.pm  view on Meta::CPAN


Either way it allows you to start using the more interesting features
of CGI.pm without rewriting your old scripts from scratch.

Unlike CGI.pm all the cgi-lib.pl functions from Version 2.18 are supported:

    ReadParse()
    SplitParam()
    MethGet()
    MethPost()
    MyBaseUrl()
    MyURL()
    MyFullUrl()
    PrintHeader()
    HtmlTop()
    HtmlBot()
    PrintVariables()
    PrintEnv()
    CgiDie()
    CgiError()

=head1 COMPATIBILITY WITH CGI.pm

I has long been suggested that the CGI and HTML parts of CGI.pm should be
split into separate modules (even the author suggests this!), CGI::Simple
represents the realization of this and contains the complete CGI side of
CGI.pm. Code-wise it weighs in at a little under 30% of the size of CGI.pm at
a little under 1000 lines.

A great deal of care has been taken to ensure that the interface remains
unchanged although a few tweaks have been made. The test suite is extensive
and includes all the CGI.pm test scripts as well as a series of new test
scripts. You may like to have a look at /t/concur.t which makes 160 tests
of CGI::Simple and CGI in parallel and compares the results to ensure they
are identical. This is the case as of CGI.pm 2.78.

You can't make an omelet without breaking eggs. A large number of methods
and global variables have been deleted as detailed below. Some pragmas are
also gone. In the tarball there is a script B</misc/check.pl> that will check if
a script seems to be using any of these now non existent methods, globals or
pragmas. You call it like this:

    perl check.pl <files>

If it finds any likely candidates it will print a line with the line number,
problem method/global and the complete line. For example here is some output
from running the script on CGI.pm:

    ...
    3162: Problem:'$CGI::OS'   local($CRLF) = "\015\012" if $CGI::OS eq 'VMS';
    3165: Problem:'fillBuffer' $self->fillBuffer($FILLUNIT);
    ....

=head1 DIFFERENCES FROM CGI.pm

CGI::Simple is strict and warnings compliant.

There are 4 modules in this distribution:

    CGI/Simple.pm           supplies all the core code.
    CGI/Simple/Cookie.pm    supplies the cookie handling functions.
    CGI/Simple/Util.pm      supplies a variety of utility functions
    CGI/Simple/Standard.pm  supplies a functional interface for Simple.pm

Simple.pm is the core module that provide all the essential functionality.
Cookie.pm is a shortened rehash of the CGI.pm module of the same name
which supplies the required cookie functionality. Util.pm has been recoded to
use an internal object for data storage and supplies rarely needed non core
functions and/or functions needed for the HTML side of things. Standard.pm is
a wrapper module that supplies a complete functional interface to the OO
back end supplied by CGI::Simple.

Although a serious attempt has been made to keep the interface identical,
some minor changes and tweaks have been made. They will likely be
insignificant to most users but here are the gory details.

=head2 Globals Variables

The list of global variables has been pruned by 75%. Here is the complete
list of the global variables used:

    $VERSION = "0.01";
    # set this to 1 to use CGI.pm default global settings
    $USE_CGI_PM_DEFAULTS = 0 unless defined $USE_CGI_PM_DEFAULTS;
    # see if user wants old  CGI.pm defaults
    do{ _use_cgi_pm_global_settings(); return } if $USE_CGI_PM_DEFAULTS;
    # no file uploads by default, set to 0 to enable uploads
    $DISABLE_UPLOADS = 1 unless defined $DISABLE_UPLOADS;
    # use a post max of 100K, set to -1 for no limits
    $POST_MAX = 102_400 unless defined $POST_MAX;
    # do not include undefined params parsed from query string
    $NO_UNDEF_PARAMS = 0 unless defined $NO_UNDEF_PARAMS;
    # separate the name=value pairs with ; rather than &
    $USE_PARAM_SEMICOLONS = 0 unless defined $USE_PARAM_SEMICOLONS;
    # only print headers once
    $HEADERS_ONCE = 0 unless defined $HEADERS_ONCE;
    # Set this to 1 to enable NPH scripts
    $NPH = 0 unless defined $NPH;
    # 0 => no debug, 1 => from @ARGV,  2 => from STDIN
    $DEBUG = 0 unless defined $DEBUG;
    # filter out null bytes in param - value pairs
    $NO_NULL  = 1 unless defined $NO_NULL;
    # set behavior when cgi_err() called -1 => silent, 0 => carp, 1 => croak
    $FATAL = -1 unless defined $FATAL;

Four of the default values of the old CGI.pm variables have been changed.
Unlike CGI.pm which by default allows unlimited POST data and file uploads
by default CGI::Simple limits POST data size to 100kB and denies file uploads
by default. $USE_PARAM_SEMICOLONS is set to 0 by default so we use (old style)
& rather than ; as the pair separator for query strings. Debugging is
disabled by default.

There are three new global variables. If $NO_NULL is true (the default) then
CGI::Simple will strip null bytes out of names, values and keywords. Null
bytes can do interesting things to C based code like Perl. Uploaded files
are not touched. $FATAL controls the behavior when B<cgi_error()> is called.
The default value of -1 makes errors silent. $USE_CGI_PM_DEFAULTS reverts the
defaults to the CGI.pm standard values ie unlimited file uploads via POST
for DNS attacks. You can also get the defaults back by using the '-default'
pragma in the use:

    use CGI::Simple qw(-default);
    use CGI::Simple::Standard qw(-default);

The values of the global variables are stored in the CGI::Simple object and
can be referenced and changed using the B<globals()> method like this:

lib/CGI/Simple.pm  view on Meta::CPAN


All the cgi-lib.pl 2.18 routines are supported. Unlike CGI.pm all the
subroutines from cgi-lib.pl are included. They have been GOLFED down to
25 lines but they all work pretty much the same as the originals.

=head1 CGI::Simple COMPLETE METHOD LIST

Here is a complete list of all the CGI::Simple methods.

=head2 Guts (hands off, except of course for new)

    _initialize_globals
    _use_cgi_pm_global_settings
    _store_globals
    import
    _reset_globals
    new
    _initialize
    _read_parse
    _parse_params
    _add_param
    _parse_keywordlist
    _parse_multipart
    _save_tmpfile
    _read_data

=head2 Core Methods

    param
    add_param
    param_fetch
    url_param
    keywords
    Vars
    append
    delete
    Delete
    delete_all
    Delete_all
    upload
    upload_info
    query_string
    parse_query_string
    parse_keywordlist

=head2 Save and Restore from File Methods

    _init_from_file
    save
    save_parameters

=head2 Miscellaneous Methods

    url_decode
    url_encode
    escapeHTML
    unescapeHTML
    put
    print

=head2 Cookie Methods

    cookie
    raw_cookie

=head2 Header Methods

    header
    cache
    no_cache
    redirect

=head2 Server Push Methods

    multipart_init
    multipart_start
    multipart_end
    multipart_final

=head2 Debugging Methods

    read_from_cmdline
    Dump
    as_string
    cgi_error

=head2 cgi-lib.pl Compatibility Routines - all 2.18 functions available

    _shift_if_ref
    ReadParse
    SplitParam
    MethGet
    MethPost
    MyBaseUrl
    MyURL
    MyFullUrl
    PrintHeader
    HtmlTop
    HtmlBot
    PrintVariables
    PrintEnv
    CgiDie
    CgiError

=head2 Accessor Methods

    version
    nph
    all_parameters
    charset
    crlf                # new, returns OS specific CRLF sequence
    globals             # get/set global variables
    auth_type
    content_length
    content_type
    document_root
    gateway_interface
    path_translated
    referer
    remote_addr
    remote_host

lib/CGI/Simple.pm  view on Meta::CPAN

    _compile_all()
    asString()
    compare()

=head2 Internal Multipart Parsing Routines

    read_multipart()
    readHeader()
    readBody()
    read()
    fillBuffer()
    eof()

=head1 EXPORT

Nothing.

=head1 AUTHOR INFORMATION

Originally copyright 2001 Dr James Freeman E<lt>jfreeman@tassie.net.auE<gt>
This release by Andy Armstrong <andy@hexten.net>

This package is free software and is provided "as is" without express or
implied warranty. It may be used, redistributed and/or modified under the terms
of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)

Address bug reports and comments to: andy@hexten.net.  When sending
bug reports, please provide the version of CGI::Simple, the version of
Perl, the name and version of your Web server, and the name and
version of the operating system you are using.  If the problem is even
remotely browser dependent, please provide information about the
affected browsers as well.

Address bug reports and comments to: andy@hexten.net

=head1 CREDITS

Lincoln D. Stein (lstein@cshl.org) and everyone else who worked on the
original CGI.pm upon which this module is heavily based

Brandon Black for some heavy duty testing and bug fixes

John D Robinson and Jeroen Latour for helping solve some interesting test
failures as well as Perlmonks:
tommyw, grinder, Jaap, vek, erasei, jlongino and strider_corinth

Thanks for patches to:

Ewan Edwards, Joshua N Pritikin, Mike Barry, Michael Nachbaur, Chris
Williams, Mark Stosberg, Krasimir Berov, Yamada Masahiro

=head1 LICENCE AND COPYRIGHT

Copyright (c) 2007, Andy Armstrong C<< <andy@hexten.net> >>. All rights reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

=head1 SEE ALSO

B<CGI>, L<CGI::Simple::Standard>, L<CGI::Simple::Cookie>,
L<CGI::Simple::Util>, L<CGI::Minimal>

=cut



( run in 0.462 second using v1.01-cache-2.11-cpan-389fe586d7c )