GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Very simple "smart" banner rotation ( TUTORIAL ) ghetto openx (https://gfy.com/showthread.php?t=992905)

SmokeyTheBear 10-17-2010 09:19 AM

Very simple "smart" banner rotation ( TUTORIAL ) ghetto openx
 
I built this recently for something , i thought i would share.

This is a simple script to display ads based on keywords in your pages title . The script will detect the pages title and display ads/banners from a list based on the keywords in the pages title. The idea being many sites have thousands of pages but the banners are template driven so they either have the same banner across the entire site in that spot or they randomly rotate banners based on no criteria.

Very usefull for things like tubesites,networks etc

make a folder called js on your server http://yoursite.com/js/

save the following as "javascript.php" in the folder you just created
Code:

<?php
Header("content-type: application/x-javascript");
?>
var scriptfolder = "http://yoursite.com/js/";
var mdt = document.title;
var title = mdt.toLowerCase().replace(/^\s+|\s+$/g, "").replace(/[_|\s]+/g, "-").replace(/[^a-z0-9-]+/g, "").replace(/[-]+/g, "-").replace(/^-+|-+$/g, "");
sij = scriptfolder + title + ".js";
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= sij;
head.appendChild(script);

Save the following as ".htaccess" in the same folder

Code:

RewriteEngine on
 RewriteRule ^(.*)\.js index.php?x=$1 [nc]

Save the following as "index.php" in the same folder

Code:

<?php
Header("content-type: application/x-javascript");
$x = $_GET['x'];
$x = str_replace("-"," ",$x);
$list = file_get_contents("list.txt");
$ali = explode("\n",$list);
$fli = explode("|",$ali[0]);
// default banner
$surl = $fli[1];
$simg = $fli[2];
// shuffle list
shuffle($ali);
foreach( $ali as $ky => $me){
$eme = explode("|",$me);
$keyword = $eme[0];
if (strlen(stristr($x,$keyword))>0) {
$surl = $eme[1];
$simg = $eme[2];
}
}
?>
surl = "<?php echo $surl; ?>";
simg = "<?php echo $simg; ?>";
document.getElementById('stbad').innerHTML = "<a href='" + surl + "' target='_blank'><img src='" + simg + "'></a>";

now save the following code as list.txt in same folder ( edit to your sponsors )

Code:

default|http://defaultsponsor|https://gfy.com/skins/gfy2007hdr/logo.gif
gay|http://sponsor.com/?x=myrefcode|http://sponsor.com/banner.jpg
twink|http://twink.com/?x=myrefcode|http://sponsor.com/banner.jpg
gfy|https://gfy.com|https://gfy.com/skins/gfy2007hdr/logo.gif

So in a nutshell the script will detect the current pages title, it will load "pages-title.js" the php will check your list.txt and see if any keywords you have in your list match keywords in the pages title, if so it will choose one to display.

The first banner is the default banner, you can use multiple banners/sponsors for the same keyword , it will randomly pick one.

to use just place the following code on your page where you want the banner to appear
( it will show up in the div )
Code:

<div id=stbad></div>
<script src=http://yoursite.com/js/javascript.php></script>


The Duck 10-17-2010 02:09 PM

Sweet, thanks!

jonnydoe 10-17-2010 02:38 PM

I have been looking for exactly something like this...THX!

alias 10-17-2010 02:44 PM

Cool script as usual, bump-o.

Fenris Wolf 10-17-2010 02:45 PM

Great little script. Thank you for sharing.:thumbsup

CyberHustler 10-17-2010 02:56 PM

Thanks... I've grown to dislike openx because it's so fucking bloated and slow. I've been looking for something like this. I will give you good rep tomorrow.

Jarmusch 10-17-2010 02:59 PM

Repped .

Caligari 10-17-2010 05:14 PM

excellent script, thanks!

signupdamnit 10-17-2010 05:21 PM

imaginary rep++ :thumbsup

epitome 10-17-2010 09:09 PM

Quote:

Originally Posted by NanoBot (Post 17616374)
Thanks... I've grown to dislike openx because it's so fucking bloated and slow. I've been looking for something like this. I will give you good rep tomorrow.

At how many daily impressions does it become bloated and slow?

We're running two installs for two networks and our host did some stuff to optimize one of them. Yesterday there were 821,200 impressions and it runs great. It's not even hosted on it's own server ... there are about 18 other sites on that server including tubes with 30k visitors a day with clips that are hosted on the server. It's pushing 40 MBPS right now with either 6 or 8 GB RAM (can't remember).

No problems to report at all so far.

Other than the impression quoted because I was already logged into OpenX, all numbers are rough.

SmokeyTheBear 10-17-2010 09:25 PM

Quote:

Originally Posted by epitome (Post 17617053)
At how many daily impressions does it become bloated and slow?

We're running two installs for two networks and our host did some stuff to optimize one of them. Yesterday there were 821,200 impressions and it runs great. It's not even hosted on it's own server ... there are about 18 other sites on that server including tubes with 30k visitors a day with clips that are hosted on the server. It's pushing 40 MBPS right now with either 6 or 8 GB RAM (can't remember).

No problems to report at all so far.

Other than the impression quoted because I was already logged into OpenX, all numbers are rough.

i actually built this because openx was bogging down and i really didn't need all the interface jazz, and i was only at like 100k imps. Another reason is openx has/had exploits and i just needed something simple i didn't need to monitor

TheSwed 11-09-2010 07:22 AM

Very great script Smokey :thumbsup
but let say I put this up on site1.com and want to use it for site2.com with out uploading
the folder to site2.com also.
Is that possible to do?
Have tried that but it will not work for me
:helpme

pornguy 11-09-2010 07:37 AM

Really nice one.

SmokeyTheBear 11-09-2010 07:45 AM

Quote:

Originally Posted by TheSwed (Post 17684819)
Very great script Smokey :thumbsup
but let say I put this up on site1.com and want to use it for site2.com with out uploading
the folder to site2.com also.
Is that possible to do?
Have tried that but it will not work for me
:helpme

it should work fine, as long as your banner urls are full urls

TheSwed 11-09-2010 07:55 AM

Quote:

Originally Posted by SmokeyTheBear (Post 17684884)
it should work fine, as long as your banner urls are full urls

hmm..tried that but site2.com want to download javascript.php
Code:

var scriptfolder = "http://site1.com/js/";
var mdt = document.title;
var title = mdt.toLowerCase().replace(/^\s+|\s+$/g, "").replace(/[_|\s]+/g, "-").replace(/[^a-z0-9-]+/g, "").replace(/[-]+/g, "-").replace(/^-+|+$/g, "");
sij = scriptfolder + title + ".js";
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= sij;
head.appendChild(script);



All times are GMT -7. The time now is 11:45 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc