コード例 #1
0
function mia_results($results){
    global $date_fields,$dont_pull;
    $getfields = sql_query("SELECT ref,title FROM resource_type_field");
    $fieldnames = array();
    for($g=0; $g<count($getfields); $g++){
       $fieldnames[$getfields[$g]['ref']]=$getfields[$g]['title'];
    }
    for($i = 0; $i < count($results); $i++) {
        $ref = $results[$i]['ref'];
        if(isset($results[$i]['ref'])){
            $query=sql_query("SELECT * FROM resource_data WHERE resource = $ref AND value != '' AND value!='NULL' AND value != ','");
            for($q=0; $q<count($query); $q++){
                if($query[$q]['value'] != "," && $query[$q]['value'] !="" && array_key_exists($query[$q]['resource_type_field'],$fieldnames)){
                    if(substr($query[$q]['value'],0,1)==","){
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=substr($query[$q]['value'],1);
                    }else{
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=$query[$q]['value'];
                    }
                }
            }

            $access = get_resource_access($results[$i]);
            $filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            $original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            if(file_exists($filepath)) {
                $results[$i]['original_link'] = $original_link;
            } else {
                $results[$i]['original_link'] = 'No original link available.';
            }
            // Get the size of the original file:
           /* $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
            $original_size = formatfilesize($original_size[0]);
            $original_size = str_replace('&nbsp;', ' ', $original_size);
            $results[$i]['original_size'] = $original_size;*/
            foreach($results[$i] as $k => $v){
                if($v == "" || $v ==","){
                    unset($results[$i][$k]);
                }
                if($k == "created_by"){
                    $user = get_user($v);
                    $results[$i][$k]=$user["fullname"];
                }
                if(in_array($k,$date_fields)){
                    $unix = strtotime($v);
                    $datetime = date('y-m-d',$unix);
                    $results[$i][$k] = $datetime;
                }
                if($k == "resource_type" && is_numeric($v)){
                   $results[$i][$k]=get_resource_type_name($v);
                }
                //need to convert type to string here
                if(in_array($k,$dont_pull)){
                   unset($results[$i][$k]);
                }
            }
       }
//  var_dump($results);exit();
  return $results;
  }
}
コード例 #2
0
ファイル: all.php プロジェクト: artsmia/mia_resourcespace
function savetoelastic($ref){
global $baseurl, $pagename;
if($pagename != "upload2"){
//error_log($ref);
   $results=array();
   $results[] = get_resource_data($ref,false);
   $resourcetype=get_resource_type_name($results[0]['resource_type']);
   if($resourcetype != "Audio"){
     $thethumb = $baseurl.str_replace("/var/www/include/..","",get_resource_path($ref,true,"thm",false,"jpg"));
     if(!file_exists($thethumb)){
       $thethumb = $results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
     }
     $results[0]["thumbnail"]=$thethumb;
   }else{
     $results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
   }
   if($resourcetype == "Audio"){
       $results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "", false, "mp3"));
   }else if($resourcetype == "Video"){
       $results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "pre", false, "mp4"));
   }
   $results = mia_results($results);
   $results=json_encode($results[0]);
   $query = push_RStoElastic($resourcetype,$ref,$results);
   if($query == false){
       //failed to connect to elastic search
       createcron($attempts=1, $ref);
   }else{
//       var_dump($query);exit();
   }
   return;
}
}
コード例 #3
0
ファイル: view.php プロジェクト: vongalpha/resourcespace
function HookResourceconnectViewResourceactions_anonymous()
{
    if (getval("resourceconnect_source", "") == "") {
        return false;
    }
    # Not a ResourceConnect result set.
    global $lang, $title_field, $ref, $baseurl, $search, $offset, $scramble_key, $language, $resource;
    # Generate access key
    $access_key = md5("resourceconnect" . $scramble_key);
    # Formulate resource link (for collections bar)
    $view_url = $baseurl . "/pages/view.php?ref=" . $ref . "&k=" . substr(md5($access_key . $ref), 0, 10) . "&language_set=" . urlencode($language) . "&resourceconnect_source=" . urlencode($baseurl);
    # Add to collections link.
    $url = getval("resourceconnect_source", "") . "/plugins/resourceconnect/pages/add_collection.php?nc=" . time();
    $url .= "&title=" . urlencode(get_data_by_field($ref, $title_field));
    $url .= "&url=" . urlencode($view_url);
    # Add back URL
    $url .= "&back=" . urlencode($baseurl . "/pages/view.php?" . $_SERVER["QUERY_STRING"]);
    # Add images
    if ($resource["has_image"] == 1) {
        $url .= "&thumb=" . urlencode(get_resource_path($ref, false, "col", false, "jpg"));
    } else {
        $url .= "&thumb=" . urlencode($baseurl . "/gfx/" . get_nopreview_icon($resource["resource_type"], $resource["file_extension"], true));
    }
    ?>
	
	<li><a target="collections" href="<?php 
    echo $url;
    ?>
">&gt; <?php 
    echo $lang["action-addtocollection"];
    ?>
</a></li>
	<?php 
}
コード例 #4
0
ファイル: all.php プロジェクト: chandradrupal/resourcespace
function HookFormat_chooserAllGetdownloadurl($ref, $size, $ext, $page = 1, $alternative = -1)
{
    global $baseurl_short;
    $path = get_resource_path($ref, true, $size, false, $ext, -1, $page, $size == "scr" && checkperm("w") && $alternative == -1, '', $alternative);
    if (file_exists($path)) {
        return false;
    }
    return $baseurl_short . 'plugins/format_chooser/pages/convert.php?ref=' . $ref . '&size=' . $size . '&ext=' . $ext . '&page=' . $page . '&alt=' . $alternative;
}
コード例 #5
0
function getPreviewURLForType($resource, $type, $alternative = -1)
{
    global $use_watermark;
    $path = get_resource_path($resource['ref'], true, $type, false, $resource["preview_extension"], -1, 1, $use_watermark, "", $alternative);
    if (!file_exists($path)) {
        return false;
    }
    return get_resource_path($resource['ref'], false, $type, false, $resource["preview_extension"], -1, 1, $use_watermark, "", $alternative);
}
コード例 #6
0
ファイル: view.php プロジェクト: chandradrupal/resourcespace
function HookEmbedvideoViewAfterresourceactions()
{
    global $embedvideo_resourcetype, $ffmpeg_preview_extension, $resource, $ref, $ffmpeg_preview_max_width, $ffmpeg_preview_max_height, $userfixedtheme, $baseurl, $lang;
    if ($resource["resource_type"] != $embedvideo_resourcetype) {
        return false;
    }
    # Not the right type.
    ?>

	<?php 
    # FLV player - plays the FLV file created to preview video resources.
    if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
        $flashpath = get_resource_path($ref, false, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
    } else {
        $flashpath = get_resource_path($ref, false, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
    }
    $flashpath = urlencode($flashpath);
    $thumb = get_resource_path($ref, false, "pre", false, "jpg");
    $thumb = urlencode($thumb);
    # Choose a colour based on the theme.
    # This is quite hacky, and ideally of course this would be CSS based, but the FLV player requires that the colour
    # is passed as a parameter.
    # The default is a neutral grey which should be acceptable for most user generated themes.
    $theme = isset($userfixedtheme) && $userfixedtheme != "" ? $userfixedtheme : getval("colourcss", "greyblu");
    $colour = "505050";
    if ($theme == "greyblu") {
        $colour = "446693";
    }
    ?>
<li><a href="#" onClick="
if (document.getElementById('embedvideo').style.display=='block') {document.getElementById('embedvideo').style.display='none';} else {document.getElementById('embedvideo').style.display='block';}
if (document.getElementById('embedvideo2').style.display=='block') {document.getElementById('embedvideo2').style.display='none';} else {document.getElementById('embedvideo2').style.display='block';}
 return false;">&gt;&nbsp;<?php 
    echo $lang["embed"];
    ?>
</a></li>
<p id="embedvideo2" style="display:none;float:left;padding:10px 0 3px 0;"><?php 
    echo $lang["embed_help"];
    ?>
</p>
<textarea id="embedvideo" style="width:335px;height:200px;display:none;"><?php 
    if (!hook("replaceembedcode")) {
        echo htmlspecialchars('
<object type="application/x-shockwave-flash" data="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" width="' . $ffmpeg_preview_max_width . '" height="' . $ffmpeg_preview_max_height . '" class="Picture"><param name="allowFullScreen" value="true" /><param name="movie" value="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" /><param name="FlashVars" value="flv=' . $flashpath . '&amp;width=' . $ffmpeg_preview_max_width . '&amp;height=' . $ffmpeg_preview_max_height . '&amp;margin=0&amp;buffer=10&amp;showvolume=1&amp;volume=200&amp;showtime=1&amp;autoplay=1&amp;autoload=0&amp;showfullscreen=1&amp;showstop=1&amp;playercolor=' . $colour . '&startimage=' . $thumb . '" /></object>
');
    }
    // end hook replaceembedcode
    ?>
</textarea>

	<?php 
    return true;
}
コード例 #7
0
function HookResourceofthedayHomeReplaceslideshow()
{
    include_once dirname(__FILE__) . "/../inc/rotd_functions.php";
    global $baseurl, $view_title_field;
    $rotd = get_resource_of_the_day();
    if ($rotd === false) {
        return false;
    }
    # No ROTD, return false to disable hook and display standard slide show.
    # Get preview width
    $sizes = get_image_sizes($rotd, true);
    foreach ($sizes as $size) {
        if ($size["id"] == "pre") {
            $width = $size["width"];
            break;
        }
    }
    # Fetch title
    $title = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field={$view_title_field}", "");
    # Fetch caption
    $caption = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=18", "");
    # Show resource!
    $pre = get_resource_path($rotd, false, "pre", false, "jpg");
    ?>
	<div class="HomePicturePanel RecordPanel" style="width: <?php 
    echo $width;
    ?>
px; padding-left: 3px;">
	<a onClick="return CentralSpaceLoad(this,true);" href="<?php 
    echo $baseurl;
    ?>
/pages/view.php?ref=<?php 
    echo $rotd;
    ?>
"><img class="ImageBorder" style="margin-bottom: 10px;" src="<?php 
    echo $pre;
    ?>
" /></a>
	<br />
	<h2 ><?php 
    echo i18n_get_translated(htmlspecialchars($title));
    ?>
</h2>
	<?php 
    echo $caption;
    ?>
	</div>
	<?php 
    return true;
}
コード例 #8
0
function HookImage_textPreviewPreviewimage()
{
    global $ext, $resource, $image_text_restypes, $baseurl, $ref, $url, $use_watermark, $k, $alternative, $image_text_filetypes, $page;
    # Return if not configured for this resource type, no image or using watermark
    if (!in_array($resource['resource_type'], $image_text_restypes) || $resource["has_image"] != 1 || !in_array(strtoupper($ext), $image_text_filetypes) || $use_watermark) {
        return false;
    }
    $path = get_resource_path($ref, true, "scr", false, $ext, -1, $page, "", "", $alternative);
    if (!file_exists($path)) {
        $size = "pre";
    } else {
        $size = "scr";
    }
    $url = $baseurl . "/pages/download.php" . "?ref=" . urlencode($ref) . "&size=" . urlencode($size) . "&ext=" . urlencode($ext) . "&k=" . urlencode($k) . "&alternative=" . urlencode($alternative) . "&noattach=true";
    return false;
}
コード例 #9
0
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;
  
}
コード例 #10
0
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;
}
コード例 #11
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);
}
コード例 #12
0
function HookRemotedownloadAllGetdownloadurl($ref, $size, $ext, $page = 1, $alternative = -1)
{
    global $remotedownload_prepend, $remotedownload_append, $remotedownload_replace, $remotedownload_addquery;
    global $storageurl;
    $url = get_resource_path($ref, false, $size, false, $ext, -1, $page, $size == "scr" && checkperm("w") && $alternative == -1, "", $alternative);
    if (!empty($remotedownload_prepend) && strpos($url, $storageurl) === 0) {
        $storageurl_len = strlen($storageurl);
        $url = substr($url, 0, $storageurl_len) . $remotedownload_prepend . substr($url, $storageurl_len);
    }
    if (!empty($remotedownload_append)) {
        $url = $url . $remotedownload_append;
    }
    foreach ($remotedownload_replace as $replace) {
        $url = str_replace($replace['match'], $replace['with'], $url);
    }
    foreach ($remotedownload_addquery as $query) {
        $url = $url . (strpos($url, "?") !== FALSE ? "?" : "&") . $query;
    }
    return $url;
}
コード例 #13
0
function alt_from_resource($source,$target,$name='',$delete=false){
	// Copy a resource as an alt file of another resource
	// alt is the source resource, $ref is the target resource that will get the new alternate
	global $view_title_field;
	$srcdata=get_resource_data($source);
	$srcext = $srcdata['file_extension'];
	$srcpath = get_resource_path($source,true,"",false,$srcext);
	if ($name == ''){
		$name = sql_value("select value from resource_data where resource_type_field = '$view_title_field' and resource = '$source'",'Untitled');
	}

	$description = '';
	if (!file_exists($srcpath)){
		echo "ERROR: File not found.";
		return false;
	} else {

		$file_size = filesize_unlimited($srcpath);
		$altid = add_alternative_file($target,$name,$description="",$file_name="",$file_extension="",$file_size,$alt_type='');
		$newpath = get_resource_path($target,true,"",true,$srcext,-1,1,false,'',$altid);
		copy($srcpath,$newpath);
		# Preview creation for alternative files (enabled via config)
                global $alternative_file_previews;
                if ($alternative_file_previews){
			create_previews($target,false,$srcext,false,false,$altid);
               	}
		if ($delete){
			// we are supposed to delete the original resource when we're done
			# Not allowed to edit this resource? They shouldn't have been able to get here.
			if ((!get_edit_access($source,$srcdata["archive"]))||checkperm('D')) {
				exit ("Permission denied.");
			} else {
				delete_resource($source);
			}
		}
		return true;

	}
}
コード例 #14
0
ファイル: resource.php プロジェクト: superdol/xlsimport
 public function updateResource()
 {
     $rid = $this->resourceId();
     // resource does not exist - create it
     if ($rid == 0) {
         $rid = create_resource($this->type);
     } else {
         update_resource_type($rid, $this->type);
     }
     foreach ($this->fields as $k => $v) {
         update_field($rid, $k, $v);
     }
     if (file_exists($this->filename)) {
         $extension = explode(".", $this->filename);
         if (count($extension) > 1) {
             $extension = trim(strtolower($extension[count($extension) - 1]));
         } else {
             $extension = "";
         }
         $path = get_resource_path($rid, true, "", true, $extension);
         copy($this->filename, $path);
         create_previews($rid, false, $extension);
         # add file extension
         sql_query("update resource set file_extension='" . escapeString($extension) . "' where ref='" . escapeString($rid) . "'");
     }
     # add resource to collection (if the collection exists)
     if ($this->collection != null) {
         $col_ref = sql_value("select ref as value from collection where name='" . escapeString($this->collection) . "'", 0);
         if (isset($col_ref)) {
             add_resource_to_collection($rid, $col_ref);
         }
     }
     # set access rights
     if ($this->access != null) {
         sql_query("update resource set access='" . escapeString($this->access) . "' where ref='" . escapeString($rid) . "'");
     }
 }
