<?
session_start();
include("../kernel/nastaveni.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>  
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">  
  <meta name="generator" content="PSPad, Bluefish">  
  <meta http-equiv="content-language" content="cs" >    
  <meta NAME="description" CONTENT="Redakční systém MyPage">	
  <meta name="robots" content="noindex,nofollow">  
  <meta NAME="distribution" CONTENT="global">	
  <meta name="author" content="Jiří Bednář">	
  <meta http-equiv="content-style-type" content="text/css">  
  <title>Přihlášení do systému MyPage   
  </title>  
  <link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>  
  <div id="login">     
<?
if(isset ($_SESSION['name'])){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
elseif(!isset ($_POST['send']) && !isset ($id)){
echo"
<center>
<fieldset>
<legend>MyPage Login</legend>
<form action=\"login.php\" method=\"post\">
Jméno: <input type=\"text\" name=\"input_name\" class=\"txt\"><br>
Heslo: <input type=\"password\" name=\"input_pass\" class=\"txt\"><br>
<input type=\"hidden\" name=\"send\" value=\"send\">
<input type=\"submit\" value=\"Přihlásit se\" id=\"submit\">
</form>
</fieldset>
<a href=\"login.php?id=heslo\">Zapomenuté heslo</a>
</center>
";
}
if(isset ($_POST['send'])){
$input_name = $_POST['input_name'];
$input_pass = $_POST['input_pass'];

if(!isset($input_name) || !isset($input_pass)){
echo "<div id=\"info\"><div id=\"bad\">Vyplňte všechny údaje <meta http-equiv=\"refresh\" content=\"1;URL=login.php\"></div></div>";
}

else{
include("../kernel/nastaveni.php");
$input_pass = md5("$input_pass");

if($input_pass != $account["pass"] || $input_name != $account["name"]){
echo "<div id=\"info\"><div id=\"bad\">Špatné jméno nebo heslo<meta http-equiv=\"refresh\" content=\"1;URL=login.php\"></div></div>";
}

else{
if($input_pass == $account["pass"] &&  $input_name == $account["name"]){
$_SESSION['name'] = $account["name"];
$_SESSION['pass'] = $account["pass"];
echo "<div id=\"info\"><div id=\"good\">Přístup povolen <meta http-equiv=\"refresh\" content=\"1;URL=index.php?$PHPSESSID\"> </div></div>";
}
}
}
}
$id = $_GET['id'];
if($id == "heslo"){
if(!isset($pass)){
echo "<div id=\"info\"><a href=\"login.php?id=heslo&pass=send\" style=\"color: black;\">Odeslat nové heslo?</a></div>";
}
$pass = $_GET['pass'];
if($pass == "send"){





    $pass = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
    $message = "
    Vaše nové heslo pro přístup do administrace MyPage je $pass
    Na tento e-mail neodpovídejte, byl vygenerován systémem MyPage  
    ";
    Mail($account["mail"], "Nove heslo", $message, "From: MyPage");
    $md5_pass = md5($pass);
    $popis = "
<?
\$account[\"name\"] = '$account[name]';
\$account[\"pass\"] ='$md5_pass';
\$account[\"mail\"] = '$account[mail]';
\$webpage[\"name\"] ='$webpage[name]';
\$webpage[\"info_text\"] = '$webpage[info_text]';
\$webpage[\"style\"] = '$webpage[style]';
?>
";
?>
<?
$fp = FOpen ("../kernel/nastaveni.php", "w"); 
if(FWrite ($fp, $popis)):
FClose ($fp);
endif;
    
    
    echo "<div id=\"info\">Heslo odesláno<meta http-equiv=\"refresh\" content=\"1;URL=login.php\"></div>";  
    
    
      
}
}
?>   



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