X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=inc%2Fpoche%2FPoche.class.php;h=0be1668d08f1649401cdcb89a606b1fdc20cfcb4;hb=1b539ba1ece99774ef28eb149f7b6d21964260e9;hp=d473321862e7ec6e7a2ca58d3674e5c7166eab88;hpb=3e0e7e1208e8d3ee3b23df42ea119d7c50b0db5f;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d4733218..0be1668d 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -326,6 +326,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.) */ @@ -334,10 +350,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'];