コード例 #15
0
ファイル: home.php プロジェクト: vongalpha/resourcespace
function HookResourceofthedayHomeReplaceslideshow()
{
    include_once dirname(__FILE__) . "/../inc/rotd_functions.php";
    $rotd = get_resource_of_the_day();
    if ($rotd === false) {
        return false;
    }
    # No ROTD, return false to disable hook and display standard slide show.
    # Fetch resource data
    $resource = get_resource_data($rotd);
    # Fetch title
    $title = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=8", "");
    # Fetch caption
    $caption = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=18", "");
    # Show resource!
    $pre = get_resource_path($rotd, false, "pre", false, "jpg");
    ?>
	<div class="HomePicturePanel RecordPanel" style="width:350px;padding-left:4px;">
	<a href="view.php?ref=<?php 
    echo $rotd;
    ?>
"><img class="ImageBorder" style="margin-bottom: 10px;" src="<?php 
    echo $pre;
    ?>
" /></a>
	<br />
	<h2 ><?php 
    echo i18n_get_translated(htmlspecialchars($title));
    ?>
</h2>
	<?php 
    echo $caption;
    ?>
	</div>
	<?php 
    return true;
}
コード例 #16
0
ファイル: crop.php プロジェクト: claytondaley/resourcespace
     $sql .= ", transform_flop=" . ($flip ? "'1'" : "null") . ", transform_rotation=" . ($rotation > 0 ? "'{$rotation}'" : "null") . "";
     $sql .= " where ref='{$newfile}'";
     $result = sql_query($sql);
     resource_log($ref, 'b', '', "{$new_ext} " . strtolower($verb) . " to {$newfilewidth} x {$newfileheight}");
 } elseif ($original && getval("slideshow", "") == "" && !$cropperestricted) {
     // we are supposed to replace the original file
     $origalttitle = $lang['priorversion'];
     $origaltdesc = $lang['replaced'] . " " . strftime("%Y-%m-%d, %H:%M");
     $origfilename = sql_value("select value from resource_data left join resource_type_field on resource_data.resource_type_field = resource_type_field.ref where resource = '{$ref}' and name = 'original_filename'", $ref . "_original.{$orig_ext}");
     $origalt = add_alternative_file($ref, $origalttitle, $origaltdesc);
     $origaltpath = get_resource_path($ref, true, "", true, $orig_ext, -1, 1, false, "", $origalt);
     $mporig = round($origwidth * $origheight / 1000000, 2);
     $filesizeorig = filesize_unlimited($originalpath);
     rename($originalpath, $origaltpath);
     $result = sql_query("update resource_alt_files set file_name='{$origfilename}',file_extension='{$orig_ext}',file_size = '{$filesizeorig}' where ref='{$origalt}'");
     $neworigpath = get_resource_path($ref, true, '', false, $new_ext);
     rename($newpath, $neworigpath);
     $result = sql_query("update resource set file_extension = '{$new_ext}' where ref = '{$ref}' limit 1");
     // update extension
     resource_log($ref, 't', '', 'original transformed');
     create_previews($ref, false, $orig_ext, false, false, $origalt);
     create_previews($ref, false, $new_ext);
     # delete existing resource_dimensions
     sql_query("delete from resource_dimensions where resource='{$ref}'");
     sql_query("insert into resource_dimensions (resource, width, height, file_size) values ('{$ref}', '{$newfilewidth}', '{$newfileheight}', '{$newfilesize}')");
     # call remove annotations, since they will not apply to transformed
     hook("removeannotations");
     // remove the cached transform preview, since it will no longer be accurate
     if (file_exists(get_temp_dir() . "/transform_plugin/pre_{$ref}.jpg")) {
         unlink(get_temp_dir() . "/transform_plugin/pre_{$ref}.jpg");
     }
コード例 #17
0
ファイル: viewer.php プロジェクト: vongalpha/resourcespace
<?php 
}
?>
var timer;
</script>

