You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by bh...@apache.org on 2010/08/23 11:04:26 UTC
svn commit: r988036 -
/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
Author: bhofmann
Date: Mon Aug 23 09:04:25 2010
New Revision: 988036
URL: http://svn.apache.org/viewvc?rev=988036&view=rev
Log:
SHINDIG-1295: Patch from Michiel Eghuizen | CURLOPT_FOLLOWLOCATION doesn't work with PHP safemode and openbasedir
Modified:
shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
Modified: shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php?rev=988036&r1=988035&r2=988036&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php (original)
+++ shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php Mon Aug 23 09:04:25 2010
@@ -250,7 +250,23 @@ class BasicRemoteContentFetcher extends
private function initCurlHandle($url) {
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
- curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1);
+ // CURLOPT_FOLLOWLOCATION doesn't work with PHP safemode and openbasedir turned on
+ $isOpenBasedir = false;
+ $isSafeMode = false;
+ try {
+ $isOpenBasedir = @ini_get('open_basedir');
+ $isSafeMode = @ini_get('safe_mode');
+ $isOpenBasedir = !empty($isOpenBasedir);
+ $isSafeMode = !empty($isSafeMode);
+ } catch (Exception $e) {
+ $isOpenBasedir = false;
+ $isSafeMode = false;
+ }
+ if(!$isOpenBasedir && !$isSafeMode) {
+ curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1);
+ } else {
+ curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
+ }
curl_setopt($handle, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_AUTOREFERER, 1);