Guest User

Key-Generator

a guest
May 18th, 2016
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <!DOCUMENT HTML>
  2. <html>
  3. <head>
  4.     <title>Keygen</title>
  5.     <meta charset='utf-8'/>
  6.     <link href='style.css' type='text/css'  rel='stylesheet'>
  7. </head>
  8. <body>
  9.     <?php
  10.         if ($_POST["submit"] != '') {
  11.             $keys_str = file_get_contents('keys.txt');
  12.             $keys = explode("\r\n", $keys_str);
  13.             $used = 0;
  14.             $max_used = 30;
  15.             $numbers = 25;
  16.             for ($i = 0; $i < count($keys); $i++) {
  17.                 if (explode(':', $keys[$i])[1] == 'used') {
  18.                     $used = $used + 1;
  19.                 }
  20.             }
  21.             if ($used < $max_used) {
  22.                 $zeichen = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
  23.                 $again = true;
  24.                 while ($again == true) {
  25.                     $key = '';
  26.                     $key_str = '';
  27.                     $again = false;
  28.                     for ($i = 0; $i < $numbers; $i++) {
  29.                         mt_srand(67485459533427 * microtime());
  30.                         $index = (mt_rand(0, 10000) + microtime()) % 35;
  31.                         $char = $zeichen[$index];
  32.                         $key = $key.$char;
  33.                         $key_str = $key_str.$char;
  34.                         if ((($i + 1) % 5 == 0) && (($i + 1) != $numbers)) {
  35.                             $key_str = $key_str.'-';
  36.                         }
  37.                     }
  38.                     for ($i = 0; $i < count($keys); $i++) {
  39.                         if (explode(':', $keys[$i])[0] == $key) {
  40.                             $again = true;
  41.                         }
  42.                     }
  43.                 }
  44.                 echo 'Key: '.$key_str;
  45.                 file_put_contents('keys.txt', $key."\r\n", FILE_APPEND);
  46.             } else {
  47.                 echo "Der Beta-Zugang wurde geschlossen";
  48.             }
  49.         }
  50.     ?>
  51.     <form action='key.html' method='post'>
  52.         <input type='submit' name='submit' value='Beta-Zugang erhalten' />
  53.     </form>
  54. </body>
Add Comment
Please, Sign In to add comment