Bogus start to dir=``$dir''"; exit; } if (eregi("[.~]", $dir)) { echo "

Bogus chars in dir=``$dir''

"; exit; } } echo "

Show JPGs: $dir

\n"; // Show any subdirs first, clicking goes there. $sorted_dirs=array(); $dir_h = opendir($dir); while (($file = readdir($dir_h)) != false) { $path = dirfile($dir,$file); if (filetype($path) == "dir") { // Protect against dir path subversion: file with a-zA-Z0-9_ if (eregi("^[a-z0-9_-]", $file)) { $dir_entry = "$file
"; array_push($sorted_dirs, $dir_entry); } //else echo "Ignore file: ``$file''
"; } } closedir($dir_h); // Should check array size first; if empty, don't print this. echo "

Click on any directories below to see images there

\n"; sort($sorted_dirs); reset($sorted_dirs); // set to first element while (list($key, $val) = each($sorted_dirs)) { echo $val . "\n"; } // Show all image files as clickable links. echo "

Click on the \"thumbnail\" images to see the full-sized image, whose size is shown.

\n"; $sorted_files = array(); $dir_h = opendir($dir); while (($file = readdir($dir_h)) != false) { //?? Protect against path wandering!! if (ereg("[^(\.tbn)]\.jpg$", $file)) { array_push($sorted_files, $file); } } closedir($dir_h); echo " \n"; sort($sorted_files); reset($sorted_files); while (list($key, $file) = each($sorted_files)) { $file_path = dirfile($dir, $file); $txt = ereg_replace("\.jpg$", ".txt", $file); $txt_path = dirfile($dir, $txt); $tbn = ereg_replace("\.jpg$", ".tbn.jpg", $file); $tbn_path = dirfile($dir, $tbn); //echo "dirfile=$dir/$file dirtbn=$dir/$tbn\n"; // Pop-up a separate window for images. echo "\n"; echo ""; echo "" //. "\n" ; if (file_exists($txt_path)) { $txt_h = fopen($txt_path, "r"); printf("\n"); } else { printf("\n"); } echo "\n"; } echo "
Thumbnail KB Description
"; if (file_exists($tbn_path)) { echo ""; } else { echo "no thumbnail "; } echo "" . round(filesize($file_path) / 1024) . "$file\n"); fpassthru($txt_h); // implicitely closes filehandle printf("$file
\n"; echo "
Chris Shenton
"; exit; ?>