示例#1
0
function resize_merged_files($items, $size)
{
    $split_array = array();
    // first we check if files are split and group the splited files
    foreach ($items as $filename) {
        if (is_part($filename)) {
            $split_array[removeExtension($filename)][] = $filename;
        }
    }
    foreach ($split_array as $restore => $parts) {
        resize_file($restore, $size, 80, basename($restore));
    }
}
示例#2
0
     // no resize
 }
 $remaining = -1 + $_GET['remaining'];
 if ($remaining < 0) {
     // not valid! ew expect at least 1
     return;
 }
 if (!isset($_SESSION["TFU_LAST_UPLOADS"]) || isset($_GET['firstStart'])) {
     // we delete the info of the last upload items!
     unset($_SESSION["TFU_LAST_UPLOADS"]);
     $_SESSION["TFU_LAST_UPLOADS"] = array();
 }
 foreach ($_FILES as $fieldName => $file) {
     $store = true;
     if (is_supported_tfu_image($file['name']) && $size < 100000) {
         $store = resize_file($file['tmp_name'], $size, 80, $file['name']);
     }
     if ($store) {
         if ($fix_utf8 == "") {
             $image = utf8_decode(str_replace("\\'", "'", $file['name']));
             // fix for special characters like öäüÖÄÜñé...
         } else {
             $image = str_replace("\\'", "'", iconv("UTF-8", $fix_utf8, $file['name']));
         }
         $filename = $dir . "/" . $image;
         $uploaded = false;
         if (@move_uploaded_file($file['tmp_name'], $filename)) {
             if (file_exists($filename)) {
                 $uploaded = true;
             }
         }
示例#3
0
function tfu_createThumb($file)
{
    global $compression, $use_image_magic, $image_magic_path, $pdf_thumb_format;
    if (!preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file)) {
        $name = removeExtension($file) . "-" . $_GET['tfu_width'] . 'x' . $_GET['tfu_height'] . "." . getExtension($file);
        resize_file($file, $_GET['tfu_width'] . 'x' . $_GET['tfu_height'], $compression, basename($file), $name);
    } else {
        if ($use_image_magic) {
            $name = dirname(__FILE__) . '/' . removeExtension($file) . "-" . $_GET['tfu_width'] . '.' . $pdf_thumb_format;
            // create a pdf thumbnail
            $ima = realpath($file);
            if (!file_exists($name)) {
                $ima = realpath($file);
                $resize = $_GET['tfu_width'] . 'x' . $_GET['tfu_height'];
                $command = $image_magic_path . ' -colorspace rgb "' . $ima . '[0]" -border 1x1 -quality 80 -thumbnail ' . $resize . ' "' . $name . '"';
                execute_command($command);
            }
        }
    }
}
     // we normalize even if not selected because saving with the default name failed!
     $filename = $dir . '/' . str_replace("\\'", "'", iconv('UTF-8', '', normalizeFileNames($base_filename)));
     if (@move_uploaded_file($file['tmp_name'], $filename)) {
         $uploaded = file_exists($filename);
     }
 }
 if ($uploaded) {
     // we check the filesize later because of basedir restrictions in the the tmp dir!
     check_valid_filesize($filename);
     if ($file_chmod != 0) {
         @chmod($filename, $file_chmod);
     }
     if ($store == 2) {
         // we resize after the move because before it was not possible on this server
         // no fallback right now because the file is already uploaded.
         resize_file($filename, $size, 80, $base_filename);
     }
     $filename_save = $filename;
     /* handles the description which can be sent with each file */
     if (isset($_GET['description'])) {
         // we have an additional description - stored as image name.txt
         if ($description_mode_store == 'txt') {
             if (!($handle = fopen($filename . '.txt', "w"))) {
                 debug('Cannot create ' . $filename . '. The following data was sent: ' . $_GET['description']);
             } else {
                 fwrite($handle, $_GET['description']);
                 fclose($handle);
             }
         } else {
             // we add the descritption to the upload that is added to the e-mail
             $filename_save .= ' - ' . $_GET['description'];
示例#5
0
         error_reporting($old_error);
     }
 }
 if ($uploaded) {
     if ($enable_upload_debug) {
         tfu_debug('6. Uploaded.');
     }
     // we check the filesize later because of basedir restrictions in the the tmp dir!
     check_valid_filesize($filename);
     if ($file_chmod != 0) {
         @chmod($filename, $file_chmod);
     }
     if ($store == 2) {
         // we resize after the move because before it was not possible on this server
         // no fallback right now because the file is already uploaded.
         resize_file($filename, $size, $compression, $base_filename);
     }
     $current_desc = '';
     /* handles the description which can be sent with each file */
     if (isset($_GET['description'])) {
         $description = stripslashes($_GET['description']);
         if ($enable_upload_debug) {
             tfu_debug('6a. Processing description: ' . $description);
         }
         // we have an additional description - stored as image name.txt
         if ($description_mode_store == 'txt') {
             if (!($handle = fopen($filename . '.txt', "w"))) {
                 tfu_debug('Cannot create ' . $filename . '. The following data was sent: ' . $description);
             } else {
                 fwrite($handle, $description);
                 fclose($handle);