Здравствуйте!
Такая проблемма: пишет Bad Request;
Че я делаю не так?
<?php
$ff="http://www.autoemex.ru/EmExWebshop/login/login.aspx";
echo $ff."<br>";
//$fp=fopen($ff,"r");
$mylink="/EmExWebshop/login/login.aspx";
$fp = fsockopen("www.autoemex.ru",80);
$getreq="GET ".$mylink." HTTP/1.0\r\n";
//echo $getreq."<br>";
fputs($fp, $getreq);
fputs($fp, "Accept: */*\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "Host: www.autoemex.ru\r\n");
fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; AIRF; Maxthon)\r\n");
fputs($fp, "Connection: keep-alive\r\n");
fputs($fp, "\r\n");
$i=0;
$pr=0;
$pre=0;
//ob_start();
$buffer="";
while (!feof($fp)) //($pre==0) //((!feof($fp)) || ($pre==0))
{
$i++;
// echo htmlspecialchars(fgets($fp, 1000));
$buffer .= fgets($fp, 1000);
}
fclose($fp);
//$buffer=str_replace ("\r\n", "<br>", $buffer);
//include "sitefilters.php";
$srep="Set-Cookie: ASP.NET_SessionId=";
$ll=strlen($srep);
$ps=strpos($buffer,$srep);
$ss1=substr($buffer,$ps+$ll,1000);
$ps2=strpos($ss1,";");
$ASPNETSESS=substr($ss1,0,$ps2);
echo "Canney: ".$ASPNETSESS. "<br>";
$srep='name="__VIEWSTATE" value="';
$ll=strlen($srep);
$ps=strpos($buffer,$srep);
$ss1=substr($buffer,$ps+$ll,1000);
$ps2=strpos($ss1,'"');
$VIEWSTATE=substr($ss1,0,$ps2);
echo "ViewState: ".$VIEWSTATE. "<br>";
echo "PASS 2 =================<br>";
$POSTDATA='__VIEWSTATE='.urlencode($VIEWSTATE).'
txtLogin=odin
txtPass=86edfae4
btnLogon=%C2%D5%CE%C4+%C4%CB%DF+%CA%CB%C8%C5%CD%D2%CE%C2
';
$POSTDATA='__VIEWSTATE='.$VIEWSTATE.'&txtLogin=odin&txtPass=86edfae4&btnLogon=AOIA
AE? EEEAIOIA';
$POSTDATA=urlencode($VIEWSTATE);
$CL=strlen($POSTDATA);
$mylink="/EmExWebshop/login/login.aspx";
$fp = fsockopen("www.autoemex.ru",80);
$getreq="POST ".$mylink." HTTP/1.0\r\n";
//echo $getreq."<br>";
fputs($fp, $getreq);
fputs($fp, "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
application/x-shockwave-flash, */*\r\n");
fputs($fp, "Referer: http://www.autoemex.ru/EmExWebshop/login/login.aspx\r\n");
fputs($fp, "Accept-Language: ru\r\n");
fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; AIRF; Maxthon)\r\n");
fputs($fp, "Host: www.autoemex.ru\r\n");
fputs($fp, "Content-Length: ".$CL."\r\n");
fputs($fp, "Pragma: no-cache\r\n");
fputs($fp, "Cookie: ASP.NET_SessionId=".$ASPNETSESS."\r\n");
fputs($fp, "Connection: keep-alive\r\n");
//fputs($fp, "\r\n");
fputs($fp, $POSTDATA."\r\n");
fputs($fp, "\r\n");
$i=0;
$pr=0;
$pre=0;
//ob_start();
$buffer="";
while (!feof($fp)) //($pre==0) //((!feof($fp)) || ($pre==0))
{
$i++;
// echo htmlspecialchars(fgets($fp, 1000));
set_time_limit(500);
$buffer .= fgets($fp, 1000);
}
fclose($fp);
//echo $POSTDATA;
echo $buffer;
?>