diff options
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x | inc/poche/Poche.class.php | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c8a09f30..8cebafa3 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -525,6 +525,14 @@ class Poche | |||
525 | $longlastingsession = isset($_POST['longlastingsession']); | 525 | $longlastingsession = isset($_POST['longlastingsession']); |
526 | $passwordTest = ($isauthenticated) ? $user['password'] : Tools::encodeString($password . $login); | 526 | $passwordTest = ($isauthenticated) ? $user['password'] : Tools::encodeString($password . $login); |
527 | Session::login($user['username'], $user['password'], $login, $passwordTest, $longlastingsession, array('poche_user' => new User($user))); | 527 | Session::login($user['username'], $user['password'], $login, $passwordTest, $longlastingsession, array('poche_user' => new User($user))); |
528 | |||
529 | # reload l10n | ||
530 | $language = $user['config']['language']; | ||
531 | @putenv('LC_ALL=' . $language); | ||
532 | setlocale(LC_ALL, $language); | ||
533 | bindtextdomain($language, LOCALE); | ||
534 | textdomain($language); | ||
535 | |||
528 | $this->messages->add('s', _('welcome to your wallabag')); | 536 | $this->messages->add('s', _('welcome to your wallabag')); |
529 | Tools::logm('login successful'); | 537 | Tools::logm('login successful'); |
530 | Tools::redirect($referer); | 538 | Tools::redirect($referer); |
@@ -552,42 +560,39 @@ class Poche | |||
552 | * import datas into your wallabag | 560 | * import datas into your wallabag |
553 | * @return boolean | 561 | * @return boolean |
554 | */ | 562 | */ |
555 | public function import() | ||
556 | { | ||
557 | if (isset($_FILES['file'])) { | ||
558 | Tools::logm('Import stated: parsing file'); | ||
559 | |||
560 | // assume, that file is in json format | ||
561 | |||
562 | $str_data = file_get_contents($_FILES['file']['tmp_name']); | ||
563 | $data = json_decode($str_data, true); | ||
564 | if ($data === null) { | ||
565 | |||
566 | // not json - assume html | ||
567 | |||
568 | $html = new simple_html_dom(); | ||
569 | $html->load_file($_FILES['file']['tmp_name']); | ||
570 | $data = array(); | ||
571 | $read = 0; | ||
572 | foreach(array('ol','ul') as $list) { | ||
573 | foreach($html->find($list) as $ul) { | ||
574 | foreach($ul->find('li') as $li) { | ||
575 | $tmpEntry = array(); | ||
576 | $a = $li->find('a'); | ||
577 | $tmpEntry['url'] = $a[0]->href; | ||
578 | $tmpEntry['tags'] = $a[0]->tags; | ||
579 | $tmpEntry['is_read'] = $read; | ||
580 | if ($tmpEntry['url']) { | ||
581 | $data[] = $tmpEntry; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | // the second <ol/ul> is for read links | ||
586 | 563 | ||
587 | $read = ((sizeof($data) && $read) ? 0 : 1); | 564 | public function import() { |
588 | } | 565 | |
589 | } | 566 | if ( isset($_FILES['file']) && $_FILES['file']['tmp_name'] ) { |
567 | Tools::logm('Import stated: parsing file'); | ||
568 | |||
569 | // assume, that file is in json format | ||
570 | $str_data = file_get_contents($_FILES['file']['tmp_name']); | ||
571 | $data = json_decode($str_data, true); | ||
572 | |||
573 | if ( $data === null ) { | ||
574 | //not json - assume html | ||
575 | $html = new simple_html_dom(); | ||
576 | $html->load_file($_FILES['file']['tmp_name']); | ||
577 | $data = array(); | ||
578 | $read = 0; | ||
579 | foreach (array('ol','ul') as $list) { | ||
580 | foreach ($html->find($list) as $ul) { | ||
581 | foreach ($ul->find('li') as $li) { | ||
582 | $tmpEntry = array(); | ||
583 | $a = $li->find('a'); | ||
584 | $tmpEntry['url'] = $a[0]->href; | ||
585 | $tmpEntry['tags'] = $a[0]->tags; | ||
586 | $tmpEntry['is_read'] = $read; | ||
587 | if ($tmpEntry['url']) { | ||
588 | $data[] = $tmpEntry; | ||
589 | } | ||
590 | } | ||
591 | # the second <ol/ul> is for read links | ||
592 | $read = ((sizeof($data) && $read)?0:1); | ||
590 | } | 593 | } |
594 | } | ||
595 | } | ||
591 | 596 | ||
592 | // for readability structure | 597 | // for readability structure |
593 | 598 | ||
@@ -630,9 +635,11 @@ class Poche | |||
630 | $this->messages->add('s', _('Articles inserted: ') . $i . _('. Please note, that some may be marked as "read".')); | 635 | $this->messages->add('s', _('Articles inserted: ') . $i . _('. Please note, that some may be marked as "read".')); |
631 | } | 636 | } |
632 | 637 | ||
633 | Tools::logm('Import of articles finished: ' . $i . ' articles added (w/o content if not provided).'); | 638 | Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).'); |
634 | } | 639 | } |
635 | 640 | else { | |
641 | $this->messages->add('s', _('Did you forget to select a file?')); | ||
642 | } | ||
636 | // file parsing finished here | 643 | // file parsing finished here |
637 | // now download article contents if any | 644 | // now download article contents if any |
638 | // check if we need to download any content | 645 | // check if we need to download any content |
@@ -751,8 +758,8 @@ class Poche | |||
751 | die(sprintf(_('User with this id (%d) does not exist.'), $user_id)); | 758 | die(sprintf(_('User with this id (%d) does not exist.'), $user_id)); |
752 | } | 759 | } |
753 | 760 | ||
754 | if (!in_array($type, $allowed_types) || $token != $config['token']) { | 761 | if (!in_array($type, $allowed_types) || !isset($config['token']) || $token != $config['token']) { |
755 | die(_('Uh, there is a problem while generating feeds.')); | 762 | die(_('Uh, there is a problem while generating feed. Wrong token used?')); |
756 | } | 763 | } |
757 | 764 | ||
758 | $feed = new FeedWriter(RSS2); | 765 | $feed = new FeedWriter(RSS2); |