Version: 0.2

Type: Full Script

Category: File Management

License: GNU General Public License

Description: Just throw this file into a directory of images, change the name of the file if you wish, and when you link to it, it creates an instant slide show with the images present in the directory! You can also adjust the code to look through any directory you choose for images. It's also my first code post ever, so go easy on me ;)



<?
//This script originally written by random 1-16-2001
//Free for use and modification, just give me a little credit eh? ;-)

//I wouldn't edit this unless you know what you're doing...
$handle=opendir('.'); //current directory, can be changed
$counter = 0;
while ($file = readdir($handle)) {
  //check file type for images
  $the_type = strrchr($file, ".");
  $is_picture = eregi("jpg|gif|bmp|png",$the_type);  //adjust for other image types
  if ($file != "." and $file != ".." and $is_picture) { 
    $mypics[$counter] = $file;
    $counter++;
    } 
  }
closedir($handle); 
?>
<html>
<head><title>Instant Slide Show!</title>
<!--Do not edit below this line-->
<!--***************************-->
<script language="Javascript">
<!--
//preload images
<?
//pic for starting point
$firstpic = $mypics[0];
//loop to write array for Javascript, except last element
print('  var imagearray = new Array(');
for ($i=0; $i < ($counter-1); $i++) { print("'" . $mypics[$i] . "', "); }
//write last element with different string
print("'" . $mypics[$counter-1] . "');\n");
?>
  mystring = new Array;
  maximum = imagearray.length; 
  for (i = 0; i < maximum ; i++) {
    mystring[i] = new Image();
    mystring[i].src = imagearray[i];
  }

var rotation = 0;  // initialize
var mydelay = 2000; // milliseconds between slides
function rotate(){
  if (document.images) { document.images.rotate.src = mystring[rotation].src; }
  else { document.all.rotate.src = mystring[rotation].src; }
  rotation++;
  if (rotation == maximum) { 
  rotation = 0; 
  //delay on the last slide
  mytimer = setTimeout("rotate()", (mydelay * 2));
    }
  else { mytimer = setTimeout("rotate()", mydelay); }
}
//-->
</script>
<!--Do not edit above this line-->
<!--***************************-->
</head>
<body bgcolor="#ffffff" onload="rotate();">
<center><h2>Enjoy the show!</h2>

<!--Don't touch this!-->
<img src="<? print($firstpic); ?>" name="rotate">
<!--Don't touch this!-->

<p>
<a href="javascript:history.back()">Click here to go back ;)</a>
</center>
</body>
</html>