コード例 #1
0
ファイル: crop.php プロジェクト: claytondaley/resourcespace
     $command .= " -flop ";
 }
 if ($rotation > 0 && !$cropperestricted) {
     $command .= " -rotate {$rotation} ";
 }
 if ($flip || $rotation > 0 && !$cropperestricted) {
     // assume we should reset exif orientation flag since they have rotated to another orientation
     $command .= " -orient undefined ";
 }
 $command .= $colorspace2;
 $command .= " \"{$newpath}\"";
 if ($cropper_debug && !$download && getval("slideshow", "") == "") {
     error_log($command);
     if (isset($_REQUEST['showcommand'])) {
         echo "{$command}";
         delete_alternative_file($ref, $newfile);
         exit;
     }
 }
 // fixme -- do we need to trap for errors from imagemagick?
 $shell_result = run_command($command);
 if ($cropper_debug) {
     error_log("SHELL RESULT: {$shell_result}");
 }
 if ($resolution != "") {
     // See if we have got exiftool, in which case we can target the Photoshop specific PPI data
     $exiftool_fullpath = get_utility_path("exiftool");
     global $exiftool_no_process;
     if ($exiftool_fullpath != false && !in_array($new_ext, $exiftool_no_process)) {
         $command = $exiftool_fullpath . " -m -overwrite_original -E ";
         $command .= "-Photoshop:XResolution={$resolution} -Photoshop:YResolution={$resolution}";
コード例 #2
0
}
$default_sort = "DESC";
if (substr($order_by, 0, 5) == "field") {
    $default_sort = "ASC";
}
$sort = getval("sort", $default_sort);
# Fetch resource data.
$resource = get_resource_data($ref);
# Not allowed to edit this resource?
if ((!get_edit_access($ref, $resource["archive"], false, $resource) || checkperm('A')) && $ref > 0) {
    exit("Permission denied.");
}
hook("pageevaluation");
# Handle deleting a file
if (getval("filedelete", "") != "") {
    delete_alternative_file($ref, getvalescaped("filedelete", ""));
}
include "../include/header.php";
?>
<div class="BasicsBox">
<p>
<a onClick="return CentralSpaceLoad(this,true);" href="<?php 
echo $baseurl_short;
?>
pages/edit.php?ref=<?php 
echo urlencode($ref);
?>
&search=<?php 
echo urlencode($search);
?>
&offset=<?php 
コード例 #3
0
     if ($ffmpeg_alternatives[$n]["lines_min"] > $sourceheight) {
         $generate = false;
     }
 }
 $tmp = hook("preventgeneratealt", "", array($file));
 if ($tmp === true) {
     $generate = false;
 }
 if ($generate) {
     if (!hook("removepreviousalts", "", array($ffmpeg_alternatives, $file, $n))) {
         # Remove any existing alternative file(s) with this name.
         # SQL Connection may have hit a timeout
         sql_connect();
         $existing = sql_query("select ref from resource_alt_files where resource='{$ref}' and name='" . escape_check($ffmpeg_alternatives[$n]["name"]) . "'");
         for ($m = 0; $m < count($existing); $m++) {
             delete_alternative_file($ref, $existing[$m]["ref"]);
         }
     }
     # Create the alternative file.
     $aref = add_alternative_file($ref, $ffmpeg_alternatives[$n]["name"]);
     $apath = get_resource_path($ref, true, "", true, $ffmpeg_alternatives[$n]["extension"], -1, 1, false, "", $aref);
     # Process the video
     $shell_exec_cmd = $ffmpeg_fullpath . "  {$ffmpeg_global_options} -y -i " . escapeshellarg($file) . " " . $ffmpeg_alternatives[$n]["params"] . " " . escapeshellarg($apath);
     $tmp = hook("ffmpegmodaltparams", "", array($shell_exec_cmd, $ffmpeg_fullpath, $file, $n, $aref));
     if ($tmp) {
         $shell_exec_cmd = $tmp;
     }
     $output = run_command($shell_exec_cmd);
     if (isset($qtfaststart_path)) {
         if ($qtfaststart_path && file_exists($qtfaststart_path . "/qt-faststart") && in_array($ffmpeg_alternatives[$n]["extension"], $qtfaststart_extensions)) {
             $apathtmp = $apath . ".tmp";
コード例 #4
0
function delete_resource($ref)
	{
	# Delete the resource, all related entries in tables and all files on disk
	
	if ($ref<0) {return false;} # Can't delete the template

	$resource=get_resource_data($ref);
	if (!$resource) {return false;} # Resource not found in database
	
	$current_state=$resource['archive'];
	
	global $resource_deletion_state;
	if (isset($resource_deletion_state) && $current_state!=3) # Really delete if already in the 'deleted' state.
		{
		# $resource_deletion_state is set. Do not delete this resource, instead move it to the specified state.
		sql_query("update resource set archive='" . $resource_deletion_state . "' where ref='" . $ref . "'");

        # log this so that administrator can tell who requested deletion
        resource_log($ref,'x','');
		
		# Remove the resource from any collections
		sql_query("delete from collection_resource where resource='$ref'");
			
		return true;
		}
	
	# Get info
	
	# Is transcoding
	if ($resource['is_transcoding']==1) {return false;} # Can't delete when transcoding

	# Delete files first
	$extensions = array();
	$extensions[]=$resource['file_extension']?$resource['file_extension']:"jpg";
	$extensions[]=$resource['preview_extension']?$resource['preview_extension']:"jpg";
	$extensions[]=$GLOBALS['ffmpeg_preview_extension'];
	$extensions[]='icc'; // also remove any extracted icc profiles
	$extensions=array_unique($extensions);
	
	foreach ($extensions as $extension)
		{
		$sizes=get_image_sizes($ref,true,$extension);
		foreach ($sizes as $size)
			{
			if (file_exists($size['path'])) {unlink($size['path']);}
			}
		}
	
	# Delete any alternative files
	$alternatives=get_alternative_files($ref);
	for ($n=0;$n<count($alternatives);$n++)
		{
		delete_alternative_file($ref,$alternatives[$n]['ref']);
		}

	
	// remove metadump file, and attempt to remove directory
	$dirpath = dirname(get_resource_path($ref, true, "", true));
	if (file_exists("$dirpath/metadump.xml")){
		unlink("$dirpath/metadump.xml");
	}
	@rmdir($dirpath); // try to delete directory, but if it has stuff in it fail silently for now
			  // fixme - should we try to handle if there are other random files still there?
	
	# Log the deletion of this resource for any collection it was in. 
	$in_collections=sql_query("select * from collection_resource where resource = '$ref'");
	if (count($in_collections)>0){
		if (!function_exists("collection_log")){include ("collections_functions.php");}
		for($n=0;$n<count($in_collections);$n++)
			{
			collection_log($in_collections[$n]['collection'],'d',$in_collections[$n]['resource']);
			}
		}

	hook("beforedeleteresourcefromdb");

	# Delete all database entries
	sql_query("delete from resource where ref='$ref'");
	sql_query("delete from resource_data where resource='$ref'");
	sql_query("delete from resource_dimensions where resource='$ref'");
	sql_query("delete from resource_keyword where resource='$ref'");
	sql_query("delete from resource_related where resource='$ref' or related='$ref'");
	sql_query("delete from collection_resource where resource='$ref'");
	sql_query("delete from resource_custom_access where resource='$ref'");
	sql_query("delete from external_access_keys where resource='$ref'");
	sql_query("delete from resource_alt_files where resource='$ref'");
		
	hook("afterdeleteresource");
	
	return true;
	}
コード例 #5
0
function create_previews($ref, $thumbonly = false, $extension = "jpg", $previewonly = false, $previewbased = false, $alternative = -1, $ignoremaxsize = false, $ingested = false)
{
    global $keep_for_hpr, $imagemagick_path, $preview_generate_max_file_size, $autorotate_no_ingest;
    // keep_for_hpr will be set to true if necessary in preview_preprocessing.php to indicate that an intermediate jpg can serve as the hpr.
    // otherwise when the file extension is a jpg it's assumed no hpr is needed.
    # Debug
    debug("create_previews(ref={$ref},thumbonly={$thumbonly},extension={$extension},previewonly={$previewonly},previewbased={$previewbased},alternative={$alternative},ingested={$ingested})");
    if (!$previewonly) {
        // make sure the extension is the same as the original so checksums aren't done for previews
        $o_ext = sql_value("select file_extension value from resource where ref={$ref}", "");
        if ($extension == $o_ext) {
            debug("create_previews - generate checksum for {$ref}");
            generate_file_checksum($ref, $extension);
        }
    }
    # first reset preview tweaks to 0
    sql_query("update resource set preview_tweaks = '0|1' where ref = '{$ref}'");
    // for compatibility with transform plugin, remove any
    // transform previews for this resource when regenerating previews
    $tpdir = get_temp_dir() . "/transform_plugin";
    if (is_dir($tpdir) && file_exists("{$tpdir}/pre_{$ref}.jpg")) {
        unlink("{$tpdir}/pre_{$ref}.jpg");
    }
    # pages/tools/update_previews.php?previewbased=true
    # use previewbased to avoid touching original files (to preserve manually-uploaded preview images
    # when regenerating previews (i.e. for watermarks)
    if ($previewbased || $autorotate_no_ingest && !$ingested) {
        $file = get_resource_path($ref, true, "lpr", false, "jpg", -1, 1, false, "", $alternative);
        if (!file_exists($file)) {
            $file = get_resource_path($ref, true, "scr", false, "jpg", -1, 1, false, "", $alternative);
            if (!file_exists($file)) {
                $file = get_resource_path($ref, true, "pre", false, "jpg", -1, 1, false, "", $alternative);
                if (!file_exists($file) && $autorotate_no_ingest && !$ingested) {
                    $file = get_resource_path($ref, true, "", false, $extension, -1, 1, false, "", $alternative);
                }
            }
        }
    } else {
        if (!$previewonly) {
            $file = get_resource_path($ref, true, "", false, $extension, -1, 1, false, "", $alternative);
        } else {
            # We're generating based on a new preview (scr) image.
            $file = get_resource_path($ref, true, "tmp", false, "jpg");
        }
    }
    # Debug
    debug("File source is {$file}");
    # Make sure the file exists, if not update preview_attempts so that we don't keep trying to generate a preview
    if (!file_exists($file)) {
        sql_query("update resource set preview_attempts=ifnull(preview_attempts,0) + 1 where ref='{$ref}'");
        return false;
    }
    # If configured, make sure the file is within the size limit for preview generation
    if (isset($preview_generate_max_file_size) && !$ignoremaxsize) {
        $filesize = filesize_unlimited($file) / (1024 * 1024);
        # Get filesize in MB
        if ($filesize > $preview_generate_max_file_size) {
            return false;
        }
    }
    # Locate imagemagick.
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        debug("ERROR: Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'");
        return false;
    }
    # Handle alternative image file generation.
    global $image_alternatives;
    if (isset($image_alternatives) && $alternative == -1) {
        for ($n = 0; $n < count($image_alternatives); $n++) {
            $exts = explode(",", $image_alternatives[$n]["source_extensions"]);
            if (in_array($extension, $exts)) {
                # Remove any existing alternative file(s) with this name.
                $existing = sql_query("select ref from resource_alt_files where resource='{$ref}' and name='" . escape_check($image_alternatives[$n]["name"]) . "'");
                for ($m = 0; $m < count($existing); $m++) {
                    delete_alternative_file($ref, $existing[$m]["ref"]);
                }
                # Create the alternative file.
                $aref = add_alternative_file($ref, $image_alternatives[$n]["name"]);
                $apath = get_resource_path($ref, true, "", true, $image_alternatives[$n]["target_extension"], -1, 1, false, "", $aref);
                $source_profile = '';
                if ($image_alternatives[$n]["icc"] === true) {
                    $iccpath = get_resource_path($ref, true, '', false, $extension) . '.icc';
                    global $icc_extraction;
                    global $ffmpeg_supported_extensions;
                    if (!file_exists($iccpath) && $extension != "pdf" && !in_array($extension, $ffmpeg_supported_extensions)) {
                        // extracted profile doesn't exist. Try extracting.
                        extract_icc_profile($ref, $extension);
                    }
                    if (file_exists($iccpath)) {
                        $source_profile = ' -strip -profile ' . $iccpath;
                    }
                }
                # Process the image
                $version = get_imagemagick_version();
                if ($version[0] > 5 || $version[0] == 5 && $version[1] > 5 || $version[0] == 5 && $version[1] == 5 && $version[2] > 7) {
                    // Use the new imagemagick command syntax (file then parameters)
                    $command = $convert_fullpath . ' ' . escapeshellarg($file) . ($extension == 'psd' ? '[0] +matte' : '') . $source_profile . ' ' . $image_alternatives[$n]['params'] . ' ' . escapeshellarg($apath);
                } else {
                    // Use the old imagemagick command syntax (parameters then file)
                    $command = $convert_fullpath . $source_profile . " " . $image_alternatives[$n]["params"] . " " . escapeshellarg($file) . " " . escapeshellarg($apath);
                }
                $output = run_command($command);
                if (file_exists($apath)) {
                    # Update the database with the new file details.
                    $file_size = filesize_unlimited($apath);
                    sql_query("update resource_alt_files set file_name='" . escape_check($image_alternatives[$n]["filename"] . "." . $image_alternatives[$n]["target_extension"]) . "',file_extension='" . escape_check($image_alternatives[$n]["target_extension"]) . "',file_size='" . $file_size . "',creation_date=now() where ref='{$aref}'");
                }
            }
        }
    }
    if ($extension == "jpg" || $extension == "jpeg" || $extension == "png" || $extension == "gif") {
        if (isset($imagemagick_path)) {
            create_previews_using_im($ref, $thumbonly, $extension, $previewonly, $previewbased, $alternative, $ingested);
        } else {
            # ----------------------------------------
            # Use the GD library to perform the resize
            # ----------------------------------------
            # For resource $ref, (re)create the various preview sizes listed in the table preview_sizes
            # Only create previews where the target size IS LESS THAN OR EQUAL TO the source size.
            # Set thumbonly=true to (re)generate thumbnails only.
            $sizes = "";
            if ($thumbonly) {
                $sizes = " where id='thm' or id='col'";
            }
            if ($previewonly) {
                $sizes = " where id='thm' or id='col' or id='pre' or id='scr'";
            }
            # fetch source image size, if we fail, exit this function (file not an image, or file not a valid jpg/png/gif).
            if ((list($sw, $sh) = @getimagesize($file)) === false) {
                return false;
            }
            $ps = sql_query("select * from preview_size {$sizes}");
            for ($n = 0; $n < count($ps); $n++) {
                # fetch target width and height
                $tw = $ps[$n]["width"];
                $th = $ps[$n]["height"];
                $id = $ps[$n]["id"];
                # Find the target path
                $path = get_resource_path($ref, true, $ps[$n]["id"], false, "jpg", -1, 1, false, "", $alternative);
                if (file_exists($path) && !$previewbased) {
                    unlink($path);
                }
                # Also try the watermarked version.
                $wpath = get_resource_path($ref, true, $ps[$n]["id"], false, "jpg", -1, 1, true, "", $alternative);
                if (file_exists($wpath)) {
                    unlink($wpath);
                }
                # only create previews where the target size IS LESS THAN OR EQUAL TO the source size.
                # or when producing a small thumbnail (to make sure we have that as a minimum)
                if ($sw > $tw || $sh > $th || $id == "thm" || $id == "col") {
                    # Calculate width and height.
                    if ($sw > $sh) {
                        $ratio = $tw / $sw;
                    } else {
                        $ratio = $th / $sh;
                    }
                    # Portrait
                    $tw = floor($sw * $ratio);
                    $th = floor($sh * $ratio);
                    # ----------------------------------------
                    # Use the GD library to perform the resize
                    # ----------------------------------------
                    $target = imagecreatetruecolor($tw, $th);
                    if ($extension == "png") {
                        $source = @imagecreatefrompng($file);
                        if ($source === false) {
                            return false;
                        }
                    } elseif ($extension == "gif") {
                        $source = @imagecreatefromgif($file);
                        if ($source === false) {
                            return false;
                        }
                    } else {
                        $source = @imagecreatefromjpeg($file);
                        if ($source === false) {
                            return false;
                        }
                    }
                    imagecopyresampled($target, $source, 0, 0, 0, 0, $tw, $th, $sw, $sh);
                    imagejpeg($target, $path, 90);
                    if ($ps[$n]["id"] == "thm") {
                        extract_mean_colour($target, $ref);
                    }
                    imagedestroy($target);
                } elseif ($id == "pre" || $id == "thm" || $id == "col") {
                    # If the source is smaller than the pre/thm/col, we still need these sizes; just copy the file
                    copy($file, get_resource_path($ref, true, $id, false, $extension, -1, 1, false, "", $alternative));
                    if ($id == "thm") {
                        sql_query("update resource set thumb_width='{$sw}',thumb_height='{$sh}' where ref='{$ref}'");
                    }
                }
            }
            # flag database so a thumbnail appears on the site
            if ($alternative == -1) {
                sql_query("update resource set has_image=1,preview_extension='jpg',preview_attempts=0,file_modified=now() where ref='{$ref}'");
            }
        }
    } else {
        # If using ImageMagick, call preview_preprocessing.php which makes use of ImageMagick and other tools
        # to attempt to extract a preview.
        global $no_preview_extensions;
        if (isset($imagemagick_path) && !in_array(strtolower($extension), $no_preview_extensions)) {
            include dirname(__FILE__) . "/preview_preprocessing.php";
        }
    }
    return true;
}
コード例 #6
0
function create_previews($ref, $thumbonly = false, $extension = "jpg", $previewonly = false, $previewbased = false, $alternative = -1)
{
    global $imagemagick_path, $preview_generate_max_file_size;
    # Debug
    debug("create_previews(ref={$ref},thumbonly={$thumbonly},extension={$extension},previewonly={$previewonly},previewbased={$previewbased},alternative={$alternative})");
    # File checksum (experimental) - disabled for now
    if (!$previewonly) {
        generate_file_checksum($ref, $extension);
    }
    # first reset preview tweaks to 0
    sql_query("update resource set preview_tweaks = '0|1' where ref = '{$ref}'");
    # pages/tools/update_previews.php?previewbased=true
    # use previewbased to avoid touching original files (to preserve manually-uploaded preview images
    # when regenerating previews (i.e. for watermarks)
    if ($previewbased) {
        $file = get_resource_path($ref, true, "lpr", false, "jpg", -1, 1, false, "", $alternative);
        if (!file_exists($file)) {
            $file = get_resource_path($ref, true, "scr", false, "jpg", -1, 1, false, "", $alternative);
            if (!file_exists($file)) {
                $file = get_resource_path($ref, true, "pre", false, "jpg", -1, 1, false, "", $alternative);
            }
        }
    } else {
        if (!$previewonly) {
            $file = get_resource_path($ref, true, "", false, $extension, -1, 1, false, "", $alternative);
        } else {
            # We're generating based on a new preview (scr) image.
            $file = get_resource_path($ref, true, "tmp", false, "jpg");
        }
    }
    # Debug
    debug("File source is {$file}");
    # Make sure the file exists
    if (!file_exists($file)) {
        return false;
    }
    # If configured, make sure the file is within the size limit for preview generation
    if (isset($preview_generate_max_file_size)) {
        $filesize = filesize_unlimited($file) / (1024 * 1024);
        # Get filesize in MB
        if ($filesize > $preview_generate_max_file_size) {
            return false;
        }
    }
    # Locate imagemagick.
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'");
    }
    # Handle alternative image file generation.
    global $image_alternatives;
    if (isset($image_alternatives) && $alternative == -1) {
        for ($n = 0; $n < count($image_alternatives); $n++) {
            $exts = explode(",", $image_alternatives[$n]["source_extensions"]);
            if (in_array($extension, $exts)) {
                # Remove any existing alternative file(s) with this name.
                $existing = sql_query("select ref from resource_alt_files where resource='{$ref}' and name='" . escape_check($image_alternatives[$n]["name"]) . "'");
                for ($m = 0; $m < count($existing); $m++) {
                    delete_alternative_file($ref, $existing[$m]["ref"]);
                }
                # Create the alternative file.
                $aref = add_alternative_file($ref, $image_alternatives[$n]["name"]);
                $apath = get_resource_path($ref, true, "", true, $image_alternatives[$n]["target_extension"], -1, 1, false, "", $aref);
                # Process the image
                $command = $convert_fullpath . " " . $image_alternatives[$n]["params"] . " " . escapeshellarg($file) . " " . escapeshellarg($apath);
                $output = run_command($command);
                if (file_exists($apath)) {
                    # Update the database with the new file details.
                    $file_size = filesize_unlimited($apath);
                    sql_query("update resource_alt_files set file_name='" . escape_check($image_alternatives[$n]["filename"] . "." . $image_alternatives[$n]["target_extension"]) . "',file_extension='" . escape_check($image_alternatives[$n]["target_extension"]) . "',file_size='" . $file_size . "',creation_date=now() where ref='{$aref}'");
                }
            }
        }
    }
    if ($extension == "jpg" || $extension == "jpeg" || $extension == "png" || $extension == "gif") {
        if (isset($imagemagick_path)) {
            create_previews_using_im($ref, $thumbonly, $extension, $previewonly, $previewbased, $alternative);
        } else {
            # ----------------------------------------
            # Use the GD library to perform the resize
            # ----------------------------------------
            # For resource $ref, (re)create the various preview sizes listed in the table preview_sizes
            # Only create previews where the target size IS LESS THAN OR EQUAL TO the source size.
            # Set thumbonly=true to (re)generate thumbnails only.
            $sizes = "";
            if ($thumbonly) {
                $sizes = " where id='thm' or id='col'";
            }
            if ($previewonly) {
                $sizes = " where id='thm' or id='col' or id='pre' or id='scr'";
            }
            # fetch source image size, if we fail, exit this function (file not an image, or file not a valid jpg/png/gif).
            if ((list($sw, $sh) = @getimagesize($file)) === false) {
                return false;
            }
            $ps = sql_query("select * from preview_size {$sizes}");
            for ($n = 0; $n < count($ps); $n++) {
                # fetch target width and height
                $tw = $ps[$n]["width"];
                $th = $ps[$n]["height"];
                $id = $ps[$n]["id"];
                # Find the target path
                $path = get_resource_path($ref, true, $ps[$n]["id"], false, "jpg", -1, 1, false, "", $alternative);
                if (file_exists($path) && !$previewbased) {
                    unlink($path);
                }
                # Also try the watermarked version.
                $wpath = get_resource_path($ref, true, $ps[$n]["id"], false, "jpg", -1, 1, true, "", $alternative);
                if (file_exists($wpath)) {
                    unlink($wpath);
                }
                # only create previews where the target size IS LESS THAN OR EQUAL TO the source size.
                # or when producing a small thumbnail (to make sure we have that as a minimum)
                if ($sw > $tw || $sh > $th || $id == "thm" || $id == "col") {
                    # Calculate width and height.
                    if ($sw > $sh) {
                        $ratio = $tw / $sw;
                    } else {
                        $ratio = $th / $sh;
                    }
                    # Portrait
                    $tw = floor($sw * $ratio);
                    $th = floor($sh * $ratio);
                    # ----------------------------------------
                    # Use the GD library to perform the resize
                    # ----------------------------------------
                    $target = imagecreatetruecolor($tw, $th);
                    if ($extension == "png") {
                        $source = @imagecreatefrompng($file);
                        if ($source === false) {
                            return false;
                        }
                    } elseif ($extension == "gif") {
                        $source = @imagecreatefromgif($file);
                        if ($source === false) {
                            return false;
                        }
                    } else {
                        $source = @imagecreatefromjpeg($file);
                        if ($source === false) {
                            return false;
                        }
                    }
                    imagecopyresampled($target, $source, 0, 0, 0, 0, $tw, $th, $sw, $sh);
                    imagejpeg($target, $path, 90);
                    if ($ps[$n]["id"] == "thm") {
                        extract_mean_colour($target, $ref);
                    }
                    imagedestroy($target);
                } elseif ($id == "pre" || $id == "thm" || $id == "col") {
                    # If the source is smaller than the pre/thm/col, we still need these sizes; just copy the file
                    copy($file, get_resource_path($ref, true, $id, false, $extension, -1, 1, false, "", $alternative));
                    if ($id == "thm") {
                        sql_query("update resource set thumb_width='{$sw}',thumb_height='{$sh}' where ref='{$ref}'");
                    }
                }
            }
            # flag database so a thumbnail appears on the site
            if ($alternative == -1) {
                sql_query("update resource set has_image=1,preview_extension='jpg',preview_attempts=0,file_modified=now() where ref='{$ref}'");
            }
        }
    } else {
        # If using ImageMagick, call preview_preprocessing.php which makes use of ImageMagick and other tools
        # to attempt to extract a preview.
        global $no_preview_extensions;
        if (isset($imagemagick_path) && !in_array(strtolower($extension), $no_preview_extensions)) {
            include dirname(__FILE__) . "/preview_preprocessing.php";
        }
    }
    return true;
}