diff options
-rw-r--r-- | import.php | 77 |
1 files changed, 52 insertions, 25 deletions
@@ -14,37 +14,64 @@ include dirname(__FILE__).'/inc/config.php'; | |||
14 | include dirname(__FILE__).'/inc/simple_html_dom.php'; | 14 | include dirname(__FILE__).'/inc/simple_html_dom.php'; |
15 | 15 | ||
16 | if (!isset($_GET['start'])) { | 16 | if (!isset($_GET['start'])) { |
17 | echo 'Please execute the import script locally, it can take a very long time. <br /><a href="import.php?start">Bye bye Pocket, let\'s go !</a>'; | 17 | echo ' |
18 | Please execute the import script locally, it can take a very long time. <br /><br /> | ||
19 | Please choose between Pocket & Readabilty : | ||
20 | <br /><a href="import.php?start=pocket">Bye bye Pocket, let\'s go !</a> | ||
21 | <br /><a href="import.php?start=readability">Bye bye Readability, let\'s go !</a>'; | ||
18 | } | 22 | } |
19 | else { | 23 | else { |
20 | $html = new simple_html_dom(); | 24 | if ($_GET['start'] == 'pocket') { |
21 | $html->load_file('ril_export.html'); | 25 | $html = new simple_html_dom(); |
22 | 26 | $html->load_file('ril_export.html'); | |
23 | $read = 0; | ||
24 | $errors = array(); | ||
25 | foreach($html->find('ul') as $ul) | ||
26 | { | ||
27 | foreach($ul->find('li') as $li) | ||
28 | { | ||
29 | $a = $li->find('a'); | ||
30 | $url = $a[0]->href; | ||
31 | 27 | ||
28 | $read = 0; | ||
29 | $errors = array(); | ||
30 | foreach($html->find('ul') as $ul) | ||
31 | { | ||
32 | foreach($ul->find('li') as $li) | ||
33 | { | ||
34 | $a = $li->find('a'); | ||
35 | $url = $a[0]->href; | ||
32 | 36 | ||
33 | action_to_do('add', $url); | 37 | action_to_do('add', $url); |
34 | if ($read == '1') { | 38 | if ($read == '1') { |
35 | $last_id = $db->getHandle()->lastInsertId(); | 39 | $last_id = $db->getHandle()->lastInsertId(); |
36 | $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?"; | 40 | $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?"; |
37 | $params_update = array($last_id); | 41 | $params_update = array($last_id); |
38 | $query_update = $db->getHandle()->prepare($sql_update); | 42 | $query_update = $db->getHandle()->prepare($sql_update); |
39 | $query_update->execute($params_update); | 43 | $query_update->execute($params_update); |
44 | } | ||
40 | } | 45 | } |
46 | # Pocket génère un fichier HTML avec deux <ul> | ||
47 | # Le premier concerne les éléments non lus | ||
48 | # Le second concerne les éléments archivés | ||
49 | $read = 1; | ||
41 | } | 50 | } |
42 | # Pocket génère un fichier HTML avec deux <ul> | 51 | |
43 | # Le premier concerne les éléments non lus | 52 | echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>'; |
44 | # Le second concerne les éléments archivés | 53 | logm('import from pocket completed'); |
45 | $read = 1; | ||
46 | } | 54 | } |
55 | else if ($_GET['start'] == 'readability') { | ||
56 | $str_data = file_get_contents("readability"); | ||
57 | $data = json_decode($str_data,true); | ||
58 | |||
59 | foreach ($data as $key => $value) { | ||
60 | $url = ''; | ||
61 | foreach ($value as $key2 => $value2) { | ||
62 | if ($key2 == 'article__url') { | ||
63 | $url = $value2; | ||
64 | } | ||
65 | } | ||
66 | if ($url != '') | ||
67 | action_to_do('add', $url); | ||
68 | } | ||
47 | 69 | ||
48 | echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>'; | 70 | echo 'Import from Readability completed. <a href="index.php">Welcome to #poche !</a>'; |
49 | logm('import from pocket completed'); | 71 | logm('import from Readability completed'); |
72 | } | ||
73 | else { | ||
74 | echo 'Error with the import. <a href="index.php">Welcome to #poche !</a>'; | ||
75 | logm('error with the import'); | ||
76 | } | ||
50 | } \ No newline at end of file | 77 | } \ No newline at end of file |