Checking array indexes before using them (#1)

This commit is contained in:
Eric van der Vlist 2020-05-09 17:46:21 +02:00
parent a2c3ade47f
commit a1edd4f01c
1 changed files with 4 additions and 2 deletions

View File

@ -39,8 +39,10 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
if ( is_callable( 'exif_read_data' ) ) { if ( is_callable( 'exif_read_data' ) ) {
$exif = @exif_read_data( $p->imagePath ); $exif = @exif_read_data( $p->imagePath );
if ( $exif !== false ) { if ( $exif !== false ) {
$item['lon'] = getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ); $item['lon'] = (array_key_exists('GPSLongiture', $exif) and array_key_exists('GPSLongitudeRef', $exif)) ?
$item['lat'] = getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ); getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ) : 0;
$item['lat'] = (array_key_exists('GPSLatitude', $exif) and array_key_exists('GPSLatitudeRef', $exif)) ?
getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ) : 0;
if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) { if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) {
$result[] = $item; $result[] = $item;
} elseif ( isset( $p->imagedate ) ) { } elseif ( isset( $p->imagedate ) ) {