Web page, with a random image

The Freeola image below is randomly generated using PHP. Hit the refresh button to see it change!
GetDotted


PHP Code used to generate random image

<?php
#   This script was put together by Freeola user 'cjh', and not Freeola. #
##########################################################################

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   SECTION 1.
   ~~~~~~~~~~
   The section below will need to be edited to fit your needs, as
   detailed in the article:
   http://chat.freeola.com/Web-Development-4-chat/PHP-Script-Random-Image-Generator-Links-2133.html
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

   
$image_folder "freeola-random-images/";

   
// Entry 1.
    
$images[] = array("cheap-domain-names.gif","GetDotted","http://getdotted.com","GetDotted domain names");
   
// Entry 2.
    
$images[] = array("freeola-bingo-logo.gif","Freeola Bingo","http://freeola.com/bingo/","Freeola Bingo, play today");
   
// Entry 3.
    
$images[] = array("freeola-main.gif","Freeola","http://freeola.com","Freeola home page");
   
// Entry 4.
    
$images[] = array("gad-header-main-061206.gif","Gameaday","http://freeola.com/gameaday/","Freeola Gameaday, win Win WIN");
   
// Entry 5.
    
$images[] = array("gad-smallpromo.gif","Gameaday","http://freeola.com/gameaday/","Freeola Gameaday, win Win WIN");
   
// Entry 6.
    
$images[] = array("get-dotted-logo.gif","GetDotted","http://getdotted.com","GetDotted domain names");
   
// Entry 7.
    
$images[] = array("skyscraper-03a.gif","Freeola Broadband","http://freeola.com/broadband/","Up to 8mb Freeola Broadband");

   
$width  "auto";
   
$height "auto";
   
$border 7;
   
$hspace 170;
   
$vspace 70;

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   SECTION 2.
   ~~~~~~~~~~
   You do not need to edit below this line. Don't be alarmed if you find the code
   below a little over-baring; this is to cater for your various choices made above.
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

   // Randomly select a number.
   
if (!$random = @mt_rand(0count($images)-1))
    
$random 0// Random number generator failed, so use number 0.

   // Create formatting, as defined by the user above.
   
$imagesettings "";

   
// Check for and set 'width' and 'height' settings.
   
if ((isset($width) && $width == "auto") || (isset($height) && $height == "auto")) {
    
// Get the image dimensions.
    
if ($auto = @getimagesize($image_folder.$images[$random][0])) {
        
// Add them to the image settings.
        
$imagesettings .= " width=\"$auto[0]\"";
        
$imagesettings .= " height=\"$auto[1]\"";
    }
   } else {
    
// No auto, so check for any pre-set width and height.
    
if (isset($width) && is_numeric($width))
        
$imagesettings .= " width=\"$width\"";
    if (isset(
$height) && is_numeric($height))
        
$imagesettings .= " height=\"$height\"";
   }

   
// Check for and set 'border' setting.
   
if (isset($border) && is_numeric($border))
    
$imagesettings .= " border=\"$border\"";

   
// Check for and set 'align' setting.
   
if (isset($align)) {
    if (
$align == "bottom"
     
|| $align == "middle"
     
|| $align == "top"
     
|| $align == "left"
     
|| $align == "right")
        
$imagesettings .= " align=\"$align\"";    
   }

   
// Check for and set 'hspace' setting.
   
if (isset($hspace) && is_numeric($hspace))
    
$imagesettings .= " hspace=\"$hspace\"";

   
// Check for and set 'vspace' setting.
   
if (isset($vspace) && is_numeric($vspace))
    
$imagesettings .= " vspace=\"$vspace\"";

   
// Check for and set 'usemap' setting.
   
if (isset($usemap) && !empty($usemap))
    
$imagesettings .= " usemap=\"#$usemap\"";

   
// Check for and set 'xhtml' - this one must be last.
   
if (isset($xhtml) && $xhtml == "yes")
    
$imagesettings .= " /";

   
// Put together the final code.
   
if (isset($images) && is_array($images)) {
    if (
count($images[$random]) != 4) {
         echo 
"<!-- 4 values expected, but ".count($images[$random])." found. -->\n";
    } else {
        echo 
"<a href=\"".$images[$random][2]."\"";
        
// Don't include the title attribute unless it can be filled.
        
if (!empty($images[$random][3]))
            echo 
" title=\"".$images[$random][3]."\"";
        echo 
">";
        echo 
"<img id=\"randomimage\" src=\"$image_folder".$images[$random][0]."\" alt=\"".$images[$random][1]."\"$imagesettings></a>\n";
    }
   }
?>