function write_copy_protection($outputfilename, $copystatus) { $new_ps_file_info_array = array('title' => "", 'author' => "Hamsterpaj.net", 'authorsposition' => "", 'caption' => "", 'captionwriter' => $_SESSION['login']['id'], 'jobname' => "", 'copyrightstatus' => $copystatus, 'copyrightnotice' => "", 'ownerurl' => "", 'keywords' => array(), 'category' => "", 'supplementalcategories' => array(), 'date' => date("Y-m-d"), 'city' => "", 'state' => "", 'country' => "", 'credit' => "", 'source' => "", 'headline' => "", 'instructions' => "", 'transmissionreference' => "", 'urgency' => ""); foreach ($new_ps_file_info_array as $var_key => $var_val) { $new_ps_file_info_array[$var_key] = stripslashes($var_val); } // Keywords should be an array - explode it on newline boundarys $new_ps_file_info_array['keywords'] = explode("\n", trim($new_ps_file_info_array['keywords'])); // Supplemental Categories should be an array - explode it on newline boundarys $new_ps_file_info_array['supplementalcategories'] = explode("\n", trim($new_ps_file_info_array['supplementalcategories'])); // Protect against hackers editing other files $path_parts = pathinfo($outputfilename); if (strcasecmp($path_parts["extension"], "jpg") != 0) { return "Incorrect File Type - JPEG Only\n"; exit; } // Change: removed limitation on file being in current directory - as of version 1.11 // Retrieve the header information $jpeg_header_data = get_jpeg_header_data($outputfilename); // Update the JPEG header information with the new Photoshop File Info $jpeg_header_data = put_photoshop_file_info($jpeg_header_data, $new_ps_file_info_array); // Check if the Update worked if ($jpeg_header_data == FALSE) { // Update of file info didn't work - output error message return "Error - Failure update File Info : {$outputfilenam} <br>\n"; exit; } // Attempt to write the new JPEG file if (FALSE == put_jpeg_header_data($outputfilename, $outputfilename, $jpeg_header_data)) { // Writing of the new file didn't work - output error message return "Error - Failure to write new JPEG : {$filename} <br>\n"; // Abort processing exit; } //return "<p><a href=\"Edit_File_Info_Example.php?jpeg_fname=$outputfilename\" >View Full Metatdata Information</a></p>\n"; }
// Protect against hackers editing other files $path_parts = pathinfo($filename); if (strcasecmp($path_parts["extension"], "jpg") != 0) { echo "Incorrect File Type - JPEG Only\n"; exit; } // Change: removed limitation on file being in current directory - as of version 1.11 // Retrieve the header information $jpeg_header_data = get_jpeg_header_data($filename); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated $Exif_array = get_EXIF_JPEG($filename); $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); $IRB_array = get_Photoshop_IRB($jpeg_header_data); // Update the JPEG header information with the new Photoshop File Info $jpeg_header_data = put_photoshop_file_info($jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array); // Check if the Update worked if ($jpeg_header_data == FALSE) { // Update of file info didn't work - output error message echo "Error - Failure update Photoshop File Info : {$filename} <br>\n"; // Output HTML with the form and data which was // sent, to allow the user to fix it $outputfilename = $filename; include "Edit_File_info.php"; echo "</body>\n"; echo "</html>\n"; // Abort processing exit; } // Attempt to write the new JPEG file if (FALSE == put_jpeg_header_data($filename, $filename, $jpeg_header_data)) {
/** * function to update image metadata */ function metadata_image($metadata_conf) { if (is_array($metadata_conf) && count($metadata_conf) > 0) { include_once 'metadata/Toolkit_Version.php'; error_reporting(0); include_once 'metadata/JPEG.php'; include_once 'metadata/XMP.php'; include_once 'metadata/Photoshop_IRB.php'; include_once 'metadata/EXIF.php'; include_once 'metadata/Photoshop_File_Info.php'; // Copy all of the HTML Posted variables into an array //$new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; $new_ps_file_info_array = $metadata_conf; $filename = $new_ps_file_info_array['filename']; //echo $filename; // Protect against hackers editing other files $path_parts = pathinfo($filename); $array_extention = array('png', 'jpg'); if (strcasecmp($path_parts["extension"], "jpg") != 0) { //if (!in_array($path_parts["extension"], $array_extention)) #echo "Incorrect File Type - JPEG Only\n"; return array('status' => 'failed', 'message' => 'Incorrect File Type - JPEG Only'); exit; } // Change: removed limitation on file being in current directory - as of version 1.11 // Retrieve the header information $jpeg_header_data = get_jpeg_header_data($filename); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated $Exif_array = get_EXIF_JPEG($filename); $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); $IRB_array = get_Photoshop_IRB($jpeg_header_data); // Update the JPEG header information with the new Photoshop File Info $jpeg_header_data = put_photoshop_file_info($jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array); // Check if the Update worked if ($jpeg_header_data == FALSE) { //echo '$jpeg_header_data false'; return array('status' => 'failed', 'message' => 'Error - Failure update Photoshop File Info : ' . $filename); // Abort processing exit; } // Attempt to write the new JPEG file if (FALSE == put_jpeg_header_data($filename, $filename, $jpeg_header_data)) { //echo 'put_jpeg_header_data false'; return array('status' => 'failed', 'message' => 'Error - Failure to write new JPEG : ' . $filename); // Abort processing exit; } return array('status' => 'succes', 'message' => $filename . ' updated'); } }