$filename = $filename_wo . "_DUPE" . $x . "." . $filename_ext;
         fwrite($fp, 'DUPE: ');
         echo "DUPE: ";
     }
 }
 //add original file name to array
 $filenames[] = $orig_filename;
 //copy file if both paths exist
 if (file_exists($scrambled) && $filename != "") {
     echo "copying " . $drive_path . $filename;
     fwrite($fp, "copying " . $drive_path . $filename . "\n");
     // allow to re-run script without re-copying files
     if (!file_exists($drive_path . $filename)) {
         // optionally write metadata
         if ($write_metadata) {
             $tmpfile = write_metadata($scrambled, $resource['ref']);
             if ($tmpfile !== false && file_exists($tmpfile)) {
                 $scrambled = $tmpfile;
             }
         }
         copy($scrambled, $drive_path . $filename);
         if ($write_metadata && $tmpfile !== false && file_exists($tmpfile)) {
             unlink($tmpfile);
         }
     }
     echo "<br />";
     // if file exists but no filename exists, export ref
 } else {
     if (file_exists($scrambled)) {
         echo "No filename: copying ref " . $resource['ref'];
         fwrite($fp, "No filename: copying ref " . $resource['ref'] . "\n");
Example #2
0
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);
header("Content-Length: " . $filesize);
# Log this activity (download only, not preview)
if ($noattach == "") {
    daily_stat("Resource download", $ref);
    resource_log($ref, 'd', 0, $usagecomment, "", "", $usage, $size);
    hook('moredlactions');
    # update hit count if tracking downloads only
    if ($resource_hit_count_on_downloads) {
        # greatest() is used so the value is taken from the hit_count column in the event that new_hit_count is zero to support installations that did not previously have a new_hit_count column (i.e. upgrade compatability).
     } else {
         if ($useoriginal == 'yes' && resource_download_allowed($ref, '', $result[$n]['resource_type'])) {
             // this size doesn't exist, so we'll try using the original instead
             $p = get_resource_path($ref, true, '', false, $result[$n]['file_extension'], -1, 1, $use_watermark);
             $pextension = $result[$n]['file_extension'];
             $subbed_original_resources[] = $ref;
             $subbed_original = true;
         }
     }
     $target_exists = file_exists($p);
 }
 # Check file exists and, if restricted access, that the user has access to the requested size.
 if (($target_exists && $access == 0 || $target_exists && $access == 1 && (image_size_restricted_access($size) || ($usesize = '' && $restricted_full_download))) && resource_download_allowed($ref, $usesize, $result[$n]['resource_type'])) {
     $used_resources[] = $ref;
     # when writing metadata, we take an extra security measure by copying the files to tmp
     $tmpfile = write_metadata($p, $ref, $id);
     // 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
$collections = generate_json('https://docs.google.com/spreadsheets/d/1I01Nva_udl0DHJnsjEQ_z-Q1XJaZ6uuAptLVoQSrNfU/pub?gid=0&single=true&output=csv');
foreach ($collections as $collection) {
    //if the $id is specified, only process that collection
    if (isset($argv[1]) > 0) {
        $id = $argv[1];
        if ($collection['project_id'] == $id) {
            //use XML writer to generate RDF for void:dataDump
            write_dump($collection);
            //create void:Dataset
            write_metadata($collection);
        }
    } else {
        //use XML writer to generate RDF for void:dataDump
        write_dump($collection);
        //create void:Dataset
        write_metadata($collection);
    }
}
function write_dump($collection)
{
    $writer = new XMLWriter();
    $writer->openURI("{$collection['project_id']}.rdf");
    //$writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(true);
    //now we need to define our Indent string,which is basically how many blank spaces we want to have for the indent
    $writer->setIndentString("    ");
    $writer->startElement('rdf:RDF');
    $writer->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema#');
    $writer->writeAttribute('xmlns:nm', "http://nomisma.org/id/");
    $writer->writeAttribute('xmlns:nmo', "http://nomisma.org/ontology#");
 $writable_tags_array = explode(" ", $writable_tags);
 $command = $exiftool_fullpath . " -ver";
 $exiftool_version = run_command($command);
 if ($exiftool_version >= 7.4) {
     #build array of writable formats
     $command = $exiftool_fullpath . " -listwf";
     $writable_formats = run_command($command);
     $writable_formats = str_replace("\n", "", $writable_formats);
     $writable_formats_array = explode(" ", $writable_formats);
     $file_writability = in_array($ext, $writable_formats_array);
 }
 # Create a report for the original file.
 $command = $exiftool_fullpath . " -s -t -G --filename --exiftoolversion --filepermissions --NativeDigest --History --Directory " . escapeshellarg($image) . " 2>&1";
 $report_original = run_command($command);
 # Create a temporary file (simulate download) and create a report for it.
 $tmpfile = write_metadata($image, $ref);
 $command = $exiftool_fullpath . " -s -t -G --filename --exiftoolversion --filepermissions --NativeDigest --History --Directory " . escapeshellarg($tmpfile) . " 2>&1";
 $report_simulated = run_command($command);
 # Remove the temporary file.
 unlink($tmpfile);
 # Process the report of the simulated download.
 $results_simulated = array();
 $i = 0;
 $fields_simulated = explode("\n", $report_simulated);
 foreach ($fields_simulated as $field_simulated) {
     $tag_value = explode("\t", $field_simulated);
     if (count($tag_value) == 3) {
         $results_simulated[$i]["group"] = trim(strtolower($tag_value[0]));
         $results_simulated[$i]["tag"] = trim(strtolower($tag_value[1]));
         $results_simulated[$i]["value"] = trim($tag_value[2]);
         $tagprops = "";
Example #6
0
        if (trim($mp4tags_check) != "Found") {
            die("Could not find mp4tags. Please make sure it’s in your path.'{$mp4tags_check}'\n");
        }
        $mp4info_command = "mp4info";
        $mp4info_check = shell_exec('command -v ' . $mp4info_command . ' >& /dev/null && echo "Found" || echo "Not Found"');
        if (trim($mp4info_check) != "Found") {
            unset($mp4info_check);
            $mp4info_command = $mp4v2_path . "/mp4info";
            $mp4info_check = shell_exec('command -v ' . $mp4info_command . ' >& /dev/null && echo "Found" || echo "Not Found"');
        }
        if (trim($mp4info_check) != "Found") {
            die("Could not find mp4info. Please make sure it’s in your path.\n");
        }
        shell_exec($mp4tags_command . ' -r w -s "' . '#' . $episode . ': ' . $options['title'] . '" -a "' . $options['artist'] . '" -A "' . $options['album'] . '" -y "' . date('Y') . '" -g "' . $options['genre'] . '" -c "' . $options['comments'] . '" -L "' . $options['comments'] . '" -m "' . $options['comments'] . '" -t ' . $episode . ' "' . $track_full_filename . '"');
        $track_playtime_output = shell_exec($mp4info_command . ' "' . $track_full_filename . '" | sed -n "s/^.*audio.*, \\([0-9]*\\)\\.[0-9]* secs,.*$/\\1/p"');
        write_metadata($post_full_filename, $episode, $options['title'], $track_filename, filesize($track_full_filename), minutes(trim($track_playtime_output)), $options['comments'], $comments_suffix);
    }
}
function write_metadata($post_full_filename, $episode, $title, $track_filename, $track_filesize, $track_playtime, $comments, $comments_suffix)
{
    if (file_exists($post_full_filename)) {
        die("Posts file at output folder already exist. Won’t overwrite.\n");
    }
    $post_array = array('title' => 'Episode ' . $episode . ': ' . $title, 'layout' => 'post', 'podcastfilename' => $track_filename, 'podcastlength' => $track_filesize, 'itunesurl' => '#ITUNESURL#', 'length' => $track_playtime . ' min');
    $yaml_output = Spyc::YAMLDump($post_array, 2, 72);
    $yaml_output .= "---\n\n" . $comments . $comments_suffix;
    if (!($handle = fopen($post_full_filename, 'w'))) {
        die("Cannot open file {$post_full_filename}");
    }
    if (fwrite($handle, $yaml_output) === FALSE) {
        die("Cannot write to file {$post_full_filename}");
				$p=get_resource_path($ref,true,'',false,$result[$n]['file_extension'],-1,1,$use_watermark);
				$pextension = $result[$n]['file_extension'];
				$subbed_original_resources[] = $ref;
				$subbed_original = true;
				$target_exists = file_exists($p);
				}

			# Check file exists and, if restricted access, that the user has access to the requested size.
			if ((($target_exists && $access==0) ||
				($target_exists && $access==1 &&
					(image_size_restricted_access($size) || ($usesize='' && $restricted_full_download))) 
					) && resource_download_allowed($ref,$usesize,$result[$n]['resource_type']))
				{
				$used_resources[]=$ref;
				# when writing metadata, we take an extra security measure by copying the files to tmp
				$tmpfile=write_metadata($p,$ref,$id); // 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);