<?php
/*Skrypt pochodzi z ksi±¿ki "PHP. 101 praktycznych skryptów"
  autor: Marcin Lis                    http://marcinlis.com*/
$bannersCount = 10;

if(isSet($_COOKIE['banner'])){
  $num = $_COOKIE['banner'] + 1;
  if($num > $bannersCount){
    $num = 1;
  }
}
else{
  $num = rand(1, $bannersCount);
}
setCookie("banner", $num, time() + 3600 * 24 * 30);

function printBannerName()
{
  $num = $GLOBALS['num'];
  $name = "banner".$num.".gif";
  echo("<img src=\"$name\" alt=\"reklama\">");;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>Moja strona WWW</title>
</head>
<body>
<div>
<?php printBannerName(); ?>
</div>
</body>
</html>
