Solved

GIG Link Banner

Posted on 1998-11-12
6
216 Views
Last Modified: 2013-12-25
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
Comment
Question by:joshf
  • 3
  • 3
6 Comments
 

Author Comment

by:joshf
ID: 1829549
Title was supposed to be CGI Link Banner??? Typo?
0
 
LVL 5

Accepted Solution

by:
aioudine earned 100 total points
ID: 1829550
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
 

Author Comment

by:joshf
ID: 1829551
Is there an easy way to accomplish this?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:aioudine
ID: 1829552
What you mean?
You did'it or not?

Do you have perl instralled?
0
 

Author Comment

by:joshf
ID: 1829553
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
 
LVL 5

Expert Comment

by:aioudine
ID: 1829554
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now