<!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">
<title>Moja strona WWW</title>
</head>
<body>
<div style="text-align:center">

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

function checkPass($user, $pass)
{
  if(!$fd = @fopen("./passwords/passwords.txt", "r")) return false;
  while (!feof ($fd)){
    $line = trim(fgets($fd));

    if(($pos = strpos($line, ":"))===false) continue;

    $tempUser = substr($line, 0, $pos);
    if($tempUser != $user) continue;

    $tempPass = substr($line, $pos + 1, strlen($line) - $pos);

    fclose($fd);
    if($tempPass == $pass){
      return true;
    }
    else{
      return false;
    }
  }
  fclose($fd);
  return false;
}

if(!isSet($_POST["haslo"]) || !isSet($_POST["nazwa"])){
  include('form.inc');
}
else if(checkPass($_POST["nazwa"], $_POST["haslo"])){
  include('index.inc');
}
else{
  include('form.inc');
}
?>

</div>
</body>
</html>
