diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2014-02-20 12:49:49 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2014-02-20 12:49:49 +0100 |
commit | ab5bb94b12e04b357f8faee376704bc29ff019a5 (patch) | |
tree | e055f9cf96738f7b8a26caed4893951022527eed /inc/poche/Poche.class.php | |
parent | d09a5674e915e79762931a3465461327fb5737ea (diff) | |
parent | e83cf5a7875d1387d79d1909050ff2eca9b4421a (diff) | |
download | wallabag-ab5bb94b12e04b357f8faee376704bc29ff019a5.tar.gz wallabag-ab5bb94b12e04b357f8faee376704bc29ff019a5.tar.zst wallabag-ab5bb94b12e04b357f8faee376704bc29ff019a5.zip |
Merge branch 'dev' of git://github.com/mariroz/wallabag into mariroz-dev
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x[-rw-r--r--] | inc/poche/Poche.class.php | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 753bd7f0..fc9a455a 100644..100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -348,17 +348,55 @@ class Poche | |||
348 | 348 | ||
349 | protected function getPageContent(Url $url) | 349 | protected function getPageContent(Url $url) |
350 | { | 350 | { |
351 | $options = array('http' => array('user_agent' => 'poche')); | 351 | // Saving and clearing context |
352 | if (isset($_SERVER['AUTH_TYPE']) && "basic" === strtolower($_SERVER['AUTH_TYPE'])) { | 352 | $REAL = array(); |
353 | $options['http']['header'] = sprintf( | 353 | foreach( $GLOBALS as $key => $value ) { |
354 | "Authorization: Basic %s", | 354 | if( $key != "GLOBALS" && $key != "_SESSION" ) { |
355 | base64_encode( | 355 | $GLOBALS[$key] = array(); |
356 | sprintf('%s:%s', $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) | 356 | $REAL[$key] = $value; |
357 | ) | 357 | } |
358 | } | ||
359 | // Saving and clearing session | ||
360 | $REAL_SESSION = array(); | ||
361 | foreach( $_SESSION as $key => $value ) { | ||
362 | $REAL_SESSION[$key] = $value; | ||
363 | unset($_SESSION[$key]); | ||
364 | } | ||
365 | |||
366 | // Running code in different context | ||
367 | $scope = function() { | ||
368 | extract( func_get_arg(1) ); | ||
369 | $_GET = $_REQUEST = array( | ||
370 | "url" => $url->getUrl(), | ||
371 | "max" => 5, | ||
372 | "links" => "preserve", | ||
373 | "exc" => "", | ||
374 | "format" => "json", | ||
375 | "submit" => "Create Feed" | ||
358 | ); | 376 | ); |
377 | ob_start(); | ||
378 | require func_get_arg(0); | ||
379 | $json = ob_get_flush(); | ||
380 | return $json; | ||
381 | }; | ||
382 | $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) ); | ||
383 | |||
384 | // Clearing and restoring context | ||
385 | foreach( $GLOBALS as $key => $value ) { | ||
386 | if( $key != "GLOBALS" && $key != "_SESSION" ) { | ||
387 | unset($GLOBALS[$key]); | ||
388 | } | ||
389 | } | ||
390 | foreach( $REAL as $key => $value ) { | ||
391 | $GLOBALS[$key] = $value; | ||
392 | } | ||
393 | // Clearing and restoring session | ||
394 | foreach( $_SESSION as $key => $value ) { | ||
395 | unset($_SESSION[$key]); | ||
396 | } | ||
397 | foreach( $REAL_SESSION as $key => $value ) { | ||
398 | $_SESSION[$key] = $value; | ||
359 | } | 399 | } |
360 | $context = stream_context_create($options); | ||
361 | $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); | ||
362 | return json_decode($json, true); | 400 | return json_decode($json, true); |
363 | } | 401 | } |
364 | 402 | ||