MediaWiki REL1_33
Exif.php
Go to the documentation of this file.
1<?php
32class Exif {
34 const BYTE = 1;
35
39 const ASCII = 2;
40
42 const SHORT = 3;
43
45 const LONG = 4;
46
50 const RATIONAL = 5;
51
53 const SHORT_OR_LONG = 6;
54
56 const UNDEFINED = 7;
57
59 const SLONG = 9;
60
64 const SRATIONAL = 10;
65
67 const IGNORE = -1;
68
73 private $mExifTags;
74
77
83
85 private $file;
86
88 private $basename;
89
91 private $log = false;
92
96 private $byteOrder;
97
108 function __construct( $file, $byteOrder = '' ) {
117 $this->mExifTags = [
118 # TIFF Rev. 6.0 Attribute Information (p22)
119 'IFD0' => [
120 # Tags relating to image structure
121 'ImageWidth' => self::SHORT_OR_LONG, # Image width
122 'ImageLength' => self::SHORT_OR_LONG, # Image height
123 'BitsPerSample' => [ self::SHORT, 3 ], # Number of bits per component
124 # "When a primary image is JPEG compressed, this designation is not"
125 # "necessary and is omitted." (p23)
126 'Compression' => self::SHORT, # Compression scheme #p23
127 'PhotometricInterpretation' => self::SHORT, # Pixel composition #p23
128 'Orientation' => self::SHORT, # Orientation of image #p24
129 'SamplesPerPixel' => self::SHORT, # Number of components
130 'PlanarConfiguration' => self::SHORT, # Image data arrangement #p24
131 'YCbCrSubSampling' => [ self::SHORT, 2 ], # Subsampling ratio of Y to C #p24
132 'YCbCrPositioning' => self::SHORT, # Y and C positioning #p24-25
133 'XResolution' => self::RATIONAL, # Image resolution in width direction
134 'YResolution' => self::RATIONAL, # Image resolution in height direction
135 'ResolutionUnit' => self::SHORT, # Unit of X and Y resolution #(p26)
136
137 # Tags relating to recording offset
138 'StripOffsets' => self::SHORT_OR_LONG, # Image data location
139 'RowsPerStrip' => self::SHORT_OR_LONG, # Number of rows per strip
140 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip
141 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI
142 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes of JPEG data
143
144 # Tags relating to image data characteristics
145 'TransferFunction' => self::IGNORE, # Transfer function
146 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity
147 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities of primarities
148 # Color space transformation matrix coefficients #p27
149 'YCbCrCoefficients' => [ self::RATIONAL, 3 ],
150 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair of black and white reference values
151
152 # Other tags
153 'DateTime' => self::ASCII, # File change date and time
154 'ImageDescription' => self::ASCII, # Image title
155 'Make' => self::ASCII, # Image input equipment manufacturer
156 'Model' => self::ASCII, # Image input equipment model
157 'Software' => self::ASCII, # Software used
158 'Artist' => self::ASCII, # Person who created the image
159 'Copyright' => self::ASCII, # Copyright holder
160 ],
161
162 # Exif IFD Attribute Information (p30-31)
163 'EXIF' => [
164 # @todo NOTE: Nonexistence of this field is taken to mean nonconformance
165 # to the Exif 2.1 AND 2.2 standards
166 'ExifVersion' => self::UNDEFINED, # Exif version
167 'FlashPixVersion' => self::UNDEFINED, # Supported Flashpix version #p32
168
169 # Tags relating to Image Data Characteristics
170 'ColorSpace' => self::SHORT, # Color space information #p32
171
172 # Tags relating to image configuration
173 'ComponentsConfiguration' => self::UNDEFINED, # Meaning of each component #p33
174 'CompressedBitsPerPixel' => self::RATIONAL, # Image compression mode
175 'PixelYDimension' => self::SHORT_OR_LONG, # Valid image height
176 'PixelXDimension' => self::SHORT_OR_LONG, # Valid image width
177
178 # Tags relating to related user information
179 'MakerNote' => self::IGNORE, # Manufacturer notes
180 'UserComment' => self::UNDEFINED, # User comments #p34
181
182 # Tags relating to related file information
183 'RelatedSoundFile' => self::ASCII, # Related audio file
184
185 # Tags relating to date and time
186 'DateTimeOriginal' => self::ASCII, # Date and time of original data generation #p36
187 'DateTimeDigitized' => self::ASCII, # Date and time of original data generation
188 'SubSecTime' => self::ASCII, # DateTime subseconds
189 'SubSecTimeOriginal' => self::ASCII, # DateTimeOriginal subseconds
190 'SubSecTimeDigitized' => self::ASCII, # DateTimeDigitized subseconds
191
192 # Tags relating to picture-taking conditions (p31)
193 'ExposureTime' => self::RATIONAL, # Exposure time
194 'FNumber' => self::RATIONAL, # F Number
195 'ExposureProgram' => self::SHORT, # Exposure Program #p38
196 'SpectralSensitivity' => self::ASCII, # Spectral sensitivity
197 'ISOSpeedRatings' => self::SHORT, # ISO speed rating
198 'OECF' => self::IGNORE,
199 # Optoelectronic conversion factor. Note: We don't have support for this atm.
200 'ShutterSpeedValue' => self::SRATIONAL, # Shutter speed
201 'ApertureValue' => self::RATIONAL, # Aperture
202 'BrightnessValue' => self::SRATIONAL, # Brightness
203 'ExposureBiasValue' => self::SRATIONAL, # Exposure bias
204 'MaxApertureValue' => self::RATIONAL, # Maximum land aperture
205 'SubjectDistance' => self::RATIONAL, # Subject distance
206 'MeteringMode' => self::SHORT, # Metering mode #p40
207 'LightSource' => self::SHORT, # Light source #p40-41
208 'Flash' => self::SHORT, # Flash #p41-42
209 'FocalLength' => self::RATIONAL, # Lens focal length
210 'SubjectArea' => [ self::SHORT, 4 ], # Subject area
211 'FlashEnergy' => self::RATIONAL, # Flash energy
212 'SpatialFrequencyResponse' => self::IGNORE, # Spatial frequency response. Not supported atm.
213 'FocalPlaneXResolution' => self::RATIONAL, # Focal plane X resolution
214 'FocalPlaneYResolution' => self::RATIONAL, # Focal plane Y resolution
215 'FocalPlaneResolutionUnit' => self::SHORT, # Focal plane resolution unit #p46
216 'SubjectLocation' => [ self::SHORT, 2 ], # Subject location
217 'ExposureIndex' => self::RATIONAL, # Exposure index
218 'SensingMethod' => self::SHORT, # Sensing method #p46
219 'FileSource' => self::UNDEFINED, # File source #p47
220 'SceneType' => self::UNDEFINED, # Scene type #p47
221 'CFAPattern' => self::IGNORE, # CFA pattern. not supported atm.
222 'CustomRendered' => self::SHORT, # Custom image processing #p48
223 'ExposureMode' => self::SHORT, # Exposure mode #p48
224 'WhiteBalance' => self::SHORT, # White Balance #p49
225 'DigitalZoomRatio' => self::RATIONAL, # Digital zoom ration
226 'FocalLengthIn35mmFilm' => self::SHORT, # Focal length in 35 mm film
227 'SceneCaptureType' => self::SHORT, # Scene capture type #p49
228 'GainControl' => self::SHORT, # Scene control #p49-50
229 'Contrast' => self::SHORT, # Contrast #p50
230 'Saturation' => self::SHORT, # Saturation #p50
231 'Sharpness' => self::SHORT, # Sharpness #p50
232 'DeviceSettingDescription' => self::IGNORE,
233 # Device settings description. This could maybe be supported. Need to find an
234 # example file that uses this to see if it has stuff of interest in it.
235 'SubjectDistanceRange' => self::SHORT, # Subject distance range #p51
236
237 'ImageUniqueID' => self::ASCII, # Unique image ID
238 ],
239
240 # GPS Attribute Information (p52)
241 'GPS' => [
242 'GPSVersion' => self::UNDEFINED,
243 # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined
244 # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix
245 'GPSLatitudeRef' => self::ASCII, # North or South Latitude #p52-53
246 'GPSLatitude' => [ self::RATIONAL, 3 ], # Latitude
247 'GPSLongitudeRef' => self::ASCII, # East or West Longitude #p53
248 'GPSLongitude' => [ self::RATIONAL, 3 ], # Longitude
249 'GPSAltitudeRef' => self::UNDEFINED,
250 # Altitude reference. Note, the exif standard says this should be an EXIF::Byte,
251 # but php seems to disagree.
252 'GPSAltitude' => self::RATIONAL, # Altitude
253 'GPSTimeStamp' => [ self::RATIONAL, 3 ], # GPS time (atomic clock)
254 'GPSSatellites' => self::ASCII, # Satellites used for measurement
255 'GPSStatus' => self::ASCII, # Receiver status #p54
256 'GPSMeasureMode' => self::ASCII, # Measurement mode #p54-55
257 'GPSDOP' => self::RATIONAL, # Measurement precision
258 'GPSSpeedRef' => self::ASCII, # Speed unit #p55
259 'GPSSpeed' => self::RATIONAL, # Speed of GPS receiver
260 'GPSTrackRef' => self::ASCII, # Reference for direction of movement #p55
261 'GPSTrack' => self::RATIONAL, # Direction of movement
262 'GPSImgDirectionRef' => self::ASCII, # Reference for direction of image #p56
263 'GPSImgDirection' => self::RATIONAL, # Direction of image
264 'GPSMapDatum' => self::ASCII, # Geodetic survey data used
265 'GPSDestLatitudeRef' => self::ASCII, # Reference for latitude of destination #p56
266 'GPSDestLatitude' => [ self::RATIONAL, 3 ], # Latitude destination
267 'GPSDestLongitudeRef' => self::ASCII, # Reference for longitude of destination #p57
268 'GPSDestLongitude' => [ self::RATIONAL, 3 ], # Longitude of destination
269 'GPSDestBearingRef' => self::ASCII, # Reference for bearing of destination #p57
270 'GPSDestBearing' => self::RATIONAL, # Bearing of destination
271 'GPSDestDistanceRef' => self::ASCII, # Reference for distance to destination #p57-58
272 'GPSDestDistance' => self::RATIONAL, # Distance to destination
273 'GPSProcessingMethod' => self::UNDEFINED, # Name of GPS processing method
274 'GPSAreaInformation' => self::UNDEFINED, # Name of GPS area
275 'GPSDateStamp' => self::ASCII, # GPS date
276 'GPSDifferential' => self::SHORT, # GPS differential correction
277 ],
278 ];
279
280 $this->file = $file;
281 $this->basename = wfBaseName( $this->file );
282 if ( $byteOrder === 'BE' || $byteOrder === 'LE' ) {
283 $this->byteOrder = $byteOrder;
284 } else {
285 // Only give a warning for b/c, since originally we didn't
286 // require this. The number of things affected by this is
287 // rather small.
288 wfWarn( 'Exif class did not have byte order specified. ' .
289 'Some properties may be decoded incorrectly.' );
290 $this->byteOrder = 'BE'; // BE seems about twice as popular as LE in jpg's.
291 }
292
293 $this->debugFile( __FUNCTION__, true );
294 if ( function_exists( 'exif_read_data' ) ) {
296 $data = exif_read_data( $this->file, 0, true );
298 } else {
299 throw new MWException( "Internal error: exif_read_data not present. " .
300 "\$wgShowEXIF may be incorrectly set or not checked by an extension." );
301 }
307 $this->mRawExifData = $data ?: [];
308 $this->makeFilteredData();
309 $this->collapseData();
310 $this->debugFile( __FUNCTION__, false );
311 }
312
316 function makeFilteredData() {
317 $this->mFilteredExifData = [];
318
319 foreach ( array_keys( $this->mRawExifData ) as $section ) {
320 if ( !array_key_exists( $section, $this->mExifTags ) ) {
321 $this->debug( $section, __FUNCTION__, "'$section' is not a valid Exif section" );
322 continue;
323 }
324
325 foreach ( array_keys( $this->mRawExifData[$section] ) as $tag ) {
326 if ( !array_key_exists( $tag, $this->mExifTags[$section] ) ) {
327 $this->debug( $tag, __FUNCTION__, "'$tag' is not a valid tag in '$section'" );
328 continue;
329 }
330
331 $this->mFilteredExifData[$tag] = $this->mRawExifData[$section][$tag];
332 // This is ok, as the tags in the different sections do not conflict.
333 // except in computed and thumbnail section, which we don't use.
334
335 $value = $this->mRawExifData[$section][$tag];
336 if ( !$this->validate( $section, $tag, $value ) ) {
337 $this->debug( $value, __FUNCTION__, "'$tag' contained invalid data" );
338 unset( $this->mFilteredExifData[$tag] );
339 }
340 }
341 }
342 }
343
362 function collapseData() {
363 $this->exifGPStoNumber( 'GPSLatitude' );
364 $this->exifGPStoNumber( 'GPSDestLatitude' );
365 $this->exifGPStoNumber( 'GPSLongitude' );
366 $this->exifGPStoNumber( 'GPSDestLongitude' );
367
368 if ( isset( $this->mFilteredExifData['GPSAltitude'] )
369 && isset( $this->mFilteredExifData['GPSAltitudeRef'] )
370 ) {
371 // We know altitude data is a <num>/<denom> from the validation
372 // functions ran earlier. But multiplying such a string by -1
373 // doesn't work well, so convert.
374 list( $num, $denom ) = explode( '/', $this->mFilteredExifData['GPSAltitude'] );
375 $this->mFilteredExifData['GPSAltitude'] = $num / $denom;
376
377 if ( $this->mFilteredExifData['GPSAltitudeRef'] === "\1" ) {
378 $this->mFilteredExifData['GPSAltitude'] *= -1;
379 }
380 unset( $this->mFilteredExifData['GPSAltitudeRef'] );
381 }
382
383 $this->exifPropToOrd( 'FileSource' );
384 $this->exifPropToOrd( 'SceneType' );
385
386 $this->charCodeString( 'UserComment' );
387 $this->charCodeString( 'GPSProcessingMethod' );
388 $this->charCodeString( 'GPSAreaInformation' );
389
390 // ComponentsConfiguration should really be an array instead of a string...
391 // This turns a string of binary numbers into an array of numbers.
392
393 if ( isset( $this->mFilteredExifData['ComponentsConfiguration'] ) ) {
394 $val = $this->mFilteredExifData['ComponentsConfiguration'];
395 $ccVals = [];
396
397 $strLen = strlen( $val );
398 for ( $i = 0; $i < $strLen; $i++ ) {
399 $ccVals[$i] = ord( substr( $val, $i, 1 ) );
400 }
401 $ccVals['_type'] = 'ol'; // this is for formatting later.
402 $this->mFilteredExifData['ComponentsConfiguration'] = $ccVals;
403 }
404
405 // GPSVersion(ID) is treated as the wrong type by php exif support.
406 // Go through each byte turning it into a version string.
407 // For example: "\x02\x02\x00\x00" -> "2.2.0.0"
408
409 // Also change exif tag name from GPSVersion (what php exif thinks it is)
410 // to GPSVersionID (what the exif standard thinks it is).
411
412 if ( isset( $this->mFilteredExifData['GPSVersion'] ) ) {
413 $val = $this->mFilteredExifData['GPSVersion'];
414 $newVal = '';
415
416 $strLen = strlen( $val );
417 for ( $i = 0; $i < $strLen; $i++ ) {
418 if ( $i !== 0 ) {
419 $newVal .= '.';
420 }
421 $newVal .= ord( substr( $val, $i, 1 ) );
422 }
423
424 if ( $this->byteOrder === 'LE' ) {
425 // Need to reverse the string
426 $newVal2 = '';
427 for ( $i = strlen( $newVal ) - 1; $i >= 0; $i-- ) {
428 $newVal2 .= substr( $newVal, $i, 1 );
429 }
430 $this->mFilteredExifData['GPSVersionID'] = $newVal2;
431 } else {
432 $this->mFilteredExifData['GPSVersionID'] = $newVal;
433 }
434 unset( $this->mFilteredExifData['GPSVersion'] );
435 }
436 }
437
444 private function charCodeString( $prop ) {
445 if ( isset( $this->mFilteredExifData[$prop] ) ) {
446 if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) {
447 // invalid. Must be at least 9 bytes long.
448
449 $this->debug( $this->mFilteredExifData[$prop], __FUNCTION__, false );
450 unset( $this->mFilteredExifData[$prop] );
451
452 return;
453 }
454 $charCode = substr( $this->mFilteredExifData[$prop], 0, 8 );
455 $val = substr( $this->mFilteredExifData[$prop], 8 );
456
457 switch ( $charCode ) {
458 case "JIS\x00\x00\x00\x00\x00":
459 $charset = "Shift-JIS";
460 break;
461 case "UNICODE\x00":
462 $charset = "UTF-16" . $this->byteOrder;
463 break;
464 default: // ascii or undefined.
465 $charset = "";
466 break;
467 }
468 if ( $charset ) {
470 $val = iconv( $charset, 'UTF-8//IGNORE', $val );
472 } else {
473 // if valid utf-8, assume that, otherwise assume windows-1252
474 $valCopy = $val;
475 UtfNormal\Validator::quickIsNFCVerify( $valCopy ); // validates $valCopy.
476 if ( $valCopy !== $val ) {
478 $val = iconv( 'Windows-1252', 'UTF-8//IGNORE', $val );
480 }
481 }
482
483 // trim and check to make sure not only whitespace.
484 $val = trim( $val );
485 if ( strlen( $val ) === 0 ) {
486 // only whitespace.
487 $this->debug( $this->mFilteredExifData[$prop], __FUNCTION__, "$prop: Is only whitespace" );
488 unset( $this->mFilteredExifData[$prop] );
489
490 return;
491 }
492
493 // all's good.
494 $this->mFilteredExifData[$prop] = $val;
495 }
496 }
497
504 private function exifPropToOrd( $prop ) {
505 if ( isset( $this->mFilteredExifData[$prop] ) ) {
506 $this->mFilteredExifData[$prop] = ord( $this->mFilteredExifData[$prop] );
507 }
508 }
509
515 private function exifGPStoNumber( $prop ) {
516 $loc =& $this->mFilteredExifData[$prop];
517 $dir =& $this->mFilteredExifData[$prop . 'Ref'];
518 $res = false;
519
520 if ( isset( $loc ) && isset( $dir )
521 && ( $dir === 'N' || $dir === 'S' || $dir === 'E' || $dir === 'W' )
522 ) {
523 list( $num, $denom ) = explode( '/', $loc[0] );
524 $res = $num / $denom;
525 list( $num, $denom ) = explode( '/', $loc[1] );
526 $res += ( $num / $denom ) * ( 1 / 60 );
527 list( $num, $denom ) = explode( '/', $loc[2] );
528 $res += ( $num / $denom ) * ( 1 / 3600 );
529
530 if ( $dir === 'S' || $dir === 'W' ) {
531 $res *= -1; // make negative
532 }
533 }
534
535 // update the exif records.
536
537 if ( $res !== false ) { // using !== as $res could potentially be 0
538 $this->mFilteredExifData[$prop] = $res;
539 unset( $this->mFilteredExifData[$prop . 'Ref'] );
540 } else { // if invalid
541 unset( $this->mFilteredExifData[$prop] );
542 unset( $this->mFilteredExifData[$prop . 'Ref'] );
543 }
544 }
545
555 function getData() {
556 return $this->mRawExifData;
557 }
558
563 function getFilteredData() {
565 }
566
581 public static function version() {
582 return 2; // We don't need no bloddy constants!
583 }
584
591 private function isByte( $in ) {
592 if ( !is_array( $in ) && sprintf( '%d', $in ) == $in && $in >= 0 && $in <= 255 ) {
593 $this->debug( $in, __FUNCTION__, true );
594
595 return true;
596 } else {
597 $this->debug( $in, __FUNCTION__, false );
598
599 return false;
600 }
601 }
602
607 private function isASCII( $in ) {
608 if ( is_array( $in ) ) {
609 return false;
610 }
611
612 if ( preg_match( "/[^\x0a\x20-\x7e]/", $in ) ) {
613 $this->debug( $in, __FUNCTION__, 'found a character not in our whitelist' );
614
615 return false;
616 }
617
618 if ( preg_match( '/^\s*$/', $in ) ) {
619 $this->debug( $in, __FUNCTION__, 'input consisted solely of whitespace' );
620
621 return false;
622 }
623
624 return true;
625 }
626
631 private function isShort( $in ) {
632 if ( !is_array( $in ) && sprintf( '%d', $in ) == $in && $in >= 0 && $in <= 65536 ) {
633 $this->debug( $in, __FUNCTION__, true );
634
635 return true;
636 } else {
637 $this->debug( $in, __FUNCTION__, false );
638
639 return false;
640 }
641 }
642
647 private function isLong( $in ) {
648 if ( !is_array( $in ) && sprintf( '%d', $in ) == $in && $in >= 0 && $in <= 4294967296 ) {
649 $this->debug( $in, __FUNCTION__, true );
650
651 return true;
652 } else {
653 $this->debug( $in, __FUNCTION__, false );
654
655 return false;
656 }
657 }
658
663 private function isRational( $in ) {
664 $m = [];
665
666 # Avoid division by zero
667 if ( !is_array( $in )
668 && preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
669 ) {
670 return $this->isLong( $m[1] ) && $this->isLong( $m[2] );
671 } else {
672 $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' );
673
674 return false;
675 }
676 }
677
682 private function isUndefined( $in ) {
683 $this->debug( $in, __FUNCTION__, true );
684
685 return true;
686 }
687
692 private function isSlong( $in ) {
693 if ( $this->isLong( abs( $in ) ) ) {
694 $this->debug( $in, __FUNCTION__, true );
695
696 return true;
697 } else {
698 $this->debug( $in, __FUNCTION__, false );
699
700 return false;
701 }
702 }
703
708 private function isSrational( $in ) {
709 $m = [];
710
711 # Avoid division by zero
712 if ( !is_array( $in ) &&
713 preg_match( '/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
714 ) {
715 return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] );
716 } else {
717 $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' );
718
719 return false;
720 }
721 }
722
734 private function validate( $section, $tag, $val, $recursive = false ) {
735 $debug = "tag is '$tag'";
736 $etype = $this->mExifTags[$section][$tag];
737 $ecount = 1;
738 if ( is_array( $etype ) ) {
739 list( $etype, $ecount ) = $etype;
740 if ( $recursive ) {
741 $ecount = 1; // checking individual elements
742 }
743 }
744
745 $count = 1;
746 if ( is_array( $val ) ) {
747 $count = count( $val );
748 if ( $ecount != $count ) {
749 $this->debug( $val, __FUNCTION__, "Expected $ecount elements for $tag but got $count" );
750 return false;
751 }
752 }
753 // If there are multiple values, recursively validate each of them.
754 if ( $count > 1 ) {
755 foreach ( $val as $v ) {
756 if ( !$this->validate( $section, $tag, $v, true ) ) {
757 return false;
758 }
759 }
760
761 return true;
762 }
763 // Does not work if not typecast
764 switch ( (string)$etype ) {
765 case (string)self::BYTE:
766 $this->debug( $val, __FUNCTION__, $debug );
767
768 return $this->isByte( $val );
769 case (string)self::ASCII:
770 $this->debug( $val, __FUNCTION__, $debug );
771
772 return $this->isASCII( $val );
773 case (string)self::SHORT:
774 $this->debug( $val, __FUNCTION__, $debug );
775
776 return $this->isShort( $val );
777 case (string)self::LONG:
778 $this->debug( $val, __FUNCTION__, $debug );
779
780 return $this->isLong( $val );
781 case (string)self::RATIONAL:
782 $this->debug( $val, __FUNCTION__, $debug );
783
784 return $this->isRational( $val );
785 case (string)self::SHORT_OR_LONG:
786 $this->debug( $val, __FUNCTION__, $debug );
787
788 return $this->isShort( $val ) || $this->isLong( $val );
789 case (string)self::UNDEFINED:
790 $this->debug( $val, __FUNCTION__, $debug );
791
792 return $this->isUndefined( $val );
793 case (string)self::SLONG:
794 $this->debug( $val, __FUNCTION__, $debug );
795
796 return $this->isSlong( $val );
797 case (string)self::SRATIONAL:
798 $this->debug( $val, __FUNCTION__, $debug );
799
800 return $this->isSrational( $val );
801 case (string)self::IGNORE:
802 $this->debug( $val, __FUNCTION__, $debug );
803
804 return false;
805 default:
806 $this->debug( $val, __FUNCTION__, "The tag '$tag' is unknown" );
807
808 return false;
809 }
810 }
811
819 private function debug( $in, $fname, $action = null ) {
820 if ( !$this->log ) {
821 return;
822 }
823 $type = gettype( $in );
824 $class = ucfirst( __CLASS__ );
825 if ( is_array( $in ) ) {
826 $in = print_r( $in, true );
827 }
828
829 if ( $action === true ) {
830 wfDebugLog( $this->log, "$class::$fname: accepted: '$in' (type: $type)" );
831 } elseif ( $action === false ) {
832 wfDebugLog( $this->log, "$class::$fname: rejected: '$in' (type: $type)" );
833 } elseif ( $action === null ) {
834 wfDebugLog( $this->log, "$class::$fname: input was: '$in' (type: $type)" );
835 } else {
836 wfDebugLog( $this->log, "$class::$fname: $action (type: $type; content: '$in')" );
837 }
838 }
839
846 private function debugFile( $fname, $io ) {
847 if ( !$this->log ) {
848 return;
849 }
850 $class = ucfirst( __CLASS__ );
851 if ( $io ) {
852 wfDebugLog( $this->log, "$class::$fname: begin processing: '{$this->basename}'" );
853 } else {
854 wfDebugLog( $this->log, "$class::$fname: end processing: '{$this->basename}'" );
855 }
856 }
857}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The Program
Definition COPYING.txt:64
GNU GENERAL PUBLIC LICENSE June Copyright(C) 1989
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfBaseName( $path, $suffix='')
Return the final portion of a pathname.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:123
Class to extract and validate Exif data from jpeg (and possibly tiff) files.
Definition Exif.php:32
const SRATIONAL
Two SLONGs.
Definition Exif.php:64
validate( $section, $tag, $val, $recursive=false)
#-
Definition Exif.php:734
isRational( $in)
Definition Exif.php:663
const BYTE
An 8-bit (1-byte) unsigned integer.
Definition Exif.php:34
exifPropToOrd( $prop)
Convert an Exif::UNDEFINED from a raw binary string to its value.
Definition Exif.php:504
getData()
#-
Definition Exif.php:555
const SHORT_OR_LONG
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer.
Definition Exif.php:53
string $file
The file being processed.
Definition Exif.php:85
const RATIONAL
Two LONGs.
Definition Exif.php:50
array $mFilteredExifData
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain conten...
Definition Exif.php:82
const UNDEFINED
An 8-bit byte that can take any value depending on the field definition.
Definition Exif.php:56
isUndefined( $in)
Definition Exif.php:682
string $byteOrder
The byte order of the file.
Definition Exif.php:96
static version()
#-
Definition Exif.php:581
const ASCII
An 8-bit byte containing one 7-bit ASCII code.
Definition Exif.php:39
isSrational( $in)
Definition Exif.php:708
getFilteredData()
Get $this->mFilteredExifData.
Definition Exif.php:563
debug( $in, $fname, $action=null)
Convenience function for debugging output.
Definition Exif.php:819
const SHORT
A 16-bit (2-byte) unsigned integer.
Definition Exif.php:42
charCodeString( $prop)
Do userComment tags and similar.
Definition Exif.php:444
const LONG
A 32-bit (4-byte) unsigned integer.
Definition Exif.php:45
array $mExifTags
Exif tags grouped by category, the tagname itself is the key and the type is the value,...
Definition Exif.php:73
array $mRawExifData
The raw Exif data returned by exif_read_data()
Definition Exif.php:76
__construct( $file, $byteOrder='')
Definition Exif.php:108
makeFilteredData()
Make $this->mFilteredExifData.
Definition Exif.php:316
isLong( $in)
Definition Exif.php:647
string $log
The private log to log to, e.g.
Definition Exif.php:91
string $basename
The basename of the file being processed.
Definition Exif.php:88
isSlong( $in)
Definition Exif.php:692
isASCII( $in)
Definition Exif.php:607
collapseData()
Collapse some fields together.
Definition Exif.php:362
isShort( $in)
Definition Exif.php:631
const IGNORE
A fake value for things we don't want or don't support.
Definition Exif.php:67
debugFile( $fname, $io)
Convenience function for debugging output.
Definition Exif.php:846
exifGPStoNumber( $prop)
Convert gps in exif form to a single floating point number for example 10 degress 2040` S -> -10....
Definition Exif.php:515
isByte( $in)
Validates if a tag value is of the type it should be according to the Exif spec.
Definition Exif.php:591
const SLONG
A 32-bit (4-byte) signed integer (2's complement notation),.
Definition Exif.php:59
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:52
MediaWiki exception.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
$res
Definition database.txt:21
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after processing
Definition hooks.txt:2012
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
Definition hooks.txt:179
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:3070
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
$debug
Definition mcc.php:31
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition postgres.txt:30
title
width