From 49cc1a0e3fb6056f501c4515f17b110540c9b5c9 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 22 Mar 2023 02:34:54 -0400 Subject: New upstream version 4.11.0. --- index.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 9 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index b261c55..3f8b038 100644 --- a/index.php +++ b/index.php @@ -2,13 +2,13 @@ /* - Single File PHP Gallery 4.10.0 (SFPG) + Single File PHP Gallery 4.11.0 (SFPG) See EULA in readme.txt for commercial use See readme.txt for configuration - Released: 10-may-2022 - http://sye.dk/sfpg/ + Released: 6-october-2022 + https://sye.dk/sfpg/ by Kenny Svalgaard */ @@ -67,6 +67,7 @@ option('UNDERSCORE_AS_SPACE', TRUE); option('SHOW_EXIF_INFO', TRUE); option('SHOW_IPTC_INFO', TRUE); + option('PNG_TEXT_CHUNKS', TRUE); // Use only lower case when set to an array. option('SHOW_INFO_BY_DEFAULT', FALSE); option('ROUND_CORNERS', 3); @@ -218,6 +219,7 @@ option('TEXT_EXIF_MAP_EMBED', 'Image map'); option('EXIF_MAP_EMBED_LINK', 'https://maps.google.com/maps?q=[lat],[long]&output=embed'); + option('TEXT_PNG_CHUNKS', 'PNG text chunks'); option('TEXT_IPTC', 'IPTC'); option('IPTC', [ @@ -936,7 +938,10 @@ if(isset($exif_data['DateTimeOriginal'])) { $exif_time = explode(':', str_replace(' ', ':', $exif_data['DateTimeOriginal'])); - $image_info['exifDate'] = block_html(mktime($exif_time[3], $exif_time[4], $exif_time[5], $exif_time[1], $exif_time[2], $exif_time[0])); + if(count($exif_time)==6) + { + $image_info['exifDate'] = block_html(mktime((int)$exif_time[3], (int)$exif_time[4], (int)$exif_time[5], (int)$exif_time[1], (int)$exif_time[2], (int)$exif_time[0])); + } } if (isset($exif_data['Model'])) { @@ -1095,6 +1100,47 @@ } } } + if (PNG_TEXT_CHUNKS and (sfpg_ext($image_file)=='.png')) + { + if ($png_fp = @fopen(GALLERY_ROOT.$image_dir.$image_file, 'rb')) + { + if("\x89PNG\x0d\x0a\x1a\x0a" === fread($png_fp, 8)) // first 8 bytes in a PNG must be like this + { + $png_text_chunks=[]; + while(!feof($png_fp)) + { + $chunk_info = @unpack('Nlength/a4type', fread($png_fp, 8)); + if(!$chunk_info or ($chunk_info['type'] == 'IEND')) + { + break; + } + if($chunk_info['type'] == 'tEXt') + { + $chunk_data = fread($png_fp, $chunk_info['length']); + $chunk_crc = @unpack('Ncrc', fread($png_fp, 4)); + if($chunk_crc and ($chunk_crc['crc'] === crc32($chunk_info['type'].$chunk_data))) + { + list($keyword, $value) = explode("\0", $chunk_data); + if((PNG_TEXT_CHUNKS === TRUE) or ((is_array(PNG_TEXT_CHUNKS)) and (in_array(strtolower($keyword), PNG_TEXT_CHUNKS)))) + { + $png_text_chunks[]=$keyword; + $png_text_chunks[]=$value; + } + } + } + else + { + fseek($png_fp, $chunk_info['length']+4, SEEK_CUR); // skipping the chunk + crc + } + } + fclose($png_fp); + if(count($png_text_chunks)>0) + { + $image_info['pngChunks'] = $png_text_chunks; + } + } + } + } if (WATERMARK) { $wm_file = GALLERY_ROOT.ICONS_DIR.WATERMARK; @@ -1328,7 +1374,21 @@ echo $name.'['.$id.'] = {'; foreach($array as $key=>$val) { - echo $sep.'"'.$key.'":"'.sts($val, $nl_to_br).'"'; + if(is_array($val)) + { + $arrSep=''; + echo $sep.'"'.$key.'":['; + foreach($val as $v) + { + echo $arrSep.'"'.sts($v, $nl_to_br).'"'; + $arrSep=', '; + } + echo ']'; + } + else + { + echo $sep.'"'.$key.'":"'.sts($val, $nl_to_br).'"'; + } $sep=', '; } echo "};\n"; @@ -1822,6 +1882,22 @@ info += '".sts(TEXT_IPTC)."
'+iptcInfo+'

'; }"; } + if (PNG_TEXT_CHUNKS) + { + echo" + if (isDef(imgInfo[id]['pngChunks'])) + { + info += '".sts(TEXT_PNG_CHUNKS)."
'; + var brsep=''; + for (i=0; i'+imgInfo[id]['pngChunks'][i]+'
'+imgInfo[id]['pngChunks'][i+1]; + brsep='

'; + } + info += '

'; + } + "; + } echo" } else @@ -1858,7 +1934,7 @@ } echo " } - info += '

Single File PHP Gallery'; + info += '

Single File PHP Gallery'; gebi('box_inner_info').innerHTML = info; } } @@ -2769,12 +2845,12 @@ $a_links[] = $gal_dirs; } } - $link_disp_lenght = strlen(TEXT_HOME) + 4; + $link_disp_length = strlen(TEXT_HOME) + 4; $start_link = count($a_names)-1; for($i = count($a_names)-1; $i >= 0; $i--) { - $link_disp_lenght += strlen($a_names[$i]) + 5; - if ($link_disp_lenght < NAVI_CHARS_MAX) + $link_disp_length += strlen($a_names[$i]) + 5; + if ($link_disp_length < NAVI_CHARS_MAX) { $start_link = $i; } -- cgit v1.2.3