'; // Set sortImagesByDate to true to sort by date. Otherwise files are sorted by filename. $sortImagesByDate = true; // Set sortInReverseOrder to true to sort images in reverse order. $sortInReverseOrder = true; // END OF OPTIONS // ----------------------- print "Creating XML for Autoviewer.
"; print "-------------------------------------------------

"; if ($sortImagesByDate){ print "Sorting images by date.
"; }else{ print "Sorting images by filename.
"; } if ($sortInReverseOrder){ print "Sorting images in reverse order.

"; }else{ print "Sorting images in forward order.

"; } //loop thru images $xml = ''.$options; $folder = opendir("images"); while($file = readdir($folder)) { if ($file[0] != "." && $file[0] != ".." && $file[0] != "Thumbs.db" ) { if ($sortImagesByDate){ $files[$file] = filemtime("images/$file"); }else{ $files[$file] = $file; } } } // now sort by date modified if ($sortInReverseOrder){ arsort($files); }else{ asort($files); } foreach($files as $key => $value) { // Get the image dimensions. $dimensions = getimagesize('images/'.$key); $width = $dimensions[0]; $height = $dimensions[1]; $xml .= "\n\n"; $xml .= "images/".$key."\n"; $xml .= " \n"; $xml .= " ".$width."\n"; $xml .= " ".$height."\n"; $xml .= "\n"; print "- Created Image Entry for: $key whose width is ".$width." and whose height is ".$height.".
"; } closedir($folder); $xml .= ''; //next line can cause erroneous warnings //chmod( 'gallery.xml', 0777 ); $file = "gallery.xml"; if (!$file_handle = fopen($file,"w")) { print "
Cannot open XML document: $file
"; } elseif (!fwrite($file_handle, $xml)) { print "
Cannot write to XML document: $file
"; }else{ print "
Successfully created XML document: $file
"; } fclose($file_handle); ?>