In WU-history-inc.php replace the function
Code: Select all
function getcsvWithoutHanging($url) {
$numberOfSeconds=4;
error_reporting(0);
$url = str_replace("http://","",$url);
$urlComponents = explode("/",$url);
$domain = $urlComponents[0];
$resourcePath = str_replace($domain,"",$url);
// $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);
$socketConnection = fsockopen('ssl://'.$domain, 443, $errno, $errstr, $numberOfSeconds);
$cols = '';
fputs($socketConnection, "GET $resourcePath HTTP/1.0\r\nHost: $domain\r\nUser-agent: $UA\r\nConnection: close\r\n\r\n");
$rows = 0;
while (!feof($socketConnection)) {
// $line = ereg_replace("<br>", "", fgets($socketConnection, 4096)); //One of these gets left in there somehow
$line = str_replace("<br>", "", fgets($socketConnection, 4096)); //One of these gets left in there somehow
$cols[] = explode(",", $line);
}
fclose ($socketConnection);
/*
$cols = file($url);
print_r($cols);
exit;
*/
for ($i = 0; $i<=11;$i++) { // Remove the header info that came with download
array_shift($cols);
}
return($cols);
}
Code: Select all
function getcsvWithoutHanging($url) {
$url = str_replace('http://','https://',$url);
$STRopts = array(
'http'=>array(
'method'=>"GET",
'protocol_version' => 1.1,
'header'=>"Cache-Control: no-cache, must-revalidate\r\n" .
"Cache-control: max-age=0\r\n" .
"Connection: close\r\n" .
"User-agent: Mozilla/5.0 (WU-history-inc.php saratoga-weather.org)\r\n" .
"Accept: text/plain,text/html\r\n"
),
'https'=>array(
'method'=>"GET",
'protocol_version' => 1.1,
'header'=>"Cache-Control: no-cache, must-revalidate\r\n" .
"Cache-control: max-age=0\r\n" .
"Connection: close\r\n" .
"User-agent: Mozilla/5.0 (WU-history-inc.php saratoga-weather.org)\r\n" .
"Accept: text/plain,text/html\r\n"
)
);
$STRcontext = stream_context_create($STRopts);
print "<!-- loading $url -->\n";
$lines = file($url,false,$STRcontext);
$headerarray = get_headers($url,0);
$theaders = join("\r\n",$headerarray);
print "<!-- headers returned: \n".$theaders." -->\n";
// process the returned file
$cols = array();
print "<!-- ".count($lines)." lines returned. -->\n";
foreach ($lines as $i => $line) {
$line = str_replace('<br>','',$line);
$cols[] = explode(',',$line);
}
if (count($cols) > 11) {
for ($i = 0; $i<=11;$i++) { // Remove the header info that came with download
array_shift($cols);
}
}
return($cols);
}
It does work correctly (with the replaced getcsvWithoutHanging function above).
Best regards,
Ken