|
AZ::CGI - HTML forms and cookies parser |
AZ::CGI - HTML forms and cookies parser
use AZ::CGI;
$cgi = AZ::CGI->new();
$cgi->set_GET(
-incEmpty => $bool, # No
-cutNull => $bool, # Yes
-maxLoops => $quantity # 128
);
$cgi->set_COOKIE(
-incEmpty => $bool, # No
-cutNull => $bool, # Yes
-maxLoops => $quantity # 128
);
$cgi->set_POST(
-incEmpty => $bool, # No
-cutNull => $bool, # Yes
-maxLoops => $quantity, # 256
-maxSize => $size, # 2Mb
-maxKeySize => $size, # 128b
-maxValSize => $size # 256Kb
);
$cgi->set_MULTI(
-incEmpty => $bool, # No
-cutNull => $bool, # Yes
-maxLoops => $quantity, # 256
-maxSize => $size, # 16Mb
-maxKeySize => $size, # 128b
-maxValSize => $size, # 256Kb
-maxFiles => $quantity # 16
);
$cgi->GET($key,$number); $cgi->GET_is($key,$number); $cgi->GET_size($key); $cgi->GET_keys();
$cgi->COOKIE($key); $cgi->COOKIE_is($key); $cgi->COOKIE_keys();
$cgi->POST($key,$number); $cgi->POST_is($key,$number); $cgi->POST_size($key); $cgi->POST_keys();
$cgi->FILE($key,$number)->name(); $cgi->FILE($key,$number)->base(); $cgi->FILE($key,$number)->temp(); $cgi->FILE($key,$number)->mime(); $cgi->FILE($key,$number)->size(); $cgi->FILE_is($key,$number); $cgi->FILE_size($key); $cgi->FILE_keys();
$cgi->env($key); $cgi->uri_encode($string); $cgi->uri_decode($string);
This is Perl module for fastest and full securely parsing CGI query. POST query loading into memory only in parts, and, for this reason, module using little memory for parsing.
new()DESTROY()set_COOKIE(...)set_POST(...)set_MULTI(...)Note: For a cancellation of action of -maxLoops, -maxSize, -maxKeySize, -maxValSize and -maxFiles parameters you can using value -1.
set_GET() and set_COOKIE() methods is 128, and
for set_POST() and set_MULTI() methods is 256.
set_POST()
and set_MULTI(). Default value for set_POST() method is 2Mb and
for set_MULTI() method is 16Mb.
set_POST() and set_MULTI(). Default value is 128.
set_POST() and set_MULTI(). Default value is 256Kb.
set_MULTI() method. Defalut value is 16.
Note: For size of files no limits.
GET(KEY[,NUMBER])GET_is(KEY[,NUMBER])GET_size(KEY)GET_keys()COOKIE(KEY)GET() method. Only one difference, - no NUMBER argument.
COOKIE_is(KEY)COOKIE_keys()POST(KEY[,NUMBER])POST_is(KEY[,NUMBER])POST_size(KEY)POST_keys()POST(multipart) query files:FILE_is(KEY[,NUMBER])FILE_size(KEY)FILE_keys()name()Note: Exists file or not, you can check by FILE_is() method.
base()temp()mime()size()env(KEY)
if ($cgi->env("REQUEST_METHOD") eq "POST") {
# ...
}
uri_decode(STRING)uri_encode(STRING)
Returns only raw data. URL-encoded data in UTF-8 mode (%uXXXX) will be decoded correctly.
No support. Only ACSII platforms supported.
This module is required installed module AZ::Splitter version 0.60 or higher.
use AZ::CGI;
my $cgi = AZ::CGI->new();
print qq{Content-type: text/html\n\n};
print qq{<HTML>\n};
print qq{<BODY>\n};
print qq{<FORM action="">\n};
print qq{<P>Your name: <INPUT type=text name="name"></P>\n};
print qq{<P><INPUT type=submit></P>\n};
print qq{</FORM>\n};
print qq{<P><HR></P>\n};
if ($cgi->GET_is("name"))
{
my $name = $cgi->GET("name");
print qq{<P>Your name: $name</P>\n};
}
print qq{</BODY>\n};
print qq{</HTML>\n};
use AZ::CGI;
my $cgi = AZ::CGI->new();
print qq{Content-type: text/html\n\n};
print qq{<HTML>\n};
print qq{<BODY>\n};
print qq{<FORM action="" method=POST enctype=multipart/form-data>\n};
print qq{<P>Select file: <INPUT type=file name="file"></P>\n};
print qq{<P><INPUT type=submit></P>\n};
print qq{</FORM>\n};
print qq{<P><HR></P>\n};
if ($cgi->FILE_is("file"))
{
my $base = $cgi->FILE("file")->base();
my $temp = $cgi->FILE("file")->temp();
if (rename($temp,"/path/to/upload/$base"))
{
print qq{<P>File "$base" has uploaded successfuly!</P>};
}
}
print qq{</BODY>\n};
print qq{</HTML>\n};
use AZ::CGI;
my $cgi = AZ::CGI->new();
for my $key (sort $cgi->POST_keys()) {
for my $number (0..$cgi->POST_size($key))
{
my $value = $cgi->POST($key,$number);
print qq{<P>$key = "$value"</P>\n};
}
}
Green Kakadu <gnezdo@gmail.com>
Andrian Zubko aka Ondr, <ondr@mail.ru>
|
AZ::CGI - HTML forms and cookies parser |