2011-02-01 38 views
1

我正在一个不接受请求(get/post)远程域的linux服务器上工作。就像,如果我在另一个域上使用表单并将其发布到此服务器上的脚本中,它就不会处理它。我想知道我必须启用哪些选项才能完成此操作,以便它能够接受远程请求?这是在php.ini中的东西?接受远程域获取/发布请求

问候

+0

这样的水煤浆通过网络服务器最有可能配置。我会使用mod_rewrite与Apache,如果我不得不阻止来自其他域的帖子,而不是PHP。 – Spliffster 2011-02-01 18:56:19

回答

2

如果Web服务器通过块引用的职位,你需要找到一种方法,从您的网站发送引用。首先将帖子发送到脚本,然后从该脚本发送到您的站点,这会让您有可能伪造引荐者请求标头。

例如PHP代理的下面的代码就是从这里借:http://snipplr.com/view/16058/php-url-proxy/

<?php 
// PHP Proxy 
// Responds to both HTTP GET and POST requests 
// 
// Author: Abdul Qabiz 
// March 31st, 2006 
// 

// Get the url of to be proxied 
// Is it a POST or a GET? 
$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); 

// NOTE: HERE YOU WILL OVERRIDE THE REFERRER REQUEST HEADER 
if ($mimeType != "") 
{ 
// The web service returns XML. Set the Content-Type appropriately 
header("Content-Type: ".$mimeType); 
} 

echo $response; 

curl_close($session); 

?>