Gossamer Forum
Home : General : Perl Programming :

Advertising

Quote Reply
Advertising
Hi,
I want to use a banner rotator script with Links that uses SSI calls. I can only use it on *.shtml pages and not on cgi generated pages. There was many discussion about this in the forum with webadverts. Unfortunatly i can't use that script.
So i'd like to know if it is possible to do the same as webadverts, adding a sub, but modyfied to call this line on cgi generated pages:<!--#exec cgi="/cgi-bin/advert/ad.cgi" -->

Maybe someone could give me an example of the modification for i'm very novice to perl scripts.
Thank you for your time...
Quote Reply
Re: Advertising In reply to
This is if you are using WebAdverts:

In the cgi script that you want a banner to show, put the following sub routine into the script and change it accordingly. Where you want an advert called, just put in &insertadvert;

sub insertadvert {
require "/path/to/ads_display.pl";
$adverts_dir = "/path/to/ads";
$display_cgi = "url to/ads.pl";
$advertzone = "";
$ADVlogIP = 0;
$NonSSI = 0;
$DefaultBanner= "";
$ADVNoPrint = 1;
&ADVsetup;
$ADVUseLocking = 1;
}

Hope that helps.


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Advertising In reply to
Hi,
Thank you for your reply!
But i'm not using webadverts.
I thought that maybe it would be possible to do something like this:

sub insertadvert {
<!--#exec cgi="/cgi-bin/advert/ad.cgi" -->
}

Is this possible?
Thank you
Quote Reply
Re: Advertising In reply to
Sure:

sub insert_advert {
my $ad = `/full/path/to/ad.cgi`;
$ad =~ s,Content-type:\stext/html//;
return $ad;
}

Basically, you are just running the program and stripping out the headers.

Hope that helps,

Alex
Quote Reply
Re: Advertising In reply to
Hi,
Thank you for the code!
But, there is a little problem, when i build my pages this is the error i get:
Content-type: text/plain Error including libraries: Substitution pattern not terminated at /home/htdocs/my_domain/cgi-bin/links/admin/site_html.pl line 1182. Make sure they exist, permissions are set properly, and paths are set correctly.

Where line 1182 is:
$ad =~ s,Content-type:\stext/html//;

Maybe you would know what that means...
Thank you for your time.
Quote Reply
Re: Advertising In reply to
That last "/" should be a ","

Smile

--Mark

------------------
You can reach me by ICQ at UIN #8602162


Quote Reply
Re: Advertising In reply to
Hi,
I changed that last "/" to a "," but i still get the same error.
This is exactly how my sub looks now:
sub insert_advert {
my $ad = `/cgi-bin/advert/ad.cgi`;
$ad =~ s,Content-type:\stext/html/,;
return $ad;
}

Thank you for your help.
Quote Reply
Re: Advertising In reply to
Hi,
Sorry about my last post...
The error i'm getting now is:
Content-type: text/plain Error including libraries: Substitution replacement not terminated.
Instead of substitution pattern mow it's substitution replacement.

This is how my sub looks like now:

sub insert_advert {
my $ad = `/cgi-bin/advert/ad.cgi`;
$ad =~ s,Content-type:\stext/html/,;
return $ad;
}

Please help me.
Thank you
Quote Reply
Re: Advertising In reply to
Hi Johnny,

I need the same help, having the same error. If you have a solution please let me know. Or to the coders, please reply here.

Thanx

Michael
Quote Reply
Re: Advertising In reply to
Mark was right (almost) the last two / should be commas. I used a comma to improve readability, but really messed it up instead. =)

Try:

$ad =~ s,Content-type:\stext/html,,;

Cheers,

Alex
Quote Reply
Re: Advertising In reply to
Thank you Alex, i can now build without any errors.
But my problem now is that there is no output. The banner is not showing.
I have the sub in my site_html.pl (last sub):
sub insert_advert {
my $ad = `/full/path/to/ad.cgi`;
$ad =~ s,Content-type:\stext/html,,;
return $ad;
}

And this is how i try to call it:
~;
&insert_advert;
print qq~

As i said, nothing shows up.

Any idea,
Thank you
Quote Reply
Re: Advertising In reply to
Well, &insert_ad does not print, it returns the text of the ad. So to print it you have to call:

print &insert_ad;

The other alternative, would be to modify &insert_ad so that it prints instead of returning. Six of one, half a dozen of the other.

Cheers,

Alex
Quote Reply
Re: Advertising In reply to
Hi Alex,

print &insert_advert;

returns the path to the advert file. In this case

/anything/mymaschine/cgi-bin/ads.pl

What to do?

Cheers


Michael
Quote Reply
Re: Advertising In reply to
Johnny, ZOul, Etc

Make sure that on the following line of code Alex provided:

my $ad = `/full/path/to/ad.cgi`;

That you are using a left single quote instead of a right single quote. On a IBM PC keyboard, a left quote ```` appears below the ~~~~ tilde symbol, while the right quote '''' appears below the double quote """"

Hope this fixes your problem...



------------------
Fred Hirsch
Web Consultant & Programmer