Random Skyscraper Advert Script

Discussion in 'Scripts' started by geekazoid, Jun 11, 2006.

  1. #1
    I have many skyscrapers assigned to many differant pages and id prefer to have them all on all the pages by using the random generator thing.

    Is there some script i can use to do this and an external txt file i can keep updating with new adverts ? Please help
     
    geekazoid, Jun 11, 2006 IP
  2. 26global

    26global Peon

    Messages:
    100
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This will work.

    Paste this into a file called rotate.php and save it to the root of your site.

    <?php
    
    //opening the text file, if this line gives you error when compiling
    //the code then you need to chmod 755 your text file
    $fcontents = join ('', file ('http://yourdomain.com/textfile.txt'));
    
    //Spliting contents of file by looking for ~ mark between codes
    //and storing everything into an array.
    $s_con = split("~",$fcontents);
    
    //getting a random number which will be within the limit of the
    //contents of the file, means if 5 different banners/ads then the number
    //will be between 0-4 (total 5 )
    $banner_no = (rand()%(count($s_con)-1));
    
    //simple scho banner
    echo $s_con[$banner_no];
    
    
    ?> 
    Code (markup):
    Then you will create a text file called textfile.txt which you will put in the contents of what you want to rotate. You can include html in this file. It looks like this. Save this file in the root of your site as well.

    <a href="link.html" target="_blank"><img src="banner.jpg" alt="banner" name="banner" width="468" height="60" border="0" id="banner" /></a>
    ~
    <a href="link2.html" target="_blank"><img src="banner2.jpg" alt="banner2" name="banner2" width="468" height="60" border="0" id="banner2" /></a>
    ~
    Code (markup):
    Remember you have to use ~ to seperate each of the contents.

    If your pages are .html or .htm then you need to include this line in your .htaccess file so it can render the php

    AddType application/x-httpd-php .html
    Code (markup):
    Now to include the rotating banner in your page you just have to place this line of code wherever you want the banners to appear.

    <?include("http://yourdomain.com/rotate.php");?>
    Code (markup):
    Hope that helps. Otherwise there are other random content rotator scripts out there. Just search google.
     
    26global, Jun 11, 2006 IP
    itsme likes this.
  3. funlounge

    funlounge Peon

    Messages:
    205
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is a very nice simple script 26global !

    thanks for sharing it...
     
    funlounge, Jun 12, 2006 IP