]>
Commit | Line | Data |
---|---|---|
0753bfef | 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'])) { | |
2ee436ea | 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>'; |
0753bfef | 18 | } |
19 | else { | |
02ea9f07 NL |
20 | if ($_GET['start'] == 'pocket') { |
21 | $html = new simple_html_dom(); | |
22 | $html->load_file('ril_export.html'); | |
cb1348bc | 23 | |
02ea9f07 NL |
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; | |
cb1348bc | 32 | |
02ea9f07 NL |
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 | } | |
b693a19e | 41 | } |
02ea9f07 NL |
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; | |
0753bfef | 46 | } |
02ea9f07 | 47 | |
2ee436ea | 48 | echo _('Import from Pocket completed.') . '<a href="index.php">' . _('Welcome to poche !') .'</a>'; |
02ea9f07 | 49 | logm('import from pocket completed'); |
0753bfef | 50 | } |
02ea9f07 NL |
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 | } | |
0753bfef | 65 | |
2ee436ea | 66 | echo _('Import from Readability completed.') . '<a href="index.php">' . _('Welcome to poche !') . '</a>'; |
02ea9f07 NL |
67 | logm('import from Readability completed'); |
68 | } | |
69 | else { | |
2ee436ea | 70 | echo _('Error with the import.') . '<a href="index.php">' . _('Back to poche'). '</a>'; |
02ea9f07 NL |
71 | logm('error with the import'); |
72 | } | |
0753bfef | 73 | } |