Ragazzi, sto sbattendo da un bel pò!
Non so se è un problema di cache, ma sembra che con la fsockopen il sito freesms.net non voglia colloquiare!
Se inserisco in una pagina php vuota questo codice:
codice:
<?php
function hostconnect($host, $timeout, $errmsg) {
$try = 0;
do {
$fp = fsockopen($host,80, $errmsg, $errmsg, $timeout);
$try++;
} while (!$fp && $try < 2); // Try 2 times to avoid aborting on first
// connection error
if(!$fp){
$risposta = $errmsg;
termina($risposta);
return FALSE;
}
return $fp;
}
$address="http://www.freesms.net/";
$addarray=parse_url($address);
$fp = hostconnect($addarray['host'], 30, "Errore, sito non disponibile");
fputs($fp, "GET ".$addarray['path']."?".$addarray['query']." HTTP/1.1\r\n");
fputs($fp, "Host: ".$addarray['host']."\r\n");
fputs($fp, "Accept: */*\r\n");
fputs($fp, "Cache-Control: no-cache\r\n");
fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-Length: 0 \r\n");
fputs($fp, "User-agent: Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$view="";
$event="";
$toolkit="";
$temp="";
$header="";
while (!feof($fp))
{
$temp=fgets($fp, 1024);
$header.=$temp;
if($tmp=stristr($temp,"__VIEWSTATE" value="")) $view=substr($tmp, 0, strpos($tmp,"""));
if($tmp=stristr($temp,"__EVENTVALIDATION" value="")) $event=substr($tmp, 0, strpos($tmp,"__EVENTVALIDATION" value=""));
if($tmp=stristr($temp,"_TSM_CombinedScripts_=")) $toolkit=trim(substr($tmp, 0, strpos($tmp,""")));
}
fclose($fp);
echo $header;
?>
Il risultato è sempre
codice:
HTTP/1.1 302 Found Cache-Control: private Content-Type: text/html; charset=iso-8859-1 Location: /Error.htm?aspxerrorpath=/default.aspx Server: Microsoft-IIS/7.5 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET Date: Fri, 13 May 2011 20:03:55 GMT Connection: close Content-Length: 163
Object moved to here.
Non riesco a capire perchè!
Se al posto di http://www.freesms.net/ ci metto un altro sito qualunque (anke http://www.google.it/) funziona alla perfezione!
Qualcuno sa come mai con freesms.net non funziona?