# 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 - separated dmi-gal from dmi-1.2.php
# 2002-08-29 Sandino Araico S�nchez - Moved config to constants
/**************************************
* WARNING: THIS SCRIPT MAY BE BROKEN *
**************************************/
include "dmi-conf.inc.php";
include "dmi-lib.inc";
if($upload && $ALLOW_UPLOAD && is_uploaded_file($new_file)) {
$success = 0;
$img = getImageSize($new_file);
// If this isn't a JPG/GIF/PNG use ImageMajik to convert
// whatever it is to a jpg
if(!is_array($img) && is_mpeg_video($new_file)) {
$new_name = basename($new_file_name);
$new_name = stripExtension($new_name);
$new_name = safeFileName($new_name);
$new_name = $new_name.".mpg";
$success = move_uploaded_file($new_file,
__DMI_PHOTO_DIR."/".$new_name);
}
elseif(!is_array($img)) {
$tmp_name = basename($new_file_name);
$tmp_name = safeFileName($tmp_name);
$new_name = stripExtension($tmp_name).".jpg";
move_uploaded_file($new_file, __DMI_PHOTO_DIR."/".$tmp_name);
$cmd = __DMI_CONVERT_PROG.' '.__DMI_PHOTO_DIR."/".shellWrap($tmp_name)
." ".__DMI_PHOTO_DIR."/".shellWrap($new_name);
//echo $cmd;
`$cmd`;
unlink($tmp_name);
if(file_exists(__DMI_PHOTO_DIR."/".$new_name))
$success = ($img = getImageSize($new_name));
else
$img = "";
}
else {
$new_name = basename($new_file_name);
$new_name = stripExtension($new_name);
$new_name = safeFileName($new_name);
$new_name = extensionize($new_name, $img[2]);
$success = move_uploaded_file($new_file,
__DMI_PHOTO_DIR."/".$new_name);
}
if(!$success) {
echo "ERROR: uploaded file is not a recoginzied "
." image file format!";
}
}
?>