Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $DB = new PDO('mysql:host=127.0.0.1;dbname=promo_usoft_ru', 'promo_usoft_ru', 'hTNzCtcjyYc5wXPS');
- $make = true;
- while ($make) {
- $sql = "SELECT * FROM `promo_codes`";
- $STMNT = $DB->prepare($sql);
- $STMNT->execute();
- if ( $STMNT->rowCount() < 1000 ) {
- $letters = array("a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "w", "x", "y", "z");
- $strLenght = rand(5, 10);
- $str = '';
- for ($i = 0; $i <= $strLenght; $i++) {
- $letNum = rand(0, sizeof($letters));
- $str = rand(0, 1000000000) . $letters[$letNum];
- }
- $str = sha1($str);
- $str = substr($str, 0, 6);
- $sql = "SELECT `id`
- FROM `promo_codes`
- WHERE `code` = ?";
- $state = $DB->prepare($sql);
- $state->execute(array($str));
- if ( $state->rowCount() == 0 && !strpos($str, 'e') ) {
- $sql = "INSERT INTO `promo_codes`
- SET `code` = ?";
- $state = $DB->prepare($sql);
- $state->execute(array($str));
- }
- } else {
- $make = false;
- }
- }
Add Comment
Please, Sign In to add comment