Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Banner Rotation
#1
Credits and Source: http://www.dreamincode.net/

Name: Banner Rotation
Description: On Refresh of a page, this script selects a random banner from the /banners/ directory to show.
Snippet:
PHP Code:
/**
 * @author Furnfield
 * @email furnfield@googlemail.com
 * @copyright 2009
 * @project RBanner
**/

$directory './banners/'//Directory where Banners are located with opening ./ and trailing .
$directory2 'banners/'//Directory where Banners are located with trailing /

$i '0'// $i is a variable used in the naming of the array, so we set it to be 0 initally

$dir opendir ($directory); //Open the directory

while (false !== ($file readdir($dir)))
{
    if(
$file != '.' && $file != '..' && exif_imagetype($directory.$file) != false)
    {
            
$farray[$i] = $file//Select the image files and put them into an array
            
$i++; // add 1 to $i
    
}
}      
//Due to the final $i++;, $i is one value too large
$rand rand(0$i 1); //Create a Random number 0 <= $rand <= $i-1 
$rand_file $farray[$rand]; //Select the file from the array with the value $rand

echo '<img src="'.$directory2.$rand_file.'">'//output image file 

Instructions: just include the code the code in your script, and put all your banners into the /banners/ directory

Though this can be changed by editing the $directory variable at the start of the code.

Thankyou Blackhat
Reply
#2
Call me a noob, but, how exactly do you put PHP into a HTML / CSS file?
At the top will be the same place you hang from.
Reply
#3
Actually its a pure php script, you can use it within a php file and can't in an HTML. I don't know why you asked this question as it is evident from the OP that it just a php script for use in php.
Reply
#4
No need to get angry, I don't know anything about PHP and I was just wondering.
At the top will be the same place you hang from.
Reply
#5
(11-07-2009, 07:12 PM)trilobyte- Wrote: No need to get angry.

No, I am not angry atall :x
be happy always Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)