aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/index.php b/index.php
index 8770b669..c2aaf84a 100644
--- a/index.php
+++ b/index.php
@@ -124,6 +124,11 @@ if (isset($_COOKIE['shaarli']) && !SessionManager::checkId($_COOKIE['shaarli']))
124$conf = new ConfigManager(); 124$conf = new ConfigManager();
125$sessionManager = new SessionManager($_SESSION, $conf); 125$sessionManager = new SessionManager($_SESSION, $conf);
126 126
127// LC_MESSAGES isn't defined without php-intl, in this case use LC_COLLATE locale instead.
128if (! defined('LC_MESSAGES')) {
129 define('LC_MESSAGES', LC_COLLATE);
130}
131
127// Sniff browser language and set date format accordingly. 132// Sniff browser language and set date format accordingly.
128if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 133if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
129 autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); 134 autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']);
@@ -436,7 +441,7 @@ if (isset($_POST['login']))
436 else 441 else
437 { 442 {
438 ban_loginFailed($conf); 443 ban_loginFailed($conf);
439 $redir = '&username='. $_POST['login']; 444 $redir = '&username='. urlencode($_POST['login']);
440 if (isset($_GET['post'])) { 445 if (isset($_GET['post'])) {
441 $redir .= '&post=' . urlencode($_GET['post']); 446 $redir .= '&post=' . urlencode($_GET['post']);
442 foreach (array('description', 'source', 'title', 'tags') as $param) { 447 foreach (array('description', 'source', 'title', 'tags') as $param) {
@@ -1436,16 +1441,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
1436 // 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.) 1441 // 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.)
1437 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { 1442 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
1438 // Short timeout to keep the application responsive 1443 // Short timeout to keep the application responsive
1439 list($headers, $content) = get_http_response($url, 4); 1444 // The callback will fill $charset and $title with data from the downloaded page.
1440 if (strpos($headers[0], '200 OK') !== false) { 1445 get_http_response($url, 25, 4194304, get_curl_download_callback($charset, $title));
1441 // Retrieve charset. 1446 if (! empty($title) && strtolower($charset) != 'utf-8') {
1442 $charset = get_charset($headers, $content); 1447 $title = mb_convert_encoding($title, 'utf-8', $charset);
1443 // Extract title.
1444 $title = html_extract_title($content);
1445 // Re-encode title in utf-8 if necessary.
1446 if (! empty($title) && strtolower($charset) != 'utf-8') {
1447 $title = mb_convert_encoding($title, 'utf-8', $charset);
1448 }
1449 } 1448 }
1450 } 1449 }
1451 1450