From 9ba98a0abe4ac5efed5213812f0f26821417b47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 10 Jan 2014 16:33:10 +0100 Subject: [PATCH 1/2] [add] display token and user id --- themes/default/config.twig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/default/config.twig b/themes/default/config.twig index ef615d39b..e22ea1da4 100644 --- a/themes/default/config.twig +++ b/themes/default/config.twig @@ -38,6 +38,8 @@
  • {% trans "Favorites feed" %}
  • {% trans "Archive feed" %}
  • +

    {% trans "Your token:" %} {{token}}

    +

    {% trans "Your user id:" %} {{user_id}}

    {% trans "You can regenerate your token: generate!." %}

    {% endif %} From f878daeb8bc9245a294677e4ac141f8bd37c2b4f Mon Sep 17 00:00:00 2001 From: adev Date: Sun, 12 Jan 2014 17:08:52 +0100 Subject: [PATCH 2/2] add basic auth in file_get_contents for content extraction when user use basic auth --- inc/poche/Poche.class.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index e033ad749..004cca8e5 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -325,6 +325,22 @@ class Poche ); } + protected function getPageContent(Url $url) + { + $options = array('http' => array('user_agent' => 'poche')); + if (isset($_SERVER['AUTH_TYPE']) && "basic" === strtolower($_SERVER['AUTH_TYPE'])) { + $options['http']['header'] = sprintf( + "Authorization: Basic %s", + base64_encode( + sprintf('%s:%s', $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) + ) + ); + } + $context = stream_context_create($options); + $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context); + return json_decode($json, true); + } + /** * Call action (mark as fav, archive, delete, etc.) */ @@ -333,10 +349,7 @@ class Poche switch ($action) { case 'add': - $options = array('http' => array('user_agent' => 'poche')); - $context = stream_context_create($options); - $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context); - $content = json_decode($json, true); + $content = $this->getPageContent($url); $title = $content['rss']['channel']['item']['title']; $body = $content['rss']['channel']['item']['description'];