• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

GIG Link Banner

I am experimenting with linkable graphics that will change each time the page is loaded... Many sites use this as banner ads... I uploaded the pl file into my cgi-bin and added <!--#exec cgi="Source/to/cgi-bin/file.pl" --> I also tried the <img src="Source/to/cgi-bin/file.pl"> neither works... But if I go directly to the location through my browser the cgi displays... How do I add it to or get it to run in the html page.  It is on an NT server if that matters?

I have asked a few people and nobody knows how to get it to work!
0
joshf
Asked:
joshf
  • 3
  • 3
1 Solution
 
joshfAuthor Commented:
Title was supposed to be CGI Link Banner??? Typo?
0
 
aioudineCommented:
First, you should have Perl installed,
+ required perl libraries, like cgi-lib.pl
"Perl for Win32" available from ActiveState
at  http://www.activestate.com/pw32/
Here you also may download PerlScript (IMHO it's for IIS)
For cgi-lib.pl search www.cgi-resourses.com 
or in altavista

Second (for most webservers) youshuld enable SSI for directory where shtml (SSI) files saved

Also html files with SSI command should have appropriate extention (usialy .shtml or .ssi)


Below I post example which work on Netware and Unixes
------ perl script ---
# jmerrill, 4/22/97
#
# Very basic advertisement rotator.  Advertisements are separate files containing HTML code.
# The script is kept very stripped down so you can see how it works and enhance it.
# An advertisement file may be as simple as a single <A> element containing an <IMG> element.
# Links and references should NOT be relative because they would be relative to the Perl script.
# Only the advertisement files should be in the PATH directory.
# Selection of advertisement is not guaranteed to be different every time.
# Almost no errorchecking is done by this script.
# The more ads there are, the better selection you will probably see.
#
# Parameters:
# PATH    The path, relative to the document root, where the advertisement files are stored.
#

require("cgil-ib.pl");
print &PrintHeader;
&ReadParse;

$tmpfile = "LASTADV.TMP";
($path   = ("$in{PATH}/" or "/")) =~ s|//|/|g;            #The path from the CGI data
$host   = "$ENV{SERVER_NAME}:$ENV{SERVER_PORT}";       #The Web Server's host name
($dir   = "$ENV{VSERVER_ROOT}docs$path/") =~ s|//|/|g;      #The real directory (e.g. SYS:WEB...)

# Build a list of advertisements in the directory
opendir(DIR, $dir);
@advers = sort(grep(!/$tmpfile/, readdir(DIR)));
closedir(DIR);

# Read the filename of the last advertisement
open(FILE, "$dir$tmpfile");
$last = <FILE>;
close(FILE);

# Randomly select an advertisement
srand(time);
$adver = $advers[rand($#advers + 1)];

# Second chance to keep it random (if the selection was same as last)
if ($adver eq $last) { $adver = $advers[rand($#advers + 1)]; }

# Write the filename of the last advertisement
open(FILE, ">$dir$tmpfile");
print FILE $adver;
close(FILE);

# Open the selected advertisement and write it
open(FILE, "$dir$adver");
print <FILE>;
close(FILE);

------end script-----

-----  of shtml file ---

<html><head><title>Example usage of advertisement rotator</title></head>
<body bgcolor="#ffffff">
<center><h2>Advertisement Rotator Example</h2></center>
This Server-side include (SSI) document uses the "#EXEC CGI=" command to call the advertisement rotator Perl script.  Click 'reload' to cycle through the advertisements.  There are four advertisements included in this example: IntranetWare, GroupWise, ManageWise and CyberMall.  They are pulled up semi-randomly.</p>
<!--#exec cgi="/perl/adrotate.pl?PATH=/tools/ads" -->
</body></html>
--end of html -----

-- example of add file ---
<a href="http://www.novell.com/groupwise"><img src="/images/gwban.gif"></a>
--end od ads file ----
0
 
joshfAuthor Commented:
Is there an easy way to accomplish this?
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
aioudineCommented:
What you mean?
You did'it or not?

Do you have perl instralled?
0
 
joshfAuthor Commented:
I accepted your answer because it looks familiar and I belive it is what I was supposed to do... However I have not had the time to implement it... I was Just wondering if there was an easier way to do this without going into such complex measures since I  and am for the first time just getting into programming languages & javascript I seem to make many mistakes...
0
 
aioudineCommented:
Of course, you may use just a JavaScript
But in this case, when you need change banners,
you must edit every file!!
In other case, when you use CGI you need just edit, replace, delete, add
files in ads directory

See JavaScript example below
--- start----
<script>
    imgs=new Array("first.gif","second.gif","third.gif");
    urls=new Array("http://www.first.com","http://www.second.com","http://www.third.com");
    </script>
then in your code, where you want to put your changing gif do this:
<script>
i=Math.floor(Math.random()*imgs.length);
 document.write("<A HREF=\""+urls[i]+"\"> <img src=\""+imgs[i]+"\" alt=\""+imgs[i]+"\"></A>");
</script>
--- end ---
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now