Example #1
1
function get_utility_version($utilityname)
{
    global $lang;
    # Get utility path.
    $utility_fullpath = get_utility_path($utilityname, $path);
    # Get utility display name.
    $name = get_utility_displayname($utilityname);
    # Check path.
    if ($path == null) {
        # There was no complete path to check - the utility is not installed.
        $error_msg = $lang["status-notinstalled"];
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    }
    if ($utility_fullpath == false) {
        # There was a path but it was incorrect - the utility couldn't be found.
        $error_msg = $lang["status-fail"] . ":<br>" . str_replace("?", $path, $lang["softwarenotfound"]);
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    }
    # Look up the argument to use to get the version.
    switch (strtolower($utilityname)) {
        case "exiftool":
            $version_argument = "-ver";
            break;
        default:
            $version_argument = "-version";
    }
    # Check execution and find out version.
    $version_command = $utility_fullpath . " " . $version_argument;
    $version = run_command($version_command);
    switch (strtolower($utilityname)) {
        case "im-convert":
            if (strpos($version, "ImageMagick") !== false) {
                $name = "ImageMagick";
            }
            if (strpos($version, "GraphicsMagick") !== false) {
                $name = "GraphicsMagick";
            }
            if ($name == "ImageMagick" || $name == "GraphicsMagick") {
                $expected = true;
            } else {
                $expected = false;
            }
            break;
        case "ghostscript":
            if (strpos(strtolower($version), "ghostscript") === false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
        case "ffmpeg":
            if (strpos(strtolower($version), "ffmpeg") === false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
        case "exiftool":
            if (preg_match("/^([0-9]+)+\\.([0-9]+)\$/", $version) == false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
    }
    if ($expected == false) {
        # There was a correct path but the version check failed - unexpected output when executing the command.
        $error_msg = $lang["status-fail"] . ":<br>" . str_replace(array("%command", "%output"), array($version_command, $version), $lang["execution_failed"]);
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    } else {
        # There was a working path and the output was the expected - the version is returned.
        $s = explode("\n", $version);
        return array("name" => $name, "version" => $s[0], "success" => true, "error" => "");
    }
}
function get_original_imagesize($ref = "", $path = "", $extension = "jpg")
{
    $fileinfo = array();
    if ($ref == "" || $path == "") {
        return false;
    }
    global $imagemagick_path, $imagemagick_calculate_sizes;
    $file = $path;
    $filesize = filesize_unlimited($file);
    # imagemagick_calculate_sizes is normally turned off
    if (isset($imagemagick_path) && $imagemagick_calculate_sizes) {
        # Use ImageMagick to calculate the size
        $prefix = '';
        # Camera RAW images need prefix
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $prefix = $rawext[0] . ':';
        }
        # Locate imagemagick.
        $identify_fullpath = get_utility_path("im-identify");
        if ($identify_fullpath == false) {
            exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
        }
        # Get image's dimensions.
        $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($prefix . $file) . '[0]';
        $identoutput = run_command($identcommand);
        preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
        @(list(, $sw, $sh) = $smatches);
        if ($sw != '' && $sh != '') {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        }
    } else {
        # check if this is a raw file.
        $rawfile = false;
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $rawfile = true;
        }
        # Use GD to calculate the size
        if (!(@(list($sw, $sh) = @getimagesize($file)) === false) && !$rawfile) {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        } else {
            # Assume size cannot be calculated.
            $sw = "?";
            $sh = "?";
            global $ffmpeg_supported_extensions;
            if (in_array(strtolower($extension), $ffmpeg_supported_extensions) && function_exists('json_decode')) {
                $ffprobe_fullpath = get_utility_path("ffprobe");
                $file = get_resource_path($ref, true, "", false, $extension);
                $ffprobe_output = run_command($ffprobe_fullpath . " -v 0 " . escapeshellarg($file) . " -show_streams -of json");
                $ffprobe_array = json_decode($ffprobe_output, true);
                # Different versions of ffprobe store the dimensions in different parts of the json output. Test both.
                if (!empty($ffprobe_array['width'])) {
                    $sw = intval($ffprobe_array['width']);
                }
                if (!empty($ffprobe_array['height'])) {
                    $sh = intval($ffprobe_array['height']);
                }
                if (isset($ffprobe_array['streams']) && is_array($ffprobe_array['streams'])) {
                    foreach ($ffprobe_array['streams'] as $stream) {
                        if (!empty($stream['codec_type']) && $stream['codec_type'] === 'video') {
                            $sw = intval($stream['width']);
                            $sh = intval($stream['height']);
                            break;
                        }
                    }
                }
            }
            if ($sw !== '?' && $sh !== '?') {
                # Size could be calculated after all
                sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
            } else {
                # Size cannot be calculated.
                $sw = "?";
                $sh = "?";
                # Insert a dummy row to prevent recalculation on every view.
                sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "','0', '0', '" . $filesize . "')");
            }
        }
    }
    $fileinfo[0] = $filesize;
    $fileinfo[1] = $sw;
    $fileinfo[2] = $sh;
    return $fileinfo;
}
function generate_transform_preview($ref){
	global $storagedir;	
        global $imagemagick_path;
	global $imversion;

	if (!isset($imversion)){
		$imversion = get_imagemagick_version();
	}

	$tmpdir = get_temp_dir();

        // get imagemagick path
        $command = get_utility_path("im-convert");
        if ($command==false) {exit("Could not find ImageMagick 'convert' utility.");}

        $orig_ext = sql_value("select file_extension value from resource where ref = '$ref'",'');
        $originalpath= get_resource_path($ref,true,'',false,$orig_ext);

	# Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
	if(!is_dir(get_temp_dir() . "/transform_plugin")){mkdir(get_temp_dir() . "/transform_plugin",0777);}

       if ($imversion[0]<6 || ($imversion[0] == 6 &&  $imversion[1]<7) || ($imversion[0] == 6 && $imversion[1] == 7 && $imversion[2]<5)){
                $colorspace1 = " -colorspace sRGB ";
                $colorspace2 =  " -colorspace RGB ";
        } else {
                $colorspace1 = " -colorspace RGB ";
                $colorspace2 =  " -colorspace sRGB ";
        }

        $command .= " \"$originalpath\" +matte -delete 1--1 -flatten $colorspace1 -geometry 450 $colorspace2 \"$tmpdir/transform_plugin/pre_$ref.jpg\"";
        run_command($command);


	// while we're here, clean up any old files still hanging around
	$dp = opendir(get_temp_dir() . "/transform_plugin");
	while ($file = readdir($dp)) {
		if ($file <> '.' && $file <> '..'){
			if ((filemtime(get_temp_dir() . "/transform_plugin/$file")) < (strtotime('-2 days'))) {
				unlink(get_temp_dir() . "/transform_plugin/$file");
			}
		}
	}
	closedir($dp);

        return true;
  
}
function generate_transform_preview($ref)
{
    global $storagedir;
    global $imagemagick_path;
    global $imversion;
    if (!isset($imversion)) {
        $imversion = get_imagemagick_version();
    }
    $tmpdir = get_temp_dir();
    // get imagemagick path
    $command = get_utility_path("im-convert");
    if ($command == false) {
        exit("Could not find ImageMagick 'convert' utility.");
    }
    $orig_ext = sql_value("select file_extension value from resource where ref = '{$ref}'", '');
    $transformsourcepath = get_resource_path($ref, true, 'scr', false, 'jpg');
    //use screen size if available to save time
    if (!file_exists($transformsourcepath)) {
        $transformsourcepath = get_resource_path($ref, true, '', false, $orig_ext);
    }
    # Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
    if (!is_dir(get_temp_dir() . "/transform_plugin")) {
        mkdir(get_temp_dir() . "/transform_plugin", 0777);
    }
    if ($imversion[0] < 6 || $imversion[0] == 6 && $imversion[1] < 7 || $imversion[0] == 6 && $imversion[1] == 7 && $imversion[2] < 5) {
        $colorspace1 = " -colorspace sRGB ";
        $colorspace2 = " -colorspace RGB ";
    } else {
        $colorspace1 = " -colorspace RGB ";
        $colorspace2 = " -colorspace sRGB ";
    }
    $command .= " \"{$transformsourcepath}\"[0] +matte -flatten {$colorspace1} -geometry 450 {$colorspace2} \"{$tmpdir}/transform_plugin/pre_{$ref}.jpg\"";
    run_command($command);
    // while we're here, clean up any old files still hanging around
    $dp = opendir(get_temp_dir() . "/transform_plugin");
    while ($file = readdir($dp)) {
        if ($file != '.' && $file != '..') {
            if (filemtime(get_temp_dir() . "/transform_plugin/{$file}") < strtotime('-2 days')) {
                unlink(get_temp_dir() . "/transform_plugin/{$file}");
            }
        }
    }
    closedir($dp);
    return true;
}
Example #5
0
/**
 * Converts the file of the given resource to the new target file with the specified size. The
 * target file format is determined from the suffix of the target file.
 * The original colorspace of the image is retained. If $width and $height are zero, the image
 * keeps its original size.
 */
