From b4fd2154fe1d05d0a0e8e2e309acd3313020d3cb Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 19 Feb 2014 19:08:19 +0200 Subject: Full-Text RSS included as a script instead of file_get_contents call. Tnx to @Faless. Fix issues #366 and #463 --- inc/poche/Poche.class.php | 56 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) mode change 100644 => 100755 inc/poche/Poche.class.php (limited to 'inc/poche') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php old mode 100644 new mode 100755 index 753bd7f0..fc9a455a --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -348,17 +348,55 @@ 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']) - ) + // Saving and clearing context + $REAL = array(); + foreach( $GLOBALS as $key => $value ) { + if( $key != "GLOBALS" && $key != "_SESSION" ) { + $GLOBALS[$key] = array(); + $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); } -- cgit v1.2.3 From e83cf5a7875d1387d79d1909050ff2eca9b4421a Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Thu, 20 Feb 2014 10:41:16 +0200 Subject: multiple tag entry displayed fix, issue #474 --- inc/poche/Database.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/poche') diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 3332b5a3..a366e866 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -345,7 +345,7 @@ class Database { } public function retrieveAllTags($user_id) { - $sql = "SELECT tags.* FROM tags + $sql = "SELECT DISTINCT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id LEFT JOIN entries ON tags_entries.entry_id=entries.id WHERE entries.user_id=?"; @@ -357,7 +357,7 @@ class Database { public function retrieveTag($id, $user_id) { $tag = NULL; - $sql = "SELECT tags.* FROM tags + $sql = "SELECT DISTINCT tags.* FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id LEFT JOIN entries ON tags_entries.entry_id=entries.id WHERE tags.id=? AND entries.user_id=?"; -- cgit v1.2.3