* @param string $url nacitame konkretni tabulku ze serveru SPORT
* @param integer $ttl nastavujeme dobu expirace stahovani, defaultne 3600 (1 hodina)
* @return string
*
*/
function showSoccerTable($url = '', $ttl = 3600)
{
// vychozi priznak
$cached = true;
// nenalezen soubor nebo probehl expiraci
if (!is_file("./cache/" . md5($url)) || time() - filemtime("./cache/" . md5($url)) > $ttl)
$cached = false;
// neni kesovano
if (!$cached)
{
// debug
//echo "znovu parsujeme tabulku - " . date('d.m.Y H:i:s');
$f = file_get_contents($url);
if (!$f)
{
echo 'Nelze načíst - ' . $url ;
return;
}
$table = preg_match("~(.+?)
~s", $f, $out);
$ourTable = '' . strip_tags($out[1], ",
,
';
// $ourTable = str_replace(array(' bgcolor="#aaaaaa"', ' bgcolor="#aaaaaa"', ' bgcolor="#f8f8f8"', ' bgcolor="#ffffff"'), array(''), $ourTable);
// ulozime
file_put_contents("./cache/".md5($url), $ourTable);
}
// nacteme tabulku
$table = file_get_contents("./cache/".md5($url));
return $table;
}
?>