ASP4::Server - Utility Methods
# Get the full disk path to /contact/form.asp: $Server->MapPath("/contact/form.asp"); # Email someone: $Server->Mail( To => 'jim@bob.com', From => 'Joe Jangles <joe@jangles.net>', Subject => 'Test Email', Message => "Hello There!", ); # Avoid XSS: <input type="text" name="foo" value="<%= $Server->HTMLEncode( $Form->{foo} ) %>" /> # Proper URLs: <a href="foo.asp?bar=<%= $Server->URLEncode($Form->{bar}) %>">Click</a>
The $Server object provides some utility methods that don't really fit anywhere else, but are still important.
$Server
Performs a simple string substitution to sanitize $str for inclusion on HTML pages.
$str
Removes the threat of cross-site-scripting (XSS).
Eg:
<tag/>
Becomes:
<tag/>
Does exactly the reverse of HTMLEncode.
Converts a string for use within a URL.
eg:
test@test.com
becomes:
test%40test.com
Converts a url-encoded string to a normal string.
Converts a relative path to a full disk path.
/contact/form.asp
/var/www/mysite.com/htdocs/contact/form.asp
Sends email - uses Mail::Sendmail's sendmail(...) function.
sendmail(...)
The supplied coderef will be executed with its arguments as the request enters its Cleanup phase.
See http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlCleanupHandler for details.
Calling <$Server-Error()>> without arguments will use the value of $@ and generate a ASP4::Error object from it, then pass it to the run(...) method of your <$Config-errors->error_handler>> for processing.
<$Server-
$@
run(...)
<$Config-
Please take a look at the documentation for ASP4::Error, ASP4::ErrorHandler and ASP4::ErrorHandler::Remote for details on how errors are handled.
It's possible that some bugs have found their way into this release.
Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4 to submit bug reports.
Please visit the ASP4 homepage at http://0x31337.org/code/ to see examples of ASP4 in action.
To install ASP4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ASP4
CPAN shell
perl -MCPAN -e shell install ASP4
For more information on module installation, please visit the detailed CPAN module installation guide.