>>никак потому что там нет LWP $)
>
>ну как то же можно, через сокеты или ещё чтонибудь
>curl какой-то есть
>
>а вот так нельзя реферер задать? у меня не работает
>header('Referer: http://site.org');
>header('Location: http://site.org/cgi-bin/perlinfo.cgi'); на каком-то Curl'e
function Wget($request, $TIMEOUT)
{
if (function_exists("curl_init"))
{
$ch = curl_init();
$header = array();
$header[] = "Accept: text/html";
$header[] = "Accept-Language: ru,en;q=0.9";
$header[] = "Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1";
$header[] = "Accept-Encoding: deflate, identity, *;q=0";
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/8.50 (Windows NT 5.1; U; ru)');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, $TIMEOUT);
$data=curl_exec ($ch);
$err=curl_errno($ch);
if($err)
{
$err=curl_error($ch);
echo $err.'<br>';
return(FALSE);
}
curl_close ($ch);
}
else
{
return(FALSE);
}
$out = parse_response($data);
return $out[2];
}
function parse_response($response)
{
/*
***original code extracted from examples at
***http://www.webreference.com/programming
/php/cookbook/chap11/1/3.html
***returns an array in the following format which varies depending on headers returned
[0] => the HTTP error or response code such as 404
[1] => Array
(
[Server] => Microsoft-IIS/5.0
[Date] => Wed, 28 Apr 2004 23:29:20 GMT
[X-Powered-By] => ASP.NET
[Connection] => close
[Set-Cookie] => COOKIESTUFF
[Expires] => Thu, 01 Dec 1994 16:00:00 GMT
[Content-Type] => text/html
[Content-Length] => 4040
)
[2] => Response body (string)
*/
do
{
list($response_headers,$response) = explode("\r\n\r\n",$response,2);
$response_header_lines = explode("\r\n",$response_headers);
// first line of headers is the HTTP response code
$http_response_line = array_shift($response_header_lines);
if (preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line,
$matches)) {
$response_code = $matches[1];
}
else
{
$response_code = "Error";
}
}
while (substr($response_code, 0,1) == "1");
$response_body = $response;
// put the rest of the headers in an array
$response_header_array = array();
foreach ($response_header_lines as $header_line) {
list($header,$value) = explode(': ',$header_line,2);
$response_header_array[$header] = $value;
}
return array($response_code,$response_header_array,$response_body);
}
В $header пишется что хочешь!
Можно без $parse_response();
тогда curl_setopt($ch, CURLOPT_HEADER, 0) и return($data)