discourse-legacysite-perl/site/glist/templates/help/GT/CGI.html
2024-06-17 22:24:05 +10:00

475 lines
12 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GT::CGI - a lightweight replacement for CGI.pm</title>
<link rev="made" href="mailto:root@penguin.office.gossamer-threads.com" />
<style type="text/css">
/* $MVD$:fontset("Untitled Font Set 1","ARIEL","HELVETICA","HELV","SANSERIF") */
/* $MVD$:fontset("Arial","Arial") */
/* $MVD$:fontset("Arial Black","Arial Black") */
/* $MVD$:fontset("Algerian","Algerian") */
body {
background-color: white;
font-family: Verdana, Arial, sans-serif;
font-size: small;
color: black;
}
p {
background-color : white;
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
h1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
background-color : white;
color : maroon;
}
h2 {
font-family : Verdana, Arial, sans-serif;
font-size : medium;
font-weight : bold;
color : blue;
background-color : white;
}
h3 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
color : black;
background-color : white;
}
h4 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : maroon;
background-color : white;
}
h5 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : blue;
background-color : white;
}
h6 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : black;
background-color : white;
}
ul {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
ol {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
li {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
th {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
td {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dd {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dt {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
code {
font-family : Courier;
font-size : small;
color : black;
}
pre {
font-family : Courier;
font-size : small;
color : black;
}
.mvd-H1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : 14.0pt;
background-color : transparent;
background-image : none;
color : maroon;
}
.mvd-H2 {
font-family : Verdana, Arial, sans-serif;
font-size : 12.0pt;
color : blue;
}
p.indent {
font-family : "Verdana, Arial, sans-serif";
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
.mvd-P-indent {
font-family : Verdana, Arial, sans-serif;
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
pre.programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE-programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE {
font-size : 9.0pt;
}
p.note {
margin-left : 28.0pt;
}
.mvd-P-note {
margin-left : 28.0pt;
}
.mvd-H4 {
font-family : Verdana, Arial, sans-serif;
font-weight : normal;
font-size : 9.0pt;
color : black;
margin-left : 6.0pt;
margin-top : -14.0pt;
}
.mvd-P {
font-family : Verdana, Arial, sans-serif;
font-size : 10.0pt;
color : black;
}
.mvd-BODY {
font-family : Verdana, Arial, sans-serif;
background-color : white;
}
p.indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
.mvd-P-indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
</style>
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<ul>
<li><a href="#param__accessing_form_input_">param - Accessing form input.</a></li>
<li><a href="#header____printing_http_headers"><code>header()</code> - Printing HTTP headers</a></li>
<li><a href="#redirect__redirecting_to_new_url_">redirect - Redirecting to new URL.</a></li>
<li><a href="#cookie__set_get_http_cookies_">cookie - Set/Get HTTP Cookies.</a></li>
<li><a href="#url__retrieve_the_current_url_">url - Retrieve the current URL.</a></li>
<li><a href="#get_hash__return_all_form_input_as_hash_">get_hash - Return all form input as hash.</a></li>
<li><a href="#escape__url_escape_a_string_">escape - URL escape a string.</a></li>
<li><a href="#unescape__url_unescape_a_string_">unescape - URL unescape a string.</a></li>
<li><a href="#html_escape__html_escape_a_string">html_escape - HTML escape a string</a></li>
<li><a href="#html_unescape__html_unescapes_a_string">html_unescape - HTML unescapes a string</a></li>
</ul>
<li><a href="#dependencies">DEPENDENCIES</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
<li><a href="#version">VERSION</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>GT::CGI - a lightweight replacement for CGI.pm</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
use GT::CGI;
my $in = new GT::CGI;
foreach my $param ($in-&gt;param) {
print &quot;VALUE: $param =&gt; &quot;, $in-&gt;param($param), &quot;\n&quot;;
}</pre>
<pre>
use GT::CGI qw/-no_parse_buttons/;</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>GT::CGI is a lightweight replacement for CGI.pm. It implements most of the
functionality of CGI.pm, with the main difference being that GT::CGI does not
provide a function-based interface (with the exception of the escape/unescape
functions, which can be called as either function or method), nor does it
provide the HTML functionality provided by CGI.pm.</p>
<p>The primary motivation for this is to provide a CGI module that can be shipped
with Gossamer products, not having to depend on a recent version of CGI.pm
being installed on remote servers. The secondary motivation is to provide a
module that loads and runs faster, thus speeding up Gossamer products.</p>
<p>Credit and thanks goes to the author of CGI.pm. A lot of the code (especially
file upload) was taken from CGI.pm.</p>
<p>
</p>
<h2><a name="param__accessing_form_input_">param - Accessing form input.</a></h2>
<p>Can be called as either a class method or object method. When called with no
arguments a list of keys is returned.</p>
<p>When called with a single argument in scalar context the first (and possibly
only) value is returned. When called in list context an array of values is
returned.</p>
<p>When called with two arguments, it sets the key-value pair.</p>
<p>
</p>
<h2><a name="header____printing_http_headers"><code>header()</code> - Printing HTTP headers</a></h2>
<p>Can be called as a class method or object method. When called with no
arguments, simply returns the HTTP header.</p>
<p>Other options include:</p>
<dl>
<dt><strong><a name="item__2dforce__3d_3e_1">-force =&gt; 1</a></strong><br />
</dt>
<dd>
Force printing of header even if it has already been displayed.
</dd>
<p></p>
<dt><strong><a name="item__2dtype__3d_3e__27text_2fplain_27">-type =&gt; 'text/plain'</a></strong><br />
</dt>
<dd>
Set the type of the header to something other then text/html.
</dd>
<p></p>
<dt><strong><a name="item__2dcookie__3d_3e__24cookie">-cookie =&gt; $cookie</a></strong><br />
</dt>
<dd>
Display any cookies. You can pass in a single GT::CGI::Cookie object, or an
array of them.
</dd>
<p></p>
<dt><strong><a name="item__2dnph__3d_3e_1">-nph =&gt; 1</a></strong><br />
</dt>
<dd>
Display full headers for nph scripts.
</dd>
<p></p></dl>
<p>If called with a single argument, sets the Content-Type.</p>
<p>
</p>
<h2><a name="redirect__redirecting_to_new_url_">redirect - Redirecting to new URL.</a></h2>
<p>Returns a Location: header to redirect a user.</p>
<p>
</p>
<h2><a name="cookie__set_get_http_cookies_">cookie - Set/Get HTTP Cookies.</a></h2>
<p>Sets or gets a cookie. To retrieve a cookie:</p>
<pre>
my $cookie = $cgi-&gt;cookie ('key');
my $cookie = $cgi-&gt;cookie (-name =&gt; 'key');</pre>
<p>or to retrieve a hash of all cookies:</p>
<pre>
my $cookies = $cgi-&gt;cookie;</pre>
<p>To set a cookie:</p>
<pre>
$c = $cgi-&gt;cookie (-name =&gt; 'foo', -value =&gt; 'bar')</pre>
<p>You can also specify -expires for when the cookie should expire, -path for
which path the cookie valid, -domain for which domain the cookie is valid, and
-secure if the cookie is only valid for secure sites.</p>
<p>You would then set the cookie by passing it to the header function:</p>
<pre>
print $in-&gt;header ( -cookie =&gt; $c );</pre>
<p>
</p>
<h2><a name="url__retrieve_the_current_url_">url - Retrieve the current URL.</a></h2>
<p>Returns the current URL of the script. It defaults to display just the script
name and query string.</p>
<p>Options include:</p>
<dl>
<dt><strong><a name="item_absolute__3d_3e_1">absolute =&gt; 1</a></strong><br />
</dt>
<dd>
Return the full URL: <a href="http://domain/path/to/script.cgi">http://domain/path/to/script.cgi</a>
</dd>
<p></p>
<dt><strong><a name="item_relative__3d_3e_1">relative =&gt; 1</a></strong><br />
</dt>
<dd>
Return only the script name: script.cgi
</dd>
<p></p>
<dt><strong><a name="item_query_string__3d_3e_1">query_string =&gt; 1</a></strong><br />
</dt>
<dd>
Return the query string as well: script.cgi?a=b
</dd>
<p></p>
<dt><strong><a name="item_path_info__3d_3e_1">path_info =&gt; 1</a></strong><br />
</dt>
<dd>
Returns the path info as well: script.cgi/foobar
</dd>
<p></p>
<dt><strong><a name="item_remove_empty__3d_3e_0">remove_empty =&gt; 0</a></strong><br />
</dt>
<dd>
Removes empty query= from the query string.
</dd>
<p></p></dl>
<p>
</p>
<h2><a name="get_hash__return_all_form_input_as_hash_">get_hash - Return all form input as hash.</a></h2>
<p>This returns the current parameters as a hash. Any values that have the same
key will be returned as an array reference of the multiple values.</p>
<p>
</p>
<h2><a name="escape__url_escape_a_string_">escape - URL escape a string.</a></h2>
<p>Returns the passed in value URL escaped. Can be called as class method or
object method.</p>
<p>
</p>
<h2><a name="unescape__url_unescape_a_string_">unescape - URL unescape a string.</a></h2>
<p>Returns the passed in value URL un-escaped. Can be called as class method or
object method. Optionally can take an array reference of strings instead of a
string. If called in this method, the values of the array reference will be
directly altered.</p>
<p>
</p>
<h2><a name="html_escape__html_escape_a_string">html_escape - HTML escape a string</a></h2>
<p>Returns the passed in value HTML escaped. Translates &amp;, &lt;, &gt; and `` to their
html equivalants.</p>
<p>
</p>
<h2><a name="html_unescape__html_unescapes_a_string">html_unescape - HTML unescapes a string</a></h2>
<p>Returns the passed in value HTML unescaped.</p>
<p>
</p>
<hr />
<h1><a name="dependencies">DEPENDENCIES</a></h1>
<p>Note: GT::CGI depends on <a href="glist.cgi?do=admin_gtdoc&topic=/GT/Base.html">the GT::Base manpage</a> and <a href="glist.cgi?do=admin_gtdoc&topic=/GT/AutoLoader.html">the GT::AutoLoader manpage</a>, and if you are
performing file uploads, GT::CGI::MultiPart, GT::CGI::Fh, and <a href="glist.cgi?do=admin_gtdoc&topic=/GT/TempFile.html">the GT::TempFile manpage</a>.
The ability to set cookies requires GT::CGI::Cookie.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved.
<a href="http://www.gossamer-threads.com/">http://www.gossamer-threads.com/</a></p>
<p>
</p>
<hr />
<h1><a name="version">VERSION</a></h1>
<p>Revision: $Id: CGI.pm,v 1.145 2005/06/21 21:02:57 jagerman Exp $</p>
</body>
</html>