Forum Moderators: open

Message Too Old, No Replies

Creating a "speed bump" between our site and external links?

         

Jaree

3:32 pm on Apr 8, 2008 (gmt 0)

10+ Year Member



I am trying to enter a "speed bump" as the FDIC calls it to release us of any liability for content contained on external links that we have on our site? I found one thread on here but I am a beginner and need detailed help if anyone has the time. I would really appreciate any help anyone can offer! I've been stumped on this since last Thursday! Thank you!

rocknbil

4:35 pm on Apr 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard Jaree, I've worked with .gov sites and am familiar with this requirement. What you want to do is create some generic script in perl,. php, .asp, or other server-side language to manage any link thrown at it, as your external links are bound to grow and you don't need to reinvent the wheel each time. Don't do this with Javascript; accessibility guidelines of .gov sites preclude Javascript dependence.

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]

phranque

12:10 am on Apr 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], Jaree!

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.

Jaree

8:47 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



So I know I am going to sound like a complete beginner, but I really am. My only experience in html coding is template design. I'm not even sure how to make this work, although it is EXACTLY what we need. I have built our site in dreamweaver and I have a folder on my desktop that publishes any and all changes I make while I am making them. Is there anyone that has the time to explain this to me in more detail. I'm sorry to be so illiterate but I am a quick learner and hopefully once I cross this bridge I won't have to again! Thanks!

piatkow

10:34 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



By the sound of it you just have static html pages. You will need to do some server side scripting, which of course assumes that you are not using a lightweight hosting service that only supports html.

Jaree

11:26 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



We are on our own server here at the bank and it is hosted through the server so it shouldn't be considered "lightweight hosting service" but again, I am a beginner. I think I am in a forum that is a bit above my knowledge level because every response seems to confuse me more and more. Thanks for your help though.

phranque

12:48 am on Apr 10, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



here is an intro to CGI (Common Gateway Interface) [hoohoo.ncsa.uiuc.edu].
really you would just be using a program or script on your server to redirect the browser to the correct address.
the redirect is a HTTP response header containing the response code (301) and the destination url.
url-encoding means replacing each special character in the final destination url(mostly &, ? and /) with a percent and 2 digit code.

rocknbil

6:36 pm on Apr 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is for a bank? runs screaming . . . .

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.

phranque

12:20 am on Apr 11, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



rocknbil - brainphart on my part - i forgot what the point was here.
you don't want the script to return a redirect, you want it to return the weasel words and a link to the destination.
also, in these cases the typical requirement is that any offsite link must be in a popup window.
the problem with a static page is you need to create a specific page for every offsite link.
depends on how well that scales with your requirements.
ok for a few offsite links, not ok for hundreds.

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)

Marshall

3:41 am on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Jaree,

Do you have .asp capabilities? I have a script that works very well for this.

Marshall

rocknbil

4:14 pm on Apr 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

webifiedOne

1:41 pm on Jul 9, 2008 (gmt 0)

10+ Year Member



I really love the script rocknbil provided in his post of 4:35 pm on Apr 8, 2008!

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!

rocknbil

7:48 am on Jul 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard webifiedOne!

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.

TonyM28

5:30 pm on Jul 22, 2008 (gmt 0)

10+ Year Member



Hi...this topic seems to be popular.

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

webifiedOne

6:09 pm on Jul 22, 2008 (gmt 0)

10+ Year Member



Thanks, Rocknbil for the great explanation on July 10 (Sorry for my slowness getting back to the thread, too.).

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]

rocknbil

8:17 pm on Jul 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I could convert it for you, but I rarely code in PHP and besides, what would you learn? :-)

This should be trivial for any of the coders in the PHP forum [webmasterworld.com].