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