HTTP Proxy support for RSS feeds

Post modules, themes or any other code you want to share with the community.

Moderator: Developers

dpashev
Posts: 1
Joined: Fri Mar 26, 2010 2:00 pm

HTTP Proxy support for RSS feeds

Postby dpashev » Fri Mar 26, 2010 2:14 pm

Patch below add HTTP proxy support for RSS feeds.

Code: Select all

--- groupoffice-com-3.4.12/modules/summary/feed_proxy.php	2009-02-17 12:45:38.000000000 +0200
+++ groupoffice-com/modules/summary/feed_proxy.php	2010-03-26 16:02:11.000000000 +0200
@@ -15,7 +15,15 @@
 $feed = $_REQUEST['feed'];
 if($feed != '' && strpos($feed, 'http') === 0){
 	header('Content-Type: text/xml');
-	$xml = @file_get_contents($feed);
+	$proxy = getenv('http_proxy');
+	if( $proxy ) {
+	    $context = stream_context_create(
+		array( 'http' => array('proxy'=>preg_replace('/^http/i','tcp',$proxy ),'request_fulluri' => True  ))
+		);
+	} else {
+	    $context = null;
+	}
+	$xml = @file_get_contents($feed,false,$context);
 	if($xml)
 	{		
 		$xml = str_replace('<content:encoded>', '<content>', $xml);
Attachments
http-proxy-for-feed-proxy-php.patch.txt
(718 Bytes) Downloaded 402 times

Who is online

Users browsing this forum: No registered users and 4 guests

cron