写得一个php天气小偷程
/***
天气预报
***/
function readall($location)
{
$max_retry_num = 3;
if(preg_match(/(http:\/\/)?([^\/\:]+)(:\d{1,5})?(\/.+)?/, $location, $url))
{
list(,,$host,$port,$path) = $url;
$port = preg_replace(/:/, , $port);
$port = strlen($port) ? $port : 80;
$path = strlen($path) ? $path : /;
$request = get $path http/1.0\r\n;
$request .= host: $host\r\n;
$request .= accept: */*\r\n;
$request .= connection: close\r\n;
$request .= user-agent: superspices bot\r\n\r\n;
$retry = 0;
$do = false;
do
{
if(@!$socket =fsockopen($host, $port, &$errmsg, &$errcode ))
{
return false;
}
fwrite($socket, $request);
$flag = true;
$header = ;
$body = ;
while(!feof($socket))
{
$line = fgets($socket, 128);
if($flag)
{
if(trim(chop($line)) == )
{
$flag = false;
}
else
{
$header .= $line;
}
}
else
{
$body .= $line;
}
}
if(preg_match(/content-length: (\d+)/, $header, $out))
{
$header_length = $out[1];
if($header_length != strlen($body))
{
$do = true;
}
else
{
$do = false;
}
}
if(is_resource($socket))
{
fclose($socket);
}
$retry ++;
}while($do && $retry }
return $body;
}
function get_weather()
{
$tqurl=http://www.ttqx.com.cn/forecast/area_weather.asp?city_name=合肥&zhou=yz;
$vax1tem=readall($tqurl);
if(!$vax1tem)
{
return false;
}
settype($arraytq,array);
$arraytq=explode(,$vax1tem);
$arraytq=explode(,$arraytq[1]);
$flash = explode(