<?php

/* =========== Config aj. =========== */
  if( !file_exists('./config.php') ){ exit; };
  require_once './config.php';

/* =========== Připojení k Databázi =========== */

  @mysql_connect( $Config['DB_read']['Database']['Host'], $Config['DB_read']['Database']['User'], $Config['DB_read']['Database']['Password'] ) 
    OR DIE("<p>Vyskytla se chyba a nelze se připojit k databázi.<br> Zkuste to později.</p>"); 
  $DB_mangos = mysql_select_db($Config['DB_read']['DB_read']['Database_web']);
  @mysql_query("SET NAMES ".$Config['DB_read']['DB_read']['Charset']); 


?>

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
    <meta name='author' content='Design & Code by HosipLan - HosipLan@seznam.cz'>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" >
    <meta http-equiv='imagetoolbar' content='no'>
    <meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="shortcut icon" href="img/favicon.ico">
    <link rel='stylesheet' type='text/css' href='css/css-defaul.css'>
    <script type='text/javascript' src='js/allJS.js'></script>
    <title>Generování klíču pro spam ochranu</title>
  </head>
  <body>

<div style="margin: 50px;">
<h3>Generování klíčů pro komentaře</h3>
<p>Heslo musí odpovídat heslu do databáze.</p>
<form action="generovani_klicu.php" method="post">
<label for="heslo"> Heslo: </label> <input type="password" id="heslo" name="heslo" /><br>
<label for="make"> Pocet: </label> <input type="text" name="pocet" />
 &nbsp; <input type="submit" value="Vygenerovat" id="make" name="make" />
</form>
<p>&nbsp;</p>

<?php

if( isset($_POST['make']) AND $_POST['heslo'] == $Config['DB_read']['Database']['Password'] ){ 
  $i = "1"; $pocet = $_POST['pocet'];
  echo "<p>";
  while( $i <= $pocet ){
    $znak[$i] = strtoupper(substr(md5(rand()),0,5));
    if( mysql_query("INSERT INTO `klice` ( `klic` ) VALUES ( '".$znak[$i]."' )") ){
      echo "<b>".$znak[$i]."</b>, \n"; }; 
    $i++;
    };
  echo "</p>\n";
  };

?>

</div>

  </body>
</head>

