-commit bc82ebfd779b8641dadd6787f51639ea9105c3e8
+commit a19c24edc1057bd411821f9e3e7d1d309d38b1bb
Author: Ismaël Bouya <ismael.bouya@normalesup.org>
Date: Sun Feb 3 20:58:18 2019 +0100
}
diff --git a/index.php b/index.php
-index 4b86a3e..85376e8 100644
+index 4b86a3e..58ae2dd 100644
--- a/index.php
+++ b/index.php
-@@ -121,7 +121,27 @@
+@@ -121,7 +121,32 @@
$_COOKIE['shaarli'] = session_id();
}
+ exit;
+}
+
++if (!isset($userspace) && isset($_POST["login"])) {
++ $userspace = preg_replace("/[^-_A-Za-z0-9]/", '', $_POST["login"]);
++ error_log("debugImmae: setting userspace from POST: " . $userspace);
++}
++
+if (isset($userspace)) {
+ $conf = new ConfigManager(null, $userspace);
+} else {
$sessionManager = new SessionManager($_SESSION, $conf);
$loginManager = new LoginManager($GLOBALS, $conf, $sessionManager);
$loginManager->generateStaySignedInToken($_SERVER['REMOTE_ADDR']);
-@@ -175,7 +195,7 @@
+@@ -175,7 +200,7 @@
}
// Display the installation form if no existing config is found
}
$loginManager->checkLoginState($_COOKIE, $clientIpId);
-@@ -205,6 +225,7 @@ function isLoggedIn()
+@@ -205,6 +230,7 @@ function isLoggedIn()
&& $loginManager->checkCredentials($_SERVER['REMOTE_ADDR'], $clientIpId, $_POST['login'], $_POST['password'])
) {
$loginManager->handleSuccessfulLogin($_SERVER);
$cookiedir = '';
if (dirname($_SERVER['SCRIPT_NAME']) != '/') {
-@@ -241,25 +262,25 @@ function isLoggedIn()
+@@ -241,25 +267,25 @@ function isLoggedIn()
$uri .= '&'.$param.'='.urlencode($_GET[$param]);
}
}
$redir = '&username='. urlencode($_POST['login']);
if (isset($_GET['post'])) {
$redir .= '&post=' . urlencode($_GET['post']);
-@@ -270,7 +291,7 @@ function isLoggedIn()
+@@ -270,7 +296,7 @@ function isLoggedIn()
}
}
// Redirect to login screen.
exit;
}
}
-@@ -1719,7 +1740,7 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager)
+@@ -1719,7 +1745,7 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager)
* @param SessionManager $sessionManager SessionManager instance
* @param LoginManager $loginManager LoginManager instance
*/
// On free.fr host, make sure the /sessions directory exists, otherwise login will not work.
if (endsWith($_SERVER['HTTP_HOST'],'.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'].'/sessions')) mkdir($_SERVER['DOCUMENT_ROOT'].'/sessions',0705);
-@@ -1755,7 +1776,7 @@ function install($conf, $sessionManager, $loginManager) {
+@@ -1755,7 +1781,7 @@ function install($conf, $sessionManager, $loginManager) {
}
{
$tz = 'UTC';
if (!empty($_POST['continent']) && !empty($_POST['city'])
-@@ -1764,15 +1785,15 @@ function install($conf, $sessionManager, $loginManager) {
+@@ -1764,15 +1790,15 @@ function install($conf, $sessionManager, $loginManager) {
$tz = $_POST['continent'].'/'.$_POST['city'];
}
$conf->set('general.timezone', $tz);
}
$conf->set('translation.language', escape($_POST['language']));
$conf->set('updates.check_updates', !empty($_POST['updateCheck']));
-@@ -1841,7 +1862,12 @@ function install($conf, $sessionManager, $loginManager) {
+@@ -1841,7 +1867,12 @@ function install($conf, $sessionManager, $loginManager) {
$app = new \Slim\App($container);
// REST API routes
$this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo')->setName('getInfo');
$this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks')->setName('getLinks');
$this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink')->setName('getLink');
-@@ -1860,7 +1886,7 @@ function install($conf, $sessionManager, $loginManager) {
+@@ -1860,7 +1891,7 @@ function install($conf, $sessionManager, $loginManager) {
$response = $app->run(true);
// Hack to make Slim and Shaarli router work together:
// If a Slim route isn't found and NOT API call, we call renderPage().