MyBB Community Forums

Full Version: Ad rotating plugin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am just wondering what you guys think the best ad rotating plugin is. I am currently using my advertisements, but it does not work with buysellads, so I guess I am wondering if there is better plugin that works with buysellads. If not I could possibly code a plugin myself.

I have money so you can suggest me paid plugins too. Smile
You could just use a script like this.

<?php

// random number 1 - 100 
$result_random=rand(1, 100);

// if result less than or equal 70, display ad 1 (70%)
if($result_random<=70){
echo "Display ad1";
}

// if result less than or equal 90, display ad 2 (20%)
elseif($result_random<=90){
echo "Display ad2";
}

// if result less than or equal 100, display ad 3 (10%)
elseif($result_random<=100){
echo "Display ad3";
}

?>
But a plugin is much easier to update. But I guess that would work. I don't really know why I didn't think of that. lol I might just give something like that a try. Smile
Phily, a better solution is something like this:

http://tremz.com/forums/images/tremz/ban...otater.php

All it is is a php page that actually outputs an image from a specified folder. Then you could just embed the php page as if it was an image. E.g.
<img class="advert" src="http://tremz.com/forums/images/tremz/banners/bannerrotater.php" />

And it will work! Simple, right?

A very simple version of this code could look something like this (untested code, just writing for example):

<?php
//the directory with your ads in it
$dir = "/path/to/your/forums/images/ads/";

//allowed img extensions
$extensions = array("png","gif","jpg");
$files = array();

//puts all valid images in an array
$handle = opendir($dir);
while ($file = readdir($handle)) {
    $parts = explode('.', $file);
    if(in_array($parts[sizeof($parts) - 1], $extensions) {
        array_push($files, $file);
    }
}
//randomly determine which file to use
$whichFile = mt_rand(0, sizeof($files) - 1);
$imgpath = $files[$whichFile];

//get extension
$parts = explode('.',$imgPath);
$extension = $parts[sizeof($parts) - 1];

//declare content type
switch($extension) {
case "png":
header('Content-type: image/png');
break;
case "jpg":
header('Content-type: image/jpg');
break;
case "gif":
header('Content-type: image/gif');
break;
default: //not a good extensions soemhow, just give them a bad image
header('Content-type: image/png');
}

$img = file_get_contents($imgPath);
echo $img;
?>
Or if you're insisted to have it as plugin then: http://yaldaram.com/showthread.php?tid=1824
Thanks Yaldaram, does this complete solution for MyBB Ads Management plugin rotate banners? Also is there a MyBB thread about it?
(2011-12-25, 10:55 PM)GFN Wrote: [ -> ]Thanks Yaldaram, does this complete solution for MyBB Ads Management plugin rotate banners? Also is there a MyBB thread about it?

Yes, it randomly rotates the ads (either code ads or banner ads)
(2011-12-25, 10:55 PM)GFN Wrote: [ -> ]Thanks Yaldaram, does this complete solution for MyBB Ads Management plugin rotate banners? Also is there a MyBB thread about it?
Yeah, you can either have ad code or rotating banners specified by you.

A live demo of random rotating banners can be seen on my friend's site,

www.dedduck.com/forums

Damn I think I might just have to get that plugin. Hopefully it works properly with buysellads though. No other plugins have though.
Hi Yaldaram, It looks good, I was about to subscribe to silver but you use 2checkout, so many details to enter, cant I just send you the Pay Pal direct?
lol I cant even register on your forum, problem with password, password not long enough, password incorrect, password not the same, Ive tried everything - giving up Sad
Pages: 1 2