2010-10-11 90 views
0

我有這個圖像的代理。它好工作在PHP 4,但並不是說我已經升級到5我得到這個錯誤:PHP的圖像代理中斷PHP 5

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /path/to/proxy.php on line 34

這裏是第34行:

curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); 

我怎樣才能解決這個問題?

下面是整個腳本。

$url = ($_POST['url']) ? $_POST['url'] : $_GET['url']; 
$headers = ($_POST['headers']) ? $_POST['headers'] : $_GET['headers']; 
$mimeType =($_POST['mimeType']) ? $_POST['mimeType'] : $_GET['mimeType']; 


//Start the Curl session 
$session = curl_init($url); 

// If it's a POST, put the POST data in the body 
if ($_POST['url']) { 
    $postvars = ''; 
    while ($element = current($_POST)) { 
     $postvars .= key($_POST).'='.$element.'&'; 
     next($_POST); 
    } 
    curl_setopt ($session, CURLOPT_POST, true); 
    curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars); 
} 


// Don't return HTTP headers. Do return the contents of the call 
curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false); 

curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); 
//curl_setopt($ch, CURLOPT_TIMEOUT, 4); 
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); 

// Make the call 
$response = curl_exec($session); 


if ($mimeType != "") 
{ 
    // The web service returns XML. Set the Content-Type appropriately 
    #header("Content-Type: ".$mimeType); 

    //Allmow caching 
    #header('Cache-Control: public'); 

} 

echo $response; 

curl_close($session); 

回答

1

顯然it can't be done。您必須通過檢查結果標頭的位置標題來解決該問題,然後從中取出。這是因爲curl會天真地遵循由web服務器發送的所有URL,包括具有明顯安全分支的file:// URL。

+0

謝謝我讓我的託管服務提供商變成了open_basedir。 – 2010-10-11 20:20:59

0

您可以閱讀錯誤消息,並檢查safe_modeopen_basedir