summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php94
1 files changed, 85 insertions, 9 deletions
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 += '<strong>".sts(TEXT_IPTC)."</strong><br><div class=\"sfpg_info_text\">'+iptcInfo+'</div><br>';
}";
}
+ if (PNG_TEXT_CHUNKS)
+ {
+ echo"
+ if (isDef(imgInfo[id]['pngChunks']))
+ {
+ info += '<strong>".sts(TEXT_PNG_CHUNKS)."</strong><br><div class=\"sfpg_info_text\">';
+ var brsep='';
+ for (i=0; i<imgInfo[id]['pngChunks'].length; i=i+2)
+ {
+ info += brsep+'<b>'+imgInfo[id]['pngChunks'][i]+'</b><br>'+imgInfo[id]['pngChunks'][i+1];
+ brsep='<br><br>';
+ }
+ info += '</div><br>';
+ }
+ ";
+ }
echo"
}
else
@@ -1858,7 +1934,7 @@
}
echo "
}
- info += '<br><br><small><a href=\"http://sye.dk/sfpg/\" target=\"_blank\" alt=\"\">Single File PHP Gallery</a></small>';
+ info += '<br><br><small><a href=\"https://sye.dk/sfpg/\" target=\"_blank\" alt=\"\">Single File PHP Gallery</a></small>';
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;
}