r{$i} = {$content}
";
}
echo "
";
flush(); @ob_flush();
}
$time_seconds = microtime(true) - $start;
echo "All Jobs Complete in {$time_seconds} seconds
";
// odpre asinhrono povezavo na skripto
function JobStartAsync($url, $conn_timeout=30, $rw_timeout=86400)
{
$errno = '';
$errstr = '';
$url = parse_url($url);
if ($url['scheme'] != 'http') {
die('Only HTTP request are supported !');
}
$host = $url['host'];
$path = $url['path'];
$query = $url['query'] != '' ? "?{$url['query']}" : "";
set_time_limit(0);
$fp = fsockopen($host, 80);
stream_set_blocking($fp, false);
stream_set_timeout($fp, $rw_timeout);
fputs($fp, "GET {$path}{$query} HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Connection: close\r\n\r\n");
return $fp;
}
// zaporedoma bere fp in vraca kaj se dogaja: returns false if HTTP disconnect (EOF), or a string (could be empty string) if still connected
function JobPollAsync(&$fp)
{
if ($fp === false) return false;
if (feof($fp)) {
fclose($fp);
$fp = false;
return false;
}
return fread($fp, 10000);
}
?>