From: ArthurHoaro Date: Mon, 16 Jan 2017 11:40:00 +0000 (+0100) Subject: Merge pull request #761 from ArthurHoaro/hotfix/referrer-warning X-Git-Tag: v0.9.0~62 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=4d9fd16ddf2a7d6488c4200aca48501e9d5886fe;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #761 from ArthurHoaro/hotfix/referrer-warning Prevent warning if HTTP_REFERER isn't set --- 4d9fd16ddf2a7d6488c4200aca48501e9d5886fe diff --combined index.php index 8055a7b7,f736fcf2..b27c83b6 --- a/index.php +++ b/index.php @@@ -13,7 -13,7 +13,7 @@@ * * Licence: http://www.opensource.org/licenses/zlib-license.php * - * Requires: PHP 5.3.x + * Requires: PHP 5.5.x */ // Set 'UTC' as the default timezone if it is not defined in php.ini @@@ -83,7 -83,7 +83,7 @@@ use \Shaarli\ThemeUtils // Ensure the PHP version is supported try { - ApplicationUtils::checkPHPVersion('5.3', PHP_VERSION); + ApplicationUtils::checkPHPVersion('5.5', PHP_VERSION); } catch(Exception $exc) { header('Content-Type: text/plain; charset=utf-8'); echo $exc->getMessage(); @@@ -1012,7 -1012,12 +1012,12 @@@ function renderPage($conf, $pluginManag $_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 +1029,12 @@@ 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; } @@@ -1207,15 -1217,15 +1217,15 @@@ $needle = trim($_POST['fromtag']); // True for case-sensitive tag search. $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true); - foreach($linksToAlter as $key=>$value) - { - $tags = explode(' ',trim($value['tags'])); - $tags[array_search($needle,$tags)] = trim($_POST['totag']); // Replace tags value. - $value['tags']=trim(implode(' ',$tags)); - $LINKSDB[$key]=$value; + foreach($linksToAlter as $key=>$value) { + $tags = preg_split('/\s+/', trim($value['tags'])); + // Replace tags value. + $tags[array_search($needle, $tags)] = trim($_POST['totag']); + $value['tags'] = implode(' ', array_unique($tags)); + $LINKSDB[$key] = $value; } $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. - echo ''; + echo ''; exit; } } @@@ -1361,7 -1371,7 +1371,7 @@@ ) { 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')); } }