diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-07-08 16:28:31 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2015-07-12 10:34:29 +0200 |
commit | 781e8aadea7590dc87b61915b6e65ec52f7d250e (patch) | |
tree | 75cd698987e2d73ae050135a7fde15ceb7e6880e /index.php | |
parent | eee711c0a8583e1c2ea2186544795d59fa41d9f6 (diff) | |
download | Shaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.tar.gz Shaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.tar.zst Shaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.zip |
Avoid tag duplicates
* Prevent duplicate client side with awesomplete
* Prevent duplicate server side (save_edit processing)
Fixes #261
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -709,7 +709,7 @@ function showRSS() | |||
709 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); | 709 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); |
710 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 710 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
711 | else $linksToDisplay = $LINKSDB; | 711 | else $linksToDisplay = $LINKSDB; |
712 | 712 | ||
713 | $nblinksToDisplay = 50; // Number of links to display. | 713 | $nblinksToDisplay = 50; // Number of links to display. |
714 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. | 714 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. |
715 | { | 715 | { |
@@ -789,7 +789,7 @@ function showATOM() | |||
789 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); | 789 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); |
790 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 790 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
791 | else $linksToDisplay = $LINKSDB; | 791 | else $linksToDisplay = $LINKSDB; |
792 | 792 | ||
793 | $nblinksToDisplay = 50; // Number of links to display. | 793 | $nblinksToDisplay = 50; // Number of links to display. |
794 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. | 794 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. |
795 | { | 795 | { |
@@ -1041,7 +1041,7 @@ function renderPage() | |||
1041 | if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); | 1041 | if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); |
1042 | elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 1042 | elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
1043 | else $links = $LINKSDB; | 1043 | else $links = $LINKSDB; |
1044 | 1044 | ||
1045 | $body=''; | 1045 | $body=''; |
1046 | $linksToDisplay=array(); | 1046 | $linksToDisplay=array(); |
1047 | 1047 | ||
@@ -1056,7 +1056,7 @@ function renderPage() | |||
1056 | $linksToDisplay[]=$link; // Add to array. | 1056 | $linksToDisplay[]=$link; // Add to array. |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | $PAGE = new pageBuilder; | 1060 | $PAGE = new pageBuilder; |
1061 | $PAGE->assign('linkcount',count($LINKSDB)); | 1061 | $PAGE->assign('linkcount',count($LINKSDB)); |
1062 | $PAGE->assign('linksToDisplay',$linksToDisplay); | 1062 | $PAGE->assign('linksToDisplay',$linksToDisplay); |
@@ -1330,6 +1330,7 @@ function renderPage() | |||
1330 | { | 1330 | { |
1331 | if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! | 1331 | if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! |
1332 | $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces. | 1332 | $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces. |
1333 | $tags = implode(' ', array_unique(explode(' ', $tags))); // Remove duplicates. | ||
1333 | $linkdate=$_POST['lf_linkdate']; | 1334 | $linkdate=$_POST['lf_linkdate']; |
1334 | $url = trim($_POST['lf_url']); | 1335 | $url = trim($_POST['lf_url']); |
1335 | if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:')) | 1336 | if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:')) |