Results 1 to 3 of 3

Thread: Random advertising banner

  1. #1
    Join Date
    Feb 2012
    Posts
    22

    Default Random advertising banner

    Hi I would like to have the main top banner to display a random banner out of a selection so it changes each time you go onto the site.. How can I go about this

    Thanks shane

  2. #2
    Join Date
    Sep 2007
    Posts
    906

    Default

    Install OpenX or another ad serving software

    Download OpenX Source | OpenX
    vShare Hosting, vShare Installation, Server Setup, Lighttpd streaming, vShare Templates
    [email protected]

  3. #3

    Default

    I have a simple php rotate script if you want it : Works best with banners of the same size :

    Step one: create a folder (in this case i used rotate1) so http://yoursite.com/rotate1/

    Step two: create file called rotate.php and enter this text ::

    Code:
    <?php/*
    By Matt Mullenweg > http://photomatt.net
    Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
    Latest version always at:
    
    
    http://photomatt.net/scripts/randomimage
    
    
    */// Make this the relative path to the images, like "../img" or "random/images/".
    // If the images are in the same directory, leave it blank.
    $folder = '';
    
    
    // Space seperated list of extensions, you probably won't have to change this.
    $exts = 'html';
    
    
    $files = array(); $i = -1; // Initialize some variables
    if ('' == $folder) $folder = './';
    
    
    $handle = opendir($folder);
    $exts = explode(' ', $exts);
    while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
    if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
    $files[] = $file; // it's good
    ++$i;
    }
    }
    }
    closedir($handle); // We're not using it anymore
    mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
    $rand = mt_rand(0, $i); // $i was incremented as we went along
    
    
    header('Location: '.$folder.$files[$rand]); // Voila!
    ?>
    Step 3: Make html files each file with the banner code you want and name them 1.html .html exc
    They must be in the same folder as the php script you created... and works best with numbers only!!

    Step 4: Add the iframe code to where you want the banner ::

    Code:
    <center><iframe src="http://Yoursite.com/rotate1/rotate.php" width="500" height="100" frameBorder="0"><p>Place a non iframe banner (without flash or java here so a banner will always show if the users browser does not support these</p>
    </iframe>
    Make sure you change the iframe size! You need it slightly bigger than the banner.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •