From 652eaac128b80e13a6dddb6ecb9ca1e647e70cf8 Mon Sep 17 00:00:00 2001 From: Piotr KUCHARSKI Date: Sat, 22 Nov 2014 23:53:35 +0100 Subject: [PATCH] "/" in the uri must never be urlencoded, it breaks opening files completely. also remove some code repetition. --- index.php | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/index.php b/index.php index 317c383..f333e5a 100644 --- a/index.php +++ b/index.php @@ -289,41 +289,27 @@ $dirs = array(); if (is_file($currentdir.'/'.$file.'.html')) { $img_captions[$file] = $file.'::'.htmlspecialchars(file_get_contents($currentdir.'/'.$file.'.html'),ENT_QUOTES); } + $linkUrl = rawurlencode("$currentdir/$file"); + $imgParams = http_build_query( + array( + 'filename' => "$thumbdir/$file", + 'size' => $thumb_size + ), + '', + '&' + ); + $imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams"; if ($lazyload) { - $linkUrl = urlencode("$currentdir/$file"); - $imgParams = http_build_query( - array( - 'filename' => "$thumbdir/$file", - 'size' => $thumb_size - ), - '', - '&' - ); - $imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams"; - - $files[] = array ( - "name" => $file, - "date" => filemtime($currentdir . "/" . $file), - "size" => filesize($currentdir . "/" . $file), - "html" => "
  • $label_loading" . $filename_caption . "
  • "); + $imgopts = "class=\"b-lazy\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\""; } else { - $linkUrl = urlencode("$currentdir/$file"); - $imgParams = http_build_query( - array( - 'filename' => "$thumbdir/$file", - 'size' => $thumb_size - ), - '', - '&' - ); - $imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams"; - - $files[] = array ( - "name" => $file, + $imgopts = "src=\"{$imgUrl}\""; + } + $files[] = array ( + "name" => $file, "date" => filemtime($currentdir . "/" . $file), "size" => filesize($currentdir . "/" . $file), - "html" => "
  • $label_loading" . $filename_caption . "
  • "); } - } + "html" => "
  • $label_loading" . $filename_caption . "
  • "); + } // Other filetypes $extension = ""; if (preg_match("/.pdf$/i", $file)) $extension = "PDF"; // PDF