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


<?php
##############################################
// CONFIGURATION SECTION

    
$img_count = "4";   
    
$img_url   = "http://yourdomain.com/images/";  
    
$img_type  = "jpg";     

##############################################

// Sanitize the var.
    
$img_count = strip_tags(trim($img_count));

// Check length for security
if( strlen($img_count) > 2) {
  die(
'<h2>Error!</h2> <p>Image count too high. Cannot exceed 99.</p>');
}

// Randomize and adjust number format (allows for 99 images 00-99)
    
$img = (rand()%$img_count);
if(
strlen($img) < 2) {
    
$img = $img + 1;
    
$img = "0$img";
}

// Redirect to random image to pull new JPG file into UBBC
    
header("Location: $img_url$img.$img_type");

?>