topical media & game development
lib-ajax-example-relay.cgi / cgi
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
# Between the line like this (see below)
# my AllowedDomains = <<LIST;
www.cs.vu.nl.com
www.few.vu.nl.com
LIST
# Notes:
# Check for a URL in the query string, as a value in a
# GET variable, or as a value in a POST variable. The
# first to match is used. If none match, exit.
my ENV{QUERY_STRING} and url = ENV{QUERY_STRING} and /)
{ ENV{REQUEST_METHOD} eq 'POST')
{
my buffer,buffer =~ /^url=(.+)url = $1; }
}
goto BOTTOM unless checkdomain = lc checkdomain =~ s!^http://!!i;
=~ s!/.*!!;
my AllowedDomains =~ s/^\s*//s;
//s;
for my AllowedDomains)
{
if(domain))
{
domainokay;
# Retrieve the page and print it to the browser.
my (success) = ();
my ua->agent(ENV{HTTP_USER_AGENT};
my ua->request(GET success = r->is_success;
if(content = content = 'Something is awry. Status code: '.content";
BOTTOM:
# end of script
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.