Пример #1
0
function tfu_preview($file)
{
    global $use_image_magic, $image_magic_path;
    $pdf_preview = false;
    if (file_exists(dirname(__FILE__) . '/thumbs') && is_writable(dirname(__FILE__) . '/thumbs')) {
        // is a caching dir available and writeable?
        $pdf_preview = true;
    }
    // we store the url of the last preview image in the session - use it if you need it ;).
    // we generate thumbs for jpge,png and gif!
    if (preg_match("/.*\\.(j|J)(p|P)(e|E){0,1}(g|G)\$/", $file) || preg_match("/.*\\.(p|P)(n|N)(g|G)\$/", $file) || preg_match("/.*\\.(g|G)(i|I)(f|F)\$/", $file)) {
        if (isset($_GET['big'])) {
            send_thumb($file, 90, 440, 280);
            // big preview 4x bigger!
        } else {
            send_thumb($file, 90, 80, 55);
            // small preview
        }
    } else {
        if (preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file) && $use_image_magic && $pdf_preview) {
            $cachename = dirname(__FILE__) . '/thumbs/' . sha1($file) . '.jpg';
            if (!file_exists($cachename)) {
                $ima = realpath($file);
                $resize = '1000x1000';
                $command = $image_magic_path . ' "' . $ima . '[0]" -border 1x1 -quality 80 -thumbnail ' . $resize . ' "' . $cachename . '"';
                execute_command($command);
            }
            if (isset($_GET['big'])) {
                send_thumb($cachename, 90, 440, 280);
                // big preview 4x bigger!
            } else {
                send_thumb($cachename, 90, 80, 55);
                // small preview
            }
            // the cleanup is done in the thumbs folder which is cleaned up regularly
            // @unlink($cachename);
            return;
        } else {
            return;
            // we return nothing if no image.
        }
    }
}
Пример #2
0
             $filename = $dir . "/" . str_replace("\\'", "'", iconv("UTF-8", "", $file['name']));
             if (@move_uploaded_file($file['tmp_name'], $filename)) {
                 if (file_exists($filename)) {
                     $uploaded = true;
                 }
             }
         }
         if ($uploaded) {
             @chmod($filename, 0777);
             // we change the file to 777 - if you like more restrictions - change the mode here!
             array_push($_SESSION["TFU_LAST_UPLOADS"], $filename);
             removeCacheThumb($filename);
             // this actually generates the two thumbnails ... set this to true if you like this ;).
             if (false) {
                 send_thumb($filename, 90, 400, 275, true);
                 send_thumb($filename, 90, 80, 55, true);
             }
         }
     }
 }
 if (count($_SESSION["TFU_LAST_UPLOADS"]) > 0 && $remaining == 0 && $_SESSION["TFU_SPLIT_EXTENSION"] != "FALSE") {
     // last item in the upload AND we have stored stuff!
     restore_split_files($_SESSION["TFU_LAST_UPLOADS"]);
     resize_merged_files($_SESSION["TFU_LAST_UPLOADS"], $size);
 }
 // we only send an email for the last item of an upload cycle
 if (isset($_SESSION["TFU_NOT_EMAIL"]) && $_SESSION["TFU_NOT_EMAIL"] != "" && $remaining == 0) {
     $youremail = $_SESSION["TFU_NOT_EMAIL_FROM"];
     $email = $_SESSION["TFU_NOT_EMAIL"];
     $submailheaders = "From: {$youremail}\n";
     $submailheaders .= "Reply-To: {$youremail}\n";
Пример #3
0
                 }
             }
         }
     }
     echo "&total=" . $total . "&ok=" . $done . "&error=" . $error . "&exists=" . $exists;
 } else {
     if ($action == "preview") {
         // preview image
         // we store the url of the last preview image in the session - use it if you need it ;).
         // we generate thumbs for jpge,png and gif!
         if (preg_match("/.*\\.(j|J)(p|P)(e|E){0,1}(g|G)\$/", $file) || preg_match("/.*\\.(p|P)(n|N)(g|G)\$/", $file) || preg_match("/.*\\.(g|G)(i|I)(f|F)\$/", $file)) {
             if (isset($_GET['big'])) {
                 send_thumb($file, 90, 440, 280);
                 // big preview 4x bigger!
             } else {
                 send_thumb($file, 90, 80, 55);
                 // small preview
             }
         } else {
             return;
             // we return nothing if no image.
         }
     } else {
         if ($action == "info") {
             // get infos about a file
             unset($_SESSION["TFU_LAST_UPLOADS"]);
             $_SESSION["TFU_LAST_PREVIEW"] = fixUrl(getRootUrl() . $file);
             echo "&size=" . filesize($file);
             // we check if the image can be resized
             if (is_supported_tfu_image($file)) {
                 set_error_handler("on_error_no_output");