function Hookyt2rsUpload_pluploadupload_page_bottom()
{
    global $userref, $yt2rs_field_id, $lang;
    $ref_user = 0 - $userref;
    $youtube_copy_path = get_data_by_field($ref_user, $yt2rs_field_id);
    if ($youtube_copy_path == "") {
        return false;
    } else {
        if (preg_match("/youtu.be\\/[a-z1-9.-_]+/", $youtube_copy_path)) {
            preg_match("/youtu.be\\/([a-z1-9.-_]+)/", $youtube_copy_path, $matches);
        } else {
            if (preg_match("/youtube.com(.+)v=([^&]+)/", $youtube_copy_path)) {
                preg_match("/v=([^&]+)/", $youtube_copy_path, $matches);
            }
        }
    }
    $ytthumb_id = $matches[1];
    $thumb_path = 'http://img.youtube.com/vi/' . $ytthumb_id . '/mqdefault.jpg';
    ?>
	<h1><?php 
    echo $lang['yt2rs_thumb'];
    ?>
</h1>
	

<?php 
    echo $thumb_path;
}
Example #2
0
function showApproval($result)
{
    $approval = sql_value("SELECT approval_status AS value FROM resource WHERE ref = {$result['ref']}", FALSE);
    $approval_form_id = sql_value("SELECT ref AS value FROM resource_type_field WHERE name = 'approval_form'", FALSE);
    if (!$approval_form_id) {
        return;
    }
    $approval_form = TidyList(get_data_by_field($result['ref'], $approval_form_id));
    if (empty($approval) and strpos($approval_form, 'Yes') !== FALSE) {
        $approval = 'waiting';
    }
    if ($approval) {
        switch ($approval) {
            case 'waiting':
                $title = 'Awaiting Approval';
                break;
            case 'minor':
                $title = 'Minor Changes Needed';
                break;
            case 'major':
                $title = 'Major Changes Needed';
                break;
            case 'approved':
                $title = 'Approved';
                break;
        }
        echo '<span class="rps-approval rps-approval-' . $approval . '" title="' . $title . '"></span>';
    }
}
Example #3
0
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 
}
Example #4
0
function HookLightbox_previewViewRenderbeforerecorddownload()
{
    global $resource, $title_field;
    $url = getPreviewURL($resource);
    if ($url === false) {
        return;
    }
    $title = get_data_by_field($resource['ref'], $title_field);
    setLink('#previewimagelink', $url, $title);
    setLink('#previewlink', $url, $title, 'lightbox-other');
}
Example #5
0
function HookApprovalViewRenderbeforeresourcedetails()
{
    global $lang, $ref, $resource, $fields;
    $approval_form_id = sql_value("SELECT ref AS value FROM resource_type_field WHERE name = 'approval_form'", FALSE);
    if (!$approval_form_id) {
        return;
    }
    $approval_form = TidyList(get_data_by_field($ref, $approval_form_id));
    if ($approval_form !== 'Yes') {
        return;
    }
    $history = sql_query('SELECT id, ref, posted, comment, name, signature, status FROM approval WHERE ref = ' . (int) $ref . ' ORDER BY posted DESC');
    ob_start();
    $path = dirname(dirname(__FILE__));
    include $path . '/inc/approval.php';
    echo ob_get_clean();
}
Example #6
0
function HookApprovalResource_emailFooterbottom()
{
    global $ref;
    $approval_form_id = sql_value("SELECT ref AS value FROM resource_type_field WHERE name = 'approval_form'", FALSE);
    if (!$approval_form_id) {
        return;
    }
    $approval_form = TidyList(get_data_by_field($ref, $approval_form_id));
    if ($approval_form !== 'Yes') {
        return;
    }
    $settings = get_plugin_config('approval');
    echo '
		<script type="text/javascript">
			document.getElementById("message").value = "' . htmlspecialchars($settings['email_message']) . '";
		</script>
	';
}
Example #7
0
/**
 * Returns the filename to be used for a specific file.
 * @param type $ref The resource for which the name should be built.
 * @param type $ext The new filename suffix to be used.
 * @param type $size A short name for the target file format, for example 'hpr'.
 */
function getTargetFilename($ref, $ext, $size)
{
    global $filename_field, $view_title_field;
    # Get filename - first try title, then original filename, and finally use the resource ID
    $filename = get_data_by_field($ref, $view_title_field);
    if (empty($filename)) {
        $filename = get_data_by_field($ref, $filename_field);
        if (!empty($filename)) {
            $originalSuffix = pathinfo($filename, PATHINFO_EXTENSION);
            $filename = mb_basename($filename, $originalSuffix);
        } else {
            $filename = strval($ref);
        }
    }
    # Remove potentially problematic characters, and make sure it's not too long
    $filename = preg_replace("/[*:<>?\\/|]/", '_', $filename);
    $filename = substr($filename, 0, 240);
    return $filename . (empty($size) ? '' : '-' . strtolower($size)) . '.' . strtolower($ext);
}
Example #8
0
function Hookyt2rsViewreplacedownloadoptions()
{
    // Replace download options
    global $ref, $yt2rs_field_id, $baseurl_short, $lang;
    $youtube_url = get_data_by_field($ref, $yt2rs_field_id);
    if ($youtube_url !== "" && isValidURL($youtube_url)) {
        ?>
			<table cellpadding="0" cellspacing="0">
				<tr >
					<td>File Information</td>
					<td>File Size </td>
					<td>Options</td>
				</tr>
				<tr class="DownloadDBlend">
					<td><h2>Online Preview</h2><p>Youtube Video</p></td>
					<td>N/A</td>
					<td class="DownloadButton HorizontalWhiteNav"><a href="<?php 
        echo $baseurl_short;
        ?>
pages/resource_request.php?ref=<?php 
        echo urlencode($ref);
        ?>
&k=<?php 
        echo getval("k", "");
        ?>
" onClick="return CentralSpaceLoad(this,true);">
				<?php 
        echo $lang["action-request"];
        ?>
</td>
				</tr>
			</table>
<?php 
        return true;
    } else {
        return false;
    }
}
	<div class="clearerleft"></div>
	<!--<h1><?php 
    echo $affiliatename;
    ?>
