aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2015-03-04 19:52:24 +0100
committernodiscc <nodiscc@gmail.com>2015-03-04 20:11:39 +0100
commitad2a397c66a3da8061564602b43db6f2002f0064 (patch)
tree4ddf581755bd8bc41f68006adc9c49b12da699c6 /index.php
parentbc1ef5b94a711a0db249f1773db9b3ca1da31c6c (diff)
downloadShaarli-ad2a397c66a3da8061564602b43db6f2002f0064.tar.gz
Shaarli-ad2a397c66a3da8061564602b43db6f2002f0064.tar.zst
Shaarli-ad2a397c66a3da8061564602b43db6f2002f0064.zip
cleanup: refactor annoying URL patterns in a single loop
* fixes https://github.com/shaarli/Shaarli/issues/133
Diffstat (limited to 'index.php')
-rw-r--r--index.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/index.php b/index.php
index d7140409..cc3d7360 100644
--- a/index.php
+++ b/index.php
@@ -1642,15 +1642,12 @@ function renderPage()
1642 { 1642 {
1643 $url=$_GET['post']; 1643 $url=$_GET['post'];
1644 1644
1645 // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...) 1645 // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook...
1646 $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i); 1646 $annoyingpatterns = array('&utm_source=', '?utm_source=', '#xtor=RSS-', '?fb_', '?__scoop', '#tk.rss_all?', '?utm_campaign=', '?utm_medium=');
1647 $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i); 1647 foreach($annoyingpatterns as $pattern)
1648 $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); 1648 {
1649 $i=strpos($url,'?fb_'); if ($i!==false) $url=substr($url,0,$i); 1649 $i=strpos($url,$pattern); if ($i!==false) $url=substr($url,0,$i);
1650 $i=strpos($url,'?__scoop'); if ($i!==false) $url=substr($url,0,$i); 1650 }
1651 $i=strpos($url,'#tk.rss_all?'); if ($i!==false) $url=substr($url,0,$i);
1652 $i=strpos($url,'?utm_campaign='); if ($i!==false) $url=substr($url,0,$i);
1653 $i=strpos($url,'?utm_medium='); if ($i!==false) $url=substr($url,0,$i);
1654 1651
1655 $link_is_new = false; 1652 $link_is_new = false;
1656 $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) 1653 $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link)