<?php
        $ip = $_SERVER[REMOTE_ADDR];

        $ban_ip = Array(); /* Zde lze vkládat IP adresy, které nebudou započítávány do statistik. Např.: $ban_ip = Array("127.0.0.1","82.202.0.2","192.56.87.3"); */
        
        $ban = 0;
        
        foreach($ban_ip as $ip_adresa) {
                if($ip == $ip_adresa) {
                        $ban = 1;
                        break;
                }
        }

        if($ban == 0) {
                $cas = time();
                dotaz("DELETE FROM forum_ip WHERE time < '$cas';");

                $den = date("w");
                $cas = $cas + 600;

                $kod = mt_rand(1,1000);

                dotaz("UPDATE forum_ip SET time = '$cas', kod = '$kod' WHERE ip = '$ip';");
                if(mysql_affected_rows() == 0) {
                        $row = mysql_fetch_array(dotaz("SELECT den FROM forum_stat WHERE id = '1';"));
                        if($row[den] == $den) {
                                dotaz("UPDATE forum_stat SET dnes = dnes + 1, celkem = celkem + 1, hitu = hitu + 1 WHERE id = '1';");
                        } else {
                                dotaz("UPDATE forum_stat SET dnes = '0', celkem = celkem + 1, den = '$den', hitu = hitu + 1 WHERE id = '1';");
                        }
                        dotaz("INSERT INTO forum_ip SET ip = '$ip', time = '$cas', kod = '$kod';");
                } else {
                        dotaz("UPDATE forum_stat SET hitu = hitu + 1 WHERE id = '1';");
                }
        }
?>