Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP5中的PHP图像代理中断_Php_Curl_Proxy - Fatal编程技术网

PHP5中的PHP图像代理中断

PHP5中的PHP图像代理中断,php,curl,proxy,Php,Curl,Proxy,我有这个图像代理。它在PHP4中运行良好,但并非因为我已升级到5,而是因为我遇到以下错误: 警告:curl_setopt() 这是第34行: curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); 我怎样才能解决这个问题 下面是整个脚本 $url = ($_POST['url']) ? $_POST['url'] : $_GET['url']; $headers = ($_POST['headers']) ? $_POST['headers']

我有这个图像代理。它在PHP4中运行良好,但并非因为我已升级到5,而是因为我遇到以下错误:

警告:curl_setopt()

这是第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);

您可以读取错误消息,并检查
safe\u mode
open\u basedir

。您必须通过检查结果头中的位置头来解决这个问题,然后从那里取回。这是因为curl会天真地跟踪web服务器发送的所有url,包括file://url,它们具有明显的安全后果。

谢谢我让我的托管提供商打开了open\u basedir。