X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=inc%2Fpoche%2FPoche.class.php;h=16235474bf601a4cc321bf1513b7d9e59326c1a1;hb=refs%2Fpull%2F943%2Fhead;hp=a49413f23816837688ee5b279278a2a9c5bc3d2e;hpb=6da20812ce04e3e45c21c6da640d6ccde91e8c38;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a49413f2..16235474 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -74,12 +74,13 @@ class Poche /** * Creates a new user */ - public function createNewUser($username, $password) + public function createNewUser($username, $password, $email = "") { if (!empty($username) && !empty($password)){ $newUsername = filter_var($username, FILTER_SANITIZE_STRING); + $email = filter_var($email, FILTER_SANITIZE_STRING); if (!$this->store->userExists($newUsername)){ - if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername))) { + if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { Tools::logm('The new user ' . $newUsername . ' has been installed'); $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); Tools::redirect(); @@ -313,6 +314,8 @@ class Poche switch ($view) { + case 'about': + break; case 'config': $dev_infos = $this->_getPocheVersion('dev'); $dev = trim($dev_infos[0]); @@ -387,7 +390,7 @@ class Poche $this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' )); $tpl_vars['page_links'] = $page_links; $tpl_vars['nb_results'] = $count; - $tpl_vars['search_term'] = $search; + $tpl_vars['searchterm'] = $search; } break; case 'view': @@ -524,6 +527,14 @@ class 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))); + + # reload l10n + $language = $user['config']['language']; + @putenv('LC_ALL=' . $language); + setlocale(LC_ALL, $language); + bindtextdomain($language, LOCALE); + textdomain($language); + $this->messages->add('s', _('welcome to your wallabag')); Tools::logm('login successful'); Tools::redirect($referer); @@ -551,42 +562,39 @@ class Poche * import datas into your wallabag * @return boolean */ - public function import() - { - if (isset($_FILES['file'])) { - Tools::logm('Import stated: parsing file'); - - // assume, that file is in json format - - $str_data = file_get_contents($_FILES['file']['tmp_name']); - $data = json_decode($str_data, true); - if ($data === null) { - - // not json - assume html - - $html = new simple_html_dom(); - $html->load_file($_FILES['file']['tmp_name']); - $data = array(); - $read = 0; - foreach(array('ol','ul') as $list) { - foreach($html->find($list) as $ul) { - foreach($ul->find('li') as $li) { - $tmpEntry = array(); - $a = $li->find('a'); - $tmpEntry['url'] = $a[0]->href; - $tmpEntry['tags'] = $a[0]->tags; - $tmpEntry['is_read'] = $read; - if ($tmpEntry['url']) { - $data[] = $tmpEntry; - } - } - - // the second
    is for read links - $read = ((sizeof($data) && $read) ? 0 : 1); - } - } + public function import() { + + if ( isset($_FILES['file']) && $_FILES['file']['tmp_name'] ) { + Tools::logm('Import stated: parsing file'); + + // assume, that file is in json format + $str_data = file_get_contents($_FILES['file']['tmp_name']); + $data = json_decode($str_data, true); + + if ( $data === null ) { + //not json - assume html + $html = new simple_html_dom(); + $html->load_file($_FILES['file']['tmp_name']); + $data = array(); + $read = 0; + foreach (array('ol','ul') as $list) { + foreach ($html->find($list) as $ul) { + foreach ($ul->find('li') as $li) { + $tmpEntry = array(); + $a = $li->find('a'); + $tmpEntry['url'] = $a[0]->href; + $tmpEntry['tags'] = $a[0]->tags; + $tmpEntry['is_read'] = $read; + if ($tmpEntry['url']) { + $data[] = $tmpEntry; + } + } + # the second
      is for read links + $read = ((sizeof($data) && $read)?0:1); } + } + } // for readability structure @@ -629,9 +637,11 @@ class Poche $this->messages->add('s', _('Articles inserted: ') . $i . _('. Please note, that some may be marked as "read".')); } - Tools::logm('Import of articles finished: ' . $i . ' articles added (w/o content if not provided).'); - } - + Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).'); + } + else { + $this->messages->add('s', _('Did you forget to select a file?')); + } // file parsing finished here // now download article contents if any // check if we need to download any content @@ -750,8 +760,8 @@ class Poche die(sprintf(_('User with this id (%d) does not exist.'), $user_id)); } - if (!in_array($type, $allowed_types) || $token != $config['token']) { - die(_('Uh, there is a problem while generating feeds.')); + if (!in_array($type, $allowed_types) || !isset($config['token']) || $token != $config['token']) { + die(_('Uh, there is a problem while generating feed. Wrong token used?')); } $feed = new FeedWriter(RSS2);