function convertImage($resource, $page, $alternative, $target, $width, $height)
{
    $command = get_utility_path("im-convert");
    if (!$command) {
        die("Could not find ImageMagick 'convert' utility.");
    }
    $originalPath = get_resource_path($resource['ref'], true, '', false, $resource['file_extension'], -1, $page, false, '', $alternative);
    $command .= " \"{$originalPath}\"[0] -auto-orient";
    if ($width != 0 && $height != 0) {
        # Apply resize ('>' means: never enlarge)
        $command .= " -resize \"{$width}";
        if ($height > 0) {
            $command .= "x{$height}";
        }
        $command .= '>"';
    }
    $command .= " \"{$target}\"";
    run_command($command);
}
function get_original_imagesize($ref = "", $path = "", $extension = "jpg")
{
    $fileinfo = array();
    if ($ref == "" || $path == "") {
        return false;
    }
    global $imagemagick_path, $imagemagick_calculate_sizes;
    $file = $path;
    $filesize = filesize_unlimited($file);
    # imagemagick_calculate_sizes is normally turned off
    if (isset($imagemagick_path) && $imagemagick_calculate_sizes) {
        # Use ImageMagick to calculate the size
        $prefix = '';
        # Camera RAW images need prefix
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $prefix = $rawext[0] . ':';
        }
        # Locate imagemagick.
        $identify_fullpath = get_utility_path("im-identify");
        if ($identify_fullpath == false) {
            exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
        }
        # Get image's dimensions.
        $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($prefix . $file) . '[0]';
        $identoutput = run_command($identcommand);
        preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
        @(list(, $sw, $sh) = $smatches);
        if ($sw != '' && $sh != '') {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        }
    } else {
        # check if this is a raw file.
        $rawfile = false;
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $rawfile = true;
        }
        # Use GD to calculate the size
        if (!(@(list($sw, $sh) = @getimagesize($file)) === false) && !$rawfile) {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        } else {
            # Size cannot be calculated.
            $sw = "?";
            $sh = "?";
            # Insert a dummy row to prevent recalculation on every view.
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "','0', '0', '" . $filesize . "')");
        }
    }
    $fileinfo[0] = $filesize;
    $fileinfo[1] = $sw;
    $fileinfo[2] = $sh;
    return $fileinfo;
}
Example #7
0
function upload_video($access_token="")
	{
	global $lang, $video_title, $video_description, $video_keywords, $video_category, $filename, $ref, $status, $youtube_video_url, $youtube_publish_developer_key;

	
	# Set status as necessary
	if ($status=="private"){$private = '<yt:private/>';} 
		else{$private = '';}
	if ($status=="unlisted"){$accesscontrol = '<yt:accessControl action="list" permission="denied"/>';}
		else{$accesscontrol = '';}
	
    $data= '<?xml version="1.0"?>
                <entry xmlns="http://www.w3.org/2005/Atom"
                  xmlns:media="http://search.yahoo.com/mrss/"
                  xmlns:yt="http://gdata.youtube.com/schemas/2007">
                  <media:group>
                    <media:title type="plain">' . htmlspecialchars( $video_title ) . '</media:title>
					' . $private . '			
                    <media:description type="plain">' . htmlspecialchars( $video_description ) . '</media:description>
                    <media:category
                      scheme="http://gdata.youtube.com/schemas/2007/categories.cat">' . htmlspecialchars($video_category) .'</media:category>
                    <media:keywords>' . htmlspecialchars($video_keywords) . '</media:keywords>
                  </media:group>
				  ' . $accesscontrol . '
                </entry>';
				
	$data.= "\r\n\r\n";			
				
	#####	For resumable
	
	$headers = array( "Authorization: Bearer " . $access_token,
                 "GData-Version: 2",
                 "X-GData-Key: key=" . $youtube_publish_developer_key,
                 "Content-length: " . strlen($data),
                 "Content-Type: application/atom+xml; charset=UTF-8",
				 "Slug: " . htmlspecialchars($filename),
				 "Connection: close" ,
				 "Expect:"
				 );
				 
				 
	$youtube_upload_url="http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads";
		
	$curl = curl_init($youtube_upload_url);
	
		
	//curl_setopt( $curl, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"] );
	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );;
	curl_setopt( $curl, CURLOPT_TIMEOUT, 10 );
	curl_setopt( $curl, CURLINFO_HEADER_OUT , 1 );
	curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
	curl_setopt( $curl, CURLOPT_POST, 1 );
	curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 0 );
	curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
	curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
	curl_setopt($curl, CURLOPT_HEADER, TRUE);
	
	$response = curl_exec( $curl );
	
	
	if(!curl_errno($curl))
		{
		$info = curl_getinfo($curl);
		if ($info['http_code']==401)
			{
			curl_close( $curl );
			get_youtube_access_token(true);
			return array(false,$lang["youtube_publish_renewing_token"],true);
			}		
		}
	else
		{
		curl_close( $curl );
		$upload_result=$lang["error"] . curl_error($curl);
		return array(false,curl_errno($curl),false);			
		}
			
	$header = substr($response, 0, $info['header_size']);
	$retVal = array();
	$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
        foreach( $fields as $field ) 
			{
            if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
                $match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
                if( isset($retVal[$match[1]]) ) 
					{
                    $retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
					} 
				else
					{
                    $retVal[$match[1]] = trim($match[2]);
					}
				}
			}
	if (isset($retVal['Location']))
		{
		$location =  $retVal['Location'];
		}
	else
		{
		$upload_result=$lang["youtube_publish_failedupload_nolocation"];
		curl_close( $curl );
		return array(false,$upload_result,false);
		}
	
			
	
	curl_close( $curl );
	
	# Finally upload the file			
	
	# Get file info for upload
	$resource=get_resource_data($ref);
	$alternative=-1;
	$ext=$resource["file_extension"];
	$path=get_resource_path($ref,true,"",false,$ext,-1,1,false,"",$alternative);
	
	# We assign a default mime-type, in case we can find the one associated to the file extension.
	$mime="application/octet-stream";
			
	# Get mime type via exiftool if possible
	$exiftool_fullpath = get_utility_path("exiftool");
	if ($exiftool_fullpath!=false)
		{	
		$command=$exiftool_fullpath . " -s -s -s -t -mimetype " . escapeshellarg($path);
		$mime=run_command($command);
		}	
		
	# Override or correct for lack of exiftool with config mappings	
	if (isset($mime_type_by_extension[$ext]))
		{
		$mime = $mime_type_by_extension[$ext];
		}
	
	
	$video_file = fopen($path, 'rb');
	
	$curl = curl_init($location);
	
	curl_setopt($curl, CURLOPT_PUT, 1);
	curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);	 
	curl_setopt($curl, CURLOPT_INFILE, $video_file); // file pointer
	curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path));
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_HEADER, $mime );
	curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3600); 
	
	
	$response = curl_exec( $curl );
	$videoxml = new SimpleXmlElement($response, LIBXML_NOCDATA);
	
	$urlAtt = $videoxml->link->attributes();
	$youtube_new_url	= $urlAtt['href'];
	$youtube_urlmatch = '#http://(www\.)youtube\.com/watch\?v=([^ &\n]+)(&.*?(\n|\s))?#i';
	preg_match($youtube_urlmatch, $youtube_new_url, $matches);	
	$youtube_new_url=$matches[0];	
		
	# end of actual file upload
	
	
	fclose($video_file);
    $video_file = null;	
	
	return array(true,$youtube_new_url,false);
	}
