我使用此脚本发送帖子并获取文件及其内容并处理请求
$postdata = http_build_query(
array(
'inUsername' => ''.$_REQUEST['inUsername'].'',
'inPassword' => ''.$_REQUEST['inPassword'].'',
'csfr_token' => ''.$_REQUEST['csfr_token'].''
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result2 = file_get_contents('http://cp.ufowebs.com/index.php', false, $context);
$result="Invalid";
if (eregi($result,$result2))
{
print '{"login":"ok"}';
}
else
{
print "ok";
header("Location:http://cp.ufowebs.com/index.php");v<meta http-equiv="refresh" content="2;url=http://cp.controlpanel.com/index.php">
}
}
?>
在本地或从其他 url 工作正常,但在同一个 url 或如果转到子域等,没有工作,总是给我这个错误:
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/hostdata/admin/public_html/domain_com/test_cp.php on line 94 Warning: file_get_contents(http://cp.domain.com/index.php): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/hostdata/admin/public_html/domain_com/test_cp.php on line 94 ok
我不知道为什么从其他域工作而不进入同一个域等