]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
split annoyingpatterns list on multpile lines, add new patterns for removal:
[github/shaarli/Shaarli.git] / index.php
index 80cf8beaebec6a2ca1cd771a4ea9168b376839a5..9561f63b63a3975b897ab894334dfa1025168f7f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -946,8 +946,12 @@ function showRSS()
     // Optionally filter the results:
     $linksToDisplay=array();
     if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
-    elseif (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
+    else if (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
     else $linksToDisplay = $LINKSDB;
+    
+    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+        $linksToDisplay = array();
+        
     $nblinksToDisplay = 50;  // Number of links to display.
     if (!empty($_GET['nb']))  // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
     {
@@ -1021,8 +1025,12 @@ function showATOM()
     // Optionally filter the results:
     $linksToDisplay=array();
     if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
-    elseif (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
+    else if (!empty($_GET['searchtags']))   $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
     else $linksToDisplay = $LINKSDB;
+    
+    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+        $linksToDisplay = array();
+        
     $nblinksToDisplay = 50;  // Number of links to display.
     if (!empty($_GET['nb']))  // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
     {
@@ -1182,6 +1190,8 @@ function showDaily()
     }
 
     $linksToDisplay=$LINKSDB->filterDay($day);
+    if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+        $linksToDisplay = array();
     // We pre-format some fields for proper output.
     foreach($linksToDisplay as $key=>$link)
     {
@@ -1260,6 +1270,10 @@ function renderPage()
         if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
         elseif (!empty($_GET['searchtags']))   $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
         else $links = $LINKSDB;
+        
+        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+            $links = array();
+            
         $body='';
         $linksToDisplay=array();
 
@@ -1274,6 +1288,7 @@ function renderPage()
                 $linksToDisplay[]=$link; // Add to array.
             }
         }
+            
         $PAGE = new pageBuilder;
         $PAGE->assign('linkcount',count($LINKSDB));
         $PAGE->assign('linksToDisplay',$linksToDisplay);
@@ -1285,6 +1300,8 @@ function renderPage()
     if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
     {
         $tags= $LINKSDB->allTags();
+        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+            $tags = array();
         // We sort tags alphabetically, then choose a font size according to count.
         // First, find max value.
         $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
@@ -1647,7 +1664,20 @@ function renderPage()
 
 
         // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook...
-        $annoyingpatterns = array('/[\?&]utm_source=[^&]*/', '/[\?&]utm_campaign=[^&]*/', '/[\?&]utm_medium=[^&]*/', '/#xtor=RSS-[^&]*/', '/[\?&]fb_[^&]*/', '/[\?&]__scoop[^&]*/', '/#tk\.rss_all\?/', '/[\?&]action_ref_map=[^&]*/', '/[\?&]action_type_map=[^&]*/', '/[\?&]action_object_map=[^&]*/');
+        $annoyingpatterns = array('/[\?&]utm_source=[^&]*/',
+            '/[\?&]utm_campaign=[^&]*/',
+            '/[\?&]utm_medium=[^&]*/',
+            '/#xtor=RSS-[^&]*/',
+            '/[\?&]fb_[^&]*/',
+            '/[\?&]__scoop[^&]*/',
+            '/#tk\.rss_all\?/',
+            '/[\?&]action_ref_map=[^&]*/',
+            '/[\?&]action_type_map=[^&]*/',
+            '/[\?&]action_object_map=[^&]*/',
+            '/[\?&]utm_content=[^&]*/',
+            '/[\?&]fb=[^&]*/',
+            '/[\?&]xtor=[^&]*/'
+            );
         foreach($annoyingpatterns as $pattern)
         {
             $url = preg_replace($pattern, "", $url);
@@ -1884,12 +1914,16 @@ function buildLinkList($PAGE,$LINKSDB)
     if (isset($_GET['searchterm'])) // Fulltext search
     {
         $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm']));
+        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+            $linksToDisplay = array();  
         $search_crits=htmlspecialchars(trim($_GET['searchterm']));
         $search_type='fulltext';
     }
     elseif (isset($_GET['searchtags'])) // Search by tag
     {
         $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
+        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
+            $linksToDisplay = array();
         $search_crits=explode(' ',trim($_GET['searchtags']));
         $search_type='tags';
     }