function HookImage_textDownloadModifydownloadfile()
{
    global $ref, $path, $tmpfile, $userref, $usergroup, $ext, $resource_data, $image_text_restypes, $image_text_override_groups, $image_text_filetypes, $size, $page, $use_watermark, $alternative, $image_text_height_proportion, $image_text_max_height, $image_text_min_height, $image_text_font, $image_text_position, $image_text_banner_position;
    # Return if not configured for this resource type or if user has requested no overlay and is permitted this
    if (!in_array($resource_data['resource_type'], $image_text_restypes) || !in_array(strtoupper($ext), $image_text_filetypes) || getval("nooverlay", "") != "" && in_array($usergroup, $image_text_override_groups) || $use_watermark) {
        return false;
    }
    # Get text from field
    global $image_text_field_select, $image_text_default_text;
    $overlaytext = get_data_by_field($ref, $image_text_field_select);
    if ($overlaytext == "") {
        if ($image_text_default_text != "") {
            $overlaytext = $image_text_default_text;
        } else {
            return false;
        }
    }
    # If this is not a temporary file having metadata written see if we already have a suitable size with the correct text
    $image_text_saved_file = get_resource_path($ref, true, $size . "_image_text_" . md5($overlaytext . $image_text_height_proportion . $image_text_max_height . $image_text_min_height . $image_text_font . $image_text_position . $image_text_banner_position) . "_", false, $ext, -1, $page);
    if ($path != $tmpfile && file_exists($image_text_saved_file)) {
        $path = $image_text_saved_file;
        return true;
    }
    # Locate imagemagick.
    $identify_fullpath = get_utility_path("im-identify");
    if ($identify_fullpath == false) {
        exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
    }
    # Get image's dimensions.
    $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($path);
    $identoutput = run_command($identcommand);
    preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
    if (@(list(, $width, $height) = $smatches) === false) {
        return false;
    }
    $olheight = floor($height * $image_text_height_proportion);
    if ($olheight < $image_text_min_height && intval($image_text_min_height) != 0) {
        $olheight = $image_text_min_height;
    }
    if ($olheight > $image_text_max_height && intval($image_text_max_height) != 0) {
        $olheight = $image_text_max_height;
    }
    # Locate imagemagick.
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'");
    }
    $tmpolfile = get_temp_dir() . "/" . $ref . "_image_text_" . $userref . "." . $ext;
    $createolcommand = $convert_fullpath . ' -background "#000" -fill white -gravity "' . $image_text_position . '" -font "' . $image_text_font . '" -size ' . $width . 'x' . $olheight . ' caption:" ' . $overlaytext . '  " ' . escapeshellarg($tmpolfile);
    $result = run_command($createolcommand);
    $newdlfile = get_temp_dir() . "/" . $ref . "_image_text_result_" . $userref . "." . $ext;
    if ($image_text_banner_position == "bottom") {
        $convertcommand = $convert_fullpath . " " . escapeshellarg($path) . ' ' . escapeshellarg($tmpolfile) . ' -append ' . escapeshellarg($newdlfile);
    } else {
        $convertcommand = $convert_fullpath . " " . escapeshellarg($tmpolfile) . ' ' . escapeshellarg($path) . ' -append ' . escapeshellarg($newdlfile);
    }
    $result = run_command($convertcommand);
    $oldpath = $path;
    if ($path != $tmpfile) {
        copy($newdlfile, $image_text_saved_file);
    }
    $path = $newdlfile;
    if (strpos(get_temp_dir(), $oldpath) !== false) {
        unlink($oldpath);
    }
    unlink($tmpolfile);
    return true;
}
 foreach ($rs as $r) {
     # For each range
     $s = explode(":", $r);
     $from = $s[0];
     $to = $s[1];
     if (getval("method", "") == "alternativefile") {
         $aref = add_alternative_file($ref, $lang["pages"] . " " . $from . " - " . $to, "", "", "pdf");
         $copy_path = get_resource_path($ref, true, "", true, "pdf", -1, 1, false, "", $aref);
     } else {
         # Create a new resource based upon the metadata/type of the current resource.
         $copy = copy_resource($ref);
         # Find out the path to the original file.
         $copy_path = get_resource_path($copy, true, "", true, "pdf");
     }
     # Extract this one page to a new resource.
     $ghostscript_fullpath = get_utility_path("ghostscript");
     $gscommand = $ghostscript_fullpath . " -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=" . escapeshellarg($copy_path) . "  -dFirstPage=" . $from . " -dLastPage=" . $to . " " . escapeshellarg($file);
     $output = run_command($gscommand);
     if (getval("method", "") == "alternativefile") {
         # Preview creation for alternative files (enabled via config)
         global $alternative_file_previews;
         if ($alternative_file_previews) {
             create_previews($ref, false, "pdf", false, false, $aref);
         }
         # Update size.
         sql_query("update resource_alt_files set file_size='" . filesize_unlimited($copy_path) . "' where ref='{$aref}'");
     } else {
         # Update the file extension
         sql_query("update resource set file_extension='pdf' where ref='{$copy}'");
         # Create preview for the page.
         create_previews($copy, false, "pdf");
Example #10
0
    include "../../../include/footer.php";
    exit;
}
$imversion = get_imagemagick_version();
// generate a preview image for the operation if it doesn't already exist
if (!file_exists(get_temp_dir() . "/transform_plugin/pre_{$ref}.jpg")) {
    //echo  "generating preview";
    //exit();
    generate_transform_preview($ref) or die("Error generating transform preview.");
}
# Locate imagemagick.
if (!isset($imagemagick_path)) {
    echo "Error: ImageMagick must be configured for crop functionality. Please contact your system administrator.";
    exit;
}
$command = get_utility_path("im-convert");
if ($command == false) {
    exit("Could not find ImageMagick 'convert' utility.");
}
// retrieve file extensions
$orig_ext = sql_value("select file_extension value from resource where ref = '{$ref}'", '');
$preview_ext = sql_value("select preview_extension value from resource where ref = '{$ref}'", '');
// retrieve image paths for preview image and original file
//$previewpath = get_resource_path($ref,true,$cropper_cropsize,false,$preview_ext);
$previewpath = get_temp_dir() . "/transform_plugin/" . $cropper_cropsize . "_{$ref}.jpg";
//echo $previewpath;
//exit();
$originalpath = get_resource_path($ref, true, '', false, $orig_ext);
// retrieve image sizes for original image and preview used for cropping
$cropsizes = getimagesize($previewpath);
$origsizes = getimagesize($originalpath);
Example #11
0
            if ($prettyfieldnames && array_key_exists('field' . $metadata_field['resource_type_field'], $full_fields_options) || array_key_exists($full_fields_options['field' . $metadata_field['resource_type_field']], $results[$i])) {
                $results[$i][$full_fields_options['field' . $metadata_field['resource_type_field']]] = $metadata_field['value'];
            }
        }
        $results[$i] = array_change_key_case($results[$i], CASE_LOWER);
    }
}
$new_results = array();
$results = array_values($results);
foreach ($results as $index => $value) {
    if (!array_key_exists('current', $value) || !array_key_exists('aspect_ratio', $value)) {
        continue;
    }
    $alt_array = sql_query("SELECT ref,name FROM resource_alt_files WHERE resource = " . $value['ref']);
    #Restructure the Results JSON.
    $im_identify_path = get_utility_path('im-identify');
    $get_height_cmd = $im_identify_path . " -format '%[fx:h]' ";
    $get_width_cmd = $im_identify_path . " -format '%[fx:w]' ";
    $sizes = array();
    #if (!isset($image_classification)) {
    #    $image_classification = $results[$i]['Image_Classification'];
    #}
    foreach ($alt_array as $index => $alt_value) {
        $alt_path = get_resource_path($value['ref'], TRUE, '', FALSE, $value['file_extension'], -1, 1, FALSE, '', $alt_value['ref']);
        $alt_path = readlink($alt_path);
        $alt_height_cmd = $get_height_cmd . $alt_path;
        $alt_width_cmd = $get_width_cmd . $alt_path;
        $sizes[$alt_value['name']]['file_path'] = $alt_path;
        $sizes[$alt_value['name']]['size'] = array('height' => trim(shell_exec($alt_height_cmd)), 'width' => trim(shell_exec($alt_width_cmd)));
    }
    $get_height_cmd .= $value['original_filepath'];
function HookImagestreamUpload_pluploadInitialuploadprocessing()
{
    #Support for uploading multi files as zip
    global $config_windows, $id, $targetDir, $resource_type, $imagestream_restypes, $imagestream_transitiontime, $zipcommand, $use_zip_extension, $userref, $session_hash, $filename, $filename_field, $collection_add, $archiver, $zipcommand, $ffmpeg_fullpath, $ffmpeg_preview_extension, $ffmpeg_preview_options, $ffmpeg_preview_min_height, $ffmpeg_preview_max_height, $ffmpeg_preview_min_width, $ffmpeg_preview_max_width, $lang, $collection_download_settings, $archiver_listfile_argument;
    $ffmpeg_fullpath = get_utility_path("ffmpeg");
    debug("DEBUG: Imagestream - checking restype: " . $resource_type . $imagestream_restypes);
    if (in_array($resource_type, $imagestream_restypes)) {
        debug("DEBUG: Imagestream - uploading file");
        #Check that we have an archiver configured
        $archiver_fullpath = get_utility_path("archiver");
        if (!isset($zipcommand) && !$use_zip_extension) {
            if ($archiver_fullpath == false) {
                exit($lang["archiver-utility-not-found"]);
            }
        }
        echo print_r($_POST) . print_r($_GET);
        if (getval("lastqueued", "")) {
            debug("DEBUG: Imagestream - last queued file");
            $ref = copy_resource(0 - $userref);
            # Copy from user template
            debug("DEBUG: Imagestream - creating resource: " . $ref);
            # Create the zip file
            $imagestreamzippath = get_resource_path($ref, true, "", true, "zip");
            if ($use_zip_extension) {
                $zip = new ZipArchive();
                $zip->open($imagestreamzippath, ZIPARCHIVE::CREATE);
            }
            $deletion_array = array();
            debug("DEBUG: opening directory: " . $targetDir);
            $imagestream_files = opendir($targetDir);
            $imagestream_workingfiles = get_temp_dir() . DIRECTORY_SEPARATOR . "plupload" . DIRECTORY_SEPARATOR . $session_hash . "workingfiles";
            if (!file_exists($imagestream_workingfiles)) {
                if ($config_windows) {
                    @mkdir($imagestream_workingfiles);
                } else {
                    @mkdir($imagestream_workingfiles, 0777, true);
                }
            }
            $filenumber = 00;
            $imagestream_filelist = array();
            while ($imagestream_filelist[] = readdir($imagestream_files)) {
                sort($imagestream_filelist);
            }
            closedir($imagestream_files);
            $imageindex = 1;
            foreach ($imagestream_filelist as $imagestream_file) {
                if ($imagestream_file != '.' && $imagestream_file != '..') {
                    $filenumber = sprintf("%03d", $filenumber);
                    $deletion_array[] = $targetDir . DIRECTORY_SEPARATOR . $imagestream_file;
                    if (!$use_zip_extension) {
                        $imagestreamcmd_file = get_temp_dir(false, $id) . "/imagestreamzipcmd" . $imagestream_file . ".txt";
                        $fh = fopen($imagestreamcmd_file, 'w') or die("can't open file");
                        fwrite($fh, $targetDir . DIRECTORY_SEPARATOR . $imagestream_file . "\r\n");
                        fclose($fh);
                        $deletion_array[] = $imagestreamcmd_file;
                    }
                    if ($use_zip_extension) {
                        debug("DEBUG: Imagestream - adding filename: " . $imagestream_file);
                        debug("DEBUG: using zip PHP extension, set up zip at : " . $imagestreamzippath);
                        $zip->addFile($imagestream_file);
                        debug(" Added files number : " . $zip->numFiles);
                        $wait = $zip->close();
                        debug("DEBUG: closed zip");
                    } else {
                        if ($archiver_fullpath) {
                            debug("DEBUG: using archiver, running command: \r\n" . $archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestream_file));
                            run_command($archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestreamcmd_file));
                        } else {
                            if (!$use_zip_extension) {
                                if ($config_windows) {
                                    debug("DEBUG: using zip command: . {$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file));
                                    exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file));
                                } else {
                                    # Pipe the command file, containing the filenames, to the executable.
                                    exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " -@ < " . escapeshellarg($imagestreamcmd_file));
                                }
                            }
                        }
                    }
                    #Create a JPEG if not already in that format
                    $imagestream_file_parts = explode('.', $imagestream_file);
                    $imagestream_file_ext = $imagestream_file_parts[count($imagestream_file_parts) - 1];
                    $imagestream_file_noext = basename($imagestream_file, $imagestream_file_ext);
                    global $imagemagick_path, $imagemagick_quality;
                    $icc_transform_complete = false;
                    # Camera RAW images need prefix
                    if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $imagestream_file_ext, $rawext)) {
                        $prefix = $rawext[0] . ':';
                    }
                    # Locate imagemagick.
                    $convert_fullpath = get_utility_path("im-convert");
                    if ($convert_fullpath == false) {
                        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'.");
                    }
                    $prefix = '';
                    if ($prefix == "cr2:" || $prefix == "nef:") {
                        $flatten = "";
                    } else {
                        $flatten = "-flatten";
                    }
                    $command = $convert_fullpath . ' ' . escapeshellarg($targetDir . DIRECTORY_SEPARATOR . $imagestream_file) . ' +matte ' . $flatten . ' -quality ' . $imagemagick_quality;
                    # EXPERIMENTAL CODE TO USE EXISTING ICC PROFILE IF PRESENT
                    global $icc_extraction, $icc_preview_profile, $icc_preview_options, $ffmpeg_supported_extensions;
                    if ($icc_extraction) {
                        $iccpath = $targetDir . DIRECTORY_SEPARATOR . $imagestream_file . '.icc';
                        if (!file_exists($iccpath) && !isset($iccfound) && $extension != "pdf" && !in_array($imagestream_file_ext, $ffmpeg_supported_extensions)) {
                            // extracted profile doesn't exist. Try extracting.
                            if (extract_icc_profile($ref, $imagestream_file_ext)) {
                                $iccfound = true;
                            } else {
                                $iccfound = false;
                            }
                        }
                    }
                    if ($icc_extraction && file_exists($iccpath) && !$icc_transform_complete) {
                        // we have an extracted ICC profile, so use it as source
                        $targetprofile = dirname(__FILE__) . '/../iccprofiles/' . $icc_preview_profile;
                        $profile = " +profile \"*\" -profile {$iccpath} {$icc_preview_options} -profile {$targetprofile} +profile \"*\" ";
                        $icc_transform_complete = true;
                    } else {
                        // use existing strategy for color profiles
                        # Preserve colour profiles? (omit for smaller sizes)
                        $profile = "+profile \"*\" -colorspace RGB";
                        # By default, strip the colour profiles ('+' is remove the profile, confusingly)
                        #if ($imagemagick_preserve_profiles && $id!="thm" && $id!="col" && $id!="pre" && $id!="scr") {$profile="";}
                    }
                    $runcommand = $command . " +matte {$profile} " . escapeshellarg($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg");
                    $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg";
                    $output = run_command($runcommand);
                    debug("processed file" . $filenumber . ": " . $imagestream_file . "\r\n");
                    debug("Image index: " . $imageindex . ". file count: " . count($imagestream_filelist));
                    if ($filenumber == 00) {
                        $snapshotsize = getimagesize($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg");
                        list($width, $height) = $snapshotsize;
                        # Frame size must be a multiple of two
                        if ($width % 2) {
                            $width++;
                        }
                        if ($height % 2) {
                            $height++;
                        }
                    }
                    if ($imageindex == count($imagestream_filelist) - 1) {
                        $additionalfile = $filenumber + 1;
                        $additionalfile = sprintf("%03d", $additionalfile);
                        copy($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg", $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg");
                        $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg";
                    }
                    $filenumber++;
                }
                #end of loop for each uploadedfile
                $imageindex++;
            }
            #Add the resource and move this zip file, set extension
            # Add to collection?
            if ($collection_add != "") {
                add_resource_to_collection($ref, $collection_add);
            }
            # Log this
            daily_stat("Resource upload", $ref);
            resource_log($ref, "u", 0);
            #Change this!!!!!!!!!!!
            #$status=upload_file($ref,true,false,false));
            if (!$config_windows) {
                @chmod($imagestreamzippath, 0777);
            }
            # Store extension in the database and update file modified time.
            sql_query("update resource set file_extension='zip',preview_extension='zip',file_modified=now(), has_image=0 where ref='{$ref}'");
            #update_field($ref,$filename_field,$filename);
            update_disk_usage($ref);
            # create the mp4 version
            # Add a new alternative file
            $aref = add_alternative_file($ref, "MP4 version");
            $imagestreamqtfile = get_resource_path($ref, true, "", false, "mp4", -1, 1, false, "", $aref);
            $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile;
            echo "Running command: " . $shell_exec_cmd;
            if ($config_windows) {
                $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile;
                file_put_contents(get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat", $shell_exec_cmd);
                $shell_exec_cmd = get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat";
                $deletion_array[] = $shell_exec_cmd;
            }
            run_command($shell_exec_cmd);
            debug("DEBUG created slideshow MP4 video");
            if (!$config_windows) {
                @chmod($imagestreamqtfile, 0777);
            }
            $file_size = @filesize_unlimited($imagestreamqtfile);
            # Save alternative file data.
            sql_query("update resource_alt_files set file_name='quicktime.mp4',file_extension='mp4',file_size='" . $file_size . "',creation_date=now() where resource='{$ref}' and ref='{$aref}'");
            #create the FLV preview as per normal video processing if possible?
            if ($height < $ffmpeg_preview_min_height) {
                $height = $ffmpeg_preview_min_height;
            }
            if ($width < $ffmpeg_preview_min_width) {
                $width = $ffmpeg_preview_min_width;
            }
            if ($height > $ffmpeg_preview_max_height) {
                $width = ceil($width * ($ffmpeg_preview_max_height / $height));
                $height = $ffmpeg_preview_max_height;
            }
            if ($width > $ffmpeg_preview_max_width) {
                $height = ceil($height * ($ffmpeg_preview_max_width / $width));
                $width = $ffmpeg_preview_max_width;
            }
            $flvzippreviewfile = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension);
            $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -i " . $imagestreamqtfile . " {$ffmpeg_preview_options} -s {$width}x{$height} " . $flvzippreviewfile;
            debug("Running command: " . $shell_exec_cmd);
            if ($config_windows) {
                file_put_contents(get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreamflv" . $session_hash . ".bat", $shell_exec_cmd);
                $shell_exec_cmd = get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreamflv" . $session_hash . ".bat";
                $deletion_array[] = $shell_exec_cmd;
            }
            run_command($shell_exec_cmd);
            debug("DEBUG created slideshow FLV video");
            if (!$config_windows) {
                @chmod($flvzippreviewfile, 0777);
            }
            #Tidy up
            rcRmdir($imagestream_workingfiles);
            rcRmdir($targetDir);
            foreach ($deletion_array as $tmpfile) {
                debug("\r\nDEBUG: Deleting: " . $tmpfile);
                delete_exif_tmpfile($tmpfile);
            }
            echo "SUCCESS";
            #return true;
            exit;
        } else {
            echo "SUCCESS";
            exit;
        }
        return true;
    } else {
        return false;
    }
}
function get_imagemagick_version($array = true)
{
    // return version number of ImageMagick, or false if it is not installed or cannot be determined.
    // will return an array of major/minor/version/patch if $array is true, otherwise just the version string
    # Locate imagemagick, or return false if it isn't installed
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        return false;
    }
    $versionstring = run_command($convert_fullpath . " --version");
    // example:
    //          Version: ImageMagick 6.5.0-0 2011-02-18 Q16 http://www.imagemagick.org
    //          Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
    if (preg_match("/^Version: +ImageMagick (\\d+)\\.(\\d+)\\.(\\d+)-(\\d+) /", $versionstring, $matches)) {
        $majorver = $matches[1];
        $minorver = $matches[2];
        $revision = $matches[3];
        $patch = $matches[4];
        if ($array) {
            return array($majorver, $minorver, $revision, $patch);
        } else {
            return "{$majorver}.{$minorver}.{$revision}-{$patch}";
        }
    } else {
        return false;
    }
}
Example #14
0
function get_page_count($resource,$alternative=-1)
    {
    # gets page count for multipage previews from resource_dimensions table.
    # also handle alternative file multipage previews by switching $resource array if necessary
    # $alternative specifies an actual alternative file
    $ref=$resource['ref'];
    if ($alternative!=-1)
        {
        $pagecount=sql_value("select page_count value from resource_alt_files where ref=$alternative","");
        $resource=get_alternative_file($ref,$alternative);
        }
    else
        {
        $pagecount=sql_value("select page_count value from resource_dimensions where resource=$ref","");
        }
    if ($pagecount!=""){return $pagecount;}
    # or, populate this column with exiftool (for installations with many pdfs already previewed and indexed, this allows pagecount updates on the fly when needed):
    # use exiftool. 
    # locate exiftool
    $exiftool_fullpath = get_utility_path("exiftool");
    if ($exiftool_fullpath==false){}
    else
        {
        $command = $exiftool_fullpath;
        if ($resource['file_extension']=="pdf" && $alternative==-1)
            {
            $file=get_resource_path($ref,true,"",false,"pdf");
            }
        else if ($alternative==-1)
            {
            # some unoconv files are not pdfs but this needs to use the auto-alt file
            $alt_ref=sql_value("select ref value from resource_alt_files where resource=$ref and unoconv=1","");
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alt_ref);
            }
        else
            {
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alternative);
            }
    
        $command=$command." -sss -pagecount $file";
        $output=run_command($command);
        $pages=str_replace("Page Count","",$output);
        $pages=str_replace(":","",$pages);
        $pages=trim($pages);

    if (!is_numeric($pages)){ $pages = 1; } // default to 1 page if we didn't get anything back

        if ($alternative!=-1)
            {
            sql_query("update resource_alt_files set page_count='$pages' where ref=$alternative");
            }
        else
            {
            sql_query("update resource_dimensions set page_count='$pages' where resource=$ref");
            }
        return $pages;
    }
}
Example #15
0
function HookVideo_spliceViewAfterresourceactions()
{
    global $videosplice_resourcetype, $resource, $lang, $config_windows, $resourcetoolsGT;
    if ($resource["resource_type"] != $videosplice_resourcetype) {
        return false;
    }
    # Not the right type.
    if (getval("video_splice_cut_from_hours", "") != "") {
        # Process actions
        $error = "";
        # Receive input
        $fh = getvalescaped("video_splice_cut_from_hours", "");
        $fm = getvalescaped("video_splice_cut_from_minutes", "");
        $fs = getvalescaped("video_splice_cut_from_seconds", "");
        $th = getvalescaped("video_splice_cut_to_hours", "");
        $tm = getvalescaped("video_splice_cut_to_minutes", "");
        $ts = getvalescaped("video_splice_cut_to_seconds", "");
        $preview = getvalescaped("preview", "") != "";
        # Calculate a duration, as needed by FFMPEG
        $from_seconds = $fh * 60 * 60 + $fm * 60 + $fs;
        $to_seconds = $th * 60 * 60 + $tm * 60 + $ts;
        $seconds = $to_seconds - $from_seconds;
        # Any problems?
        if ($seconds <= 0) {
            $error = $lang["error-from_time_after_to_time"];
        }
        # Convert seconds to HH:MM:SS as required by FFmpeg.
        $dh = floor($seconds / (60 * 60));
        $dm = floor(($seconds - $dh * 60 * 60) / 60);
        $ds = floor($seconds - $dh * 60 * 60 - $dm * 60);
        # Show error message if necessary
        if ($error != "") {
            ?>
			<script type="text/javascript">
			alert("<?php 
            echo $error;
            ?>
");
			</script>
			<?php 
        } else {
            # Process video.
            $ss = $fh . ":" . $fm . ":" . $fs;
            $t = str_pad($dh, 2, "0", STR_PAD_LEFT) . ":" . str_pad($dm, 2, "0", STR_PAD_LEFT) . ":" . str_pad($ds, 2, "0", STR_PAD_LEFT);
            # Establish FFMPEG location.
            $ffmpeg_fullpath = get_utility_path("ffmpeg");
            # Work out source/destination
            global $ffmpeg_preview_extension, $ref;
            if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
                $source = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            } else {
                $source = get_resource_path($ref, true, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            }
            # Preview only?
            global $userref;
            if ($preview) {
                # Preview only.
                $target = get_temp_dir() . "/video_splice_preview_" . $userref . "." . $ffmpeg_preview_extension;
            } else {
                # Not a preview. Create a new resource.
                $newref = copy_resource($ref);
                $target = get_resource_path($newref, true, "", true, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
                # Set parent resource field details.
                global $videosplice_parent_field;
                update_field($newref, $videosplice_parent_field, $ref . ": " . $resource["field8"] . " [{$fh}:{$fm}:{$fs} - {$th}:{$tm}:{$ts}]");
                # Set created_by, archive and extension
                sql_query("update resource set created_by='{$userref}',archive=-2,file_extension='" . $ffmpeg_preview_extension . "' where ref='{$newref}'");
            }
            # Unlink the target
            if (file_exists($target)) {
                unlink($target);
            }
            if ($config_windows) {
                # Windows systems have a hard time with the long paths used for video generation.
                $target_ext = strrchr($target, '.');
                $source_ext = strrchr($source, '.');
                $target_temp = get_temp_dir() . "/vs_t" . $newref . $target_ext;
                $target_temp = str_replace("/", "\\", $target_temp);
                $source_temp = get_temp_dir() . "/vs_s" . $ref . $source_ext;
                $source_temp = str_replace("/", "\\", $source_temp);
                copy($source, $source_temp);
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source_temp) . " -ss {$ss} -t {$t} " . escapeshellarg($target_temp);
                $output = exec($shell_exec_cmd);
                rename($target_temp, $target);
                unlink($source_temp);
            } else {
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source) . " -ss {$ss} -t {$t} " . escapeshellarg($target);
                $output = exec($shell_exec_cmd);
            }
            #echo "<p>" . $shell_exec_cmd . "</p>";
            # Generate preview/thumbs if not in preview mode
            if (!$preview) {
                include_once "../include/image_processing.php";
                create_previews($newref, false, $ffmpeg_preview_extension);
                # Add the resource to the user's collection.
                global $usercollection, $baseurl;
                add_resource_to_collection($newref, $usercollection);
                ?>
				<script type="text/javascript">
				top.collections.location.href="<?php 
                echo $baseurl;
                ?>
/pages/collections.php?nc=<?php 
                echo time();
                ?>
";
				</script>
				<?php 
            }
        }
    }
    ?>
<li><a href="#" onClick="
if (document.getElementById('videocut').style.display=='block') {document.getElementById('videocut').style.display='none';} else {document.getElementById('videocut').style.display='block';} return false;"><?php 
    echo ($resourcetoolsGT ? "&gt; " : "") . $lang["action-cut"];
    ?>
</a></li>
<form id="videocut" style="<?php 
    if (!(isset($preview) && $preview)) {
        ?>
display:none;<?php 
    }
    ?>
padding:10px 0 3px 0;" method="post">

<table>
<tr>
<td><?php 
    echo $lang["from-time"];
    ?>
</td>
<td><?php 
    echo $lang["hh"];
    ?>
<select name="video_splice_cut_from_hours">
<?php 
    for ($n = 0; $n < 100; $n++) {
        ?>
<option <?php 
        if (isset($fh) && $fh == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
<td><?php 
    echo $lang["mm"];
    ?>
<select name="video_splice_cut_from_minutes">
<?php 
    for ($n = 0; $n < 60; $n++) {
        ?>
<option <?php 
        if (isset($fm) && $fm == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
<td><?php 
    echo $lang["ss"];
    ?>
<select name="video_splice_cut_from_seconds">
<?php 
    for ($n = 0; $n < 60; $n++) {
        ?>
<option <?php 
        if (isset($fs) && $fs == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
</tr>

<tr>
<td><?php 
    echo $lang["to-time"];
    ?>
</td>
<td><?php 
    echo $lang["hh"];
    ?>
<select name="video_splice_cut_to_hours">
<?php 
    for ($n = 0; $n < 100; $n++) {
        ?>
<option <?php 
        if (isset($th) && $th == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
<td><?php 
    echo $lang["mm"];
    ?>
<select name="video_splice_cut_to_minutes">
<?php 
    for ($n = 0; $n < 60; $n++) {
        ?>
<option <?php 
        if (isset($tm) && $tm == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
<td><?php 
    echo $lang["ss"];
    ?>
<select name="video_splice_cut_to_seconds">
<?php 
    for ($n = 0; $n < 60; $n++) {
        ?>
<option <?php 
        if (isset($ts) && $ts == $n) {
            ?>
selected<?php 
        }
        ?>
><?php 
        echo str_pad($n, 2, "0", STR_PAD_LEFT);
        ?>
</option><?php 
    }
    ?>
</select></td>
</tr>

<tr><td colspan=4 align="center">
<input type="submit" name="preview" value="<?php 
    echo $lang["action-preview"];
    ?>
" style="width:40%;">
&nbsp;&nbsp;
<input type="submit" name="cut" value="<?php 
    echo $lang["action-cut"];
    ?>
" style="width:40%;">
</td></tr>

</table>

<?php 
    if (isset($preview) && $preview) {
        # Show the preview
        # Work out a colour theme
        global $userfixedtheme;
        $theme = isset($userfixedtheme) && $userfixedtheme != "" ? $userfixedtheme : getval("colourcss", "greyblu");
        $colour = "505050";
        if ($theme == "greyblu") {
            $colour = "446693";
        }
        global $baseurl;
        # Embedded preview player
        ?>
	<p align="center">
	<object type="application/x-shockwave-flash" data="../lib/flashplayer/player_flv_maxi.swf" width="240" height="135">
    <param name="allowFullScreen" value="true" />
	
     <param name="movie" value="../lib/flashplayer/player_flv_maxi.swf" />
     <param name="FlashVars" value="flv=<?php 
        echo convert_path_to_url($target);
        ?>
&amp;width=240&amp;height=135&amp;margin=0&amp;buffer=10&amp;showvolume=0&amp;volume=200&amp;showtime=0&amp;autoplay=1&amp;autoload=1&amp;showfullscreen=0&amp;showstop=0&amp;playercolor=<?php 
        echo $colour;
        ?>
" />
	</object>
	</p>
	<?php 
    }
    ?>



</form>

	<?php 
    return true;
}
<?php

include '../../../../include/config.php';
include '../../../../include/db.php';
include '../../../../include/general.php';
include '../../../../include/authenticate.php';
include '../../include/colorfunctions.php';
putenv("MAGICK_HOME=" . $imagemagick_path);
putenv("PATH=" . $ghostscript_path . ":" . $imagemagick_path);
$convert_fullpath = get_utility_path("im-convert");
$composite_fullpath = get_utility_path("im-composite");
// There is only one slot now but future revision to manage multiple themes
// may be able to use this as a starting point.
// the default colorthemer theme name "colorthemer_1" is based on this ref.
$ref = 1;
$sat = getval("sat", "100");
$rounded = getval("rounded", false);
$hue = getval("hue", "0");
$style = getval("style", "greyblu");
$generate = getval("generate", false);
// create a colorthemes folder if necessary
if (!is_dir($storagedir . "/colorthemes")) {
    mkdir($storagedir . "/colorthemes", 0777);
}
if (!is_dir($storagedir . "/colorthemes/{$ref}")) {
    mkdir($storagedir . "/colorthemes/{$ref}", 0777);
}
if ($generate) {
    # create all the files
    include 'colortheme_generate.php';
} else {
Example #17
0
function get_image_sizes($ref,$internal=false,$extension="jpg",$onlyifexists=true)
	{
	# Returns a table of available image sizes for resource $ref. The standard image sizes are translated using $lang. Custom image sizes are i18n translated.
	# The original image file assumes the name of the 'nearest size (up)' in the table

	global $imagemagick_calculate_sizes;

	# Work out resource type
	$resource_type=sql_value("select resource_type value from resource where ref='$ref'","");

	# add the original image
	$return=array();
	$lastname=sql_value("select name value from preview_size where width=(select max(width) from preview_size)",""); # Start with the highest resolution.
	$lastpreview=0;$lastrestricted=0;
	$path2=get_resource_path($ref,true,'',false,$extension);

	if (file_exists($path2) && !checkperm("T" . $resource_type . "_"))
	{ 
		$returnline=array();
		$returnline["name"]=lang_or_i18n_get_translated($lastname, "imagesize-");
		$returnline["allow_preview"]=$lastpreview;
		$returnline["allow_restricted"]=$lastrestricted;
		$returnline["path"]=$path2;
		$returnline["id"]="";
		$dimensions = sql_query("select width,height,file_size,resolution,unit from resource_dimensions where resource=". $ref);
		
		if (count($dimensions))
			{
			$sw = $dimensions[0]['width']; if ($sw==0) {$sw="?";}
			$sh = $dimensions[0]['height']; if ($sh==0) {$sh="?";}
			$filesize=$dimensions[0]['file_size'];
			# resolution and unit are not necessarily available, set to empty string if so.
			$resolution = ($dimensions[0]['resolution'])?$dimensions[0]['resolution']:"";
			$unit = ($dimensions[0]['unit'])?$dimensions[0]['unit']:"";
			}
		else
			{
			global $imagemagick_path;
			$file=$path2;
			$filesize=filesize_unlimited($file);
			
			# imagemagick_calculate_sizes is normally turned off 
			if (isset($imagemagick_path) && $imagemagick_calculate_sizes)
				{
				# Use ImageMagick to calculate the size
				
				$prefix = '';
				# Camera RAW images need prefix
				if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) { $prefix = $rawext[0] .':'; }

				# Locate imagemagick.
                $identify_fullpath = get_utility_path("im-identify");
                if ($identify_fullpath==false) {exit("Could not find ImageMagick 'identify' utility at location '$imagemagick_path'.");}	
				# Get image's dimensions.
                $identcommand = $identify_fullpath . ' -format %wx%h '. escapeshellarg($prefix . $file) .'[0]';
				$identoutput=run_command($identcommand);
				preg_match('/^([0-9]+)x([0-9]+)$/ims',$identoutput,$smatches);
				@list(,$sw,$sh) = $smatches;
				if (($sw!='') && ($sh!=''))
				  {
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."', '". $sw ."', '". $sh ."', '" . $filesize . "')");
					}
				}	
			else 
				{
				# check if this is a raw file.	
				$rawfile = false;
				if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)){$rawfile=true;}
					
				# Use GD to calculate the size
				if (!((@list($sw,$sh) = @getimagesize($file))===false)&& !$rawfile)
				 	{		
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."', '". $sw ."', '". $sh ."', '" . $filesize . "')");
					}
				else
					{
					# Size cannot be calculated.
					$sw="?";$sh="?";
					
					# Insert a dummy row to prevent recalculation on every view.
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."','0', '0', '" . $filesize . "')");
					}
				}
			}
		if (!is_numeric($filesize)) {$returnline["filesize"]="?";$returnline["filedown"]="?";}
		else {$returnline["filedown"]=ceil($filesize/50000) . " seconds @ broadband";$returnline["filesize"]=formatfilesize($filesize);}
		$returnline["width"]=$sw;			
		$returnline["height"]=$sh;
		$returnline["extension"]=$extension;
		(isset($resolution))?$returnline["resolution"]=$resolution:$returnline["resolution"]="";
		(isset($unit))?$returnline["unit"]=$unit:$returnline["unit"]="";
		$return[]=$returnline;
	}
	# loop through all image sizes
	$sizes=sql_query("select * from preview_size order by width desc");
	for ($n=0;$n<count($sizes);$n++)
		{
		$path=get_resource_path($ref,true,$sizes[$n]["id"],false,"jpg");

		$resource_type=sql_value("select resource_type value from resource where ref='$ref'","");
		if ((file_exists($path) || (!$onlyifexists)) && !checkperm("T" . $resource_type . "_" . $sizes[$n]["id"]))
			{
			if (($sizes[$n]["internal"]==0) || ($internal))
				{
				$returnline=array();
				$returnline["name"]=lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
				$returnline["allow_preview"]=$sizes[$n]["allow_preview"];

				# The ability to restrict download size by user group and resource type.
				if (checkperm("X" . $resource_type . "_" . $sizes[$n]["id"]))
					{
					# Permission set. Always restrict this download if this resource is restricted.
					$returnline["allow_restricted"]=false;
					}
				else
					{
					# Take the restriction from the settings for this download size.
					$returnline["allow_restricted"]=$sizes[$n]["allow_restricted"];
					}
				$returnline["path"]=$path;
				$returnline["id"]=$sizes[$n]["id"];
				if ((list($sw,$sh) = @getimagesize($path))===false) {$sw=0;$sh=0;}
				if (($filesize=@filesize_unlimited($path))===false) {$returnline["filesize"]="?";$returnline["filedown"]="?";}
				else {$returnline["filedown"]=ceil($filesize/50000) . " seconds @ broadband";$filesize=formatfilesize($filesize);}
				$returnline["filesize"]=$filesize;			
				$returnline["width"]=$sw;			
				$returnline["height"]=$sh;
				$returnline["extension"]='jpg';
				$return[]=$returnline;
				}
			}
		$lastname=lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
		$lastpreview=$sizes[$n]["allow_preview"];
		$lastrestricted=$sizes[$n]["allow_restricted"];
		}
	return $return;
	}
    $height = 850;
    $font = dirname(__FILE__) . "/../gfx/fonts/vera.ttf";
    $im = imagecreatetruecolor($width, $height);
    $col = imagecolorallocate($im, 255, 255, 255);
    imagefilledrectangle($im, 0, 0, $width, $height, $col);
    $col = imagecolorallocate($im, 0, 0, 0);
    imagettftext($im, 9, 0, 10, 25, $col, $font, $text);
    imagejpeg($im, $target);
    $newfile = $target;
}
/* ----------------------------------------
	Try FFMPEG for video files
   ----------------------------------------
*/
$ffmpeg_fullpath = get_utility_path("ffmpeg");
$ffprobe_fullpath = get_utility_path("ffprobe");
global $ffmpeg_preview, $ffmpeg_preview_seconds, $ffmpeg_preview_extension, $ffmpeg_preview_options, $ffmpeg_preview_min_width, $ffmpeg_preview_min_height, $ffmpeg_preview_max_width, $ffmpeg_preview_max_height, $php_path, $ffmpeg_preview_async, $ffmpeg_preview_force;
// If a snapshot has already been created and $ffmpeg_no_new_snapshots, never revert the snapshot (this is usually a custom preview)
debug('FFMPEG-VIDEO: ####################################################################');
debug('FFMPEG-VIDEO: Start trying FFMPeg for video files -- resource ID ' . $ref);
if ($ffmpeg_fullpath != false && $snapshotcheck && in_array($extension, $ffmpeg_supported_extensions) && $ffmpeg_no_new_snapshots) {
    debug('FFMPEG-VIDEO: Create a preview for this video by going straight to ffmpeg_processing.php');
    $target = get_resource_path($ref, true, "pre", false, 'jpg', -1, 1, false, "");
    include dirname(__FILE__) . "/ffmpeg_processing.php";
} else {
    if ($ffmpeg_fullpath != false && !isset($newfile) && in_array($extension, $ffmpeg_supported_extensions)) {
        debug('FFMPEG-VIDEO: Start process for creating previews...');
        $snapshottime = 1;
        $out = run_command($ffprobe_fullpath . " -i " . escapeshellarg($file), true);
        debug('FFMPEG-VIDEO: Running information command: ' . $ffprobe_fullpath . ' -i ' . $file);
        if (preg_match("/Duration: (\\d+):(\\d+):(\\d+)\\.\\d+, start/", $out, $match)) {
Example #19
0
function get_mime_type($path, $ext = null)
{
    global $mime_type_by_extension;
    if (empty($ext)) {
        $ext = pathinfo($path, PATHINFO_EXTENSION);
    }
    if (isset($mime_type_by_extension[$ext])) {
        return $mime_type_by_extension[$ext];
    }
    # Get mime type via exiftool if possible
    $exiftool_fullpath = get_utility_path("exiftool");
    if ($exiftool_fullpath != false) {
        $command = $exiftool_fullpath . " -s -s -s -t -mimetype " . escapeshellarg($path);
        return run_command($command);
    }
    return "application/octet-stream";
}
Example #20
0
 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}";
         $command .= " " . escapeshellarg($newpath);
         $output = run_command($command);
     }
 }
 // get final pixel dimensions of resulting file
 $newfilesize = filesize_unlimited($newpath);
 $newfiledimensions = getimagesize($newpath);
 $newfilewidth = $newfiledimensions[0];
 $newfileheight = $newfiledimensions[1];
 // generate previews if needed
 global $alternative_file_previews;
include "../../include/authenticate.php";
if (!checkperm("a")) {
    exit("Permission denied");
}
include "../../include/image_processing.php";
include "../../include/resource_functions.php";
$max = sql_value("select max(ref) value from resource", 0);
$ref = getvalescaped("ref", 1);
$resourceinfo = sql_query("select ref,file_extension from resource where ref='{$ref}'");
if (count($resourceinfo) > 0) {
    $extension = $resourceinfo[0]['file_extension'];
    $file = get_resource_path($ref, true, "", false, $extension);
    $filesize = @filesize_unlimited($file);
    if (isset($imagemagick_path)) {
        # Check ImageMagick identify utility.
        $identify_fullpath = get_utility_path("im-identify");
        if ($identify_fullpath == false) {
            exit("Could not find ImageMagick 'identify' utility.");
        }
        $prefix = '';
        # Camera RAW images need prefix
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $prefix = $rawext[0] . ':';
        }
        # Get image's dimensions.
        $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($prefix . $file) . '[0]';
        $identoutput = run_command($identcommand);
        preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
        @(list(, $sw, $sh) = $smatches);
        if ($sw != '' && $sh != '') {
            $size_db = sql_query("select 'true' from resource_dimensions where resource = " . $ref);
    if (file_exists(get_temp_dir() . "/contactsheet.jpg")) {
        unlink(get_temp_dir() . "/contactsheet.jpg");
    }
    if (file_exists(get_temp_dir() . "/contactsheet.pdf")) {
        unlink(get_temp_dir() . "/contactsheet.pdf");
    }
    echo $pdf->GetPage();
    $pdf->Output(get_temp_dir() . "/contactsheet.pdf", "F");
    # Set up
    putenv("MAGICK_HOME=" . $imagemagick_path);
    putenv("PATH=" . $ghostscript_path . ":" . $imagemagick_path);
    # Path
    $ghostscript_fullpath = get_utility_path("ghostscript");
    $command = $ghostscript_fullpath . " -sDEVICE=jpeg -dFirstPage={$previewpage} -o -r100 -dLastPage={$previewpage} -sOutputFile=" . escapeshellarg(get_temp_dir() . "/contactsheetrip.jpg") . " " . escapeshellarg(get_temp_dir() . "/contactsheet.pdf") . ($config_windows ? "" : " 2>&1");
    run_command($command);
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'");
    }
    $command = $convert_fullpath . " -resize " . $contact_sheet_preview_size . " -quality 90 -colorspace " . $imagemagick_colorspace . " \"" . get_temp_dir() . "/contactsheetrip.jpg\" \"" . get_temp_dir() . "/contactsheet.jpg\"" . ($config_windows ? "" : " 2>&1");
    run_command($command);
    exit;
}
#check configs, decide whether PDF outputs to browser or to a new resource.
if ($contact_sheet_resource == true) {
    $newresource = create_resource(1, 0);
    update_field($newresource, 8, i18n_get_collection_name($collectiondata) . " " . $date);
    update_field($newresource, $filename_field, $newresource . ".pdf");
    #Relate all resources in collection to the new contact sheet resource
    relate_to_collection($newresource, $collection);
    #update file extension
Example #23
0
function get_image_dimension($fullpath, $type)
{
    $im_identify_path = get_utility_path('im-identify');
    if ($type == "height") {
        $get_dimension_cmd = $im_identify_path . " -format '%[fx:h]' ";
    } elseif ($type == "width") {
        $get_dimension_cmd = $im_identify_path . " -format '%[fx:w]' ";
    } else {
        echo "The value of the type variable is incorrect. " . PHP_EOL;
    }
    $get_dimension_cmd .= $fullpath;
    $value = shell_exec($get_dimension_cmd);
    return $value;
}
    }
    return $nb;
}
if ($use_zip_extension) {
    // set the time limit to unlimited, default 300 is not sufficient here.
    set_time_limit(0);
}
function update_zip_progress_file($note)
{
    global $progress_file;
    $fp = fopen($progress_file, 'w');
    $filedata = $note;
    fwrite($fp, $filedata);
    fclose($fp);
}
$archiver_fullpath = get_utility_path("archiver");
if (!isset($zipcommand) && !$use_zip_extension) {
    if (!$collection_download) {
        exit($lang["download-of-collections-not-enabled"]);
    }
    if ($archiver_fullpath == false) {
        exit($lang["archiver-utility-not-found"]);
    }
    if (!isset($collection_download_settings)) {
        exit($lang["collection_download_settings-not-defined"]);
    } else {
        if (!is_array($collection_download_settings)) {
            exit($lang["collection_download_settings-not-an-array"]);
        }
    }
    if (!isset($archiver_listfile_argument)) {
Example #25
-1
/**
 * Converts the file of the given resource to the new target file with the specified size. The
 * target file format is determined from the suffix of the target file.
 * The original colorspace of the image is retained. If $width and $height are zero, the image
 * keeps its original size.
 */
function convertImage($resource, $page, $alternative, $target, $width, $height, $profile)
{
    $command = get_utility_path("im-convert");
    if (!$command) {
        die("Could not find ImageMagick 'convert' utility.");
    }
    $originalPath = get_resource_path($resource['ref'], true, '', false, $resource['file_extension'], -1, $page, false, '', $alternative);
    $command .= " \"{$originalPath}\"[0] -auto-orient";
    if ($width != 0 && $height != 0) {
        # Apply resize ('>' means: never enlarge)
        $command .= " -resize \"{$width}";
        if ($height > 0) {
            $command .= "x{$height}";
        }
        $command .= '>"';
    }
    if ($profile === '') {
        $command .= ' +profile *';
    } else {
        if (!empty($profile)) {
            // Find out if the image does already have a profile
            $identify = get_utility_path("im-identify");
            $identify .= ' -verbose "' . $originalPath . '"';
            $info = run_command($command);
            $basePath = dirname(__FILE__) . '/../../../';
            if (preg_match("/Profile-icc:/", $info) != 1) {
                $command .= ' -profile "' . $basePath . 'config/sRGB_IEC61966-2-1_black_scaled.icc"';
            }
            $command .= ' -profile "' . $basePath . $profile . '"';
        }
    }
    $command .= " \"{$target}\"";
    run_command($command);
}
    $s = explode("\n", $version);
    $custom_field_4 = $s[0];
}
# ExifTool version
$exiftool_fullpath = get_utility_path("exiftool");
if ($exiftool_fullpath == false) {
    $custom_field_5 = "N/A";
    # Should not be translated as this information is sent to the bug tracker.
} else {
    $version = run_command($exiftool_fullpath . ' -ver');
    # Set version
    $s = explode("\n", $version);
    $custom_field_5 = $s[0];
}
# FFmpeg version
$ffmpeg_fullpath = get_utility_path("ffmpeg");
if ($ffmpeg_fullpath == false) {
    $custom_field_6 = "N/A";
    # Should not be translated as this information is sent to the bug tracker.
} else {
    $version = run_command($ffmpeg_fullpath . " -version");
    # Set version
    $s = explode("\n", $version);
    $custom_field_6 = $s[0];
}
# Server Platform
$serverversion = $_SERVER['SERVER_SOFTWARE'];
# PHP version
$custom_field_3 = phpversion();
if (isset($_REQUEST['submit'])) {
    header("Location: " . 'http://bugs.resourcespace.org/bug_report_advanced_page.php?' . "platform={$serverversion}&" . "product_version={$p_version}&" . "custom_field_2={$custom_field_2}&" . "custom_field_4={$custom_field_4}&" . "custom_field_6={$custom_field_6}&" . "custom_field_5={$custom_field_5}&" . "custom_field_3={$custom_field_3}&" . "build={$build}&" . "additional_info={$errortext}");