]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
copy of poche.sqlite
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 5 Aug 2013 08:32:15 +0000 (10:32 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 5 Aug 2013 08:32:15 +0000 (10:32 +0200)
.gitignore
db/poche.sqlite.in [new file with mode: 0755]
inc/poche/Poche.class.php
inc/poche/Tools.class.php
index.php

index 08db745d957c3d137a8dff689982593f54d4f2ee..050a138695ff7130350044b0d284e010e58c460a 100644 (file)
@@ -1,2 +1,3 @@
 vendor
-composer.phar
\ No newline at end of file
+composer.phar
+db/poche.sqlite
\ No newline at end of file
diff --git a/db/poche.sqlite.in b/db/poche.sqlite.in
new file mode 100755 (executable)
index 0000000..45add0d
Binary files /dev/null and b/db/poche.sqlite.in differ
index 0d37e3c2cd62f83c3108d7c1dcc483fec332bce2..12cb1b42afa2334cdbfc8815cc7e7ab1d730c4a2 100644 (file)
@@ -212,6 +212,7 @@ class Poche
 
     private function importFromInstapaper()
     {
+        # TODO gestion des articles favs
         $html = new simple_html_dom();
         $html->load_file('./instapaper-export.html');
 
@@ -229,9 +230,8 @@ class Poche
                     $this->store->archiveById($last_id);
                 }
             }
-            # Instapaper génère un fichier HTML avec deux <ol>
-            # Le premier concerne les éléments non lus
-            # Le second concerne les éléments archivés
+
+            # the second <ol> is for read links
             $read = 1;
         }
         Tools::logm('import from instapaper completed');
@@ -240,6 +240,7 @@ class Poche
 
     private function importFromPocket()
     {
+        # TODO gestion des articles favs
         $html = new simple_html_dom();
         $html->load_file('./ril_export.html');
 
@@ -257,9 +258,8 @@ class Poche
                     $this->store->archiveById($last_id);
                 }
             }
-            # Pocket génère un fichier HTML avec deux <ul>
-            # Le premier concerne les éléments non lus
-            # Le second concerne les éléments archivés
+            
+            # the second <ul> is for read links
             $read = 1;
         }
         Tools::logm('import from pocket completed');
@@ -268,17 +268,24 @@ class Poche
 
     private function importFromReadability()
     {
-        # TODO finaliser tout ça ici
-        # noms des variables + gestion des articles lus
+        # TODO gestion des articles lus / favs
         $str_data = file_get_contents("./readability");
         $data = json_decode($str_data,true);
 
         foreach ($data as $key => $value) {
             $url = '';
-            foreach ($value as $key2 => $value2) {
-                if ($key2 == 'article__url') {
-                    $url = new Url(base64_encode($value2));
+            foreach ($value as $attr => $attr_value) {
+                if ($attr == 'article__url') {
+                    $url = new Url(base64_encode($attr_value));
                 }
+                // if ($attr_value == 'favorite' && $attr_value == 'true') {
+                //     $last_id = $this->store->getLastId();
+                //     $this->store->favoriteById($last_id);
+                // }
+                // if ($attr_value == 'archive' && $attr_value == 'true') {
+                //     $last_id = $this->store->getLastId();
+                //     $this->store->archiveById($last_id);
+                // }
             }
             if ($url->isCorrect())
                 $this->action('add', $url);
index 1ff4ba55c90680790d9b9819e9d7dee23d672476..834940ffb4ec98359a53bd753f173d3a621e2bbb 100644 (file)
@@ -206,8 +206,8 @@ class Tools
         return sha1($string . SALT);
     }
 
-    public static function checkVar($var)
+    public static function checkVar($var, $default = '')
     {
-        return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
+        return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
     }
 }
\ No newline at end of file
index 294620d1ebcc4136bc0f3c10d860a200a3bd283d..654403c8415d853333666ddaa1cc1cc621c5c4b6 100644 (file)
--- a/index.php
+++ b/index.php
 include dirname(__FILE__).'/inc/poche/config.inc.php';
 
 #XSRF protection with token
-// if (!empty($_POST)) {
-//     if (!Session::isToken($_POST['token'])) {
-//         die(_('Wrong token'));
-//         // TODO remettre le test
-//     }
-//     unset($_SESSION['tokens']);
-// }
+if (!empty($_POST)) {
+    if (!Session::isToken($_POST['token'])) {
+        die(_('Wrong token'));
+    }
+    unset($_SESSION['tokens']);
+}
 
 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
-$view = Tools::checkVar('view');
+$view = Tools::checkVar('view', 'home');
 $action = Tools::checkVar('action');
 $id = Tools::checkVar('id');
 $_SESSION['sort'] = Tools::checkVar('sort');