1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-23 17:42:15 -05:00

Full-Text RSS included as a script instead of file_get_contents call. Tnx to @Faless. Fix issues #366 and #463

This commit is contained in:
Maryana Rozhankivska 2014-02-19 19:08:19 +02:00
parent f37891fdb6
commit b4fd2154fe
3 changed files with 51 additions and 10 deletions

2
inc/3rdparty/config.php vendored Normal file → Executable file
View File

@ -11,6 +11,8 @@
// options you'd like to override in custom_config.php. // options you'd like to override in custom_config.php.
// ..................................................... // .....................................................
global $options;
// Create config object // Create config object
if (!isset($options)) $options = new stdClass(); if (!isset($options)) $options = new stdClass();

1
inc/3rdparty/makefulltextfeed.php vendored Normal file → Executable file
View File

@ -424,6 +424,7 @@ $http->rewriteUrls = $options->rewrite_url;
////////////////////////////////// //////////////////////////////////
// Set up Content Extractor // Set up Content Extractor
////////////////////////////////// //////////////////////////////////
global $extractor;
$extractor = new ContentExtractor(dirname(__FILE__).'/site_config/custom', dirname(__FILE__).'/site_config/standard'); $extractor = new ContentExtractor(dirname(__FILE__).'/site_config/custom', dirname(__FILE__).'/site_config/standard');
$extractor->debug = $debug_mode; $extractor->debug = $debug_mode;
SiteConfig::$debug = $debug_mode; SiteConfig::$debug = $debug_mode;

58
inc/poche/Poche.class.php Normal file → Executable file
View File

@ -348,17 +348,55 @@ class Poche
protected function getPageContent(Url $url) protected function getPageContent(Url $url)
{ {
$options = array('http' => array('user_agent' => 'poche')); // Saving and clearing context
if (isset($_SERVER['AUTH_TYPE']) && "basic" === strtolower($_SERVER['AUTH_TYPE'])) { $REAL = array();
$options['http']['header'] = sprintf( foreach( $GLOBALS as $key => $value ) {
"Authorization: Basic %s", if( $key != "GLOBALS" && $key != "_SESSION" ) {
base64_encode( $GLOBALS[$key] = array();
sprintf('%s:%s', $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) $REAL[$key] = $value;
) }
); }
// Saving and clearing session
$REAL_SESSION = array();
foreach( $_SESSION as $key => $value ) {
$REAL_SESSION[$key] = $value;
unset($_SESSION[$key]);
}
// Running code in different context
$scope = function() {
extract( func_get_arg(1) );
$_GET = $_REQUEST = array(
"url" => $url->getUrl(),
"max" => 5,
"links" => "preserve",
"exc" => "",
"format" => "json",
"submit" => "Create Feed"
);
ob_start();
require func_get_arg(0);
$json = ob_get_flush();
return $json;
};
$json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) );
// Clearing and restoring context
foreach( $GLOBALS as $key => $value ) {
if( $key != "GLOBALS" && $key != "_SESSION" ) {
unset($GLOBALS[$key]);
}
}
foreach( $REAL as $key => $value ) {
$GLOBALS[$key] = $value;
}
// Clearing and restoring session
foreach( $_SESSION as $key => $value ) {
unset($_SESSION[$key]);
}
foreach( $REAL_SESSION as $key => $value ) {
$_SESSION[$key] = $value;
} }
$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); return json_decode($json, true);
} }