]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Cached bookmarks: remove $cacheFolder
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 16 Oct 2015 14:59:13 +0000 (11:59 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 16 Oct 2015 14:59:13 +0000 (11:59 -0300)
data/config.default.php
data/templates/default/bookmarks.tpl.php

index dd220ac2943b07594861f831486b624123071790..95df176f0ada85388644bf0447b56b2975eb687f 100644 (file)
@@ -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.
  */
index 35bbcdbfdebc3fd95eac5110e0a7d6be229cd34f..27b27ee6efa246615738ba1c37682ca2db06af9d 100644 (file)
@@ -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 = "| <a href=\"$assetLink\">Cache</a>";
+      // 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 = "| <a href=\"$assetLink\">Cache</a>";
+        }
+
+        curl_close($fp);
       }
     }