aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-05-18 12:21:43 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commitc56a540c6ef211cd9cb0189ba09911bb77696f28 (patch)
tree3f4c0f1eda4f20c22e51556b5efb024ef2eb3da9 /index.php
parent029ada5a071240fd10f3557fd3c0fc865c54c5a8 (diff)
downloadShaarli-c56a540c6ef211cd9cb0189ba09911bb77696f28.tar.gz
Shaarli-c56a540c6ef211cd9cb0189ba09911bb77696f28.tar.zst
Shaarli-c56a540c6ef211cd9cb0189ba09911bb77696f28.zip
Remove legacy handling of /add-tag route
Diffstat (limited to 'index.php')
-rw-r--r--index.php40
1 files changed, 1 insertions, 39 deletions
diff --git a/index.php b/index.php
index 9dc67c4b..5d689ccb 100644
--- a/index.php
+++ b/index.php
@@ -486,45 +486,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
486 486
487 // -------- User clicks on a tag in a link: The tag is added to the list of searched tags (searchtags=...) 487 // -------- User clicks on a tag in a link: The tag is added to the list of searched tags (searchtags=...)
488 if (isset($_GET['addtag'])) { 488 if (isset($_GET['addtag'])) {
489 // Get previous URL (http_referer) and add the tag to the searchtags parameters in query. 489 header('Location: ./add-tag/'. $_GET['addtag']);
490 if (empty($_SERVER['HTTP_REFERER'])) {
491 // In case browser does not send HTTP_REFERER
492 header('Location: ?searchtags='.urlencode($_GET['addtag']));
493 exit;
494 }
495 parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $params);
496
497 // Prevent redirection loop
498 if (isset($params['addtag'])) {
499 unset($params['addtag']);
500 }
501
502 // Check if this tag is already in the search query and ignore it if it is.
503 // Each tag is always separated by a space
504 if (isset($params['searchtags'])) {
505 $current_tags = explode(' ', $params['searchtags']);
506 } else {
507 $current_tags = array();
508 }
509 $addtag = true;
510 foreach ($current_tags as $value) {
511 if ($value === $_GET['addtag']) {
512 $addtag = false;
513 break;
514 }
515 }
516 // Append the tag if necessary
517 if (empty($params['searchtags'])) {
518 $params['searchtags'] = trim($_GET['addtag']);
519 } elseif ($addtag) {
520 $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']);
521 }
522
523 // We also remove page (keeping the same page has no sense, since the
524 // results are different)
525 unset($params['page']);
526
527 header('Location: ?'.http_build_query($params));
528 exit; 490 exit;
529 } 491 }
530 492