Solved

GIG Link Banner

Posted on 1998-11-12
6
224 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

809 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