<?php /*
   +------------------------------------------------------------------+
   | Green-Beast.com                                                  |
   | PHP: Masthead Rotator                                            |
   | PHP Hypertext Preprocessor                                       |
   | Copyright Jul 2007                                               |
   | Use with attribution by visible link please!                     |
   | Attribute to: <a href="http://green-beast.com/">Mike Cherim</a>  |
   +------------------------------------------------------------------+
*/
?>

<?php
/*
* This is a super simple lightweight solution. I suppose "rotator" is
* a misnomer since it actually randomizes. Enjoy.
*/
?>

<?php
########################################################## Begin Config

    
$pmr_count=     7;            // Max number of mastheads
    
$pmr_collect=  "Mastheads";   // Collection (directory) name

############################################################ End Config
/*
  Set the default mastehad number value
*/
    
$pmr_mast=            0;
/*
  This part randomizes the number up to the max
*/
    
$pmr_mast = (rand()%$pmr_count);
/*
  Add a little variable security. First we limit variable lengths: 2 digits
  for max and masthead number, and 20 digits for the folder/directory name.
  With these settings you can have up to 100 mastheads per collection (0-99).
*/
if( strlen($pmr_mast) > 2 || strlen($pmr_count) > 2 || strlen($pmr_collect) > 20 )  {
    exit(
'<h2>Variable Length Error!</h2>');
}
/*
  Now let's get rid of tags and whitespace if any
*/
    
$pmr_mast = strip_tags(trim($pmr_mast));
    
$pmr_count = strip_tags(trim($pmr_count));
    
$pmr_collect = strip_tags(trim($pmr_collect));

/*
  See the XHTML file to see how this is put to use
*/
?>