X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fpoche%2FPoche.class.php;h=9345d1c1cd9a73bbbf4e863a7ce445e0be24fe0f;hb=68268c01995d2136e4c04c4e8c650e7d0a4eaca2;hp=e9b14121631130647b9fae84b3222130cab6dc6d;hpb=f4fbfaa7cbaaf07aae7d8f0533d293fa4dc605cc;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index e9b14121..9345d1c1 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -228,10 +228,6 @@ class Poche # filter for reading time $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); $this->tpl->addFilter($filter); - - # filter for simple filenames in config view - $filter = new Twig_SimpleFilter('getPrettyFilename', function($string) { return str_replace(ROOT, '', $string); }); - $this->tpl->addFilter($filter); } private function install() @@ -375,7 +371,7 @@ class Poche { case 'add': $content = $this->getPageContent($url); - $title = $content['rss']['channel']['item']['title']; + $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); $body = $content['rss']['channel']['item']['description']; if ($this->store->add($url->getUrl(), $title, $body, $this->user->getId())) { @@ -480,8 +476,8 @@ class Poche switch ($view) { case 'config': - $dev = $this->getPocheVersion('dev'); - $prod = $this->getPocheVersion('prod'); + $dev = trim($this->getPocheVersion('dev')); + $prod = trim($this->getPocheVersion('prod')); $compare_dev = version_compare(POCHE, $dev); $compare_prod = version_compare(POCHE, $prod); $themes = $this->getInstalledThemes(); @@ -565,7 +561,8 @@ class Poche if (count($entries) > 0) { $this->pagination->set_total(count($entries)); - $page_links = $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . '&'); + $page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')), + $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . '&')); $datas = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit()); $tpl_vars['entries'] = $datas; $tpl_vars['page_links'] = $page_links; @@ -692,17 +689,17 @@ class Poche */ private function credentials() { if(isset($_SERVER['PHP_AUTH_USER'])) { - return array($_SERVER['PHP_AUTH_USER'],'php_auth'); + return array($_SERVER['PHP_AUTH_USER'],'php_auth',true); } if(!empty($_POST['login']) && !empty($_POST['password'])) { - return array($_POST['login'],$_POST['password']); + return array($_POST['login'],$_POST['password'],false); } if(isset($_SERVER['REMOTE_USER'])) { - return array($_SERVER['REMOTE_USER'],'http_auth'); + return array($_SERVER['REMOTE_USER'],'http_auth',true); } - return array(false,false); - } + return array(false,false,false); + } /** * checks if login & password are correct and save the user in session. @@ -713,19 +710,20 @@ class Poche */ public function login($referer) { - list($login,$password)=$this->credentials(); + list($login,$password,$isauthenticated)=$this->credentials(); if($login === false || $password === false) { $this->messages->add('e', _('login failed: you have to fill all fields')); Tools::logm('login failed'); Tools::redirect(); } if (!empty($login) && !empty($password)) { - $user = $this->store->login($login, Tools::encodeString($password . $login)); + $user = $this->store->login($login, Tools::encodeString($password . $login), $isauthenticated); if ($user != array()) { # Save login into Session - $longlastingsession = isset($_POST['longlastingsession']); - Session::login($user['username'], $user['password'], $login, Tools::encodeString($password . $login), $longlastingsession, array('poche_user' => new User($user))); - $this->messages->add('s', _('welcome to your poche')); + $longlastingsession = isset($_POST['longlastingsession']); + $passwordTest = ($isauthenticated) ? $user['password'] : Tools::encodeString($password . $login); + Session::login($user['username'], $user['password'], $login, $passwordTest, $longlastingsession, array('poche_user' => new User($user))); + $this->messages->add('s', _('welcome to your wallabag')); Tools::logm('login successful'); Tools::redirect($referer); } @@ -744,7 +742,6 @@ class Poche { $this->user = array(); Session::logout(); - $this->messages->add('s', _('see you soon!')); Tools::logm('logout'); Tools::redirect(); } @@ -1008,6 +1005,7 @@ class Poche $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); } + $token = str_replace('+', '', $token); $this->store->updateUserConfig($this->user->getId(), 'token', $token); $currentConfig = $_SESSION['poche_user']->config; $currentConfig['token'] = $token;