aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-08-14 01:14:07 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-08-15 15:58:38 +0200
commitd9d776af19fd0a191f82525991dafbb56e1bcfcb (patch)
tree96f5271dfc13048c43e81079b6d8a10d876b8b79 /index.php
parenta3b1b4ae709bd3c5a8ec6fe29aa36fd01c52bca5 (diff)
downloadShaarli-d9d776af19fd0a191f82525991dafbb56e1bcfcb.tar.gz
Shaarli-d9d776af19fd0a191f82525991dafbb56e1bcfcb.tar.zst
Shaarli-d9d776af19fd0a191f82525991dafbb56e1bcfcb.zip
Links: refactor & improve URL cleanup
Relates to #141 Relates to #133 Modifications - move URL cleanup to `application/Url.php` - rework the cleanup function - fragments: `#stuff` - GET parameters: `?var1=val1&var2=val2` - add documentation (APIs the params belong to) - add test coverage Reference - http://php.net/parse_url - http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php27
1 files changed, 4 insertions, 23 deletions
diff --git a/index.php b/index.php
index 84b8f015..74f95497 100755
--- a/index.php
+++ b/index.php
@@ -74,6 +74,7 @@ require_once 'application/Cache.php';
74require_once 'application/CachedPage.php'; 74require_once 'application/CachedPage.php';
75require_once 'application/LinkDB.php'; 75require_once 'application/LinkDB.php';
76require_once 'application/TimeZone.php'; 76require_once 'application/TimeZone.php';
77require_once 'application/Url.php';
77require_once 'application/Utils.php'; 78require_once 'application/Utils.php';
78require_once 'application/Config.php'; 79require_once 'application/Config.php';
79 80
@@ -1479,29 +1480,9 @@ function renderPage()
1479 } 1480 }
1480 1481
1481 // -------- User want to post a new link: Display link edit form. 1482 // -------- User want to post a new link: Display link edit form.
1482 if (isset($_GET['post'])) 1483 if (isset($_GET['post'])) {
1483 { 1484 $url = new Url($_GET['post']);
1484 $url=$_GET['post']; 1485 $url->cleanup();
1485
1486 // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook...
1487 $annoyingpatterns = array('/[\?&]utm_source=[^&]*/',
1488 '/[\?&]utm_campaign=[^&]*/',
1489 '/[\?&]utm_medium=[^&]*/',
1490 '/#xtor=RSS-[^&]*/',
1491 '/[\?&]fb_[^&]*/',
1492 '/[\?&]__scoop[^&]*/',
1493 '/#tk\.rss_all\?/',
1494 '/[\?&]action_ref_map=[^&]*/',
1495 '/[\?&]action_type_map=[^&]*/',
1496 '/[\?&]action_object_map=[^&]*/',
1497 '/[\?&]utm_content=[^&]*/',
1498 '/[\?&]fb=[^&]*/',
1499 '/[\?&]xtor=[^&]*/'
1500 );
1501 foreach($annoyingpatterns as $pattern)
1502 {
1503 $url = preg_replace($pattern, "", $url);
1504 }
1505 1486
1506 $link_is_new = false; 1487 $link_is_new = false;
1507 $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) 1488 $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link)