"; return 0; } $dir_handle = opendir($GLOBALS["PHOTO_DIR"]); while ($file = readdir($dir_handle)) { if ($file == ".." || $file == ".") continue; $full_file = $GLOBALS["PHOTO_DIR"]."/".$file; $img_info = @getImageSize($full_file); if (is_array($img_info)) { $files[] = $file; } elseif (is_mpeg_video($file)) { $files[] = $file; } } usort ($files,"cmp"); while (list ($key, $val) = each ($files)) { $full_file = $GLOBALS["PHOTO_DIR"]."/".$val; $img_info = @getImageSize($full_file); if (is_array($img_info)) { $thumb_info = @getImageSize($GLOBALS["PHOTO_DIR"] ."/thumbs/".stripExtension($val)."_thumb" .getExtension($img_info[2])); if (is_array($thumb_info)) { $thumb_infos[] = $thumb_info; } else { $thumb_infos[] = ""; } } elseif (is_mpeg_video($val)) { $thumb_info = @getImageSize($GLOBALS["PHOTO_DIR"] ."/thumbs/".stripExtension($val)."_thumb.gif"); if (is_array($thumb_info)) { $thumb_infos[] = $thumb_info; } else { $thumb_infos[] = ""; } } $img_info = ""; $thumb_info = ""; } return array($files, $thumb_infos); } // this function is the replacement for /bin/find to make things a // little safer and to possibly allow windows portability function getListing() { if(!is_dir($GLOBALS["PHOTO_DIR"])) { echo "ERROR: ".$GLOBALS["PHOTO_DIR"]." is not a " ." directory!
"; return 0; } $dir_handle = opendir($GLOBALS["PHOTO_DIR"]); while($file = readdir($dir_handle)) { if($file == ".." || $file == ".") continue; $full_file = $GLOBALS["PHOTO_DIR"]."/".$file; $img_info = @getImageSize($full_file); if(is_array($img_info)) { $files[] = $file; $thumb_info = @getImageSize($GLOBALS["PHOTO_DIR"] ."/thumbs/".stripExtension($file)."_thumb" .getExtension($img_info[2])); if(is_array($thumb_info)) $thumb_infos[] = $thumb_info; else $thumb_infos[] = ""; } elseif(is_mpeg_video($file)) { $files[] = $file; $thumb_info = @getImageSize($GLOBALS["PHOTO_DIR"] ."/thumbs/".stripExtension($file)."_thumb.gif"); if(is_array($thumb_info)) $thumb_infos[] = $thumb_info; else $thumb_infos[] = ""; } $img_info = ""; $thumb_info = ""; } return array($files, $thumb_infos); } function clearBitmaps($dump_dir) { if(!is_dir($GLOBALS["PHOTO_DIR"]."/thumbs/".$dump_dir)) { return 0; } $full_dump_dir = $GLOBALS["PHOTO_DIR"]."/thumbs/".$dump_dir; $bmp_dir_handle = opendir($full_dump_dir); while($file = readdir($bmp_dir_handle)) { if($file == ".." || $file == ".") continue; $full_file = $GLOBALS["PHOTO_DIR"] ."/thumbs/".$dump_dir."/".$file; if(eregi("\.bmp$", $full_file)) $deleted = unlink($full_file); } $success = @rmdir($full_dump_dir); return $success; } function getThumbFullPath($name) { $file_path = $GLOBALS["PHOTO_DIR"]."/".$name; $thumb_path = $GLOBALS["PHOTO_DIR"]."/thumbs/"; if(is_mpeg_video($file_path)) { $thumb_name = $thumb_path.getFileName2($name) ."_thumb.gif"; } else { $image_info = @getImageSize($file_path); $thumb_name = $thumb_path.getFileName2($name) ."_thumb".getExtension($image_info[2]); } return $thumb_name; } function deleteThumb($name) { $thumb_name = getThumbFullPath($name); if(is_writable($thumb_name)) { unlink($thumb_name); } } function deleteImage($name) { $full_name = $GLOBALS["PHOTO_DIR"]."/".$name; if(is_writable($full_name)) unlink($full_name); } function errorImage() { header("Content-type: image/gif"); // this image is image1.gif blatently ripped off from the // apache icons directory $image = "R0lGODlhFAAWAOMAAP/////MM/9mZsz//8zMzJmZmZlmADMzMwAA" ."AAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGlu" ."IHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmlu" ."aEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBA