2011-04-16 01:23:15 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2012-05-03 20:13:10 +00:00
|
|
|
* Extraction of JPEG image metadata.
|
|
|
|
|
*
|
|
|
|
|
* This program 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.
|
|
|
|
|
*
|
|
|
|
|
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-24 20:17:53 +00:00
|
|
|
use Wikimedia\AtEase\AtEase;
|
2018-06-01 02:14:06 +00:00
|
|
|
use Wikimedia\XMPReader\Reader as XMPReader;
|
|
|
|
|
|
2012-05-03 20:13:10 +00:00
|
|
|
/**
|
|
|
|
|
* Class for reading jpegs and extracting metadata.
|
|
|
|
|
* see also BitmapMetadataHandler.
|
|
|
|
|
*
|
2013-03-13 07:42:41 +00:00
|
|
|
* Based somewhat on GIFMetadataExtractor.
|
2012-05-03 20:13:10 +00:00
|
|
|
*
|
|
|
|
|
* @ingroup Media
|
|
|
|
|
*/
|
2011-04-16 01:23:15 +00:00
|
|
|
class JpegMetadataExtractor {
|
2019-11-12 01:46:51 +00:00
|
|
|
/**
|
2021-11-19 23:19:42 +00:00
|
|
|
* The max segment is a safety check. A JPEG file should never even remotely have
|
2019-11-12 01:46:51 +00:00
|
|
|
* that many segments. Your average file has about 10.
|
|
|
|
|
*/
|
|
|
|
|
private const MAX_JPEG_SEGMENTS = 200;
|
2011-04-16 01:23:15 +00:00
|
|
|
|
|
|
|
|
/** Function to extract metadata segments of interest from jpeg files
|
2013-03-07 16:27:38 +00:00
|
|
|
* based on GIFMetadataExtractor.
|
|
|
|
|
*
|
|
|
|
|
* we can almost use getimagesize to do this
|
|
|
|
|
* but gis doesn't support having multiple app1 segments
|
|
|
|
|
* and those can't extract xmp on files containing both exif and xmp data
|
|
|
|
|
*
|
2014-07-24 17:43:25 +00:00
|
|
|
* @param string $filename Name of jpeg file
|
|
|
|
|
* @return array Array of interesting segments.
|
|
|
|
|
* @throws MWException If given invalid file.
|
2013-03-07 16:27:38 +00:00
|
|
|
*/
|
2020-05-16 21:42:24 +00:00
|
|
|
public static function segmentSplitter( $filename ) {
|
2015-03-12 22:49:22 +00:00
|
|
|
$showXMP = XMPReader::isSupported();
|
2011-04-16 01:23:15 +00:00
|
|
|
|
|
|
|
|
$segmentCount = 0;
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$segments = [
|
|
|
|
|
'XMP_ext' => [],
|
|
|
|
|
'COM' => [],
|
|
|
|
|
'PSIR' => [],
|
|
|
|
|
];
|
2011-04-16 01:23:15 +00:00
|
|
|
|
2011-04-18 13:08:20 +00:00
|
|
|
if ( !$filename ) {
|
|
|
|
|
throw new MWException( "No filename specified for " . __METHOD__ );
|
|
|
|
|
}
|
|
|
|
|
if ( !file_exists( $filename ) || is_dir( $filename ) ) {
|
|
|
|
|
throw new MWException( "Invalid file $filename passed to " . __METHOD__ );
|
|
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
|
|
|
|
|
$fh = fopen( $filename, "rb" );
|
|
|
|
|
|
2011-04-18 13:08:20 +00:00
|
|
|
if ( !$fh ) {
|
|
|
|
|
throw new MWException( "Could not open file $filename" );
|
|
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
|
|
|
|
|
$buffer = fread( $fh, 2 );
|
2011-04-18 13:08:20 +00:00
|
|
|
if ( $buffer !== "\xFF\xD8" ) {
|
|
|
|
|
throw new MWException( "Not a jpeg, no SOI" );
|
|
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
while ( !feof( $fh ) ) {
|
|
|
|
|
$buffer = fread( $fh, 1 );
|
|
|
|
|
$segmentCount++;
|
|
|
|
|
if ( $segmentCount > self::MAX_JPEG_SEGMENTS ) {
|
|
|
|
|
throw new MWException( 'Too many jpeg segments. Aborting' );
|
|
|
|
|
}
|
2018-02-21 22:45:35 +00:00
|
|
|
while ( $buffer !== "\xFF" && !feof( $fh ) ) {
|
2016-10-19 06:20:23 +00:00
|
|
|
// In theory JPEG files are not allowed to contain anything between the sections,
|
|
|
|
|
// but in practice they sometimes do. It's customary to ignore the garbage data.
|
|
|
|
|
$buffer = fread( $fh, 1 );
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$buffer = fread( $fh, 1 );
|
2013-04-20 21:11:46 +00:00
|
|
|
while ( $buffer === "\xFF" && !feof( $fh ) ) {
|
2011-10-24 02:41:34 +00:00
|
|
|
// Skip through any 0xFF padding bytes.
|
|
|
|
|
$buffer = fread( $fh, 1 );
|
|
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
if ( $buffer === "\xFE" ) {
|
|
|
|
|
// COM section -- file comment
|
|
|
|
|
// First see if valid utf-8,
|
|
|
|
|
// if not try to convert it to windows-1252.
|
|
|
|
|
$com = $oldCom = trim( self::jpegExtractMarker( $fh ) );
|
2015-03-07 09:27:42 +00:00
|
|
|
UtfNormal\Validator::quickIsNFCVerify( $com );
|
2011-04-16 01:23:15 +00:00
|
|
|
// turns $com to valid utf-8.
|
|
|
|
|
// thus if no change, its utf-8, otherwise its something else.
|
|
|
|
|
if ( $com !== $oldCom ) {
|
2022-02-24 20:17:53 +00:00
|
|
|
AtEase::suppressWarnings();
|
2011-04-16 15:53:08 +00:00
|
|
|
$com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom );
|
2022-02-24 20:17:53 +00:00
|
|
|
AtEase::restoreWarnings();
|
2011-04-16 15:53:08 +00:00
|
|
|
}
|
|
|
|
|
// Try it again, if its still not a valid string, then probably
|
|
|
|
|
// binary junk or some really weird encoding, so don't extract.
|
2015-03-07 09:27:42 +00:00
|
|
|
UtfNormal\Validator::quickIsNFCVerify( $com );
|
2011-04-16 15:53:08 +00:00
|
|
|
if ( $com === $oldCom ) {
|
|
|
|
|
$segments["COM"][] = $oldCom;
|
|
|
|
|
} else {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . " Ignoring JPEG comment as is garbage." );
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
2011-08-21 17:16:57 +00:00
|
|
|
} elseif ( $buffer === "\xE1" ) {
|
2011-04-16 01:23:15 +00:00
|
|
|
// APP1 section (Exif, XMP, and XMP extended)
|
|
|
|
|
// only extract if XMP is enabled.
|
|
|
|
|
$temp = self::jpegExtractMarker( $fh );
|
|
|
|
|
// check what type of app segment this is.
|
2011-08-21 17:16:57 +00:00
|
|
|
if ( substr( $temp, 0, 29 ) === "http://ns.adobe.com/xap/1.0/\x00" && $showXMP ) {
|
2019-09-11 22:12:22 +00:00
|
|
|
// use trim to remove trailing \0 chars
|
|
|
|
|
$segments["XMP"] = trim( substr( $temp, 29 ) );
|
2011-08-21 17:16:57 +00:00
|
|
|
} elseif ( substr( $temp, 0, 35 ) === "http://ns.adobe.com/xmp/extension/\x00" && $showXMP ) {
|
2019-09-11 22:12:22 +00:00
|
|
|
// use trim to remove trailing \0 chars
|
|
|
|
|
$segments["XMP_ext"][] = trim( substr( $temp, 35 ) );
|
2011-08-21 17:16:57 +00:00
|
|
|
} elseif ( substr( $temp, 0, 29 ) === "XMP\x00://ns.adobe.com/xap/1.0/\x00" && $showXMP ) {
|
2011-04-16 01:23:15 +00:00
|
|
|
// Some images (especially flickr images) seem to have this.
|
|
|
|
|
// I really have no idea what the deal is with them, but
|
|
|
|
|
// whatever...
|
2019-09-11 22:12:22 +00:00
|
|
|
// use trim to remove trailing \0 chars
|
|
|
|
|
$segments["XMP"] = trim( substr( $temp, 29 ) );
|
2011-04-16 01:23:15 +00:00
|
|
|
wfDebug( __METHOD__ . ' Found XMP section with wrong app identifier '
|
2020-06-01 05:00:39 +00:00
|
|
|
. "Using anyways." );
|
2011-08-21 17:16:57 +00:00
|
|
|
} elseif ( substr( $temp, 0, 6 ) === "Exif\0\0" ) {
|
|
|
|
|
// Just need to find out what the byte order is.
|
|
|
|
|
// because php's exif plugin sucks...
|
|
|
|
|
// This is a II for little Endian, MM for big. Not a unicode BOM.
|
|
|
|
|
$byteOrderMarker = substr( $temp, 6, 2 );
|
|
|
|
|
if ( $byteOrderMarker === 'MM' ) {
|
|
|
|
|
$segments['byteOrder'] = 'BE';
|
|
|
|
|
} elseif ( $byteOrderMarker === 'II' ) {
|
|
|
|
|
$segments['byteOrder'] = 'LE';
|
|
|
|
|
} else {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . " Invalid byte ordering?!" );
|
2011-08-21 17:16:57 +00:00
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
|
|
|
|
} elseif ( $buffer === "\xED" ) {
|
|
|
|
|
// APP13 - PSIR. IPTC and some photoshop stuff
|
|
|
|
|
$temp = self::jpegExtractMarker( $fh );
|
|
|
|
|
if ( substr( $temp, 0, 14 ) === "Photoshop 3.0\x00" ) {
|
2012-01-05 23:25:39 +00:00
|
|
|
$segments["PSIR"][] = $temp;
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
|
|
|
|
} elseif ( $buffer === "\xD9" || $buffer === "\xDA" ) {
|
|
|
|
|
// EOI - end of image or SOS - start of scan. either way we're past any interesting segments
|
|
|
|
|
return $segments;
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
} elseif ( in_array( $buffer, [
|
|
|
|
|
"\xC0", "\xC1", "\xC2", "\xC3", "\xC5", "\xC6", "\xC7",
|
|
|
|
|
"\xC9", "\xCA", "\xCB", "\xCD", "\xCE", "\xCF" ] )
|
|
|
|
|
) {
|
|
|
|
|
// SOF0, SOF1, SOF2, ... (same list as getimagesize)
|
|
|
|
|
$temp = self::jpegExtractMarker( $fh );
|
|
|
|
|
$segments["SOF"] = wfUnpack( 'Cbits/nheight/nwidth/Ccomponents', $temp );
|
2011-04-16 01:23:15 +00:00
|
|
|
} else {
|
|
|
|
|
// segment we don't care about, so skip
|
2011-10-24 02:19:11 +00:00
|
|
|
$size = wfUnpack( "nint", fread( $fh, 2 ), 2 );
|
2016-09-29 22:15:48 +00:00
|
|
|
if ( $size['int'] < 2 ) {
|
2013-04-20 21:11:46 +00:00
|
|
|
throw new MWException( "invalid marker size in jpeg" );
|
|
|
|
|
}
|
2018-02-23 09:42:10 +00:00
|
|
|
// Note it's possible to seek beyond end of file if truncated.
|
|
|
|
|
// fseek doesn't report a failure in this case.
|
2011-04-16 01:23:15 +00:00
|
|
|
fseek( $fh, $size['int'] - 2, SEEK_CUR );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// shouldn't get here.
|
|
|
|
|
throw new MWException( "Reached end of jpeg file unexpectedly" );
|
|
|
|
|
}
|
2011-04-18 13:18:15 +00:00
|
|
|
|
2011-04-16 01:23:15 +00:00
|
|
|
/**
|
2012-10-07 23:35:26 +00:00
|
|
|
* Helper function for jpegSegmentSplitter
|
2013-12-05 19:27:27 +00:00
|
|
|
* @param resource &$fh File handle for JPEG file
|
2012-10-07 23:35:26 +00:00
|
|
|
* @throws MWException
|
2013-12-05 19:27:27 +00:00
|
|
|
* @return string Data content of segment.
|
2012-10-07 23:35:26 +00:00
|
|
|
*/
|
2011-04-16 01:23:15 +00:00
|
|
|
private static function jpegExtractMarker( &$fh ) {
|
2011-10-24 02:19:11 +00:00
|
|
|
$size = wfUnpack( "nint", fread( $fh, 2 ), 2 );
|
2016-09-29 22:15:48 +00:00
|
|
|
if ( $size['int'] < 2 ) {
|
2012-02-09 19:29:36 +00:00
|
|
|
throw new MWException( "invalid marker size in jpeg" );
|
|
|
|
|
}
|
2016-09-29 22:15:48 +00:00
|
|
|
if ( $size['int'] === 2 ) {
|
|
|
|
|
// fread( ..., 0 ) generates a warning
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2011-10-24 02:19:11 +00:00
|
|
|
$segment = fread( $fh, $size['int'] - 2 );
|
2012-02-09 19:29:36 +00:00
|
|
|
if ( strlen( $segment ) !== $size['int'] - 2 ) {
|
|
|
|
|
throw new MWException( "Segment shorter than expected" );
|
|
|
|
|
}
|
2013-12-05 10:05:05 +00:00
|
|
|
|
2011-10-24 02:19:11 +00:00
|
|
|
return $segment;
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2013-03-07 16:27:38 +00:00
|
|
|
* This reads the photoshop image resource.
|
|
|
|
|
* Currently it only compares the iptc/iim hash
|
|
|
|
|
* with the stored hash, which is used to determine the precedence
|
|
|
|
|
* of the iptc data. In future it may extract some other info, like
|
|
|
|
|
* url of copyright license.
|
|
|
|
|
*
|
|
|
|
|
* This should generally be called by BitmapMetadataHandler::doApp13()
|
|
|
|
|
*
|
2014-07-24 17:43:25 +00:00
|
|
|
* @param string $app13 Photoshop psir app13 block from jpg.
|
2013-03-07 16:27:38 +00:00
|
|
|
* @throws MWException (It gets caught next level up though)
|
2013-12-05 19:27:27 +00:00
|
|
|
* @return string If the iptc hash is good or not. One of 'iptc-no-hash',
|
|
|
|
|
* 'iptc-good-hash', 'iptc-bad-hash'.
|
2013-03-07 16:27:38 +00:00
|
|
|
*/
|
2013-03-18 19:44:43 +00:00
|
|
|
public static function doPSIR( $app13 ) {
|
2011-04-18 13:08:20 +00:00
|
|
|
if ( !$app13 ) {
|
2012-01-05 23:25:39 +00:00
|
|
|
throw new MWException( "No App13 segment given" );
|
2011-04-18 13:08:20 +00:00
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
// First compare hash with real thing
|
|
|
|
|
// 0x404 contains IPTC, 0x425 has hash
|
|
|
|
|
// This is used to determine if the iptc is newer than
|
|
|
|
|
// the xmp data, as xmp programs update the hash,
|
|
|
|
|
// where non-xmp programs don't.
|
|
|
|
|
|
|
|
|
|
$offset = 14; // skip past PHOTOSHOP 3.0 identifier. should already be checked.
|
|
|
|
|
$appLen = strlen( $app13 );
|
|
|
|
|
$realHash = "";
|
|
|
|
|
$recordedHash = "";
|
|
|
|
|
|
|
|
|
|
// the +12 is the length of an empty item.
|
|
|
|
|
while ( $offset + 12 <= $appLen ) {
|
2011-04-16 16:23:08 +00:00
|
|
|
$valid = true;
|
2011-04-16 01:23:15 +00:00
|
|
|
if ( substr( $app13, $offset, 4 ) !== '8BIM' ) {
|
|
|
|
|
// its supposed to be 8BIM
|
|
|
|
|
// but apparently sometimes isn't esp. in
|
|
|
|
|
// really old jpg's
|
|
|
|
|
$valid = false;
|
|
|
|
|
}
|
|
|
|
|
$offset += 4;
|
|
|
|
|
$id = substr( $app13, $offset, 2 );
|
|
|
|
|
// id is a 2 byte id number which identifies
|
|
|
|
|
// the piece of info this record contains.
|
|
|
|
|
|
|
|
|
|
$offset += 2;
|
|
|
|
|
|
|
|
|
|
// some record types can contain a name, which
|
|
|
|
|
// is a pascal string 0-padded to be an even
|
|
|
|
|
// number of bytes. Most times (and any time
|
|
|
|
|
// we care) this is empty, making it two null bytes.
|
|
|
|
|
|
|
|
|
|
$lenName = ord( substr( $app13, $offset, 1 ) ) + 1;
|
|
|
|
|
// we never use the name so skip it. +1 for length byte
|
2011-04-18 13:08:20 +00:00
|
|
|
if ( $lenName % 2 == 1 ) {
|
|
|
|
|
$lenName++;
|
|
|
|
|
} // pad to even.
|
2011-04-16 01:23:15 +00:00
|
|
|
$offset += $lenName;
|
|
|
|
|
|
|
|
|
|
// now length of data (unsigned long big endian)
|
2011-10-24 02:19:11 +00:00
|
|
|
$lenData = wfUnpack( 'Nlen', substr( $app13, $offset, 4 ), 4 );
|
|
|
|
|
// PHP can take issue with very large unsigned ints and make them negative.
|
|
|
|
|
// Which should never ever happen, as this has to be inside a segment
|
|
|
|
|
// which is limited to a 16 bit number.
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $lenData['len'] < 0 ) {
|
|
|
|
|
throw new MWException( "Too big PSIR (" . $lenData['len'] . ')' );
|
|
|
|
|
}
|
2011-10-24 02:19:11 +00:00
|
|
|
|
2011-04-16 01:23:15 +00:00
|
|
|
$offset += 4; // 4bytes length field;
|
|
|
|
|
|
|
|
|
|
// this should not happen, but check.
|
|
|
|
|
if ( $lenData['len'] + $offset > $appLen ) {
|
2012-01-05 23:25:39 +00:00
|
|
|
throw new MWException( "PSIR data too long. (item length=" . $lenData['len']
|
|
|
|
|
. "; offset=$offset; total length=$appLen)" );
|
2011-04-16 01:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $valid ) {
|
|
|
|
|
switch ( $id ) {
|
|
|
|
|
case "\x04\x04":
|
|
|
|
|
// IPTC block
|
|
|
|
|
$realHash = md5( substr( $app13, $offset, $lenData['len'] ), true );
|
|
|
|
|
break;
|
|
|
|
|
case "\x04\x25":
|
|
|
|
|
$recordedHash = substr( $app13, $offset, $lenData['len'] );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if odd, add 1 to length to account for
|
|
|
|
|
// null pad byte.
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $lenData['len'] % 2 == 1 ) {
|
|
|
|
|
$lenData['len']++;
|
|
|
|
|
}
|
2011-04-16 01:23:15 +00:00
|
|
|
$offset += $lenData['len'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$realHash || !$recordedHash ) {
|
|
|
|
|
return 'iptc-no-hash';
|
|
|
|
|
} elseif ( $realHash === $recordedHash ) {
|
|
|
|
|
return 'iptc-good-hash';
|
|
|
|
|
} else { /*$realHash !== $recordedHash */
|
|
|
|
|
return 'iptc-bad-hash';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|