X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=5cc440bb33501cd3abb0db8768200f7d6dc15dc8;hb=refs%2Fpull%2F767%2Fhead;hp=e553d1ddcfd3564f3a8abdeeb575a9f428ee248b;hpb=7418f7cb60524c3bfc2f240386b5e3e7eb9b3257;p=github%2Fshaarli%2FShaarli.git
diff --git a/index.php b/index.php
index e553d1dd..5cc440bb 100644
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
/shaarli/
define('WEB_PATH', substr($_SERVER['REQUEST_URI'], 0, 1+strrpos($_SERVER['REQUEST_URI'], '/', 0)));
@@ -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();
@@ -204,7 +204,7 @@ function setup_login_state($conf)
}
// If session does not exist on server side, or IP address has changed, or session has expired, logout.
if (empty($_SESSION['uid'])
- || ($conf->get('security.session_protection_disabled') == false && $_SESSION['ip'] != allIPs())
+ || ($conf->get('security.session_protection_disabled') === false && $_SESSION['ip'] != allIPs())
|| time() >= $_SESSION['expires_on'])
{
logout();
@@ -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;
}
@@ -1198,7 +1208,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
$LINKSDB[$key]=$value;
}
$LINKSDB->save($conf->get('resource.page_cache'));
- echo '';
+ echo '';
exit;
}
@@ -1207,15 +1217,15 @@ function renderPage($conf, $pluginManager, $LINKSDB)
$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 @@ 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'));
}
}
@@ -2237,6 +2247,7 @@ $app = new \Slim\App($container);
// REST API routes
$app->group('/api/v1', function() {
$this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo');
+ $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks');
})->add('\Shaarli\Api\ApiMiddleware');
$response = $app->run(true);