# get all resources in the DB $resources = sql_query("select ref,field" . $view_title_field . ",file_extension from resource where ref>0 order by ref DESC"); //loop: foreach ($resources as $resource) { $resource_path = get_resource_path($resource['ref'], true, "", false, $resource['file_extension']); if (file_exists($resource_path)) { $filesize = filesize_unlimited($resource_path); sql_query("update resource_dimensions set file_size={$filesize} where resource='" . $resource['ref'] . "'"); echo "Ref: " . $resource['ref'] . " - " . $resource['field' . $view_title_field] . " - updating resource_dimensions file_size column - " . formatfilesize($filesize); echo "<br />"; } $alt_files = sql_query("select file_extension,file_name,ref from resource_alt_files where resource=" . $resource['ref']); if (count($alt_files) > 0) { foreach ($alt_files as $alt) { $alt_path = get_resource_path($resource['ref'], true, "", false, $alt['file_extension'], -1, 1, false, "", $alt['ref']); if (file_exists($alt_path)) { // allow to re-run script without re-copying files $filesize = filesize_unlimited($alt_path); sql_query("update resource_alt_files set file_size={$filesize} where resource='" . $resource['ref'] . "' and ref='" . $alt['ref'] . "'"); echo " ALT - " . $alt['file_name'] . " - updating alt file size - " . formatfilesize($filesize); echo "<br />"; } } } update_disk_usage($resource['ref']); echo "updating disk usage"; echo "<br />"; echo "<br />"; flush(); ob_flush(); }
function update_disk_usage_cron() { # Update disk usage for all resources that have not yet been updated or have not been updated in the past 30 days. # Limit to a reasonable amount so that this process is spread over several cron intervals for large data sets. $resources=sql_array("select ref value from resource where ref>0 and disk_usage_last_updated is null or datediff(now(),disk_usage_last_updated)>30 limit 20000"); foreach ($resources as $resource) { update_disk_usage($resource); } }
function upload_file($ref, $no_exif = false, $revert = false, $autorotate = false) { hook("beforeuploadfile", "", array($ref)); 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", "", array($ref)); $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']; } global $filename_field; if ($no_exif && isset($filename_field)) { $user_set_filename = get_data_by_field($ref, $filename_field); if (trim($user_set_filename) != '') { // Get extension of file just in case the user didn't provide one $path_parts = pathinfo($filename); $original_extension = $path_parts['extension']; $filename = $user_set_filename; // If the user filename doesn't have an extension add the original one $path_parts = pathinfo($filename); if (!isset($path_parts['extension'])) { $filename .= '.' . $original_extension; } } } } # Work out extension if (!isset($extension)) { # first try to get it from the filename $extension = explode(".", $filename); if (count($extension) > 1) { $extension = escape_check(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); } else { 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); } // Get title field: $resource = get_resource_data($ref); $read_from = get_exiftool_fields($resource['resource_type']); for ($i = 0; $i < count($read_from); $i++) { if ($read_from[$i]['name'] == 'title') { $oldval = get_data_by_field($ref, $read_from[$i]['ref']); if (strpos($oldval, $merged_filename) !== 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); } } } } # 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, $amended_filename; if (isset($filename_field)) { if (isset($amended_filename)) { $filename = $amended_filename; } } 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; }
function HookImagestreamUpload_pluploadInitialuploadprocessing() { #Support for uploading multi files as zip global $config_windows, $id, $targetDir, $resource_type, $imagestream_restypes, $imagestream_transitiontime, $zipcommand, $use_zip_extension, $userref, $session_hash, $filename, $filename_field, $collection_add, $archiver, $zipcommand, $ffmpeg_fullpath, $ffmpeg_preview_extension, $ffmpeg_preview_options, $ffmpeg_preview_min_height, $ffmpeg_preview_max_height, $ffmpeg_preview_min_width, $ffmpeg_preview_max_width, $lang, $collection_download_settings, $archiver_listfile_argument; $ffmpeg_fullpath = get_utility_path("ffmpeg"); debug("DEBUG: Imagestream - checking restype: " . $resource_type . $imagestream_restypes); if (in_array($resource_type, $imagestream_restypes)) { debug("DEBUG: Imagestream - uploading file"); #Check that we have an archiver configured $archiver_fullpath = get_utility_path("archiver"); if (!isset($zipcommand) && !$use_zip_extension) { if ($archiver_fullpath == false) { exit($lang["archiver-utility-not-found"]); } } echo print_r($_POST) . print_r($_GET); if (getval("lastqueued", "")) { debug("DEBUG: Imagestream - last queued file"); $ref = copy_resource(0 - $userref); # Copy from user template debug("DEBUG: Imagestream - creating resource: " . $ref); # Create the zip file $imagestreamzippath = get_resource_path($ref, true, "", true, "zip"); if ($use_zip_extension) { $zip = new ZipArchive(); $zip->open($imagestreamzippath, ZIPARCHIVE::CREATE); } $deletion_array = array(); debug("DEBUG: opening directory: " . $targetDir); $imagestream_files = opendir($targetDir); $imagestream_workingfiles = get_temp_dir() . DIRECTORY_SEPARATOR . "plupload" . DIRECTORY_SEPARATOR . $session_hash . "workingfiles"; if (!file_exists($imagestream_workingfiles)) { if ($config_windows) { @mkdir($imagestream_workingfiles); } else { @mkdir($imagestream_workingfiles, 0777, true); } } $filenumber = 00; $imagestream_filelist = array(); while ($imagestream_filelist[] = readdir($imagestream_files)) { sort($imagestream_filelist); } closedir($imagestream_files); $imageindex = 1; foreach ($imagestream_filelist as $imagestream_file) { if ($imagestream_file != '.' && $imagestream_file != '..') { $filenumber = sprintf("%03d", $filenumber); $deletion_array[] = $targetDir . DIRECTORY_SEPARATOR . $imagestream_file; if (!$use_zip_extension) { $imagestreamcmd_file = get_temp_dir(false, $id) . "/imagestreamzipcmd" . $imagestream_file . ".txt"; $fh = fopen($imagestreamcmd_file, 'w') or die("can't open file"); fwrite($fh, $targetDir . DIRECTORY_SEPARATOR . $imagestream_file . "\r\n"); fclose($fh); $deletion_array[] = $imagestreamcmd_file; } if ($use_zip_extension) { debug("DEBUG: Imagestream - adding filename: " . $imagestream_file); debug("DEBUG: using zip PHP extension, set up zip at : " . $imagestreamzippath); $zip->addFile($imagestream_file); debug(" Added files number : " . $zip->numFiles); $wait = $zip->close(); debug("DEBUG: closed zip"); } else { if ($archiver_fullpath) { debug("DEBUG: using archiver, running command: \r\n" . $archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestream_file)); run_command($archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestreamcmd_file)); } else { if (!$use_zip_extension) { if ($config_windows) { debug("DEBUG: using zip command: . {$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file)); exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file)); } else { # Pipe the command file, containing the filenames, to the executable. exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " -@ < " . escapeshellarg($imagestreamcmd_file)); } } } } #Create a JPEG if not already in that format $imagestream_file_parts = explode('.', $imagestream_file); $imagestream_file_ext = $imagestream_file_parts[count($imagestream_file_parts) - 1]; $imagestream_file_noext = basename($imagestream_file, $imagestream_file_ext); global $imagemagick_path, $imagemagick_quality; $icc_transform_complete = false; # Camera RAW images need prefix if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $imagestream_file_ext, $rawext)) { $prefix = $rawext[0] . ':'; } # Locate imagemagick. $convert_fullpath = get_utility_path("im-convert"); if ($convert_fullpath == false) { exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'."); } $prefix = ''; if ($prefix == "cr2:" || $prefix == "nef:") { $flatten = ""; } else { $flatten = "-flatten"; } $command = $convert_fullpath . ' ' . escapeshellarg($targetDir . DIRECTORY_SEPARATOR . $imagestream_file) . ' +matte ' . $flatten . ' -quality ' . $imagemagick_quality; # EXPERIMENTAL CODE TO USE EXISTING ICC PROFILE IF PRESENT global $icc_extraction, $icc_preview_profile, $icc_preview_options, $ffmpeg_supported_extensions; if ($icc_extraction) { $iccpath = $targetDir . DIRECTORY_SEPARATOR . $imagestream_file . '.icc'; if (!file_exists($iccpath) && !isset($iccfound) && $extension != "pdf" && !in_array($imagestream_file_ext, $ffmpeg_supported_extensions)) { // extracted profile doesn't exist. Try extracting. if (extract_icc_profile($ref, $imagestream_file_ext)) { $iccfound = true; } else { $iccfound = false; } } } if ($icc_extraction && file_exists($iccpath) && !$icc_transform_complete) { // we have an extracted ICC profile, so use it as source $targetprofile = dirname(__FILE__) . '/../iccprofiles/' . $icc_preview_profile; $profile = " +profile \"*\" -profile {$iccpath} {$icc_preview_options} -profile {$targetprofile} +profile \"*\" "; $icc_transform_complete = true; } else { // use existing strategy for color profiles # Preserve colour profiles? (omit for smaller sizes) $profile = "+profile \"*\" -colorspace RGB"; # By default, strip the colour profiles ('+' is remove the profile, confusingly) #if ($imagemagick_preserve_profiles && $id!="thm" && $id!="col" && $id!="pre" && $id!="scr") {$profile="";} } $runcommand = $command . " +matte {$profile} " . escapeshellarg($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg"); $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg"; $output = run_command($runcommand); debug("processed file" . $filenumber . ": " . $imagestream_file . "\r\n"); debug("Image index: " . $imageindex . ". file count: " . count($imagestream_filelist)); if ($filenumber == 00) { $snapshotsize = getimagesize($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg"); list($width, $height) = $snapshotsize; # Frame size must be a multiple of two if ($width % 2) { $width++; } if ($height % 2) { $height++; } } if ($imageindex == count($imagestream_filelist) - 1) { $additionalfile = $filenumber + 1; $additionalfile = sprintf("%03d", $additionalfile); copy($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg", $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg"); $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg"; } $filenumber++; } #end of loop for each uploadedfile $imageindex++; } #Add the resource and move this zip file, set extension # Add to collection? if ($collection_add != "") { add_resource_to_collection($ref, $collection_add); } # Log this daily_stat("Resource upload", $ref); resource_log($ref, "u", 0); #Change this!!!!!!!!!!! #$status=upload_file($ref,true,false,false)); if (!$config_windows) { @chmod($imagestreamzippath, 0777); } # Store extension in the database and update file modified time. sql_query("update resource set file_extension='zip',preview_extension='zip',file_modified=now(), has_image=0 where ref='{$ref}'"); #update_field($ref,$filename_field,$filename); update_disk_usage($ref); # create the mp4 version # Add a new alternative file $aref = add_alternative_file($ref, "MP4 version"); $imagestreamqtfile = get_resource_path($ref, true, "", false, "mp4", -1, 1, false, "", $aref); $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile; echo "Running command: " . $shell_exec_cmd; if ($config_windows) { $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile; file_put_contents(get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat", $shell_exec_cmd); $shell_exec_cmd = get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat"; $deletion_array[] = $shell_exec_cmd; } run_command($shell_exec_cmd); debug("DEBUG created slideshow MP4 video"); if (!$config_windows) { @chmod($imagestreamqtfile, 0777); } $file_size = @filesize_unlimited($imagestreamqtfile); # Save alternative file data. sql_query("update resource_alt_files set file_name='quicktime.mp4',file_extension='mp4',file_size='" . $file_size . "',creation_date=now() where resource='{$ref}' and ref='{$aref}'"); #create the FLV preview as per normal video processing if possible? if ($height < $ffmpeg_preview_min_height) { $height = $ffmpeg_preview_min_height; } if ($width < $ffmpeg_preview_min_width) { $width = $ffmpeg_preview_min_width; } if ($height > $ffmpeg_preview_max_height) { $width = ceil($width * ($ffmpeg_preview_max_height / $height)); $height = $ffmpeg_preview_max_height; } if ($width > $ffmpeg_preview_max_width) { $height = ceil($height * ($ffmpeg_preview_max_width / $width)); $width = $ffmpeg_preview_max_width; } $flvzippreviewfile = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension); $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -i " . $imagestreamqtfile . " {$ffmpeg_preview_options} -s {$width}x{$height} " . $flvzippreviewfile; debug("Running command: " . $shell_exec_cmd); if ($config_windows) { file_put_contents(get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreamflv" . $session_hash . ".bat", $shell_exec_cmd); $shell_exec_cmd = get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreamflv" . $session_hash . ".bat"; $deletion_array[] = $shell_exec_cmd; } run_command($shell_exec_cmd); debug("DEBUG created slideshow FLV video"); if (!$config_windows) { @chmod($flvzippreviewfile, 0777); } #Tidy up rcRmdir($imagestream_workingfiles); rcRmdir($targetDir); foreach ($deletion_array as $tmpfile) { debug("\r\nDEBUG: Deleting: " . $tmpfile); delete_exif_tmpfile($tmpfile); } echo "SUCCESS"; #return true; exit; } else { echo "SUCCESS"; exit; } return true; } else { return false; } }
//remove tmp file unlink($tempdir.$filename); set_time_limit(600); // if contact name fields are detected in $_POST if(array_key_exists("field_80",$_POST)){$creator = $_POST['field_80'];contacts($creator,$_POST,80);}; if(array_key_exists("field_184",$_POST)){$creator = $_POST['field_184'];contacts($creator,$_POST, 184);}; if(array_key_exists("field_171",$_POST)){$creator = $_POST['field_171'];contacts($creator, $_POST, 171);}; if(array_key_exists("field_125",$_POST)){$creator = $_POST['field_125'];contacts($creator, $_POST, 125);}; if(array_key_exists("field_177",$_POST)){$creator = $_POST['field_177'];contacts($creator, $_POST, 177);}; if(array_key_exists("field_178",$_POST)){$creator = $_POST['field_178'];contacts($creator, $_POST, 178);}; if(array_key_exists("field_180",$_POST)){$creator = $_POST['field_180'];contacts($creator, $_POST, 180);}; //Update image sizes in database get_original_imagesize($ref,$rs_path,$file_extension); // Update disk usage update_disk_usage($ref); //Bug Fix for Videos not storing width and height values in the resource_dimensions table if($resource_type==3){ $exiftool_fullpath = get_utility_path("exiftool"); $command = $exiftool_fullpath . " -j -sourceImageWidth -sourceImageHeight ".escapeshellarg($rs_path)." 2>&1"; $dimensions = run_command($command); $result=json_decode($dimensions); //if extraction was success if(isset($result[0]->SourceImageWidth) && isset($result[0]->SourceImageHeight)){ $width = $result[0]->SourceImageWidth; $height = $result[0]->SourceImageHeight; $resolution = $width*$height; if(isset($width) && isset($height)){ sql_query("UPDATE resource_dimensions SET width=$width,height=$height,resolution=$resolution WHERE resource = $ref");
// - set a new user to a file // - set file size : no size set when file uploaded by API, execute after file upload // - rename a file // - rename a collection // - move file to another collection // ============================================================ // set a new user to a file if ($set && $file_id && $user_id) { $setUser = sql_query("UPDATE resource SET created_by='{$user_id}' WHERE ref='{$file_id}'"); $newUser = array('new_user' => $user_id, 'file' => $file_id); printJson($newUser); } // set file size : no size set when file uploaded by API // execute after file upload if ($set && $update_file_size && $file_id) { update_disk_usage($file_id); } // rename a file if ($set && $file_id && $new_file_name) { $new_file_name = urldecode($new_file_name); $renameFile = sql_query("UPDATE resource_data SET value=\"{$new_file_name}\" WHERE resource_type_field=51 AND resource='{$file_id}'"); $newFileName = array('new_file_name' => $new_file_name, 'file' => $file_id); printJson($newFileName); } // rename a collection if ($set && $collection_id && $new_collection_name) { $new_collection_name = urldecode($new_collection_name); $new_collection_name = str_replace('_', ' ', $new_collection_name); $renameCollection = sql_query("UPDATE collection SET name=\"{$new_collection_name}\" WHERE ref='{$collection_id}'"); $newCollectionName = array('new_folder_name' => $new_collection_name); printJson($newCollectionName);
$file_size = @filesize_unlimited($path); # Save alternative file data. sql_query("update resource_alt_files set file_name='" . escape_check($plfilename) . "',file_extension='" . escape_check($extension) . "',file_size='" . $file_size . "',creation_date=now() where resource='{$alternative}' and ref='{$aref}'"); if ($alternative_file_previews_batch) { create_previews($alternative, false, $extension, false, false, $aref); } echo "SUCCESS " . htmlspecialchars($alternative) . ", " . htmlspecialchars($aref); // Check to see if we need to notify users of this change if ($notify_on_resource_change_days != 0) { // we don't need to wait for this.. ob_flush(); flush(); notify_resource_change($replace_resource); } # Update disk usage update_disk_usage($resource); exit; } if ($replace == "" && $replace_resource == "") { # Standard upload of a new resource # create ref via copy_resource() or other method $modified_ref = hook("modifyuploadref"); if ($modified_ref != "") { $ref = $modified_ref; } else { $ref = copy_resource(0 - $userref); # Copy from user template } # Add to collection? if ($collection_add != "") { add_resource_to_collection($ref, $collection_add);