]> git.immae.eu Git - github/wallabag/wallabag.git/blob - import.php
composer
[github/wallabag/wallabag.git] / import.php
1 <?php
2 /**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11 set_time_limit(0);
12
13 include dirname(__FILE__).'/inc/config.php';
14 include dirname(__FILE__).'/inc/simple_html_dom.php';
15
16 if (!isset($_GET['start'])) {
17 echo _('Please execute the import script locally, it can take a very long time.') . '<br /><br />' . _('Please choose between Pocket & Readabilty :') . '<br /><a href="import.php?start=pocket">' . _('Bye bye Pocket, let\'s go !') . '</a><br /><a href="import.php?start=readability">' . _('Bye bye Readability, let\'s go !') . '</a>';
18 }
19 else {
20 if ($_GET['start'] == 'pocket') {
21 $html = new simple_html_dom();
22 $html->load_file('ril_export.html');
23
24 $read = 0;
25 $errors = array();
26 foreach($html->find('ul') as $ul)
27 {
28 foreach($ul->find('li') as $li)
29 {
30 $a = $li->find('a');
31 $url = $a[0]->href;
32
33 action_to_do('add', $url);
34 if ($read == '1') {
35 $last_id = $db->getHandle()->lastInsertId();
36 $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
37 $params_update = array($last_id);
38 $query_update = $db->getHandle()->prepare($sql_update);
39 $query_update->execute($params_update);
40 }
41 }
42 # Pocket génère un fichier HTML avec deux <ul>
43 # Le premier concerne les éléments non lus
44 # Le second concerne les éléments archivés
45 $read = 1;
46 }
47
48 echo _('Import from Pocket completed.') . '<a href="index.php">' . _('Welcome to poche !') .'</a>';
49 logm('import from pocket completed');
50 }
51 else if ($_GET['start'] == 'readability') {
52 $str_data = file_get_contents("readability");
53 $data = json_decode($str_data,true);
54
55 foreach ($data as $key => $value) {
56 $url = '';
57 foreach ($value as $key2 => $value2) {
58 if ($key2 == 'article__url') {
59 $url = $value2;
60 }
61 }
62 if ($url != '')
63 action_to_do('add', $url);
64 }
65
66 echo _('Import from Readability completed.') . '<a href="index.php">' . _('Welcome to poche !') . '</a>';
67 logm('import from Readability completed');
68 }
69 else {
70 echo _('Error with the import.') . '<a href="index.php">' . _('Back to poche'). '</a>';
71 logm('error with the import');
72 }
73 }