我正在尝试使用 PHP 制作一个套接字帖子,但它似乎无法正常工作:
$sCRLF = "\r\n";
$sBoundary = "------".md5(time())."------".$sCRLF;
$_HEAD = $_CONTEXT['vars']['sMethod']." ".$_CONTEXT['vars']['sPage']." ".$_CONTEXT['vars']['sHTTP'].$sCRLF;
$_HEAD .= "Host: ".$_CONTEXT['vars']['sHost'].$sCRLF;
$_HEAD .= "User-Agent: ".$_CONTEXT['vars']['sAgent'].$sCRLF;
$_HEAD .= "Accept: ".$_CONTEXT['vars']['sAccept'].$sCRLF;
$_HEAD .= "Accept-Language: ".$_CONTEXT['vars']['sAcceptLanguage'].$sCRLF;
$_HEAD .= "Accept-Encoding: ".$_CONTEXT['vars']['sAcceptEncoding'].$sCRLF;
$_HEAD .= "Accept-Charset: ".$_CONTEXT['vars']['sAcceptCharSet'].$sCRLF;
$_HEAD .= "Connection: ".$_CONTEXT['vars']['sConnection'].$sCRLF;
$_HEAD .= "Referer: ".$_CONTEXT['vars']['sReferer'].$sCRLF;
if(isset($_CONTEXT['vars']['sCookie']) && !empty($_CONTEXT['vars']['sCookie'])){
$_HEAD .= "Cookie: ".$_CONTEXT['vars']['sCookie'].$sCRLF;
}
$_HEAD .= "Content-Disposition: form-data; name=\"".$_CONTEXT['vars']['sVarUpload']."\"; filename=\"".$_CONTEXT['vars']['sFileName']."\"".$sCRLF;
$_HEAD .= "Content-Type: ".$_CONTEXT['vars']['sMedia']."; boundary= ".$sBoundary.$sCRLF;
$_HEAD .= "Content-Transfer-Encoding: binary".$sCRLF;
$_HEAD .= "Content-Type: application/octet-stream".$sCRLF.$sCRLF;
$_HEAD .= readfile($sDest);
$rConnect = @fsockopen($_CONTEXT['vars']['sHost'],80,$errno,$errstr,30);
if($rConnect){
fwrite($rConnect,$_HEAD);
while(!feof($rConnect)){
echo fgets($rConnect,128);
}
fclose($rConnect);
}
我确实收到了响应,200 OK 和 html 表单,但是如果我转储 $_FILES 和/或 $_POST,我会得到一个空数组。所以显然变量根本没有发送。我尝试更改标题,但我继续得到相同的结果。遗憾的是,我没有访问 cUrl 的权限,所以这是没有选择的。
任何帮助,将不胜感激。