From 79be2a1431af533baab0d2be0cbce882ba6a1fd8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 19 Apr 2017 23:52:25 -0300 Subject: Cache: Handle PDF links --- data/templates/default/bookmarks.tpl.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index a2ff752..818eea0 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -344,9 +344,17 @@ if ($currenttag!= '') { // Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html $assetHash = sha1($row['bAddress'] . "\n"); $assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash; - $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; - $assetPdf = $assetLink .'/screenshot.pdf'; - $assetPng = $assetLink .'/screenshot.png'; + $assetBase = $GLOBALS['cacheUrl'] . '/' . $assetHash; + $assetLink = $assetBase; + $assetPdf = $assetBase.'/screenshot.pdf'; + $assetPng = $assetBase .'/screenshot.png'; + + // Handle PDF links + $assetFile = basename(parse_url($row['bAddress'])['path']); + $assetExt = strtolower(pathinfo($assetFile, PATHINFO_EXTENSION)); + if ($assetExt == 'pdf') { + $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash . '/' . $assetFile; + } // Check if the link exists if (file_exists($cacheInfo .'/'. $assetHash .'/hascache')) { @@ -360,7 +368,7 @@ if ($currenttag!= '') { $cacheLink .= " | PNG"; } } - else if ($fp = curl_init($assetLink)) { + else if ($fp = curl_init($assetBase)) { curl_setopt($fp, CURLOPT_NOBODY, true); curl_exec($fp); -- cgit v1.2.3