aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-01-16 13:07:53 +0100
committerArthurHoaro <arthur@hoa.ro>2017-01-16 13:07:53 +0100
commit95e5add4be1fb98a1cae5d30f4fd6e0d2b0a56bc (patch)
tree195cbf8a570faa7765a1f4f01f5f9dc3eff9b352 /index.php
parentae7f6b9d09c0f3e31d64e6c8a9804d5ab0c62eae (diff)
downloadShaarli-95e5add4be1fb98a1cae5d30f4fd6e0d2b0a56bc.tar.gz
Shaarli-95e5add4be1fb98a1cae5d30f4fd6e0d2b0a56bc.tar.zst
Shaarli-95e5add4be1fb98a1cae5d30f4fd6e0d2b0a56bc.zip
Fix redirection after link deletion
relates to #756
Diffstat (limited to 'index.php')
-rw-r--r--index.php34
1 files changed, 9 insertions, 25 deletions
diff --git a/index.php b/index.php
index 145ea3f6..677c196a 100644
--- a/index.php
+++ b/index.php
@@ -1349,31 +1349,15 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1349 1349
1350 // If we are called from the bookmarklet, we must close the popup: 1350 // If we are called from the bookmarklet, we must close the popup:
1351 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } 1351 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
1352 // Pick where we're going to redirect 1352
1353 // ============================================================= 1353 $location = '?';
1354 // Basically, we can't redirect to where we were previously if it was a permalink 1354 if (isset($_SERVER['HTTP_REFERER'])) {
1355 // or an edit_link, because it would 404. 1355 // Don't redirect to where we were previously if it was a permalink or an edit_link, because it would 404.
1356 // Cases: 1356 $location = generateLocation(
1357 // - / : nothing in $_GET, redirect to self 1357 $_SERVER['HTTP_REFERER'],
1358 // - /?page : redirect to self 1358 $_SERVER['HTTP_HOST'],
1359 // - /?searchterm : redirect to self (there might be other links) 1359 ['delete_link', 'edit_link', $link['shorturl']]
1360 // - /?searchtags : redirect to self 1360 );
1361 // - /permalink : redirect to / (the link does not exist anymore)
1362 // - /?edit_link : redirect to / (the link does not exist anymore)
1363 // PHP treats the permalink as a $_GET variable, so we need to check if every condition for self
1364 // redirect is not satisfied, and only then redirect to /
1365 $location = "?";
1366 // Self redirection
1367 if (count($_GET) == 0
1368 || isset($_GET['page'])
1369 || isset($_GET['searchterm'])
1370 || isset($_GET['searchtags'])
1371 ) {
1372 if (isset($_POST['returnurl'])) {
1373 $location = $_POST['returnurl']; // Handle redirects given by the form
1374 } else if (isset($_SERVER['HTTP_REFERER'])) {
1375 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('delete_link'));
1376 }
1377 } 1361 }
1378 1362
1379 header('Location: ' . $location); // After deleting the link, redirect to appropriate location 1363 header('Location: ' . $location); // After deleting the link, redirect to appropriate location