<?php 
$page = 1;
$resources = do_search("!collection" . $ref);
foreach ($resources as $resource) {
    $file_path = get_resource_path($resource["ref"], true, $size, false, $resource["preview_extension"], -1, 1, $use_watermark);
    if (file_exists($file_path)) {
        $preview_path = get_resource_path($resource["ref"], false, $size, false, $resource["preview_extension"], -1, 1, $use_watermark);
    } else {
        # Fall back to 'pre' size
        $preview_path = get_resource_path($resource["ref"], false, "pre", false, $resource["preview_extension"], -1, 1, $use_watermark);
    }
    # sets height and width to display
    $ratio = $resource["thumb_width"] / $resource["thumb_height"];
    if ($ratio >= 1) {
        # Landscape image, width is the largest - scale the height
        $width = getvalescaped("width", "");
        $height = floor($width / $ratio);
    } else {
        $height = getvalescaped("width", "");
        $width = floor($height * $ratio);
    }
    ?>
	<a class="embedslideshow_preview_inner" id="embedslideshow_preview<?php 
    echo $page;
    ?>
コード例 #18
0
 <?php 
}
?>
id="ResourceShell<?php 
echo $ref;
?>
">
	<div class="ResourcePanelSmall">	
		<?php 
if (!hook("renderimagesmallthumb")) {
    ?>
		<?php 
    $access = get_resource_access($result[$n]);
    $use_watermark = check_use_watermark();
    # Work out the preview image path
    $col_url = get_resource_path($ref, false, "col", false, $result[$n]["preview_extension"], -1, 1, $use_watermark, $result[$n]["file_modified"]);
    if (isset($result[$n]["col_url"])) {
        $col_url = $result[$n]["col_url"];
    }
    # If col_url set in data, use instead, e.g. by manipulation of data via process_search_results hook
    ?>
		<table border="0" class="ResourceAlignSmall">
		<?php 
    hook("resourcetop");
    ?>
		<tr><td>
		<a href="<?php 
    echo $url;
    ?>
"  onClick="return CentralSpaceLoad(this,true);" <?php 
    if (!$infobox) {
コード例 #19
0
						// swap title fields if necessary

						if (isset($metadata_template_title_field) && isset($metadata_template_resource_type))
							{
							if ($result[$n]['resource_type']==$metadata_template_resource_type)
								{
								$title=$result[$n]["field".$metadata_template_title_field];
								}	
							}	
								
						?>
						
						<!--Resource Panel-->
						<div class="ResourcePanelShellSmall">
						<table border="0" class="ResourceAlignSmall"><tr><td>
						<a href="<?php echo $baseurl_short?>pages/view.php?ref=<?php echo $rref?>&search=<?php echo urlencode("!related" . $ref)?>" onClick="return CentralSpaceLoad(this,true);"><?php if ($result[$n]["has_image"]==1) { ?><img border=0 src="<?php echo get_resource_path($rref,false,"col",false,$result[$n]["preview_extension"],-1,1,checkperm("w"),$result[$n]["file_modified"])?>" class="CollectImageBorder"/><?php } else { ?><img border=0 src="../gfx/<?php echo get_nopreview_icon($result[$n]["resource_type"],$result[$n]["file_extension"],true)?>"/><?php } ?></a></td>
						</tr></table>
						<div class="ResourcePanelInfo"><a href="<?php echo $baseurl_short?>pages/view.php?ref=<?php echo $rref?>" onClick="return CentralSpaceLoad(this,true);"><?php echo tidy_trim(i18n_get_translated($title),15)?></a>&nbsp;</div>
						<div class="ResourcePanelIcons"><input type="checkbox" id="share<?php echo $rref ?>" class="checkselect" onChange="UpdateRelatedField(this,<?php echo $rref ?>);"></div>
						
						</div>
						<?php		
						}
					}
					?>
					</div><!-- end of sharerelatedtype -->
					<div class="clearerleft"> </div>
					<?php
				} //end of display loop by resource extension
		
		?>
