1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to setup up rotating ad banners?

Discussion in 'Site & Server Administration' started by Cartman, Oct 28, 2004.

  1. #1
    Sorry if this has been covered, but I did a search and didn't come up with anything..

    I want to have rotating ad banners on my site, and have come across alot of different scripts to accomplish this. Wondering what you guys use to do this and what you would suggest. Thanks!
     
    Cartman, Oct 28, 2004 IP
  2. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,740
    Likes Received:
    1,702
    Best Answers:
    78
    Trophy Points:
    510
    #2
    I had my guru write a script to rotate ads once a day on my sites. I do not know what is avaliable as freeware or shareware.

    Shannon
     
    Smyrl, Oct 28, 2004 IP
  3. disgust

    disgust Guest

    Messages:
    2,417
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    0
    #3
    here's something I use quite often... a few steps involved though

    1) create a file, put the following in it...

    <?
    $OpenDir = opendir("ads");
    while ($DirFiles = readdir($OpenDir)) {
      $Filename = "ads/" . $DirFiles;
      if (is_file($Filename)) {
        if (!isset($i)) {
          $i = 0;
        } else {
          $i++;
        }
        $Ads[$i] = $Filename;
      }
    }
    $RandAd = rand(0, $i);
    include($Ads[$RandAd]);
    ?>
    PHP:
    2) create a folder called /ads/ in the main directory of the server, write seperate ads to be rotated, following this naming pattern: ad1.txt, ad2.txt, ad3.txt, etc. inside each of those txt files put different html/whatever you want to be randomly selected.

    3) where you want the "random" bits to be, use this code...

    
    <? php include "file-name-mentioned-in-first-step.php" ?>
    
    PHP:

    you can use this for things other than ads too, if you want. hope someone finds it useful, sorry if the explanation was a bit confusing.
     
    disgust, Oct 28, 2004 IP
    flawebworks likes this.
  4. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #4
    I too was looking for something like that. Thanks for the code.:)
     
    ResaleBroker, Oct 28, 2004 IP
  5. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #5
    Hey Cartman,

    disgust's code looks good, might give it a whirl some time :)

    I asked a similar question a while back in the post Adserver Solution needed when I was looking for a fairly bullet-proof, industry-standard ad server that could make life easier between publisher and advertiser.

    Basically TOPS30 suggested phpAdsNew, an open source system. There's also Thruport's Adjuggler and some others. I didn't go for these in the end for reasons of limited R&D time.

    If you want to go high-end there's realmedia's OpenAdStream which has lots of capability should you need it.
     
    Lever, Oct 28, 2004 IP
  6. Cartman

    Cartman Active Member

    Messages:
    354
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    88
    #6
    Very interesting, disgust! I've also got a similar solution using Javascript, I'll play with the 2 different options and see what works. Using your code, would I need to make my index.htm an index.php then? (I haven't used PHP before, so this is all new to me)
     
    Cartman, Oct 28, 2004 IP
  7. disgust

    disgust Guest

    Messages:
    2,417
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    0
    #7
    depends on your php configuration... on all of my servers I could use php on *.htm/l files
     
    disgust, Oct 28, 2004 IP
  8. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #8
    What are your sites hosted on Cartman?

    If it's apache, you sould just ad this to your .htaccess file

    AddType application/x-httpd-php .php .htm .html
    Code (markup):
    That should do the trick :)

    (It's from the ad network code BTW)....
     
    SEbasic, Oct 28, 2004 IP
  9. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #9
    Disgust,
    When I run this script with multiple ads, every so often I get this error:

    Warning: main(): Failed opening '' for inclusion (include_path='.:/usr/local/lib/php:../:../../:../../../:../../../../') in /hsphere/local/home/resale/resalebroker.com/content.php on line 15

    Any ideas?

    EDIT:
    I think I got it. I changed the 0 value to 1 and it seems to be stable.

    <?
    $OpenDir = opendir("ads");
    while ($DirFiles = readdir($OpenDir)) {
    $Filename = "ads/" . $DirFiles;
    if (is_file($Filename)) {
    if (!isset($i)) {
    $i = 1;
    } else {
    $i++;
    }
    $Ads[$i] = $Filename;
    }
    }
    $RandAd = rand(1, $i);
    include($Ads[$RandAd]);
    ?>
     
    ResaleBroker, Oct 28, 2004 IP
  10. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #10
    PHP is server-side;JavaScript is client-side.

    The net results of this are:

    If you use PHP for a link rotater, Google will see one link at a time.

    If you use JavaScript for a link rotater, Google will see all of the links all of the time.
     
    Will.Spencer, Oct 30, 2004 IP
  11. Cartman

    Cartman Active Member

    Messages:
    354
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    88
    #11
    Ok, I've gone with the JavaScript solution for now, and it seems to work just great. My host has the Entropy Banner Rotation script installed already, but since the domain I'm trying to use it on is a subdomain of my main site, it's giving me some problems and I'm waiting to hear back from the hosting company as to why it's acting like that.

    For those users without JavaScript (are there any people out there without this in this day and age?), what will they see? If they see nothing, that's fine and I might leave the Javascipt solution alone. Thanks for everyone's help!
     
    Cartman, Oct 30, 2004 IP
  12. disgust

    disgust Guest

    Messages:
    2,417
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    0
    #12
    turn off js and try it?

    that's why php is ideal though... it doesn't depend on what's on the client's end at all.
     
    disgust, Oct 30, 2004 IP