我在共享服务器上托管的网站存在问题,该服务器设置了“open_basedir”...因此信用系统会引发错误并且不会向买家的信用卡收费。
错误信息
警告:curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION 在安全模式或 open_basedir 设置时无法激活
代码
function http_post($method, $server, $port, $url, $vars) {
$postdata = "";
foreach($vars as $key => $value) {
$postdata .= urlencode($key) . "=" . urlencode($value) . "&";
}
$postdata = substr($postdata,0,-1);
$content_length = strlen($postdata);
$headers = "POST $url HTTP/1.1\r\n".
"Accept: */*\r\n".
"Accept-Language: en-nz\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Host: $server\r\n".
"Connection: Keep-Alive\r\n".
"Cache-Control: no-cache\r\n".
"Content-Length: $content_length\r\n\r\n";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $method . '://' . $server .":". $port . $url);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
无论如何,在没有访问根 PHP.ini 并且必须切换主机的情况下,是否存在这种情况?谢谢你。