Forum Moderators: coopster & phranque

Message Too Old, No Replies

Random Image Script Question...

How to, where to install?

         

Litefoot

1:50 am on Jul 29, 2005 (gmt 0)

10+ Year Member



Hello, I am having one of those problems that seems to reflect "not seeing the forest for the trees" here. :(

I am trying to install a script from NMS that will call random images on a web site's page(s). It will go on the Template page (xyz.dwt for example) so that it will show on all pages attached to the template.

To be honest, I am lost trying to figure this out. I have created sites, added pages, configured message boards, admin'd them but I am having a time of it trying to figure this simple script out.

Just exactly what goes where? I know the .pl file goes to the cgi-bin and the random images go in a folder to be called from but, I am lost trying to configure the script.

If someone could lay it out step by step I would be most appreciative. I am doing this for a non-profit organization that is looking to see the site up by the first of the month. They are wanting to run a banner that changes with each page change or refresh that will link back to the banner's site. (ie: banner for Hannah Home linked to their site)

Thanks.

lexipixel

3:25 am on Jul 29, 2005 (gmt 0)

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



Most likely you need to use SSI, (server side include).

Some servers are configured to only parse SSI calls when they are in a file with an .shtml, .html, or .htm file extension, (regardless, you can instruct it to use non-standard shtml extension, see step #2).

The basic checklist is:

1. have a valid Perl/CGI script, (you should be able to call the script as a direct URL to test that it works), ie-

http://www.domain.tld/cgi-bin/script.pl

2. be sure that the server is configured to parse SSI, (if you are not the admin, ask -- if you are, check that you have the following (or similar) in the .htaccess file for the domain;

AddType text/html .shtml
AddHandler server-parsed .htm
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

3. add the following SSI "exec" tag to the document you want the script to insert the random image into-

<!--#exec cgi="/cgi-bin/script.pl" -->

Hope this helps.

WWMike

4:16 am on Jul 29, 2005 (gmt 0)

10+ Year Member



Here's a working /cgi-bin/randombanner.cgi script:

#!/usr/local/bin/perl

@images = ( "http://mydomain.com/banners/1.jpg", "http://mydomain.com/banners/2.jpg", "http://mydomain.com/banners/3.jpg" );
@links = ( "http://banner1.com", "http://banner2.com", "http://banner3.com" );

$selected = int(rand(@images));

print "Content-type: text/html\n\n";

print "<A HREF=$links[$selected]><IMG SRC=$images[$selected]></A>";

exit;

Here's the HTML call (requires SSI):

<!--#include virtual="/cgi-bin/randombanner.cgi" -->

Just modify the @images & @links array as well as the HREF & IMG tags to suit your needs.

Litefoot

2:06 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



Thanks guys, this is helping. Now, do I put the HTML call in the table I want the image to appear in?

WWMike

2:14 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



Anywhere on the HTML page such as:

<TABLE>
<TD><!--#include virtual="/cgi-bin/randombanner.cgi" --></TD>
</TABLE>

Litefoot

6:23 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



Thanks for the help! I really appreciate it. :)