From 04f8158cfa7827de0b0e3c70d98d02c14f05354f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 12 Aug 2015 10:04:22 -0300 Subject: Fix opensearch URL when root config is defined --- www/api/opensearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/api/opensearch.php b/www/api/opensearch.php index 3e7dbf7..9d3eae7 100644 --- a/www/api/opensearch.php +++ b/www/api/opensearch.php @@ -12,5 +12,5 @@ echo '<' . '?xml version="1.0" encoding="utf-8" ?' . ">\n"; Jan Seifert "jan.seifert@uid.com" semanticscuttle bookmark web data:image/gif;base64,R0lGODlhEAAQAMZ9ANaPE9mREteTHtSXLdmXIdiXJtaYKdiYJ9iYKNeaLtKdP9CdRd2dLNWfQuWiFMqjX9+hNMykXt6jPOCkPM2oaM+paeCpQuGoR+OqOeKpR+GqS9+uWeSwU+ayS+uzOeWxVeWxWOSyWOu0POazXOS0YOm8Zee8cOy+WOm9a/jBLum+bPbCNurAbe7BYuvBc/LDV/LEV+zEdv/KKf/KLP/KLf/LLuzHe//MNP/NN/nMTv/OOf/OPP/OP/jNW//PPvnOVv/QQv7QRv/QRP/RR/HOhP/SSf/STPnRav/TT//TUPfScf/UUvzUXP/UVP/VV/bTfv/WWf/WW//WXP7XYf/XX//XYP/YZPPVmf/ZZv/ZZ/vYeP/aaf/aa//abP/abf/abvvaef/bb//bcfzbfP/ccv/cc//cdP/cdf/dd//deP/def3egP/ee//efP/efv/ffv/ggf/gg//ghP/ghfrfmv/hif/ii//ijP/jkfzjm//kkv7klv/lmP///////////yH5BAEKAH8ALAAAAAAQABAAAAergH+Cg38hhIeHIFcmiIgDLnt0Go2EE1pyd0QbjQMQDC9bZGprKBcjA4IfAQMrQUhOVFlhaGNPMRl/Aw4yMzc7QkZNUlZdZmASqAJKcW1WPDpARUtQUx0RgyR5fHpzUTU4PkMiqIMVNnh2c25lSTQpAIgqdXJvaWReXz0JiCxwbWhiuGCp8uMAohJszhw5AYMJlBwFEHFoYQHBAwUEMHgwgKjBA0QLKFAaKSgQADs= - + -- cgit v1.2.3 From 1b056fa2334b5743ce0ed69b4ec550d974b711fd Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 12 Aug 2015 10:33:35 -0300 Subject: Fix mod_rewrite issue --- www/.htaccess | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/.htaccess b/www/.htaccess index 563fe53..5799444 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -3,6 +3,10 @@ # (see $cleanurls in config.inc.php) ##################################### +# See https://stackoverflow.com/questions/4558629/mod-rewrite-not-behaving-nicely +# http://www.bennadel.com/blog/2218-Negotiation-Discovered-File-s-Matching-Request-None-Could-Be-Negotiated.htm +# https://httpd.apache.org/docs/current/content-negotiation.html +Options -MultiViews +FollowSymLinks # Rewrite clean URLs onto real files -- cgit v1.2.3 From 9a0f688b376bd8c95356f4226a960a0fbc466422 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 12 Aug 2015 10:49:40 -0300 Subject: Initial code for showing cached bookmarks --- data/config.default.php | 23 +++++++++++++++++++++++ data/templates/default/bookmarks.tpl.php | 15 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/data/config.default.php b/data/config.default.php index 5e560a7..dd220ac 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -778,4 +778,27 @@ $unittestUrl = null; */ $allowUnittestMode = false; +/*************************************************** + * Caching support + * + * Use the following configuration if you want to provide a link + * to a cached copy of your bookmarks. + * + * Please note that these feature just provide the link if a cached + * copy exists. + * + * You should download SemanticScuttle bookmarks using a tool like + * https://git.sarava.org/?p=httruta.git + */ + +/** + * Set to the filesystem folder where your bookmark cache resides. + */ +$cacheFolder = null; + +/** + * Set to the base public URL of you cache folder. + */ +$cacheUrl = null; + ?> diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 2a3d169..35bbcdb 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -337,6 +337,20 @@ if ($currenttag!= '') { } } + // Local cache + $cacheLink = null; + if ($GLOBALS['cacheFolder'] != null && $GLOBALS['cacheUrl'] != null) { + // 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; + $assetFile = $GLOBALS['cacheFolder'] . '/' . $assetHash; + + if (file_exists($assetFile)) { + $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; + $cacheLink = "| Cache"; + } + } + // Copy link if ($userservice->isLoggedOn() && ($currentUser->getId() != $row['uId']) @@ -425,6 +439,7 @@ if ($currenttag!= '') { . $copy . "\n" . $edit . "\n" . $update . "\n" + . $cacheLink ."\n" . " \n"; echo $privateNoteField != '' ? '
'.$privateNoteField."
\n" -- cgit v1.2.3 From ee8d18f0f9dafd2b148a28a2647f62559c76a960 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 16 Oct 2015 11:59:13 -0300 Subject: Cached bookmarks: remove $cacheFolder --- data/config.default.php | 7 +------ data/templates/default/bookmarks.tpl.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/data/config.default.php b/data/config.default.php index dd220ac..95df176 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -788,14 +788,9 @@ $allowUnittestMode = false; * copy exists. * * You should download SemanticScuttle bookmarks using a tool like - * https://git.sarava.org/?p=httruta.git + * https://git.fluxo.info/?p=httruta.git */ -/** - * Set to the filesystem folder where your bookmark cache resides. - */ -$cacheFolder = null; - /** * Set to the base public URL of you cache folder. */ diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 35bbcdb..27b27ee 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -339,15 +339,24 @@ if ($currenttag!= '') { // Local cache $cacheLink = null; - if ($GLOBALS['cacheFolder'] != null && $GLOBALS['cacheUrl'] != null) { + if ($GLOBALS['cacheUrl'] != null) { // 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; - $assetFile = $GLOBALS['cacheFolder'] . '/' . $assetHash; + $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; - if (file_exists($assetFile)) { - $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; - $cacheLink = "| Cache"; + // Check if the link exists + if ($fp = curl_init($assetLink)) { + curl_setopt($fp, CURLOPT_NOBODY, true); + curl_exec($fp); + + $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); + + if ($retcode == 200) { + $cacheLink = "| Cache"; + } + + curl_close($fp); } } -- cgit v1.2.3 From 6eee6f93b6a6255982f261e7edd122a5bc760f32 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 16 Oct 2015 13:29:23 -0300 Subject: Local cache: test for 404 status code --- data/templates/default/bookmarks.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 27b27ee..4fa8d8b 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -352,7 +352,7 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); - if ($retcode == 200) { + if ($retcode != 404) { $cacheLink = "| Cache"; } -- cgit v1.2.3 From e5ebe4e5519c48b225b03b5532eb8c5643b7afea Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 19:42:25 -0300 Subject: Cache: PDF support --- data/templates/default/bookmarks.tpl.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 4fa8d8b..19ab6a8 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -344,6 +344,7 @@ if ($currenttag!= '') { $assetHash = sha1($row['bAddress'] . "\n"); $assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash; $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; + $assetPdf = $assetLink .'/screenshot.pdf'; // Check if the link exists if ($fp = curl_init($assetLink)) { @@ -354,6 +355,20 @@ if ($currenttag!= '') { if ($retcode != 404) { $cacheLink = "| Cache"; + + // Check if PDF is available + if ($fp = curl_init($assetPdf)) { + curl_setopt($fp, CURLOPT_NOBODY, true); + curl_exec($fp); + + $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); + + if ($retcode != 404) { + $cacheLink .= " | PDF"; + } + + curl_close($fp); + } } curl_close($fp); -- cgit v1.2.3 From 153bf795eb756fdd92583ccd4d2485640085015d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 20:48:42 -0300 Subject: Cache: PNG support --- data/templates/default/bookmarks.tpl.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 19ab6a8..4f22e91 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -345,6 +345,7 @@ if ($currenttag!= '') { $assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash; $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; $assetPdf = $assetLink .'/screenshot.pdf'; + $assetPng = $assetLink .'/screenshot.png'; // Check if the link exists if ($fp = curl_init($assetLink)) { @@ -369,6 +370,20 @@ if ($currenttag!= '') { curl_close($fp); } + + // Check if PNG is available + if ($fp = curl_init($assetPng)) { + curl_setopt($fp, CURLOPT_NOBODY, true); + curl_exec($fp); + + $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); + + if ($retcode != 404) { + $cacheLink .= " | PNG"; + } + + curl_close($fp); + } } curl_close($fp); -- cgit v1.2.3 From de24e70ae17850b12ff8ac69439da86bb6d77d74 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 22:08:01 -0300 Subject: Cache cacheUrl information to avoid slowness due to excessive curls calls --- data/templates/default/bookmarks.tpl.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 4f22e91..6b8a7c7 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -338,6 +338,7 @@ if ($currenttag!= '') { } // Local cache + $cacheInfo = $GLOBALS['dir_cache'] .'/urls'; $cacheLink = null; if ($GLOBALS['cacheUrl'] != null) { // Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html @@ -348,13 +349,29 @@ if ($currenttag!= '') { $assetPng = $assetLink .'/screenshot.png'; // Check if the link exists - if ($fp = curl_init($assetLink)) { + if (file_exists($cacheInfo .'/' $assetHash .'/hascache')) { + $cacheLink = "| Cache"; + + if (file_exists($cacheInfo .'/' $assetHash .'/haspdf')) { + $cacheLink .= " | PDF"; + } + + if (file_exists($cacheInfo .'/' $assetHash .'/haspng')) { + $cacheLink .= " | PNG"; + } + } + else if ($fp = curl_init($assetLink)) { curl_setopt($fp, CURLOPT_NOBODY, true); curl_exec($fp); $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { + if (!file_exists($cacheInfo .'/' $assetHash)) { + mkdir($cacheInfo .'/' $assetHash); + } + + touch($cacheInfo .'/' $assetHash .'/hascache'); $cacheLink = "| Cache"; // Check if PDF is available @@ -365,6 +382,7 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { + touch($cacheInfo .'/' $assetHash .'/haspdf'); $cacheLink .= " | PDF"; } @@ -379,6 +397,7 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { + touch($cacheInfo .'/' $assetHash .'/haspng'); $cacheLink .= " | PNG"; } -- cgit v1.2.3 From 5c168b0e892c9a1d2a7acee2e3eaf13156b16020 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 22:10:13 -0300 Subject: Syntax fixes --- data/templates/default/bookmarks.tpl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 6b8a7c7..a0ef56e 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -349,14 +349,14 @@ if ($currenttag!= '') { $assetPng = $assetLink .'/screenshot.png'; // Check if the link exists - if (file_exists($cacheInfo .'/' $assetHash .'/hascache')) { + if (file_exists($cacheInfo .'/'. $assetHash .'/hascache')) { $cacheLink = "| Cache"; - if (file_exists($cacheInfo .'/' $assetHash .'/haspdf')) { + if (file_exists($cacheInfo .'/'. $assetHash .'/haspdf')) { $cacheLink .= " | PDF"; } - if (file_exists($cacheInfo .'/' $assetHash .'/haspng')) { + if (file_exists($cacheInfo .'/'. $assetHash .'/haspng')) { $cacheLink .= " | PNG"; } } @@ -367,11 +367,11 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { - if (!file_exists($cacheInfo .'/' $assetHash)) { + if (!file_exists($cacheInfo .'/'. $assetHash)) { mkdir($cacheInfo .'/' $assetHash); } - touch($cacheInfo .'/' $assetHash .'/hascache'); + touch($cacheInfo .'/'. $assetHash .'/hascache'); $cacheLink = "| Cache"; // Check if PDF is available @@ -382,7 +382,7 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { - touch($cacheInfo .'/' $assetHash .'/haspdf'); + touch($cacheInfo .'/'. $assetHash .'/haspdf'); $cacheLink .= " | PDF"; } -- cgit v1.2.3 From 7209ebbb7017553ce106c9f23730190a153d2f2e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 22:12:00 -0300 Subject: Syntax fixes --- data/templates/default/bookmarks.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index a0ef56e..9b05650 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -368,7 +368,7 @@ if ($currenttag!= '') { if ($retcode != 404) { if (!file_exists($cacheInfo .'/'. $assetHash)) { - mkdir($cacheInfo .'/' $assetHash); + mkdir($cacheInfo .'/'. $assetHash); } touch($cacheInfo .'/'. $assetHash .'/hascache'); @@ -397,7 +397,7 @@ if ($currenttag!= '') { $retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE); if ($retcode != 404) { - touch($cacheInfo .'/' $assetHash .'/haspng'); + touch($cacheInfo .'/'. $assetHash .'/haspng'); $cacheLink .= " | PNG"; } -- cgit v1.2.3 From b17948a6e493bc6930303527011942212a543db2 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 22:17:12 -0300 Subject: Create cacheUrl cacheInfo folder recursivelly --- data/templates/default/bookmarks.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 9b05650..a2ff752 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -368,7 +368,7 @@ if ($currenttag!= '') { if ($retcode != 404) { if (!file_exists($cacheInfo .'/'. $assetHash)) { - mkdir($cacheInfo .'/'. $assetHash); + mkdir($cacheInfo .'/'. $assetHash, 0755, true); } touch($cacheInfo .'/'. $assetHash .'/hascache'); -- cgit v1.2.3 From bc9aa35e8f2f32e6b2537d15eb5cd87ef3bd08f3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 22:36:31 -0300 Subject: Adds cache into .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7695176..725443e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ semanticscuttle-dump.sql data/config.php data/config.testing.php data/config.testing-tmp.php +cache -- cgit v1.2.3 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 From f06e78a888f914788f0634feb93fcef071518e9d Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 12 Sep 2017 08:51:08 -0500 Subject: Added missing semicolon. --- data/schema/2.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/schema/2.sql b/data/schema/2.sql index 6c3bfaf..171e011 100644 --- a/data/schema/2.sql +++ b/data/schema/2.sql @@ -1,4 +1,4 @@ -ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` VARCHAR( 1500 ) +ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` VARCHAR( 1500 ); CREATE TABLE `sc_tagscache` ( `tcId` int(11) NOT NULL auto_increment, `tag1` varchar(100) NOT NULL default '', -- cgit v1.2.3