Forum Moderators: martinibuster

Message Too Old, No Replies

Can you put ads in a SSI file?

Are there any (dis)advantages to doing this?

         

Rightz

10:47 am on Jun 4, 2006 (gmt 0)

10+ Year Member



I was considering putting adsense ads in a SSI file (alongside the navigation).

I was wondering whether this is recommended?

I'm assuming they will still be randomly generated and load ok?

Any clues?

gudrunj

11:51 am on Jun 4, 2006 (gmt 0)

10+ Year Member



I've been using both adblocks and adlinks in ssi files for well over a year and there has been absolutely no problem with it. They look just like the ones that are not in ssi files.

Rightz

2:08 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



Great - thanks for the advice. Will try them out :)

jetteroheller

2:12 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To put all ads in SSI was part of my Adsense security program.

The other notebooks of my family have special user agent strings and show Amazon instead.

Some IP addresses are also checked by the SSI script. They show alos Amazon instead.

greatstart

3:12 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It works fine for me.

I simply place the AdSense code in a text file and call it "adsense.txt".

Then I addded this code to my pages -
<!--#include virtual="adsense.txt"-->

Just make sure you have this line in your .htaccess file -
AddType text/x-server-parsed-html .html

This will make .html pages work with SSI so you won't have to use .shtml pages.

Rightz

4:35 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



jetteroheller - I've currently got SSI files. How would I go about checking IP addresses to show either affiliates or adsense ads?

greatstart - my host says you have to have .shtml pages no matter what is in the .htaccess file - Is that normal?

jetteroheller

5:05 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



use strict "vars";
use strict "refs";
use strict "subs";

$cgi::mailprogram= "/usr/sbin/sendmail";

init();

sub init
{
print "Content-type: text/html\n\n";

$env::query_string= $ENV { 'QUERY_STRING' };

my @query_tab= split ( /\&/, $env::query_string );
my $query;
foreach $query ( @query_tab )
{
$query=~ s/\+/ /go;

my ( $key, $val )= split ( /\=/, $query, 2 );

# Convert %XX from hex numbers to alphanumeric
$key=~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
$val=~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;

if ( $key eq "insert") { $ssi::insert= $val;}
if ( $key eq "from") { $ssi::from= $val;}
if ( $key eq "arb") { $ssi::arb= $val;}
}

$env::remote_host= $ENV { 'REMOTE_HOST' };#Apache V1.3 does not set
if (! $env::remote_host ){ $env::remote_host= $ENV { 'REMOTE_ADDR' } }

if ( index ( $ENV { 'REQUEST_URI'},'.htm?as=no') > 0) { noad ( "REQUEST_URI with .htm?as=no") }
if ( index ( $ENV { 'HTTP_REFERER'},'.htm?as=no') > 0) { noad ( "HTTP_REFERER with .htm?as=no") }
if ( index ( $ENV { 'HTTP_USER_AGENT' },'Alexa Toolbar YYYYMMDD') > 0) { noad ( "My wife visits") }
if ( $env::remote_host eq "unwanted visitor") { noad ( "unwanted visitor") }

my $file= "../admin/source/$ssi::from.txt";
my ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks )
= stat ( $file );
if (! $ctime )
{#no file found
$ssi::message.= "
Can not open $file";
message ();
return;
}#no file found

open( GET_SOURCE,$file);
binmode( GET_SOURCE);
sysread( GET_SOURCE,$ssi::file, $size);
close( GET_SOURCE);

my $ad= extract ( "$ssi::alt$ssi::insert" );

$ssi::arb=~ s/\ /\%20/g;
$ad=~ s/AMAZON_RB/$ssi::arb/g;

message ();
print $ad;
}

sub noad
{
my ( $message )= @_;
$ssi::message.= "\n$message";
$ssi::alt= "alt.";
}

sub extract
{
my ( $key )= @_;
my $text_search= "\n$key=";
my $val= "\n$ssi::file\n";
my $text_index_begin= index ( $val, $text_search );
if ( $text_index_begin < 0 )
{#begin not found
$ssi::message.= "
from $ssi::from insert $ssi::insert text $key
begin not found";
return "";
}#begin not found

my $text_index_end;
{#container block found, extract text
$text_index_end= rindex ( $val, $text_search . "END" );
if ( $text_index_begin < $text_index_end ){ last }
$text_index_end= index ( $val, "\n", $text_index_begin + 1 );
if ( $text_index_end >= 0 ){ last }
$ssi::message.= "
from $ssi::from insert $ssi::insert text $key
end not found";
return "";
}#container block found, extract text

my $text_search_length= length ( $text_search );
$val= substr ( $val, $text_index_begin + $text_search_length,
$text_index_end - $text_index_begin - $text_search_length );
return $val;
}

sub message
{
if (! $ssi::message ) { return }

open ( MAIL,"¦$cgi::mailprogram -t" );

print MAIL "To: webmaster\@example.com (Jettero Heller)
From: script\@$ENV{'SERVER_NAME'} (script error report)
Subject: error report - $ENV{'SCRIPT_URI'}
The following problems occured:

$ssi::message
";my $k; foreach $k ( keys %ENV ) { my $v = $ENV{$k}; print MAIL "\n[ $k ]=[ $v ]"; }
close(MAIL);
}

_______________________________________

The file contsains

300x250=
AdSense code for 300x250
300x250=END

alt.300x250=
Code to be shown instead of AdSense
alt.300x250=END

call is like

<!--#include virtual="/cgi-bin/ssi.pl?from=google-g&insert=300x250&arb=Theme" -->

arb means Amazon recommended book
This parameter is used to display recommended books about a theme.

from=google-g means from what file to load. google-g contains the code with the German channels and also the alt code for German.

jetteroheller

6:06 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



my host says you have to have .shtml pages no matter what is in the .htaccess file - Is that normal?

No!

Change Your host to be normal or change Your host.

mattg3

6:27 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just use php includes since a year no probs.

Rightz

7:58 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



Wow - jetteroheller: I really appreciate the time its taken you to do that but I wouldn't know where to begin with altering it to fit my needs. Is it CGI?

jetteroheller

8:18 pm on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I wouldn't know where to begin with altering it to fit my needs. Is it CGI?

It's Perl

To change:

Where is Your send email program

The path from the script to access the google.txt where all the ads are stored

All the conditions to show alt ads like

if ( condition ) { noads ( "message" ) }