X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=c2aaf84a14959590279bb07d809459141e49c7e5;hb=bc3ce7ec2a652eec1441774958050cf83105560a;hp=60ac24ac2ec766421a112a89b1b9cbdebdb6b7e8;hpb=9d4736a3e95332198896f97ecc8a83abb0cbe85b;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 60ac24ac..c2aaf84a 100644 --- a/index.php +++ b/index.php @@ -124,6 +124,11 @@ if (isset($_COOKIE['shaarli']) && !SessionManager::checkId($_COOKIE['shaarli'])) $conf = new ConfigManager(); $sessionManager = new SessionManager($_SESSION, $conf); +// LC_MESSAGES isn't defined without php-intl, in this case use LC_COLLATE locale instead. +if (! defined('LC_MESSAGES')) { + define('LC_MESSAGES', LC_COLLATE); +} + // Sniff browser language and set date format accordingly. if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); @@ -436,7 +441,7 @@ if (isset($_POST['login'])) else { ban_loginFailed($conf); - $redir = '&username='. $_POST['login']; + $redir = '&username='. urlencode($_POST['login']); if (isset($_GET['post'])) { $redir .= '&post=' . urlencode($_GET['post']); foreach (array('description', 'source', 'title', 'tags') as $param) { @@ -1012,11 +1017,21 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager) // -------- User wants to see only private links (toggle) if (isset($_GET['visibility'])) { - unset($_SESSION['visibility']); if ($_GET['visibility'] === 'private') { - $_SESSION['visibility'] = 'private'; // See only private links + // Visibility not set or not already private, set private, otherwise reset it + if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'private') { + // See only private links + $_SESSION['visibility'] = 'private'; + } else { + unset($_SESSION['visibility']); + } } else if ($_GET['visibility'] === 'public') { - $_SESSION['visibility'] = 'public'; // See only public links + if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') { + // See only public links + $_SESSION['visibility'] = 'public'; + } else { + unset($_SESSION['visibility']); + } } if (! empty($_SERVER['HTTP_REFERER'])) { @@ -1426,16 +1441,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager) // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.) if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { // Short timeout to keep the application responsive - list($headers, $content) = get_http_response($url, 4); - if (strpos($headers[0], '200 OK') !== false) { - // Retrieve charset. - $charset = get_charset($headers, $content); - // Extract title. - $title = html_extract_title($content); - // Re-encode title in utf-8 if necessary. - if (! empty($title) && strtolower($charset) != 'utf-8') { - $title = mb_convert_encoding($title, 'utf-8', $charset); - } + // The callback will fill $charset and $title with data from the downloaded page. + get_http_response($url, 25, 4194304, get_curl_download_callback($charset, $title)); + if (! empty($title) && strtolower($charset) != 'utf-8') { + $title = mb_convert_encoding($title, 'utf-8', $charset); } }