Forum Moderators: open
Basically the logic is:
- capture the external link.
- display "exit" message, with real link below.
So your external links would read:
myscript.cgi?L=http://example.com/page.html
myscript.cgi (or .php, .asp, whatever) would get the value of "L" and put it in a link directly below your exit message. I don't think they want you to auto-redirect after X seconds, it has to be a static link (if memory serves.)
EDIT: Below is a tested perl sample. It can easily be ported to any language. EXCHANGE THE ¦ CHARACTERS FOR VERTICAL PIPES.
#!/usr/bin/perl
## Configure as required
$template = "/virtual/server/path/to/your/site-template.txt";
$sitename = 'Your Site Name';
$html = "Exiting the $sitename Site";
## The subroutine get_data reads and parses the input
## and stores it in the associative array %data.
## in this script, only GET is supported (it's all we need)
&get_data;
## Error if no link is passed.
unless ($data{'L'} =~ /^http\:\/\/\w+/i) { &error('No Exit URL Specified'); }
## The html subroutine outputs the page neatly in your site template.
&html;
##############
sub html {
$content = qq¦
<p>You are exiting the $sitename web site. We claim no responsibility over third-party sites.</p>
<p><a href="$data{'L'}">I understand and wish to move on</a>.</p>
¦;
open (TEMPLATE, "$template") ¦¦ &error ("Could not open template $template");
while ($ln = <TEMPLATE>) {
$ln =~ s/\¦HEADING\¦/$html/g;
$ln =~ s/\¦CONTENT\¦/$content/g;
$final .= $ln;
}
close (TEMPLATE);
print "Content-type: text/html\n\n";
print "$final\n";
exit 0;
}
######################
## Read and parse the input data:
sub get_data {
my ($query,@pairs,$name,$value);
unless ($ENV{'QUERY_STRING'}) { &error("only get method is supported"); }
$query = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $query);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$data{$name} = $value;
}
}
################## error handler
sub error {
my ($error);
$error = shift (@_);
print "Content-type: text/html\n\n";
print qq¦<p>A program error has occurred: $error.</p>¦;
exit 0;
}
[edited by: encyclo at 5:00 pm (utc) on April 8, 2008]
[edit reason] disabled smilies in code [/edit]
So your external links would read:
myscript.cgi?L=http://example.com/page.html
you should use url-encoding on the external url before inserting as a parameter value so that you don't have problems with reserved characters.
Just create a static page to a second static page
<a href="exit-to-google.html">Google</a>
Let exit-to-google.html contain your message and final link. You'll have to create one page for each link, but if they put a bank's web site in your hands and you don't have server-side skills, this will do.
Note to phranque: I think what you're suggesting is a redirect, no? They're looking for one of those "you're leaving this site" pages. Where did I get smileys in? It wasn't intentional.
also i think it was a ";" followed by a space and a ")" which tripped the smiley in two places (if you have smileys on in your preferences)
the problem with a static page is you need to create a specific page for every offsite link.
ABSOLUTELY - but given the OP's inability to play with server-side scripting, this is a solution (not a great one, but at least is is harmless and will work.)
The scriptlet I posted was intended for your average web site, I retract it now knowing this is for a bank. You'd want to do a lot more than encode special characters, it's not really fit for a secure situation.
I work for a .gov site, and would really like to adapt that script for our use.
Two questions I can't seem to answer, and wondered if you could help:
1. What is the syntax for the actual hyperlink code? Example: would it be: < a href="mysite.cgi?L=http://externallink.com/page.html">Link</ a>? (Extra spaces added to prevent real code from happening here.)
2. I do not understand the reference to "template.txt" at the top of the script. Do we build a templated page in which the contents of the Perl printout would read? Is that what that is?
Sorry for my coding shortcomings. Some stuff just goes right over my head. Thx!
In the previous example, site-template.txt would be something like this,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>¦HEADING¦</title>
<link rel="stylesheet" type="text/css" href="your_styles.css">
</head>
<body>
<h1>¦HEADING¦</h1>
¦CONTENT¦
</body>
</html>
And just like the perl sample, the ¦'s need to be an actual pipe character. The substitutions in the script would swap out the heading and script output for the "markers" in the template. Use any doctype you like, style it as you wish, the key is the markers.
That would be the correct link syntax.
What I have is a site showcasing my artwork, but between each link to a particular item, I would like to have a "speed bump" page that says "by clicking here you agree to the terms..." Once the user clicks on that button, it would then take them to the particular item.
How would I go about revising the code to fit what I need, and further more, how would I revise the code to PHP as opposed to Perl?
Thanks a bunch,
Tony
This seems like very good Perl script for our purposes. Dot Gov sites always have a bunch of restrictions and parameters on just about everything having to do with Web development, but this script accommodates most, or all, of them.
[edited by: webifiedOne at 6:10 pm (utc) on July 22, 2008]
This should be trivial for any of the coders in the PHP forum [webmasterworld.com].