aboutsummaryrefslogtreecommitdiffhomepage
path: root/import.php
diff options
context:
space:
mode:
Diffstat (limited to 'import.php')
-rw-r--r--import.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/import.php b/import.php
new file mode 100644
index 00000000..7a657c21
--- /dev/null
+++ b/import.php
@@ -0,0 +1,55 @@
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
11set_time_limit(0);
12
13include dirname(__FILE__).'/inc/config.php';
14include dirname(__FILE__).'/inc/simple_html_dom.php';
15
16if (!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>';
18}
19else {
20 $html = new simple_html_dom();
21 $html->load_file('ril_export.html');
22
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 $parametres_url = prepare_url($url);
32 $sql_action = 'INSERT INTO entries ( url, title, content, is_read ) VALUES (?, ?, ?, ?)';
33 $params_action = array($url, $parametres_url['title'], $parametres_url['content'], $read);
34 try
35 {
36 # action query
37 if (isset($sql_action))
38 {
39 $query = $db->getHandle()->prepare($sql_action);
40 $query->execute($params_action);
41 }
42 }
43 catch (Exception $e)
44 {
45 $errors[] = $e->getMessage();
46 }
47 }
48 # Pocket génère un fichier HTML avec deux <ul>
49 # Le premier concerne les éléments non lus
50 # Le second concerne les éléments archivés
51 $read = '-1';
52 }
53
54 echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>';
55} \ No newline at end of file