]> git.immae.eu Git - github/wallabag/wallabag.git/blame - import.php
Merge branch 'dev'
[github/wallabag/wallabag.git] / import.php
CommitLineData
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
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
b693a19e 23 $read = 0;
0753bfef 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
cb1348bc 32
e4d2565e 33 action_to_do('add', $url);
b693a19e 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 }
0753bfef 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
b693a19e 45 $read = 1;
0753bfef 46 }
47
48 echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>';
713b2d69 49 logm('import from pocket completed');
0753bfef 50}