Merge pull request #141 from nodiscc/cleanurl-filters

Add URL cleaning filters + refactoring
This commit is contained in:
nodiscc 2015-03-05 13:42:38 +01:00
commit 01b8f52718

View file

@ -1642,10 +1642,13 @@ function renderPage()
{ {
$url=$_GET['post']; $url=$_GET['post'];
// We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...)
$i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i); // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook...
$i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i); $annoyingpatterns = array('/[\?&]utm_source=[^&]*/', '/[\?&]utm_campaign=[^&]*/', '/[\?&]utm_medium=[^&]*/', '/#xtor=RSS-[^&]*/', '/[\?&]fb_[^&]*/', '/[\?&]__scoop[^&]*/', '/#tk\.rss_all\?/', '/[\?&]action_ref_map=[^&]*/', '/[\?&]action_type_map=[^&]*/', '/[\?&]action_object_map=[^&]*/');
$i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); foreach($annoyingpatterns as $pattern)
{
$url = preg_replace($pattern, "", $url);
}
$link_is_new = false; $link_is_new = false;
$link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link)