コード例 #20
0
    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
    sql_query("update resource set file_extension='pdf' where ref='{$newresource}'");
    # Create the file in the new resource folder:
    $path = get_resource_path($newresource, true, "", true, "pdf");
    $pdf->Output($path, 'F');
    #Create thumbnails and redirect browser to the new contact sheet resource
    create_previews($newresource, true, "pdf");
    redirect($baseurl_short . "pages/view.php?ref=" . $newresource);
} else {
    $out1 = ob_get_contents();
    if ($out1 != "") {
        ob_end_clean();
    }
    $pdf->Output(i18n_get_collection_name($collectiondata) . ".pdf", "D");
}
コード例 #21
0
             echo "No file to copy: ref " . $resource['ref'];
             fwrite($fp, "No file to copy: ref " . $resource['ref'] . "\n");
             echo "<br />";
         }
     }
 }
 // NEW FOR ALT FILES:
 $alt_files = sql_query("select * from resource_alt_files where resource=" . $resource['ref']);
 if (count($alt_files) > 0) {
     // make folder of the original_filename_alts (if not there already)
     if (!file_exists($drive_path . $filename . "_alts")) {
         mkdir($drive_path . $filename . "_alts");
         chmod($drive_path . $filename . "_alts", 0777);
     }
     foreach ($alt_files as $alt) {
         $scrambled_alt = get_resource_path($resource['ref'], true, "", false, $alt['file_extension'], -1, 1, false, "", $alt['ref']);
         if (file_exists($scrambled_alt)) {
             // allow to re-run script without re-copying files
             if (!file_exists($drive_path . $filename . "_alts/" . $alt['file_name'])) {
                 copy($scrambled_alt, $drive_path . $filename . "_alts/" . $alt['file_name']);
             }
         }
         fwrite($fpa, $filename . "-- copying alt: " . $alt['file_name'] . "\n");
         echo "&nbsp;&nbsp;<b>" . $filename . "-- copying alt: " . $alt['file_name'] . "</b>";
         echo "<br />";
     }
 }
 // unset all vars in the loop to avoid unintended reuse.
 unset($scrambled);
 unset($filename);
 unset($x);
