]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Prevent warning if HTTP_REFERER isn't set 761/head
authorArthurHoaro <arthur@hoa.ro>
Sun, 15 Jan 2017 16:58:19 +0000 (17:58 +0100)
committerArthurHoaro <arthur@hoa.ro>
Sun, 15 Jan 2017 16:58:19 +0000 (17:58 +0100)
Fixes #723

index.php

index beb1cbca592aefae1071254c9ab95c04ea635526..f736fcf2fe203252aad4377612ee5ac973e9daa4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1012,7 +1012,12 @@ function renderPage($conf, $pluginManager, $LINKSDB)
             $_SESSION['LINKS_PER_PAGE']=abs(intval($_GET['linksperpage']));
         }
 
-        header('Location: '. generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('linksperpage')));
+        if (! empty($_SERVER['HTTP_REFERER'])) {
+            $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('linksperpage'));
+        } else {
+            $location = '?';
+        }
+        header('Location: '. $location);
         exit;
     }
 
@@ -1024,7 +1029,12 @@ function renderPage($conf, $pluginManager, $LINKSDB)
             unset($_SESSION['privateonly']); // See all links
         }
 
-        header('Location: '. generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly')));
+        if (! empty($_SERVER['HTTP_REFERER'])) {
+            $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly'));
+        } else {
+            $location = '?';
+        }
+        header('Location: '. $location);
         exit;
     }
 
@@ -1361,7 +1371,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
         ) {
             if (isset($_POST['returnurl'])) {
                 $location = $_POST['returnurl']; // Handle redirects given by the form
-            } else {
+            } else if (isset($_SERVER['HTTP_REFERER'])) {
                 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('delete_link'));
             }
         }