# Copyright (c) 2002 Sandino Araico Sánchez /* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ # Changelog: # 2002-01-25 Tony J. White tjw@tjw.org - DirectoryMediaIndex (dmi) 1.2 # 2002-03-14 Sandino Araico Sánchez - Renamed main file to dmi.php # 2002-08-29 Sandino Araico Sánchez - Moved config to constants # 2002-09-08 Sandino Araico Sánchez - Fixed broken table include "dmi-conf.inc.php"; include "dmi-lib.inc"; include "s/s-extended.inc"; $success = 0; $name = stripslashes($name); s_log(__DMI_PHOTO_DIR."/".$name); $image_info = @getImageSize(__DMI_PHOTO_DIR."/".$name); s_log("image_info: ".serialize($image_info)); if(!$image_info) { if(is_mpeg_video(__DMI_PHOTO_DIR."/".$name)) { $success = 1; $is_mpeg_video = 1; } } else $success = 1; s_log("THUMBS_DIR:".__DMI_THUMBS_DIR); if(!s_check_dir(__DMI_THUMBS_DIR, 0755)) errorImage(); s_log("before $is_mpeg_video", __FILE__, __LINE__); if($is_mpeg_video) { $thumb_name = __DMI_THUMBS_DIR.getFileName($name) ."_thumb.gif"; $dump_dir = __DMI_THUMBS_DIR.getFileName($name); if(!($thumb_info = @getImageSize($thumb_name))) { // clean up any old bitmaps that might be laying // around clearBitmaps(getFileName($name)); if(!@mkdir($dump_dir, 0755)) errorImage(); putenv("SDL_VIDEODRIVER=dummy"); putenv("SDL_AUDIODRIVER=disk"); putenv("SDL_DISKAUDIOFILE=/dev/null"); // dumpmpeg dumps bitmaps to the current dir if(!@chdir($dump_dir)) errorImage(); // dump out the bitmaps $command = __DMI_DUMPMPEG_PROG." --dump " .shellWrap(__DMI_MPEG_FRAME_FREQ)." ../../" .shellWrap($name); //echo $command; `$command`; // create an animated gif of the bitmaps $command = __DMI_CONVERT_PROG." -loop 100 -delay " .shellWrap(__DMI_ANIM_DELAY) ." -geometry ".__DMI_THUMB_WIDTH ."x".__DMI_THUMB_HEIGHT." " .shellWrap($dump_dir)."/*.bmp " .shellWrap($thumb_name); //echo $command; `$command`; clearBitmaps(getFileName($name)); if(!($thumb_info = @getImageSize($thumb_name))) errorImage(); } header("Content-type: image/gif"); readfile($thumb_name); } else { $thumb_name = __DMI_THUMBS_DIR.getFileName($name) ."_thumb".getExtension($image_info[2]); s_log("thumb_name: $thumb_name"); if(!($thumb_info = @getImageSize($thumb_name))) { $command = __DMI_CONVERT_PROG." -geometry ".__DMI_THUMB_WIDTH ."x".__DMI_THUMB_HEIGHT." " . __DMI_PHOTO_DIR."/".shellWrap($name)." " .shellWrap($thumb_name); s_log($command); `$command`; if(!($thumb_info = @getImageSize($thumb_name))) errorImage(); } header("Content-type: ".getMimeType($thumb_info[2])); readfile($thumb_name); } ?>