[Linpha-cvs] SF.net SVN: linpha: [4661] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-11-23 21:46:30
|
Revision: 4661 http://svn.sourceforge.net/linpha/?rev=4661&view=rev Author: fangehrn Date: 2006-11-23 13:46:25 -0800 (Thu, 23 Nov 2006) Log Message: ----------- 2006-11-23 flo * todo: only save iptc data if we entered some data in the iptc form -- done * todo: show full exif informations with pjmt/ShowFileInfo.php (provide security!) -- done Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/metadata_define_post.php trunk/linpha2/admin/metadata_select.php trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/classes/pjmt/Photoshop_File_Info.php trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/modules/module.ajax.php trunk/linpha2/lib/modules/module.browse.php trunk/linpha2/templates/default/fragments.php trunk/linpha2/templates/default/themes/default/css/view_img.css trunk/linpha2/templates/default/view_img.html.php Added Paths: ----------- trunk/linpha2/lib/include/File_Info_Edit.php trunk/linpha2/lib/include/File_Info_Show.php Removed Paths: ------------- trunk/linpha2/lib/classes/pjmt/ShowFileInfo.php trunk/linpha2/lib/include/Edit_File_Info.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/ChangeLog 2006-11-23 21:46:25 UTC (rev 4661) @@ -1,7 +1,9 @@ +2006-11-23 flo + * todo: only save iptc data if we entered some data in the iptc form -- done + * todo: show full exif informations with pjmt/ShowFileInfo.php (provide security!) -- done + 2006-11-19 flo * mostly finished iptc write support - @todo only save iptc data if we entered some data in the iptc form - @todo show full exif informations with pjmt/ShowFileInfo.php (provide security!) 2006-11-17 flo * nearly finished meta data support Modified: trunk/linpha2/admin/metadata_define_post.php =================================================================== --- trunk/linpha2/admin/metadata_define_post.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/admin/metadata_define_post.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -15,7 +15,7 @@ $linpha->db->Execute("UPDATE ".LIN_PREFIX."meta_fields SET " . "flags = '".$flag."' ". - "WHERE id = '".linSql::linAddslashes($key)."'"); + "WHERE id = '".LinSql::linAddslashes($key)."'"); } break; @@ -24,20 +24,20 @@ * check for duplicates with the same name */ $linpha->db->Execute("INSERT into ".LIN_PREFIX."meta_fields (name, field_type, flags) " . - "VALUES ('".linSql::linAddslashes($_POST['new_name'])."', '".linSql::linAddslashes($_POST['new_type'])."', '7') "); + "VALUES ('".LinSql::linAddslashes($_POST['new_name'])."', '".LinSql::linAddslashes($_POST['new_type'])."', '7') "); break; case 'change_field': - if(linSql::linAddslashes($_POST['builtin'][$_POST['id']])) { + if(LinSql::linAddslashes($_POST['builtin'][$_POST['id']])) { $flag = 7; } else { $flag = 8; } $linpha->db->Execute("UPDATE ".LIN_PREFIX."meta_fields SET " . - "name = '".linSql::linAddslashes($_POST['new_name'])."', ". + "name = '".LinSql::linAddslashes($_POST['new_name'])."', ". "flags = '".$flag."' ". - "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; case 'delete': ?> @@ -53,7 +53,7 @@ <?php break; case 'do_delete': - $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_fields WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_fields WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; case 'add_new_category': if(isset($_POST['isprivate'])) { @@ -62,8 +62,8 @@ $isprivate = 0; } $linpha->db->Execute("INSERT into ".LIN_PREFIX."meta_category (field_id, name, isprivate) VALUES (" . - "'".linSql::linAddslashes($_POST['field_id'])."'," . - "'".linSql::linAddslashes($_POST['new_name'])."'," . + "'".LinSql::linAddslashes($_POST['field_id'])."'," . + "'".LinSql::linAddslashes($_POST['new_name'])."'," . "'".$isprivate."')"); break; @@ -75,13 +75,13 @@ } $linpha->db->Execute("UPDATE ".LIN_PREFIX."meta_category SET " . - "name = '".linSql::linAddslashes($_POST['new_name'])."', ". + "name = '".LinSql::linAddslashes($_POST['new_name'])."', ". "isprivate = '".$isprivate."' ". - "WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + "WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; case 'delete_category': - $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_category WHERE id = '".linSql::linAddslashes($_POST['id'])."'"); + $linpha->db->Execute("DELETE FROM ".LIN_PREFIX."meta_category WHERE id = '".LinSql::linAddslashes($_POST['id'])."'"); break; case 'update_exifiptc': $linpha->sql->config->updateConfig('sys_image_'.$cat3,$_POST['exifiptc_enable']); Modified: trunk/linpha2/admin/metadata_select.php =================================================================== --- trunk/linpha2/admin/metadata_select.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/admin/metadata_select.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -66,7 +66,7 @@ foreach($_POST['select_image_fields'] AS $value) { $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_fields (name, flags)" . - " VALUES ('".linSql::linAddslashes($value)."','".$flag_nr."')"); + " VALUES ('".LinSql::linAddslashes($value)."','".$flag_nr."')"); } } } Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/index.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -55,6 +55,9 @@ case 'newimg': require_once(LINPHA_DIR.'/lib/modules/module.newimg.php'); break; +case 'exif': + require_once(LINPHA_DIR.'/lib/include/File_Info_Show.php'); + break; case 'empty': require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); break; Modified: trunk/linpha2/lib/classes/linpha.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.class.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/linpha.class.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -45,7 +45,7 @@ function __construct() { - $this->sql = new linSql(); + $this->sql = new LinSql(); /** * some defines Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -90,7 +90,7 @@ * set file informations */ $current_data = $GLOBALS['linpha']->db->GetRow("SELECT id, name, img_type, parent_id, md5sum, width, height FROM ".LIN_PREFIX."photos " . - "WHERE id = '".linSql::linAddslashes($GLOBALS['linpha']->template->idCurrent)."'"); + "WHERE id = '".LinSql::linAddslashes($GLOBALS['linpha']->template->idCurrent)."'"); /** * check for valid id */ @@ -1286,8 +1286,8 @@ } $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_comments (meta_time, md5sum, meta_author, meta_comment)" . - "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['inputAddCommentAuthor'])."'," . - "'".linSql::linAddslashes($comment)."')"); + "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".LinSql::linAddslashes($_POST['inputAddCommentAuthor'])."'," . + "'".LinSql::linAddslashes($comment)."')"); $this->newCommentAdded = true; // used for ajax } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -777,46 +777,53 @@ } // end function showEditMetaData() + /** + * save meta linpha and meta iptc separetaly + */ function saveModifiedMetaData() { if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { - if(isset($_POST['cmd']) && $_POST['cmd']=='insert_metadata') + /** + * write linpha meta data + */ + if(isset($_POST['linCmd']) && $_POST['linCmd']=='linInsertMetaLinpha') { LinMetaDataModificate::saveModifiedMetaDataLinpha(); + } + + /** + * write iptc data + */ + if( isset($_POST['linCmd']) + && $_POST['linCmd']=='linInsertMetaIptc' + && $GLOBALS['linpha']->sql->config->value['sys_image_iptc'] + && isset($GLOBALS['linpha']->imgview->src_file) + && file_exists($GLOBALS['linpha']->imgview->src_file) ) + { + global $new_ps_file_info_array; + $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc'] - && isset($GLOBALS['linpha']->imgview->src_file) - && file_exists($GLOBALS['linpha']->imgview->src_file) - ) + /** + * important! + * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! + * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this + */ + unset($new_ps_file_info_array['linCmd']); + unset($new_ps_file_info_array['linMetaField']); + unset($new_ps_file_info_array['submit']); + + if( LinMetaDataModificate::saveModifiedMetaDataIptc( $new_ps_file_info_array ) ) { /** - * write iptc data + * force read data from file again if write was successful */ - global $new_ps_file_info_array; - $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; - - /** - * important! - * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! - * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this - */ - unset($new_ps_file_info_array['cmd']); - unset($new_ps_file_info_array['linMetaField']); - unset($new_ps_file_info_array['submit']); - - if( LinMetaDataModificate::saveModifiedMetaDataIptc( $new_ps_file_info_array ) ) - { - /** - * force read data from file again if write was successful - */ - unset($new_ps_file_info_array); - LinImport::updateEntry( - $GLOBALS['linpha']->template->idCurrent , - dirname($GLOBALS['linpha']->imgview->src_file) , - basename($GLOBALS['linpha']->imgview->src_file) - ); - } + unset($new_ps_file_info_array); + LinImport::updateEntry( + $GLOBALS['linpha']->template->idCurrent , + dirname($GLOBALS['linpha']->imgview->src_file) , + basename($GLOBALS['linpha']->imgview->src_file) + ); } } } @@ -859,8 +866,6 @@ * save iptc metadata back to file * * copied from pjmt/Write_File_Info.php - * - * @todo only save data if we entered some data in the iptc form!! */ function saveModifiedMetaDataIptc( & $new_ps_file_info_array ) { @@ -933,7 +938,7 @@ /** * echo "Error - Failure update Photoshop File Info : $filename <br>\n"; */ - linSysLog( i18n("Error - Failure update Photoshop File Info :" .' '. $filename) ); + linSysLog( i18n("Error: Failure update Photoshop File Info:" .' '. $filename) ); // Output HTML with the form and data which was // sent, to allow the user to fix it Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -176,7 +176,7 @@ /** - * register sub class linSqlConfig + * register sub class LinSqlConfig * (not during install, because we dont have any config table yet) */ if( ! isset($_SESSION['installmode2']) ) @@ -489,7 +489,7 @@ { $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".LIN_PREFIX."permissions " . "WHERE perm_type = '".LinSql::linAddslashes($perm_type)."' " . - "AND photos_id = '".linSql::linAddslashes($photos_id)."'"); + "AND photos_id = '".LinSql::linAddslashes($photos_id)."'"); if( isset( $data[0] ) && !empty( $data[0] ) ) { @@ -822,11 +822,11 @@ setcookie("linpha_password", $md5pw, (time() + 60 * 60 * 24 * 31), $php_self_dir); } -} // end class linSql +} // end class LinSql /** - * sub-class linSqlConfig + * sub-class LinSqlConfig */ class LinSqlConfig { @@ -934,6 +934,6 @@ } } -} // end sub-class linSqlConfig +} // end sub-class LinSqlConfig ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/pjmt/Photoshop_File_Info.php =================================================================== --- trunk/linpha2/lib/classes/pjmt/Photoshop_File_Info.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/pjmt/Photoshop_File_Info.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -912,7 +912,7 @@ if ( count( $date_pieces ) != 3 ) { // INVALID DATE - echo "Invalid Date - must be YYYY-MM-DD format<br>"; + linSysLog( i18n("Invalid Date - must be YYYY-MM-DD format") ); return FALSE; } @@ -923,7 +923,7 @@ if ( ! is_numeric( $piece ) ) { // INVALID DATE - echo "Invalid Date - must be YYYY-MM-DD format<br>"; + linSysLog( i18n("Invalid Date - must be YYYY-MM-DD format") ); return FALSE; } } Deleted: trunk/linpha2/lib/classes/pjmt/ShowFileInfo.php =================================================================== --- trunk/linpha2/lib/classes/pjmt/ShowFileInfo.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/classes/pjmt/ShowFileInfo.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -1,218 +0,0 @@ -<html> - -<!--*************************************************************************** -* -* Filename: Example.php -* -* Description: An example of how the PHP JPEG Metadata Toolkit can be used to -* display JPEG Metadata. -* -* Author: Evan Hunter -* -* Date: 30/7/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.11 -* -* Changes: 1.00 -> 1.10 : Changed name of GET parameter from 'filename' to 'jpeg_fname' -* to stop script-kiddies using the google command 'allinurl:*.php?filename=*' -* to find servers to attack -* Changed behavior when no filename is given, to be cleaner -* 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php -* Changed this example file to be easily relocatable -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit is free software; you can -* redistribute it and/or modify it under the terms of the -* GNU General Public License as published by the Free Software -* Foundation; either version 2 of the License, or (at your -* option) any later version. -* -* The PHP JPEG Metadata Toolkit is distributed in the hope -* that it will be useful, but WITHOUT ANY WARRANTY; without -* even the implied warranty of MERCHANTABILITY or FITNESS -* FOR A PARTICULAR PURPOSE. See the GNU General Public License -* for more details. -* -* You should have received a copy of the GNU General Public -* License along with the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************--> - - <head> - - <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> - <STYLE TYPE="text/css" MEDIA="screen, print, projection"> - <!-- - - BODY { background-color:#505050; color:#F0F0F0 } - a { color:orange } - .EXIF_Main_Heading { color:red } - .EXIF_Secondary_Heading{ color: orange} - .EXIF_Table { border-collapse: collapse ; border: 1px solid #909000} - .EXIF_Table tbody td{border-width: 1px; border-style:solid; border-color: #909000;} - - --> - </STYLE> - - - <?php - // Turn off Error Reporting - error_reporting ( 0 ); - - // Change: Allow this example file to be easily relocatable - as of version 1.11 - $Toolkit_Dir = "./"; // Ensure dir name includes trailing slash - - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - include $Toolkit_Dir . 'Toolkit_Version.php'; // Change: added as of version 1.11 - include $Toolkit_Dir . 'JPEG.php'; // Change: Allow this example file to be easily relocatable - as of version 1.11 - include $Toolkit_Dir . 'JFIF.php'; - include $Toolkit_Dir . 'PictureInfo.php'; - include $Toolkit_Dir . 'XMP.php'; - include $Toolkit_Dir . 'Photoshop_IRB.php'; - include $Toolkit_Dir . 'EXIF.php'; - - // Retrieve the JPEG image filename from the http url request - if ( ( !array_key_exists( 'jpeg_fname', $GLOBALS['HTTP_GET_VARS'] ) ) || - ( $GLOBALS['HTTP_GET_VARS']['jpeg_fname'] == "" ) ) - { - echo "<title>No image filename defined</title>\n"; - echo "</head>\n"; - echo "<body>\n"; - echo "<p>No image filename defined - use GET method with field: jpeg_fname</p>\n"; - echo "<p><a href=\"http://www.ozhiker.com/electronics/pjmt/\" >PHP JPEG Metadata Toolkit version " . $GLOBALS['Toolkit_Version'] . ", Copyright (C) 2004 Evan Hunter</a></p>\n"; // Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 - echo "</body>\n"; - exit( ); - } - else - { - $filename = $GLOBALS['HTTP_GET_VARS']['jpeg_fname']; - } - - - // Output the title - echo "<title>Metadata details for $filename</title>"; - - // Retrieve the header information - $jpeg_header_data = get_jpeg_header_data( $filename ); - - ?> - - </head> - - <body> - - <p>Interpreted using: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> <!-- Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 --> - <br> - <br> - - <h1><B><U>Metadata for "<?php echo $filename; ?>"</U></B></h1> - <br> - - <!-- Output a link allowing user to edit the Photoshop File Info - Change: Allow this example file to be easily relocatable - as of version 1.11 - --> - <?php $relative_filename = get_relative_path( $filename, $Toolkit_Dir ); ?> - <h4><a href="<?php echo $Toolkit_Dir."Edit_File_Info_Example.php?jpeg_fname=$relative_filename"; ?>" >Click here to edit the Photoshop File Info for this file</a></h4> - <br> - - - - <!-- Output the information about the APP segments --> - <?php echo Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Intrinsic JPEG Information --> - <?php echo Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JPEG Comment --> - <?php echo Interpret_Comment_to_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JPEG File Interchange Format Information --> - <?php echo Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the JFIF Extension Information --> - <?php echo Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Picture Info Text --> - <?php echo Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the EXIF Information --> - <?php echo Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the XMP Information --> - <?php echo Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ) ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Photoshop IRB (including the IPTC-NAA info --> - <?php echo Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Output the Meta Information --> - <?php echo Interpret_EXIF_to_HTML( get_Meta_JPEG( $filename ), $filename ); ?> - - <BR> - <HR> - <BR> - - <!-- Display the original image --> - - <h2>Original Image</h2> - <?php echo "<img src=\"$filename\">"; ?> - - - <BR> - <BR> - <BR> - <p>Interpreted using:</p> - <p><a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> <!-- Change: displayed toolkit version numbers to reference Toolkit_Version.php - as of version 1.11 --> - - </body> - -</html> \ No newline at end of file Deleted: trunk/linpha2/lib/include/Edit_File_Info.php =================================================================== --- trunk/linpha2/lib/include/Edit_File_Info.php 2006-11-19 20:41:34 UTC (rev 4660) +++ trunk/linpha2/lib/include/Edit_File_Info.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -1,562 +0,0 @@ -<?php -if(!defined('LINPHA_DIR')) { exit(1); } - -/**************************************************************************** -* -* Filename: Edit_File_Info.php -* -* Description: Allows the user to edit the metadata of an image over the internet -* in the same way that Photoshop edits 'File Info' data -* This file provides only the html for a form containing the file info -* input fields. The rest of the html file must be provided by the calling script. -* $outputfilename must always be defined - it is ne name of the file which -* have the metadata changed after the form has been submitted -* -* This file has several modes of operation: -* -* 1) If $new_ps_file_info_array is defined then it's data will be used -* to fill the fields. -* 2) If $new_ps_file_info_array is not defined but $filename is defined, -* then the file info fields will be filled from the metadata in the file specified -* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array -* are defined, then the file info fields will be filled from the metadata -* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array -* 4) Otherwise the fields will be blank -* -* See Edit_File_Info_Example.php for an example of usage -* -* Author: Evan Hunter -* -* Date: 17/11/2004 -* -* Project: PHP JPEG Metadata Toolkit -* -* Revision: 1.11 -* -* Changes: 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php -* -* URL: http://electronics.ozhiker.com -* -* Copyright: Copyright Evan Hunter 2004 -* -* License: This file is part of the PHP JPEG Metadata Toolkit. -* -* The PHP JPEG Metadata Toolkit is free software; you can -* redistribute it and/or modify it under the terms of the -* GNU General Public License as published by the Free Software -* Foundation; either version 2 of the License, or (at your -* option) any later version. -* -* The PHP JPEG Metadata Toolkit is distributed in the hope -* that it will be useful, but WITHOUT ANY WARRANTY; without -* even the implied warranty of MERCHANTABILITY or FITNESS -* FOR A PARTICULAR PURPOSE. See the GNU General Public License -* for more details. -* -* You should have received a copy of the GNU General Public -* License along with the PHP JPEG Metadata Toolkit; if not, -* write to the Free Software Foundation, Inc., 59 Temple -* Place, Suite 330, Boston, MA 02111-1307 USA -* -* If you require a different license for commercial or other -* purposes, please contact the author: ev...@oz... -* -***************************************************************************/ - - - - include LINPHA_DIR.'/lib/classes/pjmt/Toolkit_Version.php'; // Change: added as of version 1.11 - - // Check for operation modes 2 or 3 - // i.e. $filename is defined, and $new_ps_file_info_array is not - if ( ( ! isset( $new_ps_file_info_array ) ) && - ( isset( $filename ) ) && - ( is_string( $filename ) ) ) - { - // Hide any unknown EXIF tags - $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; - - // Accessing the existing file info for the specified file requires these includes - include_once( LINPHA_DIR.'/lib/classes/pjmt/JPEG.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/XMP.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_IRB.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/EXIF.php' ); - include_once( LINPHA_DIR.'/lib/classes/pjmt/Photoshop_File_Info.php' ); - - // Retrieve the header information from the JPEG file - $jpeg_header_data = get_jpeg_header_data( $filename ); - - // Retrieve EXIF information from the JPEG file - $Exif_array = get_EXIF_JPEG( $filename ); - - // Retrieve XMP information from the JPEG file - $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) ); - - // Retrieve Photoshop IRB information from the JPEG file - $IRB_array = get_Photoshop_IRB( $jpeg_header_data ); - - // Retrieve Photoshop File Info from the three previous arrays - $new_ps_file_info_array = get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array ); - - - - // Check if there is an array of defaults available - if ( ( isset( $default_ps_file_info_array) ) && - ( is_array( $default_ps_file_info_array) ) ) - { - // There are defaults defined - - // Check if there is a default for the date defined - if ( ( ! array_key_exists( 'date', $default_ps_file_info_array ) ) || - ( ( array_key_exists( 'date', $default_ps_file_info_array ) ) && - ( $default_ps_file_info_array['date'] == '' ) ) ) - { - // No default for the date defined - // figure out a default from the file - - // Check if there is a EXIF Tag 36867 "Date and Time of Original" - if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36867, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time of Original" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36867]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 34665, $Exif_array[0] ) ) && - ( array_key_exists( 0, $Exif_array[0][34665] ) ) && - ( array_key_exists( 36868, $Exif_array[0][34665][0] ) ) ) - { - // Tag "Date and Time when Digitized" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36868]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - // Check if there is a EXIF Tag 306 "Date and Time" - else if ( ( $Exif_array != FALSE ) && - ( array_key_exists( 0, $Exif_array ) ) && - ( array_key_exists( 306, $Exif_array[0] ) ) ) - { - // Tag "Date and Time" found - use it for the default date - $default_ps_file_info_array['date'] = $Exif_array[0][306]['Data'][0]; - $default_ps_file_info_array['date'] = preg_replace( "/(\d\d\d\d):(\d\d):(\d\d)( \d\d:\d\d:\d\d)/", "$1-$2-$3", $default_ps_file_info_array['date'] ); - } - else - { - // Couldn't find an EXIF date in the image - // Set default date as creation date of file - $default_ps_file_info_array['date'] = date ("Y-m-d", filectime( $filename )); - } - } - - // Cycle through all the elements of the default values array - foreach( $default_ps_file_info_array as $def_key =>$default_item ) - { - // Check if the current element is Keywords or - // Supplemental Categories as these are arrays - // and need to be treated differently - if ( ( strcasecmp( $def_key, "keywords" ) == 0 ) || - ( strcasecmp( $def_key, "supplementalcategories" ) == 0 ) ) - { - // Keywords or Supplemental Categories found - // Check if the File Info from the file is empty for this element - // and if there are default values in this array element - if ( ( count( $new_ps_file_info_array[ $def_key ] ) == 0 ) && - ( is_array( $default_item ) ) && - ( count( $default_item ) >= 0 ) ) - { - // The existing file info is empty, and there are - // defaults - add them - $new_ps_file_info_array[ $def_key ] = $default_item; - } - } - // Otherwise, this is not an array element, just check if it is blank in the existing file info - else if ( trim( $new_ps_file_info_array[ $def_key ] ) == "" ) - { - // The existing file info is blank, add the default value - $new_ps_file_info_array[ $def_key ] = $default_item; - } - - } - } - } - // Check for operation mode 4 - $new_ps_file_info_array and $filename are not defined, - else if ( ( ( !isset($new_ps_file_info_array) ) || ( ! is_array($new_ps_file_info_array) ) ) && - ( ( !isset($filename) ) || ( ! is_string( $filename ) ) ) ) - { - // No filename or new_ps_file_info_array defined, create a blank file info array to display - $new_ps_file_info_array = array( - "title" => "", - "author" => "", - "authorsposition" => "", - "caption" => "", - "captionwriter" => "", - "jobname" => "", - "copyrightstatus" => "", - "copyrightnotice" => "", - "ownerurl" => "", - "keywords" => array(), - "category" => "", - "supplementalcategories" => array(), - "date" => "", - "city" => "", - "state" => "", - "country" => "", - "credit" => "", - "source" => "", - "headline" => "", - "instructions" => "", - "transmissionreference" => "", - "urgency" => "" ); - } - - - -/*************************************************************************** -* -* Now output the actual HTML form -* -***************************************************************************/ -/** -?> - - - - - <form name="EditJPEG" action="Write_File_Info.php" method="post"> - - - echo "<input name=\"filename\" type=\"hidden\" value=\"$outputfilename\">"; - - <table> -*/ -?> - <tr> - <td> - Title - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"title\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'title' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Author - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"author\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'author' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - <tr> - <td> - Authors Position - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"authorsposition\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'authorsposition' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop 7 or higher"; - ?> - </td> - </tr> - - <tr> - <td> - Description - </td> - <td> - <textarea name="caption" class="linForms" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'caption' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Description Writer - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"captionwriter\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'captionwriter' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Keywords - </td> - <td> - <textarea class="linForms" name="keywords" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword ) - { - echo htmlspecialchars($keyword, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Status - </td> - <td> - <select size=1 class="linForms" name="copyrightstatus"> - <?php - $copystatus = $new_ps_file_info_array[ 'copyrightstatus' ]; - if ( $copystatus == "Unknown" ) - { - echo "<option value=\"Unknown\" SELECTED >Unknown</option>\n"; - } - else - { - echo "<option value=\"Unknown\">Unknown</option>\n"; - } - - if ( $copystatus == "Copyrighted Work" ) - { - echo "<option value=\"Copyrighted Work\" SELECTED >Copyrighted Work</option>\n"; - } - else - { - echo "<option value=\"Copyrighted Work\">Copyrighted Work</option>\n"; - } - - if ( $copystatus == "Public Domain" ) - { - echo "<option value=\"Public Domain\" SELECTED >Public Domain</option>\n"; - } - else - { - echo "<option value=\"Public Domain\">Public Domain</option>\n"; - } - ?> - </select> - </td> - </tr> - - - <tr> - <td> - Copyright Notice - </td> - <td> - <textarea class="linForms" name="copyrightnotice" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'copyrightnotice' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Copyright Info URL - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"ownerurl\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\">\n"; - if ($new_ps_file_info_array[ 'ownerurl' ] != "" ) - { - echo "<a href=\"". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) ."\" > (". htmlspecialchars($new_ps_file_info_array[ 'ownerurl' ], ENT_QUOTES) .")</a>\n"; - } - ?> - - </td> - </tr> - - - <tr> - <td> - Category - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"category\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'category' ], ENT_QUOTES) ."\">\n"; - ?> - - </td> - </tr> - - <tr> - <td> - Supplemental Categories - </td> - <td> - <textarea class="linForms" name="supplementalcategories" rows=3 cols=37 wrap="off"><?php - foreach( $new_ps_file_info_array[ 'supplementalcategories' ] as $supcat ) - { - echo htmlspecialchars($supcat, ENT_QUOTES)."
"; - } - ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Date Created - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"date\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'date' ], ENT_QUOTES) ."\">"; - ?> - - Note date must be YYYY-MM-DD format - </td> - </tr> - - <tr> - <td> - City - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"city\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'city' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - State - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"state\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'state' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Country - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"country\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'country' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Credit - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"credit\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'credit' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - <tr> - <td> - Source - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"source\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'source' ], ENT_QUOTES) ."\">"; - ?> - </td> - </tr> - - - - <tr> - <td> - Headline - </td> - <td> - <textarea class="linForms" name="headline" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'headline' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - - <tr> - <td> - Instructions - </td> - <td> - <textarea class="linForms" name="instructions" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'instructions' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - - <tr> - <td> - Transmission Reference - </td> - <td> - <textarea class="linForms" name="transmissionreference" rows=3 cols=37 wrap="off"><?php echo htmlspecialchars($new_ps_file_info_array[ 'transmissionreference' ], ENT_QUOTES); ?></textarea> - </td> - </tr> - - <tr> - <td> - Job Name - </td> - <td> - <?php - echo "<input size=49 class=\"linForms\" name=\"jobname\" type=\"text\" value=\"". htmlspecialchars($new_ps_file_info_array[ 'jobname' ], ENT_QUOTES) ."\"> - Note: not used in Photoshop CS"; - ?> - </td> - </tr> - - <tr> - <td> - Urgency - </td> - <td> - <select size="1" class="linForms" name="urgency"> - <?php - for( $i = 1; $i <= 8; $i++ ) - { - echo "<option value=\"$i\""; - if ( $new_ps_file_info_array[ 'urgency' ] == $i ) - { - echo " SELECTED "; - } - echo ">"; - if ( $i == 1 ) - { - echo "High"; - } - else if ( $i == 5 ) - { - echo "Normal"; - } - else if ( $i == 8 ) - { - echo "Low"; - } - else - { - echo "$i"; - } - echo "</option>\n"; - } - if ( $new_ps_file_info_array[ 'urgency' ] == "none" ) - { - echo "<option value=\"none\" SELECTED >None</option>"; - } - else - { - echo "<option value=\"none\" >None</option>"; - } - ?> - - </select> - </td> - </tr> Copied: trunk/linpha2/lib/include/File_Info_Edit.php (from rev 4660, trunk/linpha2/lib/include/Edit_File_Info.php) =================================================================== --- trunk/linpha2/lib/include/File_Info_Edit.php (rev 0) +++ trunk/linpha2/lib/include/File_Info_Edit.php 2006-11-23 21:46:25 UTC (rev 4661) @@ -0,0 +1,590 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +/**************************************************************************** +* +* Filename: Edit_File_Info.php +* +* Description: Allows the user to edit the metadata of an image over the internet +* in the same way that Photoshop edits 'File Info' data +* This file provides only the html for a form containing the file info +* input fields. The rest of the html file must be provided by the calling script. +* $outputfilename must always be defined - it is ne name of the file which +* have the metadata changed after the form has been submitted +* +* This file has several modes of operation: +* +* 1) If $new_ps_file_info_array is defined then it's data will be used +* to fill the fields. +* 2) If $new_ps_file_info_array is not defined but $filename is defined, +* then the file info fields will be filled from the metadata in the file specified +* 3) If $new_ps_file_info_array is not defined but $filename and $default_ps_file_info_array +* are defined, then the file info fields will be filled from the metadata +* in the file specified, but where fields are blank, they will be filled from $default_ps_file_info_array +* 4) Otherwise the fields will be blank +* +* See Edit_File_Info_Example.php for an example of usage +* +* Author: Evan Hunter +* +* Date: 17/11/2004 +* +* Project: PHP JPEG Metadata Toolkit +* +* Revision: 1.11 +* +* Changes: 1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php +* +* URL: http://electronics.ozhiker.com +* +* Copyright: Copyright Evan Hunter 2004 +* +* License: This file is part of the PHP JPEG Metadata Toolkit. +* +* The PHP JPEG Metadata Toolkit is free software; you can +* redistribute it and/or modify it under the terms of the +* GNU General Public License as published by the Free Software +* Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* The PHP JPEG Metadata Toolkit is distributed in the hope +* that it will be useful, but WITHOUT ANY WARRANTY; without +* even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +* You should have received a copy of the GNU General Public +* License along with the PHP JPEG Metadata Toolkit; if not, +* write to the Free Software Foundation, Inc., 59 Temple +* Place, Suite 330, Boston, MA 02111-1307 USA +* +* If you require a different license for commercial or other +* purposes, please contact the author: ev...@oz... +* +***************************************************************************/ + +/** + * if $default_ps_file_info_array is set and the key 'date' is empty + * it will be auto filled with the exif date and we prevent errors like + * "Invalid Date - must be YYYY-MM-DD format" + */ +$default_ps_file_info_array = array ( + 'title' => "", + 'author' => "", + 'authorsposition' => "", + 'caption' => "", + 'captionwriter' => "", + 'jobname' => "", + 'copyrightstatus' => "", + 'copyrightnotice' => "", + 'ownerurl' => "", + 'keywords' => array(), + 'category' => "", + 'supplementalcategories'=> array(), + 'date' => "", + 'city' => "", + 'state' => "", + 'country' => "", + 'credit' => "", + 'source' => "", + 'headline' => "", + 'instructions' => "", + 'transmissionreference' => "", + 'urgency' => "" + ); + + ... [truncated message content] |