1<?php 2/************************* 3 Coppermine Photo Gallery 4 ************************ 5 Copyright (c) 2003-2016 Coppermine Dev Team 6 v1.0 originally written by Gregory Demar 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License version 3 10 as published by the Free Software Foundation. 11 12 ******************************************** 13 Coppermine version: 1.6.03 14 $HeadURL$ 15**********************************************/ 16 17function strip_IPTC($data) { 18 if (is_array($data)) { 19 foreach ($data as $key=>$item) { 20 $data[$key]=strip_IPTC($item); 21 } 22 } else { 23 $data=htmlentities(strip_tags(trim($data,"\x7f..\xff\x0..\x1f")),ENT_QUOTES); //sanitize data against sql/html injection; trim any nongraphical non-ASCII character: 24 } 25 return $data; 26} 27 28function get_IPTC($filename) { 29 $IPTC_data=array(); 30 $size = GetImageSize ($filename, $info); 31 if (isset($info["APP13"])) { 32 $iptc = iptcparse($info["APP13"]); 33 if (is_array($iptc)) { 34 $IPTC_data=array( "Title" => $iptc["2#005"][0], # Max 65 octets, non-repeatable, alphanumeric 35 "Urgency" => $iptc["2#010"][0], # Max 1 octet, non-repeatable, numeric, 1 - High, 8 - Low 36 "Category" => $iptc["2#015"][0], # Max 3 octets, non-repeatable, alpha 37 "SubCategories" => $iptc["2#020"], # Max 32 octets, repeatable, alphanumeric 38 "Keywords" => $iptc["2#025"], # Max 64 octets, repeatable, alphanumeric 39 "Instructions" => $iptc["2#040"][0], # Max 256 octets, non-repeatable, alphanumeric 40 "CreationDate" => $iptc["2#055"][0], # Max 8 octets, non-repeatable, numeric, YYYYMMDD 41 "CreationTime" => $iptc["2#060"][0], # Max 11 octets, non-repeatable, numeric+-, HHMMSS(+|-)HHMM 42 "ProgramUsed" => $iptc["2#065"][0], # Max 32 octets, non-repeatable, alphanumeric 43 "Author" => $iptc["2#080"][0], #!Max 32 octets, repeatable, alphanumeric 44 "Position" => $iptc["2#085"][0], #!Max 32 octets, repeatable, alphanumeric 45 "City" => $iptc["2#090"][0], # Max 32 octets, non-repeatable, alphanumeric 46 "State" => $iptc["2#095"][0], # Max 32 octets, non-repeatable, alphanumeric 47 "Country" => $iptc["2#101"][0], # Max 64 octets, non-repeatable, alphanumeric 48 "TransmissionReference" => $iptc["2#103"][0], # Max 32 octets, non-repeatable, alphanumeric 49 "Headline" => $iptc["2#105"][0], # Max 256 octets, non-repeatable, alphanumeric 50 "Credit" => $iptc["2#110"][0], # Max 32 octets, non-repeatable, alphanumeric 51 "Source" => $iptc["2#115"][0], # Max 32 octets, non-repeatable, alphanumeric 52 "Copyright" => $iptc["2#116"][0], # Max 128 octets, non-repeatable, alphanumeric 53 "Caption" => $iptc["2#120"][0], # Max 2000 octets, non-repeatable, alphanumeric 54 "CaptionWriter" => $iptc["2#122"][0], # Max 32 octets, non-repeatable, alphanumeric 55 ); 56 $IPTC_data=strip_IPTC($IPTC_data); //sanitize data against sql/html injection; trim any nongraphical non-ASCII character: 57 $IPTC_data=filter_content($IPTC_data); //run the data against the bad word list 58 } 59 } 60return $IPTC_data; 61} 62//EOF