<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
    <meta name="author" content="Roman Janko">

    <title>Tabulka - fotbal.cz</title>
</head>

<body>


<style type="text/css">

table.soccer-table
{
    font-family: Arial;
    width: 500px;
    font-size: 12px;
    border:  2px solid gray;
    border-collapse: collapse;
    
}


table.soccer-table td
{
    border-bottom:  1px solid gray;
    padding: 4px;
}
</style>

<?php



echo showFotbalczTable('http://fotbal.cz/c/KaO/RKMorava/souteze.asp?soutez=003J2B');




/**
 * showFotbalczTable()
 * 
 * Funkce umoznuje parsovat fotbalove tabulky ze serveru FOTBAL.CZ, 
 * funkce fungovalo dnem vytvoreni 4-10-2008
 * mozna casem nebude a to tehdy pokud se zmeni vysledne HTML tabulky
 *  
 * @date 04-10-2008
 * @author Roman Janko <admin@rjwebdesign.net>     
 * @param string $url  nacitame konkretni tabulku ze serveru Fotbal.cz
 * @param integer $ttl  nastavujeme dobu expirace stahovani, defaultne 3600 (1 hodina)
 * @return string
 *  
 */


function showFotbalczTable($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');
        
        
$source        file_get_contents($url);
        if (!
$source)
        {
            echo 
'Nelze načíst - ' $url ;
            return;
        }
        
      
        
//$table    = preg_match("~<table id="teamTable">(.+?)</table>~s", $f, $out);
        
preg_match("~TABULKA(.+?)</table>~s"$source$out);
        
$out[1] = trim($out[1]);
        
$src substr($out[1], strpos($out[1], "</tr>") + 6strlen($out[1]));
        
        
// odstranime vnorene zastarale html tagy obarvujici radky aby byla tabulka cista
        
$remove_tags = array('bgcolor="#aaaaaa"''bgcolor="#ffffff"''bgcolor="bbbbbb"''bgcolor="#f8f8f8"');
        foreach (
$remove_tags as $rem)
        {
            
$src str_replace($rem''$src);
        }

        
// vysledne, cista tabulka
        
$ourTable '<table class="soccer-table">' $src '</table>';

        
// ulozime
        
file_put_contents("./cache/".md5($url), $ourTable);
    }

        
// nacteme tabulku
        
$table file_get_contents("./cache/".md5($url));
        
        return 
$table;
    
}

?>



</body>
</html>