</h1>-->
	<?php 
    for ($n = $offset; $n < count($results) && $n < $offset + $pagesize; $n++) {
        $result = $results[$n];
        $ref = $result["ref"];
        $url = $baseurl . "/pages/view.php?ref=" . $ref . "&k=" . substr(md5($access_key . $ref), 0, 10) . "&language_set=" . urlencode($language) . "&search=" . urlencode($search) . "&offset=" . $offset . "&resourceconnect_source=" . urlencode(getval("resourceconnect_source", ""));
        # Wrap with local page that includes header/footer/sidebar
        $link_url = "../plugins/resourceconnect/pages/view.php?search=" . urlencode($search) . "&url=" . urlencode($url);
        $title = str_replace(array("\"", "'"), "", htmlspecialchars(i18n_get_translated($result["field" . $view_title_field])));
        # Add to collections link.
        $add_url = getval("resourceconnect_source", "") . "/plugins/resourceconnect/pages/add_collection.php?nc=" . time();
        $add_url .= "&title=" . urlencode(get_data_by_field($ref, $view_title_field));
        $add_url .= "&url=" . urlencode(str_replace("&search", "&source_search", $url));
        # Move the search so it doesn't get set, and therefore the nav is hidden when viewing the resource
        $add_url .= "&back=" . urlencode($baseurl . "/pages/view.php?" . $_SERVER["QUERY_STRING"]);
        # Add image
        if ($result["has_image"] == 1) {
            $add_url .= "&thumb=" . urlencode(get_resource_path($ref, false, "col", false, "jpg"));
            $add_url .= "&large_thumb=" . urlencode(get_resource_path($ref, false, "thm", false, "jpg"));
            $add_url .= "&xl_thumb=" . urlencode(get_resource_path($ref, false, "pre", false, "jpg"));
        } else {
            $add_url .= "&thumb=" . urlencode($baseurl . "/gfx/" . get_nopreview_icon($result["resource_type"], $result["file_extension"], true));
            $add_url .= "&large_thumb=" . urlencode($baseurl . "/gfx/" . get_nopreview_icon($result["resource_type"], $result["file_extension"], false));
            $add_url .= "&xl_thumb=" . urlencode($baseurl . "/gfx/" . get_nopreview_icon($result["resource_type"], $result["file_extension"], false));
        }
        ?>
		<div class="ResourcePanelShell">
        # Display resource ID
        ?>
	<p><?php 
        echo $lang["resourceid"];
        ?>
: <?php 
        echo $ref;
        ?>
</p>
	<?php 
    }
    # Display fields
    for ($n = 0; $n < count($infobox_fields); $n++) {
        $field = $infobox_fields[$n];
        if ((checkperm("f" . $field) || checkperm("f*")) && !checkperm("f-" . $field)) {
            $value = trim(get_data_by_field($ref, $field));
            $type = sql_value("select type value from resource_type_field where ref = {$field}", 0);
            if ($value != "") {
                if ($type != 8) {
                    $value = nl2br(htmlspecialchars(TidyList(i18n_get_translated($value))));
                }
                if ($type == 4) {
                    $value = nicedate($value);
                }
                ?>
			<p><?php 
                echo $value;
                ?>
</p>
			<?php 
            }
Example #11
0
    exit("Permission denied");
}
include "../include/resource_functions.php";
if (!$speedtagging) {
    exit("This function is not enabled.");
}
if (getval("save", "") != "") {
    $ref = getvalescaped("ref", "", true);
    $keywords = getvalescaped("keywords", "");
    # support resource_type based tag fields
    $resource_type = get_resource_data($ref);
    $resource_type = $resource_type['resource_type'];
    if (isset($speedtagging_by_type[$resource_type])) {
        $speedtaggingfield = $speedtagging_by_type[$resource_type];
    }
    $oldval = get_data_by_field($ref, $speedtaggingfield);
    update_field($ref, $speedtaggingfield, $keywords);
    # Write this edit to the log.
    resource_log($ref, 'e', $speedtaggingfield, "", $oldval, $keywords);
}
# append resource type restrictions based on 'T' permission
# look for all 'T' permissions and append to the SQL filter.
global $userpermissions;
$rtfilter = array();
$sql_join = "";
$sql_filter = "";
for ($n = 0; $n < count($userpermissions); $n++) {
    if (substr($userpermissions[$n], 0, 1) == "T") {
        $rt = substr($userpermissions[$n], 1);
        if (is_numeric($rt)) {
            $rtfilter[] = $rt;
Example #12
0
function hookView_in_finderViewRenderinnerresourcedownloadspace()
{
    global $resource;
    global $afp_server_path;
    global $access;
    global $staticSyncSyncDirField, $staticSyncDirs, $staticSyncUseArray;
    $restrictedAccess = false;
    $viewInFinder = get_plugin_config("view_in_finder");
    /*
    echo "<pre>";
    print_r($viewInFinder);
    echo "</pre>";
    */
    // check to see if we are using permissions, and if yes then do they have access to this resource type?
    if ($viewInFinder['afpServerPath'] && $access != 0) {
        $restrictedAccess = true;
    }
    if (!$restrictedAccess) {
        //echo "Access Allowed... ";
        if ($resource["file_path"] != "") {
            //echo "Got the file path…. ";
            if ($staticSyncUseArray) {
                $syncPath = get_data_by_field($resource['ref'], $staticSyncSyncDirField);
                $found = false;
                $lSyncDir = "";
                if ($syncPath != "") {
                    foreach ($staticSyncDirs as $tDir) {
                        if (!$found) {
                            if (strpos($syncPath, $tDir['syncdir']) !== false) {
                                $found = true;
                                $lSyncDir = $tDir['syncdir'];
                            }
                        }
                    }
                    if ($found) {
                        //echo "sync dir found : ". $lSyncDir;
                        // check the afp path from the config.
                        if (array_key_exists($lSyncDir, $viewInFinder['multiafpServerPath'])) {
                            $afp_link = $viewInFinder['multiafpServerPath'][$lSyncDir] . "/" . $resource["file_path"];
                        } else {
                            // use the default
                            $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                        }
                        //echo $afp_link;
                    }
                } else {
                    // $syncPath is empty or not fouond, use the default
                    $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                    $found = true;
                }
            } else {
                if (array_key_exists('afpServerPath', $viewInFinder)) {
                    $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                    $found = true;
                }
            }
            if ($found) {
                echo "<table>";
                echo '<tr class="DownloadDBlend">';
                echo '<td>Open Original File In Finder</td>';
                $fName = explode("/", $resource["file_path"]);
                $fid = count($fName) - 1;
                echo '<td class="DownloadButton"><a href="' . $afp_link . '">' . $fName[$fid] . '</a></ td>';
                echo '</tr>';
                echo "</table>";
            }
        }
    }
}
Example #13
0
	<?php 
    exit;
}
# Fetch videos
$videos = do_search("!collection" . $usercollection);
if (getval("splice", "") != "" && count($videos) > 1) {
    $ref = copy_resource($videos[0]["ref"]);
    # Base new resource on first video (top copy metadata).
    # Set parent resource field details.
    global $videosplice_parent_field;
    $resources = "";
    for ($n = 0; $n < count($videos); $n++) {
        if ($n > 0) {
            $resources .= ", ";
        }
        $crop_from = get_data_by_field($videos[$n]["ref"], $videosplice_parent_field);
        $resources .= $videos[$n]["ref"] . ($crop_from != "" ? " " . str_replace("%resourceinfo", $crop_from, $lang["cropped_from_resource"]) : "");
    }
    $history = str_replace("%resources", $resources, $lang["merged_from_resources"]);
    update_field($ref, $videosplice_parent_field, $history);
    # Establish FFMPEG location.
    $ffmpeg_fullpath = get_utility_path("ffmpeg");
    $vidlist = "";
    # Create FFMpeg syntax to merge all additional videos.
    for ($n = 0; $n < count($videos); $n++) {
        # Work out source/destination
        global $ffmpeg_preview_extension;
        if (file_exists(get_resource_path($videos[$n]["ref"], true, "", false, $videos[$n]["file_extension"]))) {
            $source = get_resource_path($videos[$n]["ref"], true, "", false, $videos[$n]["file_extension"], -1, 1, false, "", -1, false);
        } else {
            exit(str_replace(array("%resourceid", "%filetype"), array($videos[$n]["ref"], $videos[$n]["file_extension"]), $lang["error-no-ffmpegpreviewfile"]));
 // copies file
 if ($tmpfile !== false && file_exists($tmpfile)) {
     $p = $tmpfile;
     // file already in tmp, just rename it
 } else {
     if (!$replaced_file) {
         $copy = true;
         // copy the file from filestore rather than renaming
     }
 }
 # if the tmpfile is made, from here on we are working with that.
 # If using original filenames when downloading, copy the file to new location so the name is included.
 $filename = '';
 if ($original_filenames_when_downloading) {
     # Retrieve the original file name
     $filename = get_data_by_field($ref, $filename_field);
     if (!empty($filename)) {
         # Only perform the copy if an original filename is set.
         # now you've got original filename, but it may have an extension in a different letter case.
         # The system needs to replace the extension to change it to jpg if necessary, but if the original file
         # is being downloaded, and it originally used a different case, then it should not come from the file_extension,
         # but rather from the original filename itself.
         # do an extra check to see if the original filename might have uppercase extension that can be preserved.
         # also, set extension to "" if the original filename didn't have an extension (exiftool identification of filetypes)
         $pathparts = pathinfo($filename);
         if (isset($pathparts['extension'])) {
             if (strtolower($pathparts['extension']) == $pextension) {
                 $pextension = $pathparts['extension'];
             }
         } else {
             $pextension = "jpg";
function extract_exif_comment($ref, $extension = "")
{
    # Extract the EXIF comment from either the ImageDescription field or the UserComment
    # Also parse IPTC headers and insert
    # EXIF headers
    $exifoption = getval("no_exif", "");
    // This may have been set to a non-standard value if allowing per field selection
    if ($exifoption == "yes") {
        $exifoption = "no";
    }
    // Sounds odd but previously was no_exif so logic reversed
    if ($exifoption == "") {
        $exifoption = "yes";
    }
    $image = get_resource_path($ref, true, "", false, $extension);
    if (!file_exists($image)) {
        return false;
    }
    hook("pdfsearch");
    global $exif_comment, $exiftool_no_process, $exiftool_resolution_calc, $disable_geocoding, $embedded_data_user_select_fields, $filename_field;
    $exiftool_fullpath = get_utility_path("exiftool");
    if ($exiftool_fullpath != false && !in_array($extension, $exiftool_no_process)) {
        $resource = get_resource_data($ref);
        # Field 8 is used in a special way for staticsync; don't overwrite.
        if ($resource['file_path'] != "") {
            $omit_title_for_staticsync = true;
        } else {
            $omit_title_for_staticsync = false;
        }
        hook("beforeexiftoolextraction");
        if ($exiftool_resolution_calc) {
            # see if we can use exiftool to get resolution/units, and dimensions here.
            # Dimensions are normally extracted once from the view page, but for the original file, it should be done here if possible,
            # and exiftool can provide more data.
            $command = $exiftool_fullpath . " -s -s -s -t -composite:imagesize -xresolution -resolutionunit " . escapeshellarg($image);
            $dimensions_resolution_unit = explode("\t", run_command($command));
            # if dimensions resolution and unit could be extracted, add them to the database.
            # they can be used in view.php to give more accurate data.
            if (count($dimensions_resolution_unit) == 3) {
                $dru = $dimensions_resolution_unit;
                $filesize = filesize_unlimited($image);
                $wh = explode("x", $dru[0]);
                $width = $wh[0];
                $height = $wh[1];
                $resolution = $dru[1];
                $unit = $dru[2];
                sql_query("insert into resource_dimensions (resource, width, height, resolution, unit, file_size) values ('{$ref}', '{$width}', '{$height}', '{$resolution}', '{$unit}', '{$filesize}')");
            }
        }
        $read_from = get_exiftool_fields($resource['resource_type']);
        # run exiftool to get all the valid fields. Use -s -s option so that
        # the command result isn't printed in columns, which will help in parsing
        # We then split the lines in the result into an array
        $command = $exiftool_fullpath . " -s -s -f -m -d \"%Y-%m-%d %H:%M:%S\" -G " . escapeshellarg($image);
        $metalines = explode("\n", run_command($command));
        $metadata = array();
        # an associative array to hold metadata field/value pairs
        # go through each line and split field/value using the first
        # occurrance of ": ".  The keys in the associative array is converted
        # into uppercase for easier lookup later
        foreach ($metalines as $metaline) {
            # Use stripos() if available, but support earlier PHP versions if not.
            if (function_exists("stripos")) {
                $pos = stripos($metaline, ": ");
            } else {
                $pos = strpos($metaline, ": ");
            }
            if ($pos) {
                # add to the associative array, also clean up leading/trailing space & single quote (on windows sometimes)
                # Extract group name and tag name.
                $s = explode("]", substr($metaline, 0, $pos));
                if (count($s) > 1 && strlen($s[0]) > 1) {
                    # Extract value
                    $value = trim(substr($metaline, $pos + 2));
                    # Replace '..' with line feed - either Exiftool itself or Adobe Bridge replaces line feeds with '..'
                    $value = str_replace('....', '\\n\\n', $value);
                    // Two new line feeds in ExifPro are replaced with 4 dots '....'
                    $value = str_replace('...', '.\\n', $value);
                    # Three dots together is interpreted as a full stop then line feed, not the other way round
                    $value = str_replace('..', '\\n', $value);
                    # Extract group name and tag name
                    $groupname = strtoupper(substr($s[0], 1));
                    $tagname = strtoupper(trim($s[1]));
                    # Store both tag data under both tagname and groupname:tagname, to support both formats when mapping fields.
                    $metadata[$tagname] = $value;
                    $metadata[$groupname . ":" . $tagname] = $value;
                    debug("Exiftool: extracted field '{$groupname}:{$tagname}', value is '{$value}'");
                }
            }
        }
        // We try to fetch the original filename from database.
        $resources = sql_query("SELECT resource.file_path FROM resource WHERE resource.ref = " . $ref);
        if ($resources) {
            $resource = $resources[0];
            if ($resource['file_path']) {
                $metadata['FILENAME'] = mb_basename($resource['file_path']);
            }
        }
        if (isset($metadata['FILENAME'])) {
            $metadata['STRIPPEDFILENAME'] = strip_extension($metadata['FILENAME']);
        }
        # Geolocation Metadata Support
        if (!$disable_geocoding && isset($metadata['GPSLATITUDE'])) {
            # Set vars
            $dec_long = 0;
            $dec_lat = 0;
            #Convert latititude to decimal.
            if (preg_match("/^(?<degrees>\\d+) deg (?<minutes>\\d+)' (?<seconds>\\d+\\.?\\d*)\"/", $metadata['GPSLATITUDE'], $latitude)) {
                $dec_lat = $latitude['degrees'] + $latitude['minutes'] / 60 + $latitude['seconds'] / (60 * 60);
            }
            if (preg_match("/^(?<degrees>\\d+) deg (?<minutes>\\d+)' (?<seconds>\\d+\\.?\\d*)\"/", $metadata['GPSLONGITUDE'], $longitude)) {
                $dec_long = $longitude['degrees'] + $longitude['minutes'] / 60 + $longitude['seconds'] / (60 * 60);
            }
            if (strpos($metadata['GPSLATITUDE'], 'S') !== false) {
                $dec_lat = -1 * $dec_lat;
            }
            if (strpos($metadata['GPSLONGITUDE'], 'W') !== false) {
                $dec_long = -1 * $dec_long;
            }
            if ($dec_long != 0 && $dec_lat != 0) {
                sql_query("update resource set geo_long='" . escape_check($dec_long) . "',geo_lat='" . escape_check($dec_lat) . "' where ref='{$ref}'");
            }
        }
        # Update portrait_landscape_field (when reverting metadata this was getting lost)
        update_portrait_landscape_field($ref);
        # now we lookup fields from the database to see if a corresponding value
        # exists in the uploaded file
        $exif_updated_fields = array();
        for ($i = 0; $i < count($read_from); $i++) {
            $field = explode(",", $read_from[$i]['exiftool_field']);
            foreach ($field as $subfield) {
                $subfield = strtoupper($subfield);
                // convert to upper case for easier comparision
                if (in_array($subfield, array_keys($metadata)) && $metadata[$subfield] != "-" && trim($metadata[$subfield]) != "") {
                    $read = true;
                    $value = $metadata[$subfield];
                    # Dropdown box or checkbox list?
                    if ($read_from[$i]["type"] == 2 || $read_from[$i]["type"] == 3) {
                        # Check that the value is one of the options and only insert if it is an exact match.
                        # The use of safe_file_name and strtolower ensures matching takes place on alphanumeric characters only and ignores case.
                        # First fetch all options in all languages
                        $options = trim_array(explode(",", strtolower($read_from[$i]["options"])));
                        for ($n = 0; $n < count($options); $n++) {
                            $options[$n] = $options[$n];
                        }
                        # If not in the options list, do not read this value
                        $s = trim_array(explode(",", $value));
                        $value = "";
                        # blank value
                        for ($n = 0; $n < count($s); $n++) {
                            if (trim($s[0]) != "" && in_array(strtolower($s[$n]), $options)) {
                                $value .= "," . $s[$n];
                            }
                        }
                        #echo($read_from[$i]["ref"] . " = " . $value . "<br>");
                    }
                    # Read the data.
                    if ($read) {
                        $plugin = dirname(__FILE__) . "/../plugins/exiftool_filter_" . $read_from[$i]['name'] . ".php";
                        if ($read_from[$i]['exiftool_filter'] != "") {
                            eval($read_from[$i]['exiftool_filter']);
                        }
                        if (file_exists($plugin)) {
                            include $plugin;
                        }
                        # Field 8 is used in a special way for staticsync; don't overwrite field 8 in this case
                        if (!($omit_title_for_staticsync && $read_from[$i]['ref'] == 8)) {
                            $exiffieldoption = $exifoption;
                            if ($exifoption == "custom" || isset($embedded_data_user_select_fields) && in_array($read_from[$i]['ref'], $embedded_data_user_select_fields)) {
                                debug("EXIF - custom option for field " . $read_from[$i]['ref'] . " : " . $exifoption);
                                $exiffieldoption = getval("exif_option_" . $read_from[$i]['ref'], $exifoption);
                            }
                            debug("EXIF - option for field " . $read_from[$i]['ref'] . " : " . $exiffieldoption);
                            if ($exiffieldoption == "no") {
                                continue;
                            } elseif ($exiffieldoption == "append") {
                                $spacechar = $read_from[$i]["type"] == 2 || $read_from[$i]["type"] == 3 ? ", " : " ";
                                $oldval = get_data_by_field($ref, $read_from[$i]['ref']);
                                if (strpos($oldval, $value) !== false) {
                                    continue;
                                }
                                $newval = $oldval . $spacechar . iptc_return_utf8($value);
                            } elseif ($exiffieldoption == "prepend") {
                                $spacechar = $read_from[$i]["type"] == 2 || $read_from[$i]["type"] == 3 ? ", " : " ";
                                $oldval = get_data_by_field($ref, $read_from[$i]['ref']);
                                if (strpos($oldval, $value) !== false) {
                                    continue;
                                }
                                $newval = iptc_return_utf8($value) . $spacechar . $oldval;
                            } else {
                                $newval = iptc_return_utf8($value);
                            }
                            global $merge_filename_with_title, $lang;
                            if ($merge_filename_with_title) {
                                $merge_filename_with_title_option = urlencode(getval('merge_filename_with_title_option', ''));
                                $merge_filename_with_title_include_extensions = urlencode(getval('merge_filename_with_title_include_extensions', ''));
                                $merge_filename_with_title_spacer = urlencode(getval('merge_filename_with_title_spacer', ''));
                                $original_filename = '';
                                if (isset($_REQUEST['name'])) {
                                    $original_filename = $_REQUEST['name'];
                                } else {
                                    $original_filename = $processfile['name'];
                                }
                                if ($merge_filename_with_title_include_extensions == 'yes') {
                                    $merged_filename = $original_filename;
                                } else {
                                    $merged_filename = strip_extension($original_filename);
                                }
                                $oldval = get_data_by_field($ref, $read_from[$i]['ref']);
                                if (strpos($oldval, $value) !== FALSE) {
                                    continue;
                                }
                                switch ($merge_filename_with_title_option) {
                                    case $lang['merge_filename_title_do_not_use']:
                                        // Do nothing since the user doesn't want to use this feature
                                        break;
                                    case $lang['merge_filename_title_replace']:
                                        $newval = $merged_filename;
                                        break;
                                    case $lang['merge_filename_title_prefix']:
                                        $newval = $merged_filename . $merge_filename_with_title_spacer . $oldval;
                                        if ($oldval == '') {
                                            $newval = $merged_filename;
                                        }
                                        break;
                                    case $lang['merge_filename_title_suffix']:
                                        $newval = $oldval . $merge_filename_with_title_spacer . $merged_filename;
                                        if ($oldval == '') {
                                            $newval = $merged_filename;
                                        }
                                        break;
                                    default:
                                        // Do nothing
                                        break;
                                }
                            }
                            update_field($ref, $read_from[$i]['ref'], $newval);
                            $exif_updated_fields[] = $read_from[$i]['ref'];
                            hook("metadata_extract_addition", "all", array($ref, $newval, $read_from, $i));
                        }
                    }
                } else {
                    // Process if no embedded title is found:
                    global $merge_filename_with_title, $lang;
                    if ($merge_filename_with_title && $read_from[$i]['ref'] == 8) {
                        $merge_filename_with_title_option = urlencode(getval('merge_filename_with_title_option', ''));
                        $merge_filename_with_title_include_extensions = urlencode(getval('merge_filename_with_title_include_extensions', ''));
                        $merge_filename_with_title_spacer = urlencode(getval('merge_filename_with_title_spacer', ''));
                        $original_filename = '';
                        if (isset($_REQUEST['name'])) {
                            $original_filename = $_REQUEST['name'];
                        } else {
                            $original_filename = $processfile['name'];
                        }
                        if ($merge_filename_with_title_include_extensions == 'yes') {
                            $merged_filename = $original_filename;
                        } else {
                            $merged_filename = strip_extension($original_filename);
                        }
                        $oldval = get_data_by_field($ref, $read_from[$i]['ref']);
                        if (strpos($oldval, $value) !== FALSE) {
                            continue;
                        }
                        switch ($merge_filename_with_title_option) {
                            case $lang['merge_filename_title_do_not_use']:
                                // Do nothing since the user doesn't want to use this feature
                                break;
                            case $lang['merge_filename_title_replace']:
                                $newval = $merged_filename;
                                break;
                            case $lang['merge_filename_title_prefix']:
                                $newval = $merged_filename . $merge_filename_with_title_spacer . $oldval;
                                if ($oldval == '') {
                                    $newval = $merged_filename;
                                }
                                break;
                            case $lang['merge_filename_title_suffix']:
                                $newval = $oldval . $merge_filename_with_title_spacer . $merged_filename;
                                if ($oldval == '') {
                                    $newval = $merged_filename;
                                }
                                break;
                            default:
                                // Do nothing
                                break;
                        }
                        update_field($ref, $read_from[$i]['ref'], $newval);
                        $exif_updated_fields[] = $read_from[$i]['ref'];
                    }
                }
            }
        }
        if (!in_array($filename_field, $exif_updated_fields)) {
            $exiffilenameoption = getval("exif_option_" . $filename_field, $exifoption);
            debug("EXIF - custom option for filename field " . $filename_field . " : " . $exiffilenameoption);
            if ($exiffilenameoption != "yes") {
                $uploadedfilename = isset($_REQUEST['name']) ? $_REQUEST['name'] : $processfile['name'];
                global $userref, $amended_filename;
                $entered_filename = get_data_by_field(-$userref, $filename_field);
                debug("EXIF - got entered file name " . $entered_filename);
                if ($exiffilenameoption == "no") {
                    $amended_filename = $entered_filename;
                    if (trim($amended_filename) == '') {
                        $amended_filename = $uploadedfilename;
                    }
                    if (strpos($amended_filename, $extension) === FALSE) {
                        $amended_filename .= '.' . $extension;
                    }
                } elseif ($exiffilenameoption == "append") {
                    $amended_filename = $entered_filename . $uploadedfilename;
                } elseif ($exiffilenameoption == "prepend") {
                    $amended_filename = strip_extension($uploadedfilename) . $entered_filename . "." . $extension;
                }
                debug("EXIF - created new file name " . $amended_filename);
            }
        }
    } elseif (isset($exif_comment)) {
        #
        # Exiftool is not installed. As a fallback we grab some predefined basic fields using the PHP function
        # exif_read_data()
        #
        if (function_exists("exif_read_data")) {
            $data = @exif_read_data($image);
        } else {
            $data = false;
        }
        if ($data !== false) {
            $comment = "";
            #echo "<pre>EXIF\n";print_r($data);exit();
            if (isset($data["ImageDescription"])) {
                $comment = $data["ImageDescription"];
            }
            if ($comment == "" && isset($data["COMPUTED"]["UserComment"])) {
                $comment = $data["COMPUTED"]["UserComment"];
            }
            if ($comment != "") {
                # Convert to UTF-8
                $comment = iptc_return_utf8($comment);
                # Save comment
                global $exif_comment;
                update_field($ref, $exif_comment, $comment);
            }
            if (isset($data["Model"])) {
                # Save camera make/model
                global $exif_model;
                update_field($ref, $exif_model, $data["Model"]);
            }
            if (isset($data["DateTimeOriginal"])) {
                # Save camera date/time
                global $exif_date;
                $date = $data["DateTimeOriginal"];
                # Reformat date to ISO standard
                $date = substr($date, 0, 4) . "-" . substr($date, 5, 2) . "-" . substr($date, 8, 11);
                update_field($ref, $exif_date, $date);
            }
        }
        # Try IPTC headers
        $size = getimagesize($image, $info);
        if (isset($info["APP13"])) {
            $iptc = iptcparse($info["APP13"]);
            #echo "<pre>IPTC\n";print_r($iptc);exit();
            # Look for iptc fields, and insert.
            $fields = sql_query("select * from resource_type_field where length(iptc_equiv)>0");
            for ($n = 0; $n < count($fields); $n++) {
                $iptc_equiv = $fields[$n]["iptc_equiv"];
                if (isset($iptc[$iptc_equiv][0])) {
                    # Found the field
                    if (count($iptc[$iptc_equiv]) > 1) {
                        # Multiple values (keywords)
                        $value = "";
                        for ($m = 0; $m < count($iptc[$iptc_equiv]); $m++) {
                            if ($m > 0) {
                                $value .= ", ";
                            }
                            $value .= $iptc[$iptc_equiv][$m];
                        }
                    } else {
                        $value = $iptc[$iptc_equiv][0];
                    }
                    $value = iptc_return_utf8($value);
                    # Date parsing
                    if ($fields[$n]["type"] == 4) {
                        $value = substr($value, 0, 4) . "-" . substr($value, 4, 2) . "-" . substr($value, 6, 2);
                    }
                    if (trim($value) != "") {
                        update_field($ref, $fields[$n]["ref"], $value);
                    }
                }
            }
        }
    }
    # Update the XML metadata dump file.
    update_xml_metadump($ref);
    # Auto fill any blank fields.
    autocomplete_blank_fields($ref);
}
        resource_log($ref, 'e', $youtube_publish_url_field ? $youtube_publish_url_field : 0, $lang["youtube_publish_log_share"], $fromvalue = $youtube_old_url, $tovalue = $save_url);
    }
}
$title = get_data_by_field($ref, $youtube_publish_title_field);
#$description=get_data_by_field($ref,$youtube_publish_descriptionfield);
$description = "";
foreach ($youtube_publish_descriptionfields as $youtube_publish_descriptionfield) {
    $resource_description = get_data_by_field($ref, $youtube_publish_descriptionfield);
    if ($description != '') {
        $description .= "\r\n";
    }
    $description .= $resource_description;
}
$video_keywords = "";
foreach ($youtube_publish_keywords_fields as $youtube_publish_keywords_field) {
    $resource_keywords = get_data_by_field($ref, $youtube_publish_keywords_field);
    $video_keywords .= $resource_keywords;
}
include "../../../include/header.php";
?>

<script language="JavaScript">
function confirmSubmit()
{
var agree=confirm("<?php 
echo $lang["youtube_publish_legal_warning"];
?>
");
if (agree)
return true ;
else
Example #17
0
	?><span class="ResourcePendingSubmissionTitle"><?php echo $lang["status-2"]?>:</span>&nbsp;<?php
	break;
	case -1:
	?><span class="ResourcePendingReviewTitle"><?php echo $lang["status-1"]?>:</span>&nbsp;<?php
	break;
	case 1:
	?><span class="ArchiveResourceTitle"><?php echo $lang["status1"]?>:</span>&nbsp;<?php
	break;
	case 2:
	?><span class="ArchiveResourceTitle"><?php echo $lang["status2"]?>:</span>&nbsp;<?php
	break;
	case 3:
	?><span class="DeletedResourceTitle"><?php echo $lang["status3"]?>:</span>&nbsp;<?php
	break;
	} }
if (!hook("replaceviewtitle")){ echo highlightkeywords(htmlspecialchars(i18n_get_translated(get_data_by_field($resource['ref'],$title_field))),$search); } /* end hook replaceviewtitle */  
?>&nbsp;</h1>
<?php } /* End of renderinnerresourceheader hook */ ?>
</div>

<?php if (!hook("replaceresourceistranscoding")){
	if (isset($resource['is_transcoding']) && $resource['is_transcoding']!=0) { ?><div class="PageInformal"><?php echo $lang['resourceistranscoding']?></div><?php }
	} //end hook replaceresourceistrancoding ?>

<?php hook('renderbeforeresourceview', '', array('resource' => $resource)); 
$download_multisize=true;
?>

<div class="RecordResource">
<?php if (!hook("renderinnerresourceview")) { ?>
<?php if (!hook("replacerenderinnerresourcepreview")) { ?>
 function upload_file($ref, $no_exif = false, $revert = false, $autorotate = false)
 {
     hook("clearaltfiles", "", array($ref));
     // optional: clear alternative files before uploading new resource
     # revert is mainly for metadata reversion, removing all metadata and simulating a reupload of the file from scratch.
     hook("removeannotations");
     $exiftool_fullpath = get_utility_path("exiftool");
     # Process file upload for resource $ref
     if ($revert == true) {
         global $filename_field;
         $original_filename = get_data_by_field($ref, $filename_field);
         # Field 8 is used in a special way for staticsync, don't overwrite.
         $test_for_staticsync = get_resource_data($ref);
         if ($test_for_staticsync['file_path'] != "") {
             $staticsync_mod = " and resource_type_field != 8";
         } else {
             $staticsync_mod = "";
         }
         sql_query("delete from resource_data where resource={$ref} {$staticsync_mod}");
         sql_query("delete from resource_keyword where resource={$ref} {$staticsync_mod}");
         #clear 'joined' display fields which are based on metadata that is being deleted in a revert (original filename is reinserted later)
         $display_fields = get_resource_table_joins();
         if ($staticsync_mod != "") {
             $display_fields_new = array();
             for ($n = 0; $n < count($display_fields); $n++) {
                 if ($display_fields[$n] != 8) {
                     $display_fields_new[] = $display_fields[$n];
                 }
             }
             $display_fields = $display_fields_new;
         }
         $clear_fields = "";
         for ($x = 0; $x < count($display_fields); $x++) {
             $clear_fields .= "field" . $display_fields[$x] . "=''";
             if ($x < count($display_fields) - 1) {
                 $clear_fields .= ",";
             }
         }
         sql_query("update resource set " . $clear_fields . " where ref={$ref}");
         #also add the ref back into keywords:
         add_keyword_mappings($ref, $ref, -1);
         $extension = sql_value("select file_extension value from resource where ref={$ref}", "");
         $filename = get_resource_path($ref, true, "", false, $extension);
         $processfile['tmp_name'] = $filename;
     } else {
         # Work out which file has been posted
         if (isset($_FILES['userfile'])) {
             $processfile = $_FILES['userfile'];
         } elseif (isset($_FILES['Filedata'])) {
             $processfile = $_FILES['Filedata'];
         }
         # Java upload (at least) needs this
         # Plupload needs this
         if (isset($_REQUEST['name'])) {
             $filename = $_REQUEST['name'];
         } else {
             $filename = $processfile['name'];
         }
     }
     # Work out extension
     if (!isset($extension)) {
         # first try to get it from the filename
         $extension = explode(".", $filename);
         if (count($extension) > 1) {
             $extension = trim(strtolower($extension[count($extension) - 1]));
         } else {
             if ($exiftool_fullpath != false) {
                 $file_type_by_exiftool = run_command($exiftool_fullpath . " -filetype -s -s -s " . escapeshellarg($processfile['tmp_name']));
                 if (strlen($file_type_by_exiftool) > 0) {
                     $extension = str_replace(" ", "_", trim(strtolower($file_type_by_exiftool)));
                     $filename = $filename;
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
     }
     # Banned extension?
     global $banned_extensions;
     if (in_array($extension, $banned_extensions)) {
         return false;
     }
     $status = "Please provide a file name.";
     $filepath = get_resource_path($ref, true, "", true, $extension);
     if (!$revert) {
         # Remove existing file, if present
         hook("beforeremoveexistingfile", "", array("resourceId" => $ref));
         $old_extension = sql_value("select file_extension value from resource where ref='{$ref}'", "");
         if ($old_extension != "") {
             $old_path = get_resource_path($ref, true, "", true, $old_extension);
             if (file_exists($old_path)) {
                 unlink($old_path);
             }
         }
         // also remove any existing extracted icc profiles
         $icc_path = get_resource_path($ref, true, "", true, $extension . '.icc');
         if (file_exists($icc_path)) {
             unlink($icc_path);
         }
         global $pdf_pages;
         $iccx = 0;
         // if there is a -0.icc page, run through and delete as many as necessary.
         $finished = false;
         $badicc_path = str_replace(".icc", "-{$iccx}.icc", $icc_path);
         while (!$finished) {
             if (file_exists($badicc_path)) {
                 unlink($badicc_path);
                 $iccx++;
                 $badicc_path = str_replace(".icc", "-{$iccx}.icc", $icc_path);
             } else {
                 $finished = true;
             }
         }
         $iccx = 0;
     }
     if (!$revert) {
         if ($filename != "") {
             global $jupload_alternative_upload_location, $plupload_upload_location;
             if (isset($plupload_upload_location)) {
                 # PLUpload - file was sent chunked and reassembled - use the reassembled file location
                 $result = rename($plupload_upload_location, $filepath);
             } elseif (isset($jupload_alternative_upload_location)) {
                 # JUpload - file was sent chunked and reassembled - use the reassembled file location
                 $result = rename($jupload_alternative_upload_location, $filepath);
             } else {
                 # Standard upload.
                 if (!$revert) {
                     $result = move_uploaded_file($processfile['tmp_name'], $filepath);
                 } else {
                     $result = true;
                 }
             }
             if ($result == false) {
                 $status = "File upload error. Please check the size of the file you are trying to upload.";
                 return false;
             } else {
                 global $camera_autorotation;
                 global $ffmpeg_audio_extensions;
                 if ($camera_autorotation) {
                     if ($autorotate && !in_array($extension, $ffmpeg_audio_extensions)) {
                         AutoRotateImage($filepath);
                     }
                 }
                 chmod($filepath, 0777);
                 global $icc_extraction;
                 global $ffmpeg_supported_extensions;
                 if ($icc_extraction && $extension != "pdf" && !in_array($extension, $ffmpeg_supported_extensions)) {
                     extract_icc_profile($ref, $extension);
                 }
                 $status = "Your file has been uploaded.";
             }
         }
     }
     # Store extension in the database and update file modified time.
     if ($revert) {
         $has_image = "";
     } else {
         $has_image = ",has_image=0";
     }
     sql_query("update resource set file_extension='{$extension}',preview_extension='jpg',file_modified=now() {$has_image} where ref='{$ref}'");
     # delete existing resource_dimensions
     sql_query("delete from resource_dimensions where resource='{$ref}'");
     # get file metadata
     if (!$no_exif) {
         extract_exif_comment($ref, $extension);
     }
     # extract text from documents (e.g. PDF, DOC).
     global $extracted_text_field;
     if (isset($extracted_text_field) && !$no_exif) {
         if (isset($unoconv_path) && in_array($extension, $unoconv_extensions)) {
             // omit, since the unoconv process will do it during preview creation below
         } else {
             extract_text($ref, $extension);
         }
     }
     # Store original filename in field, if set
     global $filename_field;
     if (isset($filename_field)) {
         if (!$revert) {
             update_field($ref, $filename_field, $filename);
         } else {
             update_field($ref, $filename_field, $original_filename);
         }
     }
     if (!$revert) {
         # Clear any existing FLV file or multi-page previews.
         global $pdf_pages;
         for ($n = 2; $n <= $pdf_pages; $n++) {
             # Remove preview page.
             $path = get_resource_path($ref, true, "scr", false, "jpg", -1, $n, false);
             if (file_exists($path)) {
                 unlink($path);
             }
             # Also try the watermarked version.
             $path = get_resource_path($ref, true, "scr", false, "jpg", -1, $n, true);
             if (file_exists($path)) {
                 unlink($path);
             }
         }
         # Remove any FLV video preview (except if the actual resource is an FLV file).
         global $ffmpeg_preview_extension;
         if ($extension != $ffmpeg_preview_extension) {
             $path = get_resource_path($ref, true, "", false, $ffmpeg_preview_extension);
             if (file_exists($path)) {
                 unlink($path);
             }
         }
         # Remove any FLV preview-only file
         $path = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension);
         if (file_exists($path)) {
             unlink($path);
         }
         # Remove any MP3 (except if the actual resource is an MP3 file).
         if ($extension != "mp3") {
             $path = get_resource_path($ref, true, "", false, "mp3");
             if (file_exists($path)) {
                 unlink($path);
             }
         }
         # Create previews
         global $enable_thumbnail_creation_on_upload;
         if ($enable_thumbnail_creation_on_upload) {
             create_previews($ref, false, $extension);
         } else {
             # Offline thumbnail generation is being used. Set 'has_image' to zero so the offline create_previews.php script picks this up.
             sql_query("update resource set has_image=0 where ref='{$ref}'");
         }
     }
     # Update file dimensions
     get_original_imagesize($ref, $filepath, $extension);
     hook("Uploadfilesuccess", "", array("resourceId" => $ref));
     # Update disk usage
     update_disk_usage($ref);
     # Log this activity.
     $log_ref = resource_log($ref, "u", 0);
     hook("upload_image_after_log_write", "", array($ref, $log_ref));
     return $status;
 }
Example #19
0
function write_metadata($path, $ref, $uniqid="")
	{
	// copys the file to tmp and runs exiftool on it	
	// uniqid tells the tmp file to be placed in an isolated folder within tmp

	global $exiftool_remove_existing,$storagedir,$exiftool_write,$exiftool_no_process,$mysql_charset;

    # Fetch file extension and resource type.
	$resource_data=get_resource_data($ref);
	$extension=$resource_data["file_extension"];
	$resource_type=$resource_data["resource_type"];

	$exiftool_fullpath = get_utility_path("exiftool");

    # Check if an attempt to write the metadata shall be performed.
	if (($exiftool_fullpath!=false) && ($exiftool_write) && !in_array($extension,$exiftool_no_process))
		{
		$filename = pathinfo($path);
		$filename = $filename['basename'];	
		$tmpfile=get_temp_dir(false,$uniqid) . "/" . $filename;
		copy($path,$tmpfile);

        # Add the call to exiftool and some generic arguments to the command string.
        # Argument -overwrite_original: Now that we have already copied the original file, we can use exiftool's overwrite_original on the tmpfile.
        # Argument -E: Escape values for HTML. Used for handling foreign characters in shells not using UTF-8.
        # Arguments -EXIF:all= -XMP:all= -IPTC:all=: Remove the metadata in the tag groups EXIF, XMP and IPTC.
		$command = $exiftool_fullpath . " -overwrite_original -E ";
        if ($exiftool_remove_existing) {$command.= "-EXIF:all= -XMP:all= -IPTC:all= ";}

        $write_to = get_exiftool_fields($resource_type); # Returns an array of exiftool fields for the particular resource type, which are basically fields with an 'exiftool field' set.

        for($i = 0; $i<count($write_to); $i++) # Loop through all the found fields.
			{
            $fieldtype = $write_to[$i]['type'];
            $writevalue = "";
    
            # Formatting and cleaning of the value to be written - depending on the RS field type.
            switch ($fieldtype)
                {
                case 2:
                    # Check box list: remove initial comma if present
                    if (substr(get_data_by_field($ref, $write_to[$i]['ref']), 0, 1)==",") {$writevalue = substr(get_data_by_field($ref, $write_to[$i]['ref']), 1);}
                    else {$writevalue = get_data_by_field($ref, $write_to[$i]['ref']);}
                    break;
                case 3:
                    # Drop down list: remove initial comma if present
                    if (substr(get_data_by_field($ref, $write_to[$i]['ref']), 0, 1)==",") {$writevalue = substr(get_data_by_field($ref, $write_to[$i]['ref']), 1);}
                    else {$writevalue = get_data_by_field($ref, $write_to[$i]['ref']);}
                    break;
                case 4:
                    # Date: write datetype fields as ISO 8601 date ("c")
                    $datecheck=get_data_by_field($ref, $write_to[$i]['ref']);
                    if ($datecheck!=""){
						$writevalue = date("c", strtotime($datecheck));
					} 
                    break;
                case 6:
                    # Expiry Date: write datetype fields as ISO 8601 date ("c")
                                        $datecheck=get_data_by_field($ref, $write_to[$i]['ref']);
                    if ($datecheck!=""){
						$writevalue = date("c", strtotime($datecheck));
					} 
                    break;
                case 9:
                    # Dynamic Keywords List: remove initial comma if present
                    if (substr(get_data_by_field($ref, $write_to[$i]['ref']), 0, 1)==",") {$writevalue = substr(get_data_by_field($ref, $write_to[$i]['ref']), 1);}
                    else {$writevalue = get_data_by_field($ref, $write_to[$i]['ref']);}
                    break;
                default:
                    # Other types
                    $writevalue = get_data_by_field($ref, $write_to[$i]['ref']);
                }

            # Add the tag name(s) and the value to the command string.
            $group_tags = explode(",", $write_to[$i]['exiftool_field']); # Each 'exiftool field' may contain more than one tag.
            foreach ($group_tags as $group_tag)
                {
                $group_tag = strtolower($group_tag); # E.g. IPTC:Keywords -> iptc:keywords
                if (strpos($group_tag,":")===false) {$tag = $group_tag;} # E.g. subject -> subject
                else {$tag = substr($group_tag, strpos($group_tag,":")+1);} # E.g. iptc:keywords -> keywords

                switch ($tag)
                    {
                    case "filesize":
                        # Do nothing, no point to try to write the filesize.
                        break;
                    case "keywords":
                        # Keywords shall be written one at a time and not all together.
                        $keywords = explode(",", $writevalue); # "keyword1,keyword2, keyword3" (with or with spaces)
                        foreach ($keywords as $keyword)
                            {
                            # Trim leading space if any.
                            if (substr($keyword, 0, 1)==" ") {$keyword = substr($keyword, 1);}
                            # Convert the data to UTF-8 if not already.
                            if (!isset($mysql_charset) || (isset($mysql_charset) && strtolower($mysql_charset)!="utf8")){$keyword = mb_convert_encoding($keyword, 'UTF-8');}
                            $command.= escapeshellarg("-" . $group_tag . "=" . htmlentities($keyword, ENT_QUOTES, "UTF-8")) . " ";
                            }
                        break;
                    default:
                        # Convert the data to UTF-8 if not already.
                        if (!isset($mysql_charset) || (isset($mysql_charset) && strtolower($mysql_charset)!="utf8")){$writevalue = mb_convert_encoding($writevalue, 'UTF-8');}
                        $command.= escapeshellarg("-" . $group_tag . "=" . htmlentities($writevalue, ENT_QUOTES, "UTF-8")) . " ";
                    }
                }
            }

            # Add the filename to the command string.
            $command.= " " . escapeshellarg($tmpfile);

            # Perform the actual writing - execute the command string.
            $output = run_command($command);

        return $tmpfile;
        }
    else
        {
        return false;
        }
    }
            $nb++;
        }
    }
    return $nb;
}
// get all resources in the DB omitting those in Deleted state.
$resources = sql_query("select ref,file_extension from resource where ref>0 and archive != 3");
// set up an array to store the filenames as they are found (to analyze dupes)
$filenames = array();
//loop:
foreach ($resources as $resource) {
    // use extension to get scrambled path
    $extension = $resource['file_extension'];
    $scrambled = get_resource_path($resource['ref'], true, "", false, $extension);
    // get original file name
    $filename = get_data_by_field($resource['ref'], $filename_field);
    // save original file name (may be appended to indicate dupe)
    $orig_filename = $filename;
    // check if a file has already been processed with this name
    if (in_array($filename, $filenames)) {
        // if so, append a dupe tag
        $path_parts = pathinfo($filename);
        if (isset($path_parts['extension']) && isset($path_parts['filename'])) {
            $filename_ext = $path_parts['extension'];
            $filename_wo = $path_parts['filename'];
            $x = findDuplicates($filenames, $filename);
            $filename = $filename_wo . "_DUPE" . $x . "." . $filename_ext;
            fwrite($fp, 'DUPE: ');
            echo "DUPE: ";
        }
    }
Example #21
0
<span class="ArchiveResourceTitle"><?php 
                echo $lang["status2"];
                ?>
:</span>&nbsp;<?php 
                break;
            case 3:
                ?>
<span class="DeletedResourceTitle"><?php 
                echo $lang["status3"];
                ?>
:</span>&nbsp;<?php 
                break;
        }
    }
    if (!hook("replaceviewtitle")) {
        echo highlightkeywords(htmlspecialchars(i18n_get_translated(get_data_by_field($resource['ref'], $title_field))), $search);
    }
    /* end hook replaceviewtitle */
    ?>
&nbsp;</h1>
<?php 
}
/* End of renderinnerresourceheader hook */
?>
</div>

<?php 
if (!hook("replaceresourceistranscoding")) {
    if (isset($resource['is_transcoding']) && $resource['is_transcoding'] == 1) {
        ?>
<div class="PageInformal"><?php 
Example #22
0
             $filename = strip_extension(mb_basename($origfile)) . "-" . $size . "." . $ext;
         } else {
             $filename = strip_extension(mb_basename($origfile)) . "." . $ext;
         }
         if ($prefix_resource_id_to_filename) {
             $filename = $prefix_filename_string . $ref . "_" . $filename;
         }
     }
 }
 if ($download_filename_id_only) {
     if (!hook('customdownloadidonly', '', array($ref, $ext, $alternative))) {
         $filename = $ref . "." . $ext;
     }
 }
 if (isset($download_filename_field)) {
     $newfilename = get_data_by_field($ref, $download_filename_field);
     if ($newfilename) {
         $filename = trim(nl2br(strip_tags($newfilename)));
         if ($size != "") {
             $filename = substr($filename, 0, 200) . "-" . $size . "." . $ext;
         } else {
             $filename = substr($filename, 0, 200) . "." . $ext;
         }
         if ($prefix_resource_id_to_filename) {
             $filename = $prefix_filename_string . $ref . "_" . $filename;
         }
     }
 }
 # Remove critical characters from filename
 $altfilename = hook("downloadfilenamealt");
 if (!$altfilename) {
Example #23
0
	}
else
	{
	# ----------------------------------- Show the PayPal integration instead ------------------------------------
	$pricing_discounted=$pricing; # Copy the pricing, which may be group specific
	include "../include/config.php"; # Reinclude the config so that $pricing is now the default, and we can work out group discounts
	
	$resources=do_search("!collection" . $usercollection);
	$n=1;
	$paypal="";
	$totalprice=0;
	$totalprice_ex_discount=0;
	foreach ($resources as $resource)
		{
		$sizes=get_image_sizes($resource["ref"]);
		$title=get_data_by_field($resource["ref"],$view_title_field);
		foreach ($sizes as $size)
			{
			if (getval("select_" . $resource["ref"],"")==$size["id"])
				{
				$name=$size["name"];
				$id=$size["id"];
				if ($id=="") {$id="hpr";}
				
				# Add to total price				
				if (array_key_exists($id,$pricing_discounted)) {$price=$pricing_discounted[$id];}	else {$price=999;}

				# Add to ex-discount price also
				if (array_key_exists($id,$pricing)) {$price_ex_discount=$pricing[$id];}	else {$price_ex_discount=999;}
				$totalprice_ex_discount+=$price_ex_discount;
								
function email_resource_request($ref, $details)
{
    # E-mails a basic resource request for a single resource (posted) to the team
    # (not a managed request)
    global $applicationname, $email_from, $baseurl, $email_notify, $username, $useremail, $userref, $lang, $request_senduserupdates, $watermark, $filename_field, $view_title_field, $access, $resource_type_request_emails;
    $resourcedata = get_resource_data($ref);
    $templatevars['thumbnail'] = get_resource_path($ref, true, "thm", false, "jpg", $scramble = -1, $page = 1, $watermark ? $access == 1 ? true : false : false);
    if (!file_exists($templatevars['thumbnail'])) {
        $templatevars['thumbnail'] = "../gfx/" . get_nopreview_icon($resourcedata["resource_type"], $resourcedata["file_extension"], false);
    }
    if (isset($filename_field)) {
        $templatevars["filename"] = $lang["fieldtitle-original_filename"] . ": " . get_data_by_field($ref, $filename_field);
    }
    if (isset($resourcedata["field" . $view_title_field])) {
        $templatevars["title"] = $resourcedata["field" . $view_title_field];
    }
    $templatevars['username'] = $username . " (" . $useremail . ")";
    $templatevars['formemail'] = getval("email", "");
    $templatevars['url'] = $baseurl . "/?r=" . $ref;
    $templatevars["requesturl"] = $templatevars['url'];
    $userdata = get_user($userref);
    $templatevars["fullname"] = $userdata["fullname"];
    $htmlbreak = "";
    global $use_phpmailer;
    if ($use_phpmailer) {
        $htmlbreak = "<br><br>";
    }
    $list = "";
    reset($_POST);
    foreach ($_POST as $key => $value) {
        if (strpos($key, "_label") !== false) {
            # Add custom field
            $data = "";
            $data = $_POST[str_replace("_label", "", $key)];
            $list .= $htmlbreak . $value . ": " . $data . "\n";
        }
    }
    $list .= $htmlbreak;
    $templatevars['list'] = $list;
    $templatevars['details'] = stripslashes($details);
    if ($templatevars['details'] != "") {
        $adddetails = $lang["requestreason"] . ": " . newlines($templatevars['details']) . "\n\n";
    } else {
        return false;
    }
    # Add custom fields
    $c = "";
    global $custom_request_fields, $custom_request_required;
    if (isset($custom_request_fields)) {
        $custom = explode(",", $custom_request_fields);
        # Required fields?
        if (isset($custom_request_required)) {
            $required = explode(",", $custom_request_required);
        }
        for ($n = 0; $n < count($custom); $n++) {
            if (isset($required) && in_array($custom[$n], $required) && getval("custom" . $n, "") == "") {
                return false;
                # Required field was not set.
            }
            $c .= i18n_get_translated($custom[$n]) . ": " . getval("custom" . $n, "") . "\n\n";
        }
    }
    $templatevars["requestreason"] = $lang["requestreason"] . ": " . $templatevars['details'] . $c . "";
    $message = $lang["user_made_request"] . "<br /><br />";
    $message .= isset($username) ? $lang["username"] . ": " . $username . " (" . $useremail . ")<br />" : "";
    $message .= !empty($templatevars["formemail"]) ? $lang["email"] . ":" . $templatevars["formemail"] . "<br />" : "";
    $message .= $adddetails . $c . "<br /><br />" . $lang["clicktoviewresource"] . "<br />" . $templatevars['url'];
    # Check if alternative request email notification address is set
    $admin_notify_email = $email_notify;
    if (isset($resource_type_request_emails)) {
        if (isset($resource_type_request_emails[$resourcedata["resource_type"]])) {
            $admin_notify_email = $resource_type_request_emails[$resourcedata["resource_type"]];
        }
    }
    send_mail($admin_notify_email, $applicationname . ": " . $lang["requestresource"] . " - {$ref}", $message, $useremail, $useremail, "emailresourcerequest", $templatevars);
    if ($request_senduserupdates) {
        $sender = !empty($useremail) ? $useremail : !empty($templatevars["formemail"]) ? $templatevars["formemail"] : "";
        $k = getval("k", "") != "" ? "&k=" . getval("k", "") : "";
        $userconfirmmessage = $lang["requestsenttext"] . "<br /><br />" . $lang["requestreason"] . ": " . $templatevars['details'] . $c . "<br /><br />" . $lang["clicktoviewresource"] . "\n{$baseurl}/?r={$ref}" . $k;
        if ($sender != "") {
            send_mail($sender, $applicationname . ": " . $lang["requestsent"] . " - {$ref}", $userconfirmmessage, $email_from, $email_notify, "emailuserresourcerequest", $templatevars);
        }
    }
    # Increment the request counter
    sql_query("update resource set request_count=request_count+1 where ref='{$ref}'");
}
Example #25
0
            echo urlencode($sort);
            ?>
&archive=<?php 
            echo urlencode($archive);
            ?>
&page=<?php 
            echo urlencode($nextpage);
            ?>
" class="PDFnav pageNext">&gt;</a><?php 
        }
        ?>
</td>
</tr></table>

<?php 
    }
    // end hook previewimage2
}
// end hook previewimage
?>

<?php 
if ($show_resource_title_in_titlebar) {
    $title = htmlspecialchars(i18n_get_translated(get_data_by_field($ref, $view_title_field)));
    if (strlen($title) > 0) {
        echo "<script language='javascript'>\n";
        echo "document.title = \"{$applicationname} - {$title}\";\n";
        echo "</script>";
    }
}
include "../include/footer.php";
Example #26
0
<?php 
//titlebar modifications
if ($show_resource_title_in_titlebar) {
    $general_title_pages = array("admin_content", "team_archive", "team_resource", "team_user", "team_request", "team_research", "team_plugins", "team_mail", "team_export", "team_stats", "team_report", "team_user_log", "research_request", "team_user_edit", "admin_content_edit", "team_request_edit", "team_research_edit", "requests", "edit", "themes", "collection_public", "collection_manage", "team_home", "help", "home", "tag", "upload_java_popup", "upload_java", "contact", "geo_search", "search_advanced", "about", "contribute", "user_preferences", "view_shares", "check", "index");
    $search_title_pages = array("contactsheet_settings", "search", "preview_all", "collection_edit", "edit", "collection_download", "collection_share", "collection_request");
    $resource_title_pages = array("view", "delete", "log", "alternative_file", "alternative_files", "resource_email", "edit", "preview");
    $additional_title_pages = array(hook("additional_title_pages_array"));
    // clear resource or search title for pages that don't apply:
    if (!in_array($pagename, array_merge($general_title_pages, $search_title_pages, $resource_title_pages)) && (empty($additional_title_pages) || !in_array($pagename, $additional_title_pages))) {
        echo "<script language='javascript'>\n";
        echo "document.title = \"{$applicationname}\";\n";
        echo "</script>";
    } else {
        if (in_array($pagename, $resource_title_pages) && !isset($_GET['collection']) && !isset($_GET['java'])) {
            $title = str_replace('"', "''", i18n_get_translated(get_data_by_field($ref, $view_title_field)));
            echo "<script type=\"text/javascript\" language='javascript'>\n";
            if ($pagename == "edit") {
                $title = $lang['action-edit'] . " - " . $title;
            }
            echo "document.title = \"{$applicationname} - {$title}\";\n";
            if ($pagename == 'edit' && $distinguish_uploads_from_edits) {
                $js = sprintf("\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tvar h1 = jQuery(\"h1\").text();\n\n\t\t\t\t\tif(h1 == \"%s\") {\n\t\t\t\t\t\tdocument.title = \"%s - \" + h1;\n\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t", $lang["addresourcebatchbrowser"], $applicationname);
                echo $js;
            }
            echo "</script>";
        } else {
            if (in_array($pagename, $search_title_pages)) {
                if (isset($search_title)) {
                    $title = str_replace('"', "''", $lang["searchresults"] . " - " . html_entity_decode(strip_tags($search_title)));
                } else {
function send_collection_feedback($collection, $comment)
{
    # Sends the feedback to the owner of the collection.
    global $applicationname, $lang, $userfullname, $userref, $k, $feedback_resource_select, $feedback_email_required, $regex_email;
    $cinfo = get_collection($collection);
    if ($cinfo === false) {
        exit("Collection not found");
    }
    $user = get_user($cinfo["user"]);
    $body = $lang["collectionfeedbackemail"] . "\n\n";
    if (isset($userfullname)) {
        $body .= $lang["user"] . ": " . $userfullname . "\n";
    } else {
        # External user.
        if ($feedback_email_required && !preg_match("/{$regex_email}/", getvalescaped("email", ""))) {
            $errors[] = $lang["youremailaddress"] . ": " . $lang["requiredfield"];
            return $errors;
        }
        $body .= $lang["fullname"] . ": " . getval("name", "") . "\n";
        $body .= $lang["email"] . ": " . getval("email", "") . "\n";
    }
    $body .= $lang["message"] . ": " . stripslashes(str_replace("\\r\\n", "\n", trim($comment)));
    $f = get_collection_comments($collection);
    for ($n = 0; $n < count($f); $n++) {
        $body .= "\n\n" . $lang["resourceid"] . ": " . $f[$n]["resource"];
        $body .= "\n" . $lang["comment"] . ": " . trim($f[$n]["comment"]);
        if (is_numeric($f[$n]["rating"])) {
            $body .= "\n" . $lang["rating"] . ": " . substr("**********", 0, $f[$n]["rating"]);
        }
    }
    if ($feedback_resource_select) {
        $body .= "\n\n" . $lang["selectedresources"] . ": ";
        $file_list = "";
        $result = do_search("!collection" . $collection);
        for ($n = 0; $n < count($result); $n++) {
            $ref = $result[$n]["ref"];
            if (getval("select_" . $ref, "") != "") {
                global $filename_field;
                $filename = get_data_by_field($ref, $filename_field);
                $body .= "\n" . $ref . " : " . $filename;
                # Append to a file list that is compatible with Adobe Lightroom
                if ($file_list != "") {
                    $file_list .= ", ";
                }
                $s = explode(".", $filename);
                $file_list .= $s[0];
            }
        }
        # Append Lightroom compatible summary.
        $body .= "\n\n" . $lang["selectedresourceslightroom"] . "\n" . $file_list;
    }
    $cc = getval("email", "");
    if (filter_var($cc, FILTER_VALIDATE_EMAIL)) {
        send_mail($user["email"], $applicationname . ": " . $lang["collectionfeedback"] . " - " . $cinfo["name"], $body, "", "", "", NULL, "", $cc);
    } else {
        send_mail($user["email"], $applicationname . ": " . $lang["collectionfeedback"] . " - " . $cinfo["name"], $body);
    }
    # Cancel the feedback request for this resource.
    /* - Commented out - as it may be useful to leave the feedback request in case the user wishes to leave
    	     additional feedback or make changes.
    	     
    	if (isset($userref))
    		{
    		sql_query("update user_collection set request_feedback=0 where collection='$collection' and user='******'");
    		}
    	else
    		{
    		sql_query("update external_access_keys set request_feedback=0 where access_key='$k'");
    		}
    	*/
}
Example #28
0
 $pubdate = date('D, d M Y H:i:s +0100', mktime($hour, $min, $sec, $month, $day, $year));
 $url = $baseurl . "/pages/view.php?ref=" . $ref;
 $imgurl = "";
 $imgurl = get_resource_path($result[$n]['ref'], true, "col", false);
 if ($result[$n]['has_image'] != 1) {
     $imgurl = $baseurl . "/gfx/" . get_nopreview_icon($result[$n]["resource_type"], $result[$n]["file_extension"], true, false, true);
 } else {
     $imgurl = get_resource_path($result[$n]['ref'], false, "col", false);
 }
 $add_desc = "";
 foreach ($rss_fields as $rssfield) {
     if (is_array($result[$n])) {
         if (isset($result[$n]['field' . $rssfield])) {
             $value = i18n_get_translated($result[$n]['field' . $rssfield]);
         } else {
             $value = i18n_get_translated(get_data_by_field($result[$n]['ref'], $rssfield));
         }
         if ($value != "" && $value != ",") {
             // allow for value filters
             for ($x = 0; $x < count($df); $x++) {
                 if ($df[$x]['ref'] == $rssfield) {
                     $plugin = "../../value_filter_" . $df[$x]['name'] . ".php";
                     if ($df[$x]['value_filter'] != "") {
                         eval($df[$x]['value_filter']);
                     } else {
                         if (file_exists($plugin)) {
                             include $plugin;
                         } else {
                             if ($df[$x]["type"] == 4 || $df[$x]["type"] == 6 || $df[$x]["type"] == 10) {
                                 $value = NiceDate($value, true, false);
                             }
<?php 
    if ($feedback_resource_select) {
        ?>
<h2><?php 
        echo $lang["selectedresources"];
        ?>
:</h2><?php 
        # Show thumbnails and allow the user to select resources.
        $result = do_search("!collection" . $collection);
        for ($n = 0; $n < count($result); $n++) {
            $ref = $result[$n]["ref"];
            $access = get_resource_access($ref);
            $use_watermark = check_use_watermark($ref);
            $title = $ref . " : " . htmlspecialchars(tidy_trim(i18n_get_translated($result[$n]["field" . $view_title_field]), 60));
            if (isset($collection_feedback_display_field)) {
                $displaytitle = htmlspecialchars(get_data_by_field($ref, $collection_feedback_display_field));
            } else {
                $displaytitle = $title;
            }
            ?>
	
		<!--Resource Panel-->
		<div class="ResourcePanelShell" id="ResourceShell<?php 
            echo $ref;
            ?>
">
		<div class="ResourcePanel">
		
		<table border="0" class="ResourceAlign<?php 
            if (in_array($result[$n]["resource_type"], $videotypes)) {
                ?>
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;
}