]>
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'])) { | |
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 | } | |
19 | else { | |
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; | |
cb1348bc | 31 | |
32 | # FIXME corriger cette génération d'ID | |
33 | $req = $db->getHandle()->query("SELECT id FROM entries ORDER BY id DESC"); | |
34 | $id = $req->fetchColumn()+1; | |
35 | ||
36 | $parametres_url = prepare_url($url, $id); | |
0753bfef | 37 | $sql_action = 'INSERT INTO entries ( url, title, content, is_read ) VALUES (?, ?, ?, ?)'; |
38 | $params_action = array($url, $parametres_url['title'], $parametres_url['content'], $read); | |
39 | try | |
40 | { | |
41 | # action query | |
42 | if (isset($sql_action)) | |
43 | { | |
44 | $query = $db->getHandle()->prepare($sql_action); | |
45 | $query->execute($params_action); | |
46 | } | |
47 | } | |
48 | catch (Exception $e) | |
49 | { | |
713b2d69 | 50 | logm('error during pocket import : ' . $e->getMessage()); |
0753bfef | 51 | } |
52 | } | |
53 | # Pocket génère un fichier HTML avec deux <ul> | |
54 | # Le premier concerne les éléments non lus | |
55 | # Le second concerne les éléments archivés | |
56 | $read = '-1'; | |
57 | } | |
58 | ||
59 | echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>'; | |
713b2d69 | 60 | logm('import from pocket completed'); |
0753bfef | 61 | } |