コード例 #22
0
            echo urlencode($archive);
            ?>
&page=<?php 
            echo urlencode($previouspage);
            ?>
" class="PDFnav  pagePrev">&lt;</a><?php 
        } elseif ($nextpage != -1 && resource_download_allowed($ref, "scr", $resource["resource_type"])) {
            ?>
<a href="#" class="PDFnav pagePrev">&nbsp;&nbsp;&nbsp;</a><?php 
        }
        ?>
</td>
<?php 
        $flvfile = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", $alternative);
        if (!file_exists($flvfile)) {
            $flvfile = get_resource_path($ref, true, "", false, $ffmpeg_preview_extension, -1, 1, false, "", $alternative);
        }
        if (!(isset($resource['is_transcoding']) && $resource['is_transcoding'] == 1) && file_exists($flvfile) && strpos(strtolower($flvfile), "." . $ffmpeg_preview_extension) !== false) {
            # Include the Flash player if an FLV file exists for this resource.
            $download_multisize = false;
            if (!hook("customflvplay")) {
                include "flv_play.php";
            }
        } elseif ($use_mp3_player && file_exists($mp3realpath) && hook("custommp3player")) {
            // leave player to place image
        } else {
            ?>


<?php 
            if (!hook("replacepreviewimage")) {
コード例 #23
0
ファイル: staticsync.php プロジェクト: vachanda/ResourceSpace
function ProcessFolder($folder, $version_dir, &$resource_array, &$resource_error)
{
    global $lang, $syncdir, $nogo, $staticsync_max_files, $count, $done, $modtimes, $lastsync, $ffmpeg_preview_extension, $staticsync_autotheme, $staticsync_folder_structure, $staticsync_extension_mapping_default, $staticsync_extension_mapping, $staticsync_mapped_category_tree, $staticsync_title_includes_path, $staticsync_ingest, $staticsync_mapfolders, $staticsync_alternatives_suffix, $theme_category_levels, $staticsync_defaultstate, $additional_archive_states, $staticsync_extension_mapping_append_values, $image_alternatives, $exclude_resize, $post_host, $media_endpoint, $image_required_height, $sync_bucket, $aws_key, $aws_secret_key;
    $collection = 0;
    echo "Processing Folder: {$folder}" . PHP_EOL;
    #$alt_path = get_resource_path(59, TRUE, '', FALSE, 'png', -1, 1, FALSE, '', 4);
    # List all files in this folder.
    $dh = opendir($folder);
    while (($file = readdir($dh)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $filetype = filetype($folder . "/" . $file);
        $fullpath = $folder . "/" . $file;
        $shortpath = str_replace($syncdir . "/", '', $fullpath);
        # Work out extension
        $extension = explode(".", $file);
        if (count($extension) > 1) {
            $extension = trim(strtolower($extension[count($extension) - 1]));
        } else {
            //No extension
            $extension = "";
        }
        if (strpos($fullpath, $nogo)) {
            echo "This directory is to be ignored." . PHP_EOL;
            continue;
        }
        if ($staticsync_mapped_category_tree) {
            $path_parts = explode("/", $shortpath);
            array_pop($path_parts);
            touch_category_tree_level($path_parts);
        }
        # -----FOLDERS-------------
        if (($filetype == "dir" || $filetype == "link") && strpos($nogo, "[{$file}]") === false && strpos($file, $staticsync_alternatives_suffix) === false) {
            # Get current version direcotries.
            if (preg_match("/[0-9]{2}-[0-9]{2}-[0-9]{4}\$/", $file)) {
                if (!in_array($file, $version_dir)) {
                    array_push($version_dir, $file);
                }
                if (preg_match('/in_progress*/', $file)) {
                    echo "The Barcode is still being processed." . PHP_EOL;
                    continue;
                }
            }
            # Recurse
            ProcessFolder($folder . "/" . $file, $version_dir, $resource_array, $resource_error);
        }
        $psd_files = array();
        if (preg_match('/images/', $fullpath)) {
            $path_array = explode('/', $fullpath);
            $psd_array = array_splice($path_array, 0, array_search('images', $path_array));
            $psd_path = implode('/', $psd_array) . '/psd/';
            $psd_files = array_diff(scandir($psd_path), array('..', '.'));
            foreach ($psd_files as $index => $psd_file) {
                $psd_files[$index] = pathinfo($psd_file, PATHINFO_FILENAME);
            }
        }
        # -------FILES---------------
        if ($filetype == "file" && substr($file, 0, 1) != "." && strtolower($file) != "thumbs.db") {
            /* Below Code Adapted  from CMay's bug report */
            global $banned_extensions;
            # Check to see if extension is banned, do not add if it is banned
            if (array_search($extension, $banned_extensions)) {
                continue;
            }
            /* Above Code Adapted from CMay's bug report */
            $count++;
            if ($count > $staticsync_max_files) {
                return true;
            }
            $last_sync_date = sql_value("select value from sysvars where name = 'last_sync'", "");
            $file_creation_date = date("Y-m-d H:i:s", filectime($fullpath));
            if (isset($last_sync_date) && $last_sync_date > $file_creation_date) {
                echo "No new file found.." . PHP_EOL;
                continue;
            }
            # Already exists?
            if (!isset($done[$shortpath])) {
                echo "Processing file: {$fullpath}" . PHP_EOL;
                if ($collection == 0 && $staticsync_autotheme) {
                    # Make a new collection for this folder.
                    $e = explode("/", $shortpath);
                    $theme = ucwords($e[0]);
                    $themesql = "theme='" . ucwords(escape_check($e[0])) . "'";
                    $themecolumns = "theme";
                    $themevalues = "'" . ucwords(escape_check($e[0])) . "'";
                    if ($staticsync_folder_structure) {
                        for ($x = 0; $x < count($e) - 1; $x++) {
                            if ($x != 0) {
                                $themeindex = $x + 1;
                                if ($themeindex > $theme_category_levels) {
                                    $theme_category_levels = $themeindex;
                                    if ($x == count($e) - 2) {
                                        echo PHP_EOL . PHP_EOL . "UPDATE THEME_CATEGORY_LEVELS TO {$themeindex} IN CONFIG!!!!" . PHP_EOL . PHP_EOL;
                                    }
                                }
                                $th_name = ucwords(escape_check($e[$x]));
                                $themesql .= " AND theme{$themeindex} = '{$th_name}'";
                                $themevalues .= ",'{$th_name}'";
                                $themecolumns .= ",theme{$themeindex}";
                            }
                        }
                    }
                    $name = count($e) == 1 ? '' : $e[count($e) - 2];
                    echo "Collection {$name}, theme={$theme}" . PHP_EOL;
                    $ul_username = $theme;
                    $escaped_name = escape_check($name);
                    $collection = sql_value("SELECT ref value FROM collection WHERE name='{$escaped_name}' AND {$themesql}", 0);
                    if ($collection == 0) {
                        sql_query("INSERT INTO collection (name,created,public,{$themecolumns},allow_changes)\n                                                   VALUES ('{$escaped_name}', NOW(), 1, {$themevalues}, 0)");
                        $collection = sql_insert_id();
                    }
                }
                # Work out a resource type based on the extension.
                $type = $staticsync_extension_mapping_default;
                reset($staticsync_extension_mapping);
                foreach ($staticsync_extension_mapping as $rt => $extensions) {
                    if (in_array($extension, $extensions)) {
                        $type = $rt;
                    }
                }
                $modified_type = hook('modify_type', 'staticsync', array($type));
                if (is_numeric($modified_type)) {
                    $type = $modified_type;
                }
                # Formulate a title
                if ($staticsync_title_includes_path) {
                    $title_find = array('/', '_', ".{$extension}");
                    $title_repl = array(' - ', ' ', '');
                    $title = ucfirst(str_ireplace($title_find, $title_repl, $shortpath));
                } else {
                    $title = str_ireplace(".{$extension}", '', $file);
                }
                $modified_title = hook('modify_title', 'staticsync', array($title));
                if ($modified_title !== false) {
                    $title = $modified_title;
                }
                # Import this file
                #$r = import_resource($shortpath, $type, $title, $staticsync_ingest);
                #Check for file name containing the psd.
                if (!empty($psd_files)) {
                    $image_file_array = explode('/', $fullpath);
                    $image_file = $image_file_array[count($image_file_array) - 1];
                    $image_psd_name = explode('_', $image_file)[0];
                    if (array_search($image_psd_name, $psd_files)) {
                        #Image name is in right format.
                        if (!validate_image_size($fullpath, $image_required_height)) {
                            $resource_error['size'][$file] = $fullpath;
                        }
                        $r = import_resource($fullpath, $type, $title, $staticsync_ingest);
                        sql_query("INSERT INTO resource_data (resource,resource_type_field,value)\n                               VALUES ('{$r}', (SELECT ref FROM resource_type_field WHERE name = 'logical_id'), '{$image_psd_name}')");
                        $original_filepath = sql_query("SELECT value FROM resource_data WHERE resource = '{$r}' AND\n                                                     resource_type_field = (SELECT ref FROM resource_type_field where name = 'original_filepath')");
                        if (isset($original_filepath)) {
                            sql_query("INSERT INTO resource_data (resource,resource_type_field,value)\n                                 VALUES ('{$r}',(SELECT ref FROM resource_type_field WHERE name = 'original_filepath'), '{$fullpath}')");
                        }
                    } else {
                        echo "Filename '{$fullpath}' is not in right format.." . PHP_EOL;
                        $resource_error['name'][$file] = $fullpath;
                        continue;
                    }
                } elseif (word_in_string($exclude_resize, explode('/', $fullpath))) {
                    $r = import_resource($fullpath, $type, $title, $staticsync_ingest);
                }
                if ($r !== false) {
                    array_push($resource_array, $r);
                    # Create current version for resource.
                    #print_r($version_dir);
                    if (count($version_dir) == 1) {
                        sql_query("INSERT into resource_data (resource,resource_type_field,value)\n                                    VALUES ('{$r}',(SELECT ref FROM resource_type_field WHERE name = 'current'), 'TRUE')");
                    }
                    $sync_status = sync_to_s3($syncdir, $sync_bucket, $aws_key, $aws_secret_key);
                    if (!$sync_status) {
                        echo "Failed to sync";
                    }
                    # Add to mapped category tree (if configured)
                    if (isset($staticsync_mapped_category_tree)) {
                        $basepath = '';
                        # Save tree position to category tree field
                        # For each node level, expand it back to the root so the full path is stored.
                        for ($n = 0; $n < count($path_parts); $n++) {
                            if ($basepath != '') {
                                $basepath .= "~";
                            }
                            $basepath .= $path_parts[$n];
                            $path_parts[$n] = $basepath;
                        }
                        update_field($r, $staticsync_mapped_category_tree, "," . join(",", $path_parts));
                    }
                    #This is an override to add user data to the resouces
                    if (!isset($userref)) {
                        $ul_username = ucfirst(strtolower($ul_username));
                        $current_user_ref = sql_query("Select ref from user where username = '******' ");
                        if (!empty($current_user_ref)) {
                            $current_user_ref = $current_user_ref[0]['ref'];
                            sql_query("UPDATE resource SET created_by='{$current_user_ref}' where ref = {$r}");
                        }
                    }
                    # default access level. This may be overridden by metadata mapping.
                    $accessval = 0;
                    # StaticSync path / metadata mapping
                    # Extract metadata from the file path as per $staticsync_mapfolders in config.php
                    if (isset($staticsync_mapfolders)) {
                        foreach ($staticsync_mapfolders as $mapfolder) {
                            $match = $mapfolder["match"];
                            $field = $mapfolder["field"];
                            $level = $mapfolder["level"];
                            if (strpos("/" . $shortpath, $match) !== false) {
                                # Match. Extract metadata.
                                $path_parts = explode("/", $shortpath);
                                if ($level < count($path_parts)) {
                                    // special cases first.
                                    if ($field == 'access') {
                                        # access level is a special case
                                        # first determine if the value matches a defined access level
                                        $value = $path_parts[$level - 1];
                                        for ($n = 0; $n < 3; $n++) {
                                            # if we get an exact match or a match except for case
                                            if ($value == $lang["access" . $n] || strtoupper($value) == strtoupper($lang['access' . $n])) {
                                                $accessval = $n;
                                                echo "Will set access level to " . $lang['access' . $n] . " ({$n})" . PHP_EOL;
                                            }
                                        }
                                    } else {
                                        if ($field == 'archive') {
                                            # archive level is a special case
                                            # first determin if the value matches a defined archive level
                                            $value = $mapfolder["archive"];
                                            $archive_array = array_merge(array(-2, -1, 0, 1, 2, 3), $additional_archive_states);
                                            if (in_array($value, $archive_array)) {
                                                $archiveval = $value;
                                                echo "Will set archive level to " . $lang['status' . $value] . " ({$archiveval})" . PHP_EOL;
                                            }
                                        } else {
                                            # Save the value
                                            #print_r($path_parts);
                                            $value = $path_parts[$level - 1];
                                            if ($staticsync_extension_mapping_append_values) {
                                                $given_value = $value;
                                                // append the values if possible...not used on dropdown, date, categroy tree, datetime, or radio buttons
                                                $field_info = get_resource_type_field($field);
                                                if (in_array($field['type'], array(0, 1, 2, 4, 5, 6, 7, 8))) {
                                                    $old_value = sql_value("select value value from resource_data where resource={$r} and resource_type_field={$field}", "");
                                                    $value = append_field_value($field_info, $value, $old_value);
                                                }
                                            }
                                            update_field($r, $field, trim($value));
                                            if (strtotime(trim($value))) {
                                                add_keyword_mappings($r, trim($value), $field, false, true);
                                            } else {
                                                add_keyword_mappings($r, trim($value), $field);
                                            }
                                            if ($staticsync_extension_mapping_append_values) {
                                                $value = $given_value;
                                            }
                                            echo " - Extracted metadata from path: {$value}" . PHP_EOL;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #Resize only original images.
                    if (!word_in_string($exclude_resize, explode('/', $fullpath))) {
                        echo "Creating preview..";
                        create_previews($r, false, $extension, false, false, -1, false, $staticsync_ingest);
                    }
                    # update access level
                    sql_query("UPDATE resource SET access = '{$accessval}',archive='{$staticsync_defaultstate}' WHERE ref = '{$r}'");
                    # Add any alternative files
                    $altpath = $fullpath . $staticsync_alternatives_suffix;
                    if ($staticsync_ingest && file_exists($altpath)) {
                        $adh = opendir($altpath);
                        while (($altfile = readdir($adh)) !== false) {
                            $filetype = filetype($altpath . "/" . $altfile);
                            if ($filetype == "file" && substr($file, 0, 1) != "." && strtolower($file) != "thumbs.db") {
                                # Create alternative file
                                # Find extension
                                $ext = explode(".", $altfile);
                                $ext = $ext[count($ext) - 1];
                                $description = str_replace("?", strtoupper($ext), $lang["originalfileoftype"]);
                                $file_size = filesize_unlimited($altpath . "/" . $altfile);
                                $aref = add_alternative_file($r, $altfile, $description, $altfile, $ext, $file_size);
                                $path = get_resource_path($r, true, '', true, $ext, -1, 1, false, '', $aref);
                                rename($altpath . "/" . $altfile, $path);
                                # Move alternative file
                            }
                        }
                    }
                    # Add to collection
                    if ($staticsync_autotheme) {
                        $test = '';
                        $test = sql_query("SELECT * FROM collection_resource WHERE collection='{$collection}' AND resource='{$r}'");
                        if (count($test) == 0) {
                            sql_query("INSERT INTO collection_resource (collection, resource, date_added)\n                                            VALUES ('{$collection}', '{$r}', NOW())");
                        }
                    }
                } else {
                    # Import failed - file still being uploaded?
                    echo " *** Skipping file - it was not possible to move the file (still being imported/uploaded?)" . PHP_EOL;
                }
            } else {
                # check modified date and update previews if necessary
                $filemod = filemtime($fullpath);
                if (array_key_exists($shortpath, $modtimes) && $filemod > strtotime($modtimes[$shortpath])) {
                    # File has been modified since we last created previews. Create again.
                    $rd = sql_query("SELECT ref, has_image, file_modified, file_extension FROM resource\n                                        WHERE file_path='" . escape_check($shortpath) . "'");
                    if (count($rd) > 0) {
                        $rd = $rd[0];
                        $rref = $rd["ref"];
                        echo "Resource {$rref} has changed, regenerating previews: {$fullpath}" . PHP_EOL;
                        extract_exif_comment($rref, $rd["file_extension"]);
                        # extract text from documents (e.g. PDF, DOC).
                        global $extracted_text_field;
                        if (isset($extracted_text_field)) {
                            if (isset($unoconv_path) && in_array($extension, $unoconv_extensions)) {
                                // omit, since the unoconv process will do it during preview creation below
                            } else {
                                extract_text($rref, $extension);
                            }
                        }
                        # Store original filename in field, if set
                        global $filename_field;
                        if (isset($filename_field)) {
                            update_field($rref, $filename_field, $file);
                        }
                        create_previews($rref, false, $rd["file_extension"], false, false, -1, false, $staticsync_ingest);
                        sql_query("UPDATE resource SET file_modified=NOW() WHERE ref='{$rref}'");
                    }
                }
            }
        }
    }
}
コード例 #24
0
}
if (!$allowed) {
    # This download is not allowed. How did the user get here?
    exit("Permission denied");
}
# additional access check, as the resource download may be allowed, but access restriction should force watermark.
$access = get_resource_access($ref);
$use_watermark = check_use_watermark($ref);
# If no extension was provided, we fallback to JPG.
if ($ext == "") {
    $ext = "jpg";
}
$noattach = getval("noattach", "");
$path = get_resource_path($ref, true, $size, false, $ext, -1, $page, $use_watermark && $alternative == -1, "", $alternative);
if (!file_exists($path)) {
    $path = get_resource_path($ref, true, "", false, $ext, -1, $page, false, "", $alternative);
}
if (!file_exists($path) && $noattach != "") {
    # Return icon for file (for previews)
    $info = get_resource_data($ref);
    $path = "../gfx/" . get_nopreview_icon($info["resource_type"], $ext, "thm");
}
# writing RS metadata to files: exiftool
if ($noattach == "" && $alternative == -1) {
    $tmpfile = write_metadata($path, $ref);
    if ($tmpfile !== false && file_exists($tmpfile)) {
        $path = $tmpfile;
    }
}
hook('modifydownloadfile');
$filesize = filesize_unlimited($path);
コード例 #25
0
ファイル: general.php プロジェクト: artsmia/mia_resourcespace
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 {
            $fileinfo = get_original_imagesize($ref, $path2, $extension);
            $filesize = $fileinfo[0];
            $sw = $fileinfo[1];
            $sh = $fileinfo[2];
        }
        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");
        $file_exists = file_exists($path);
        if (($file_exists || !$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 ($file_exists) {
                    $filesize = @filesize_unlimited($path);
                } else {
                    $filesize = 0;
                }
                if ($filesize === 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;
}
コード例 #26
0
			$conditionand = "and collection_resource.collection = '$collectionid' ";
			}
	
	if($field_resource_type==0){
		$rd=sql_query("select ref,file_extension from resource $join $condition order by ref");
	} else {
		$rd=sql_query("select ref,file_extension from resource $join where resource_type=$field_resource_type $conditionand order by ref");
	}	

	for ($n=0;$n<count($rd);$n++)
		{		
		
		$ref=$rd[$n]['ref'];
		$extension=$rd[$n]['file_extension'];
	
		$image=get_resource_path($ref,true,"",false,$extension);
		if (file_exists($image)) {
		
		$resource=get_resource_data($ref);
			
		$command = $exiftool_fullpath . " -s -s -s -" . $exiftool_tag . " " . escapeshellarg($image);
	
		$value = iptc_return_utf8(trim(run_command($command)));
	
		$plugin="../../plugins/exiftool_filter_" . $name . ".php";
		if ($exiftool_filter!=""){
			eval($exiftool_filter);
			}
		if (file_exists($plugin)) {include $plugin;}
	
		if ($blanks=="true"){
コード例 #27
0
                }
                ?>
<a class="lightbox" href="<?php 
                echo $path;
                ?>
" title="<?php 
                echo $displaytitle;
                ?>
"><img width="<?php 
                echo $result[$n]["thumb_width"];
                ?>
" height="<?php 
                echo $result[$n]["thumb_height"];
                ?>
" src="<?php 
                echo get_resource_path($ref, false, "thm", false, $result[$n]["preview_extension"], -1, 1, (checkperm("w") || $k != "" && isset($watermark)) && $access == 1, $result[$n]["file_modified"]);
                ?>
" class="ImageBorder"></a>
		<?php 
            } else {
                ?>
		<img border=0 src="../gfx/<?php 
                echo get_nopreview_icon($result[$n]["resource_type"], $result[$n]["file_extension"], false);
                ?>
"/><?php 
            }
            ?>

		
		</td>
		</tr></table>
コード例 #28
0
    }
}
include "../include/header.php";
?>
<div class="BasicsBox">
<h1><?php 
echo $lang["collectioncomments"];
?>
</h1>
<p><?php 
echo $lang["collectioncommentsinfo"];
?>
</p>
<?php 
$imagepath = get_resource_path($ref, true, "col", false, "jpg");
$imageurl = get_resource_path($ref, false, "col", false, "jpg");
if (file_exists($imagepath)) {
    ?>
<div class="Question">
<label for="image"><?php 
    echo $lang["preview"];
    ?>
</label><img src="<?php 
    echo $imageurl;
    ?>
?nc=<?php 
    echo time();
    ?>
" alt="" class="Picture" />
<div class="clearerleft"> </div>
</div>
コード例 #29
0
function recover_resource_files($id, $res, $meta, $alts)
{
    // this is where we actually start doing the import
    global $res_skipped;
    $ext = pathinfo($res, PATHINFO_EXTENSION);
    if (sql_value("select count(*) value from resource where ref = '{$id}'", "0") > 0) {
        echo "resource {$id} already exists! Skipping!\n";
        $res_skipped++;
        return false;
    } else {
        echo "new resource\n";
        // 1: photo, 2:document, 3:video, 4: audio
        // going to have to guess at the type for now, since the xml file did not record it. Fixme - xml file should have this.
        global $ffmpeg_supported_extensions, $ffmpeg_audio_extensions, $camera_autorotation_ext, $unoconv_extensions;
        if (in_array($ext, $ffmpeg_supported_extensions)) {
            $rtype = '3';
        } elseif (in_array($ext, $ffmpeg_audio_extensions)) {
            $rtype = '4';
        } elseif (in_array($ext, $unoconv_extensions)) {
            $rtype = '2';
        } elseif (in_array($ext, $camera_autorotation_ext)) {
            $rtype = '1';
        } else {
            $rtype = 'null';
        }
        $sql = "insert into resource (ref, title, file_extension,resource_type) values ('{$id}','RECOVERED','{$ext}','{$rtype}')";
        sql_query($sql);
        $newpath = get_resource_path($id, true, '', true, $ext);
        if (!copy($res, $newpath)) {
            echo "ERROR copying {$res}.\n";
            die;
        }
        // fixme: add alternates
        foreach ($alts as $altid => $altpath) {
            $filext = pathinfo($altpath, PATHINFO_EXTENSION);
            $filesize = filesize_unlimited($altpath);
            $newid = add_alternative_file($id, "{$altid}.{$filext}", '', '', $filext, $filesize);
            $newpath = get_resource_path($id, true, "", false, $filext, -1, 1, false, "", $newid);
            if (!copy($altpath, $newpath)) {
                echo "ERROR copying {$res}.\n";
                die;
            }
            echo "previews: " . create_previews($id, false, $filext, false, false, $newid);
            echo "\n\n";
        }
        create_previews($id, false, $ext);
        populate_metadata_from_dump($id, $meta);
    }
}
コード例 #30
-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);
}