Solved

GIG Link Banner

Posted on 1998-11-12
6
219 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PowerShell Special Characters In Text String 3 134
Powershell variable with -SearchBase cmdlet 2 85
Run command in each subfolder using batch file 7 50
React or Angular? 6 51
Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

929 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

9 Experts available now in Live!

Get 1:1 Help Now