diff --git a/README.md b/README.md
index b44e7d3..09f48b1 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# poche
-Abandon Pocket, Instapaper and other Readability service : adopt poche. It is the same, but it is open source.
+Abandon Pocket, Instapaper and other Readability service : adopt poche. It is the same, but it is open source. Moreover, you can migrate from Pocket & Readability.
![poche](http://inthepoche.com/img/logo.png)
@@ -11,23 +11,23 @@ To get news from poche, [follow us on twitter](http://twitter.com/getpoche) or [
[![flattr](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1265480/poche-a-read-it-later-open-source-system)
-## Usage
-You can easily add a "poched" page with the bookmarklet.
-
-poche save the entire content of a poched links : text and pictures are stored on your server.
-
-You can :
-* read a page in a comfortable reading view
-* archive a link
-* put a link in favorite
-* delete a link
-
## Requirements & installation
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
+[PHP cURL](http://www.php.net/manual/en/book.curl.php) & [tidy_parse_string](http://www.php.net/manual/en/tidy.parsestring.php) are recommended.
+
Get the [latest version](https://github.com/inthepoche/poche) of poche on github. Unzip it and upload it on your server. poche must have write access on assets, cache and db directories.
-That's all, **poche works** !
+Install composer in your project :
+```bash
+curl -s http://getcomposer.org/installer | php
+```
+Install via composer :
+```bash
+php composer.phar install
+```
+
+That's all, you can use poche !
## Security
You **have** to protect your db/poche.sqlite file. Modify the virtual host of your website to add this condition :
@@ -46,12 +46,11 @@ location ~ /(db) {
}
```
-## Import from Pocket
-
-If you want to import your Pocket datas, [export them here](https://getpocket.com/export). Put the HTML file in your poche directory, execute import.php file locally by following instructions. Be careful, the script can take a very long time.
+## Usage
+See the documentation on our website : [inthepoche.com](http://inthepoche.com).
## License
Copyright © 2010-2013 Nicolas Lœuillet {% trans "Please execute the import script locally, it can take a very long time." %} {% trans "More infos in the official doc:" %} inthepoche.com
+ # Le premier concerne les éléments non lus
+ # Le second concerne les éléments archivés
+ $read = 1;
+ }
+ Tools::logm('import from pocket completed');
+ Tools::redirect();
+ }
+
+ private function importFromReadability()
+ {
+ # TODO finaliser tout ça ici
+ # noms des variables + gestion des articles lus
+ $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));
+ }
+ }
+ if ($url->isCorrect())
+ $this->action('add', $url);
+ }
+ Tools::logm('import from Readability completed');
+ Tools::redirect();
+ }
+
public function import($from)
{
if ($from == 'pocket') {
- $html = new simple_html_dom();
- $html->load_file('./ril_export.html');
-
- $read = 0;
- $errors = array();
- foreach($html->find('ul') as $ul)
- {
- foreach($ul->find('li') as $li)
- {
- $a = $li->find('a');
- $url = new Url($a[0]->href);
- $this->action('add', $url);
- if ($read == '1') {
- $last_id = $this->store->lastInsertId();
- $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
- $params_update = array($last_id);
- $query_update = $this->store->prepare($sql_update);
- $query_update->execute($params_update);
- }
- }
- # Pocket génère un fichier HTML avec deux
- # Le premier concerne les éléments non lus
- # Le second concerne les éléments archivés
- $read = 1;
- }
- logm('import from pocket completed');
- Tools::redirect();
+ $this->importFromPocket();
}
else if ($from == 'readability') {
- # TODO finaliser tout ça ici
- $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($value2);
- }
- }
- if ($url != '')
- action_to_do('add', $url);
- }
- logm('import from Readability completed');
- Tools::redirect();
+ $this->importFromReadability();
+ }
+ else if ($from == 'instapaper') {
+ $this->importFromInstapaper();
}
}
public function export()
{
-
+ $entries = $this->store->retrieveAll();
+ echo $this->tpl->render('export.twig', array(
+ 'export' => Tools::renderJson($entries),
+ ));
+ Tools::logm('export view');
}
}
\ No newline at end of file
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index c277035..1ff4ba5 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -205,4 +205,9 @@ class Tools
{
return sha1($string . SALT);
}
+
+ public static function checkVar($var)
+ {
+ return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
+ }
}
\ No newline at end of file
diff --git a/index.php b/index.php
index 1554c0a..381b8cc 100644
--- a/index.php
+++ b/index.php
@@ -10,16 +10,21 @@
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']);
-// }
+#XSRF protection with token
+if (!empty($_POST)) {
+ if (!Session::isToken($_POST['token'])) {
+ die(_('Wrong token'));
+ // TODO remettre le test
+ }
+ unset($_SESSION['tokens']);
+}
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
+$view = Tools::checkVar('view');
+$action = Tools::checkVar('action');
+$id = Tools::checkVar('id');
+$_SESSION['sort'] = Tools::checkVar('sort');
+$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
if (isset($_GET['login'])) {
# hello you
@@ -36,15 +41,9 @@ elseif (isset($_GET['config'])) {
elseif (isset($_GET['import'])) {
$poche->import($_GET['from']);
}
-
-# Aaaaaaand action !
-$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
-$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
-$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
-$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
-$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
-
-$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
+elseif (isset($_GET['export'])) {
+ $poche->export();
+}
$tpl_vars = array(
'referer' => $referer,
@@ -64,4 +63,5 @@ else {
$tpl_file = 'login.twig';
}
+# Aaaaaaand action !
echo $poche->tpl->render($tpl_file, $tpl_vars);
\ No newline at end of file
diff --git a/tpl/_footer.twig b/tpl/_footer.twig
index 59b58fa..b1d7b8d 100644
--- a/tpl/_footer.twig
+++ b/tpl/_footer.twig
@@ -1,3 +1,3 @@
\ No newline at end of file
diff --git a/tpl/config.twig b/tpl/config.twig
index 9a51e56..c18806b 100644
--- a/tpl/config.twig
+++ b/tpl/config.twig
@@ -40,11 +40,11 @@
-
{% trans "Click here" %} {% trans "to export your poche datas." %}
+{% trans "Click here" %} {% trans "to export your poche datas." %}
{% endblock %} \ No newline at end of file diff --git a/tpl/export.twig b/tpl/export.twig index d22d05f..4adb954 100644 --- a/tpl/export.twig +++ b/tpl/export.twig @@ -1 +1 @@ -export {$export} \ No newline at end of file +{{ export }} \ No newline at end of file diff --git a/tpl/js/poche.js b/tpl/js/poche.js index 97d9911..b4eac11 100644 --- a/tpl/js/poche.js +++ b/tpl/js/poche.js @@ -23,7 +23,7 @@ function toggle_archive(element, id, view_article) { } function sort_links(view, sort) { - $.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) { + $.get('index.php', { view: view, sort: sort }, function(data) { $('#content').html(data); }); } diff --git a/tpl/login.twig b/tpl/login.twig index 70c2190..c302879 100644 --- a/tpl/login.twig +++ b/tpl/login.twig @@ -16,9 +16,9 @@