view release on metacpan or search on metacpan
Apache::ASP provides an Active Server Pages port to the
Apache Web Server with Perl scripting only, and enables developing
of dynamic web applications
with session management and embedded Perl code. There are also
many powerful extensions, including XML taglibs, XSLT rendering,
and new events not originally part of the ASP API!
=begin html
<table class="noescape" border="0"><tr><td>
<b>Apache::ASP's features include:</b>
<font face=verdana,helvetica,arial size=-1>
<ul>
<li> Scripting SYNTAX is Natural and Powerful
<li> Rich OBJECTS Developer API
<li> Web Application EVENTS Model
<li> Modular SSI Decomposition, Code Sharing
<li> User SESSIONS, CIFS & NFS Cluster Ready
<li> XML/XSLT Rendering & Custom Tag Technology
<li> CGI Compatibility
PerlSetVar CacheDB MLDBM::Sync::SDBM_File
=begin html
Here are some benchmarks about the CacheDB when used
with caching output from $Response->Include(\%cache)
running on a Linux 2.2.14 dual PIII-450.
The variables are output size being cached & the CacheDB used,
the default being MLDBM::Sync::SDBM_File.
<table class="noescape" border="0">
<tr><th>CacheDB</th><th>Output Cached</th><th>Operation</th><th>Ops/sec</th></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>3200 bytes</td> <td>read</td> <td>177</td></tr>
<tr><td>DB_File</td> <td>3200 bytes</td> <td>read</td> <td>59</td></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>32000 bytes</td> <td>read</td> <td>42</td></tr>
<tr><td>DB_File</td> <td>32000 bytes</td> <td>read</td> <td>53</td></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>3200 bytes</td> <td>write</td> <td>42</td></tr>
<tr><td>DB_File</td> <td>3200 bytes</td> <td>write</td> <td>39</td></tr>
</table>
=end html
data instead of the file name. This works just like the normal
$Response->Include() API, except a string reference is passed in
instead of a filename. For example:
<%
my $script = "<\% print 'TEST'; %\>";
$Response->Include(\$script);
%>
This include would output TEST. Note that tokens like
<% and %> must be escaped so Apache::ASP does not try
to compile those code blocks directly when compiling
the original script. If the $script data were fetched
directly from some external resource like a database,
then these tokens would not need to be escaped at all as in:
<%
my $script = $dbh->selectrow_array(
"select script_text from scripts where script_id = ?",
undef, $script_id
);
$Response->Include(\$script);
%>
This method could also be used to render other types of dynamic scripts,
ASP API extension.
=item $Server->GetLastError()
Not implemented, will likely not ever be because this is dependent
on how IIS handles errors and is not relevant in Apache.
=item $Server->HTMLEncode( $string || \$string )
Returns an HTML escapes version of $string. &, ", >, <, are each
escapes with their HTML equivalents. Strings encoded in this nature
should be raw text displayed to an end user, as HTML tags become
escaped with this method.
As of version 2.23, $Server->HTMLEncode() may take a string reference
for an optmization when encoding a large buffer as an API extension.
Here is how one might use one over the other:
my $buffer = '&' x 100000;
$buffer = $Server->HTMLEncode($buffer);
print $buffer;
- or -
my $buffer = '&' x 100000;
As of Apache::ASP 2.31, this method now accepts optional
arguments like $Response->Include & $Server->Execute.
$Server->Transfer is now just a wrapper for:
$Response->Include($file, @args);
$Response->End;
=item $Server->URLEncode($string)
Returns the URL-escaped version of the string $string. +'s are substituted in
for spaces and special characters are escaped to the ascii equivalents.
Strings encoded in this manner are safe to put in urls... they are especially
useful for encoding data used in a query string as in:
$data = $Server->URLEncode("test data");
$url = "http://localhost?data=$data";
$url evaluates to http://localhost?data=test+data, and is a
valid URL for use in anchor <a> tags and redirects, etc.
=item $Server->URL($url, \%params)
against invalid internal data. There was enough data left in these
old objects to make debugging the my closure problem confusing, where
it looked like the ASP object state became invalid.
+Added system debug diagnostics to inspect StateManager group cleanup
(d) Documentation update about flock() work around for
Win95/Win98/WinMe systems, confirmed by Rex Arul
(d) Documentation/site build bug found by Mitsunobu Ozato,
where <% %> not being escaped correctly with $Server->HTMLEncode().
New japanese documentation project started by him
at http://sourceforge.jp/projects/apache-asp-jp/
-InitPackageGlobals() called after new Apache::ASP object created so
core system templates can be compiled even when there was a runtime
compilation error of user templates. Bug fix needed pointed out by
Eamon Daly
=item $VERSION = 2.33; $DATE="04/29/2002"
data instead of the file name. This works just like the normal
$Response->Include() API, except a string reference is passed in instead
of a filename. For example:
<%
my $script = "<\% print 'TEST'; %\>";
$Response->Include(\$script);
%>
This include would output TEST. Note that tokens like <% and %> must be
escaped so Apache::ASP does not try to compile those code blocks
directly when compiling the original script. If the $script data were
fetched directly from some external resource like a database, then these
tokens would not need to be escaped at all as in:
<%
my $script = $dbh->selectrow_array(
"select script_text from scripts where script_id = ?",
undef, $script_id
);
$Response->Include(\$script);
%>
This method could also be used to render other types of dynamic scripts,
Returns the absolute file path to current executing script. Same as
Apache->request->filename when running under mod_perl.
ASP API extension.
$Server->GetLastError()
Not implemented, will likely not ever be because this is dependent on
how IIS handles errors and is not relevant in Apache.
$Server->HTMLEncode( $string || \$string )
Returns an HTML escapes version of $string. &, ", >, <, are each escapes
with their HTML equivalents. Strings encoded in this nature should be
raw text displayed to an end user, as HTML tags become escaped with this
method.
As of version 2.23, $Server->HTMLEncode() may take a string reference
for an optmization when encoding a large buffer as an API extension.
Here is how one might use one over the other:
my $buffer = '&' x 100000;
$buffer = $Server->HTMLEncode($buffer);
print $buffer;
- or -
because the original script will not pick up where it left off.
As of Apache::ASP 2.31, this method now accepts optional arguments like
$Response->Include & $Server->Execute. $Server->Transfer is now just a
wrapper for:
$Response->Include($file, @args);
$Response->End;
$Server->URLEncode($string)
Returns the URL-escaped version of the string $string. +'s are
substituted in for spaces and special characters are escaped to the
ascii equivalents. Strings encoded in this manner are safe to put in
urls... they are especially useful for encoding data used in a query
string as in:
$data = $Server->URLEncode("test data");
$url = "http://localhost?data=$data";
$url evaluates to http://localhost?data=test+data, and is a
valid URL for use in anchor <a> tags and redirects, etc.
against invalid internal data. There was enough data left in these
old objects to make debugging the my closure problem confusing, where
it looked like the ASP object state became invalid.
+Added system debug diagnostics to inspect StateManager group cleanup
(d) Documentation update about flock() work around for
Win95/Win98/WinMe systems, confirmed by Rex Arul
(d) Documentation/site build bug found by Mitsunobu Ozato,
where <% %> not being escaped correctly with $Server->HTMLEncode().
New japanese documentation project started by him
at http://sourceforge.jp/projects/apache-asp-jp/
-InitPackageGlobals() called after new Apache::ASP object created so
core system templates can be compiled even when there was a runtime
compilation error of user templates. Bug fix needed pointed out by
Eamon Daly
$VERSION = 2.33; $DATE="04/29/2002"
- fixed up t/server_mail.t test to skip if a sendmail server
lib/Apache/ASP/Request.pm view on Meta::CPAN
if(&config($asp, 'RequestParams')) {
$self->{'Params'} = bless { %$parsed_query, %$form }, 'Apache::ASP::Collection';
}
# do cookies now
my %cookies;
if(my $cookie = $headers_in->get('Cookie')) {
my @parts = split(/;\s*/, ($cookie || ''));
for(@parts) {
my($name, $value) = split(/\=/, $_, 2);
$name = &Unescape($self, $name);
next if ($name eq $Apache::ASP::SessionCookieName);
next if $cookies{$name}; # skip dup's
$cookies{$name} = ($value =~ /\=/) ?
&ParseParams($self, $value) : &Unescape($self, $value);
}
}
$self->{Cookies} = bless \%cookies, 'Apache::ASP::Collection';
$self;
}
sub DESTROY {
my $self = shift;
lib/Apache/ASP/Request.pm view on Meta::CPAN
my %params;
defined($string) || return(\%params);
my @params = split /[\&\;]/, $string, -1;
# we have to iterate through the params here to collect multiple values for
# the same param, say from a multiple select statement
for my $pair (@params) {
my($key, $value) = map {
# inline for greater efficiency
# &Unescape($self, $_)
my $todecode = $_;
$todecode =~ tr/+/ /; # pluses become spaces
$todecode =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/ge;
$todecode;
} split (/\=/, $pair, 2);
if(defined $params{$key}) {
my $collect = $params{$key};
if(ref $collect) {
# we have already collected more than one param for that key
lib/Apache/ASP/Request.pm view on Meta::CPAN
}
} else {
# normal use, one to one key value pairs, just set
$params{$key} = $value;
}
}
\%params;
}
# unescape URL-encoded data
sub Unescape {
my $todecode = $_[1];
$todecode =~ tr/+/ /; # pluses become spaces
$todecode =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/ge;
$todecode;
}
*config = *Apache::ASP::config;
1;
lib/Apache/ASP/Response.pm view on Meta::CPAN
$value =~ s/\"//sgo;
}
$attribs{$key} = $value;
}
# GET URL from tag attribs finally
my $rel_url = $attribs{$LinkTags{$tag}};
# $asp->Debug($rel_url, $element, \%attribs);
if(defined $rel_url) {
my $new_url = &SessionQueryParseURL($self, $rel_url);
# escape all special characters so they are not interpreted
if($new_url ne $rel_url) {
$rel_url =~ s/([\W])/\\$1/sg;
$element =~ s|($LinkTags{$tag}\s*\=\s*[\"\']?)$rel_url|$1$new_url|isg;
# $asp->Debug("parsed new element $element");
}
}
$new_content .= $head . $element;
}
lib/Apache/ASP/Response.pm view on Meta::CPAN
$frag = $4;
} else {
$new_url = $rel_url;
$query = '';
}
# for the split, we do not need to handle other entity references besides &
# because &, =, and ; should be the only special characters in the query string
# and the only of these characters that are represented by an entity reference
# is & as & ... the rest of the special characters that might be encoded
# in a URL should be URI escaped
# --jc 2/10/2003
my @new_query_parts;
map {
(! /^$Apache::ASP::SessionCookieName\=/) && push(@new_query_parts, $_);
}
split(/&|&/, $query);
my $new_query = join('&',
@new_query_parts,
$Apache::ASP::SessionCookieName.'='.$asp->{session_id}
site/changes.html view on Meta::CPAN
against invalid internal data. There was enough data left in these
old objects to make debugging the my closure problem confusing, where
it looked like the ASP object state became invalid.
+Added system debug diagnostics to inspect StateManager group cleanup
(d) Documentation update about flock() work around for
Win95/Win98/WinMe systems, confirmed by Rex Arul
(d) Documentation/site build bug found by Mitsunobu Ozato,
where <% %> not being escaped correctly with $Server->HTMLEncode().
New japanese documentation project started by him
at <a href=http://sourceforge.jp/projects/apache-asp-jp/>http://sourceforge.jp/projects/apache-asp-jp/</a>
-InitPackageGlobals() called after new Apache::ASP object created so
core system templates can be compiled even when there was a runtime
compilation error of user templates. Bug fix needed pointed out by
Eamon Daly
</pre></font>
<p>
site/config.html view on Meta::CPAN
DB_File or GDBM_File are probably better to use.
<font face="courier new" size=3><pre>
PerlSetVar CacheDB MLDBM::Sync::SDBM_File
</pre></font>Here are some benchmarks about the CacheDB when used
with caching output from $Response->Include(\%cache)
running on a Linux 2.2.14 dual PIII-450.
The variables are output size being cached & the CacheDB used,
the default being MLDBM::Sync::SDBM_File.
<font face="courier new" size=3><pre>
</pre></font><table class="noescape" border="0">
<tr><th>CacheDB</th><th>Output Cached</th><th>Operation</th><th>Ops/sec</th></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>3200 bytes</td> <td>read</td> <td>177</td></tr>
<tr><td>DB_File</td> <td>3200 bytes</td> <td>read</td> <td>59</td></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>32000 bytes</td> <td>read</td> <td>42</td></tr>
<tr><td>DB_File</td> <td>32000 bytes</td> <td>read</td> <td>53</td></tr>
<tr><td>MLDBM::Sync::SDBM_File</td> <td>3200 bytes</td> <td>write</td> <td>42</td></tr>
<tr><td>DB_File</td> <td>3200 bytes</td> <td>write</td> <td>39</td></tr>
</table>
<font face="courier new" size=3><pre>
</pre></font>For your own benchmarks to test the relative speeds of the
site/eg/source.inc view on Meta::CPAN
unless(open(FILE, $basefile)) {
print "Can't read $basefile\n";
$Response->End();
}
local $/ = undef;
my $data = <FILE>;
close FILE;
$data =~ s|^\#\!\/[^\n]+\n||sg;
$data =~ s/^\s+//s;
$data =~ s/\s+$//s;
my $escaped = $Server->HTMLEncode($data);
$escaped =~ s/(<%=?)(.*?)(%>)/
"<b><font color=#cc0000 face=\"courier new\">$1<font color=#000099>$2<\/font>$3<\/font><\/b>";
/egsx;
$escaped =~ s/(<\!\-\-\s*\#include\s*file\s*\=)(.*?)(\-\->)/
"<b><font color=#009900 face=\"courier new\">$1<font color=#555555>$2<\/font>$3<\/font><\/b>";
/egsx;
$escaped =~ s/(<\/?)([\w-]+:[\w-]+)/$1\<font color=\#008000\><b>$2<\/b>\<\/font\>/isg;
$escaped =~ s/(<\/?)([a-z]+)/$1\<font color=#007070\><b>$2<\/b>\<\/font\>/isg;
%>
<h3>Source of file <%=$file%>:</h3>
<pre>
<%= $escaped %>
</pre>
<%
} else {
$Response->Write("No file to be displayed");
}
%>
<!--#include file=footer.inc-->
site/index.html view on Meta::CPAN
<font face=verdana><font class=title size=+1 color=#555555><b>INTRO</b></font>
<font face="courier new" size=3><pre>
</pre></font>Apache::ASP provides an Active Server Pages port to the
Apache Web Server with Perl scripting only, and enables developing
of dynamic web applications
with session management and embedded Perl code. There are also
many powerful extensions, including XML taglibs, XSLT rendering,
and new events not originally part of the ASP API!
<font face="courier new" size=3><pre>
</pre></font><table class="noescape" border="0"><tr><td>
<b>Apache::ASP's features include:</b>
<font face=verdana,helvetica,arial size=-1>
<ul>
<li> Scripting <a href=syntax.html><font size=-1 face=verdana><b>SYNTAX</b></font></a> is Natural and Powerful
<li> Rich <a href=objects.html><font size=-1 face=verdana><b>OBJECTS</b></font></a> Developer API
<li> Web Application <a href=events.html><font size=-1 face=verdana><b>EVENTS</b></font></a> Model
<li> Modular <a href=ssi.html><font size=-1 face=verdana><b>SSI</b></font></a> Decomposition, Code Sharing
<li> User <a href=sessions.html><font size=-1 face=verdana><b>SESSIONS</b></font></a>, CIFS & NFS Cluster Ready
<li> <a href=xml.html><font size=-1 face=verdana><b>XML/XSLT</b></font></a> Rendering & Custom Tag Technology
<li> <a href=cgi.html><font size=-1 face=verdana><b>CGI</b></font></a> Compatibility
site/objects.html view on Meta::CPAN
that are generated dynamically by passing in a reference to the script
data instead of the file name. This works just like the normal
$Response->Include() API, except a string reference is passed in
instead of a filename. For example:
<font face="courier new" size=3><pre>
<%
my $script = "<\% print 'TEST'; %\>";
$Response->Include(\$script);
%>
</pre></font>This include would output TEST. Note that tokens like
<% and %> must be escaped so Apache::ASP does not try
to compile those code blocks directly when compiling
the original script. If the $script data were fetched
directly from some external resource like a database,
then these tokens would not need to be escaped at all as in:
<font face="courier new" size=3><pre>
<%
my $script = $dbh->selectrow_array(
"select script_text from scripts where script_id = ?",
undef, $script_id
);
$Response->Include(\$script);
%>
</pre></font>This method could also be used to render other types of dynamic scripts,
like XML docs using XMLSubs for example, though for complex
site/objects.html view on Meta::CPAN
<a name=%24Server-%3EGetb3d1ac42></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Server->GetLastError()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented, will likely not ever be because this is dependent
on how IIS handles errors and is not relevant in Apache.</font>
<p>
<a name=%24Server-%3EHTMb165f10b></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Server->HTMLEncode( $string || \$string )</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns an HTML escapes version of $string. &, ", >, <, are each
escapes with their HTML equivalents. Strings encoded in this nature
should be raw text displayed to an end user, as HTML tags become
escaped with this method.
<font face="courier new" size=3><pre>
</pre></font>As of version 2.23, $Server->HTMLEncode() may take a string reference
for an optmization when encoding a large buffer as an API extension.
Here is how one might use one over the other:
<font face="courier new" size=3><pre>
my $buffer = '&' x 100000;
$buffer = $Server->HTMLEncode($buffer);
print $buffer;
- or -
my $buffer = '&' x 100000;
site/objects.html view on Meta::CPAN
$Server->Transfer is now just a wrapper for:
<font face="courier new" size=3><pre>
$Response->Include($file, @args);
$Response->End;
</pre></font>
<p>
<a name=%24Server-%3EURL3674cef0></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Server->URLEncode($string)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the URL-escaped version of the string $string. +'s are substituted in
for spaces and special characters are escaped to the ascii equivalents.
Strings encoded in this manner are safe to put in urls... they are especially
useful for encoding data used in a query string as in:
<font face="courier new" size=3><pre>
$data = $Server->URLEncode("test data");
$url = "<tt>http://localhost?data=$data";</tt>
$url evaluates to <tt>http://localhost?data=test+data,</tt> and is a
valid URL for use in anchor <a> tags and redirects, etc.
</pre></font>