Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → 3d Party Tools → [Script] Registration

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 1

1

Topic: [Script] Registration

<?php
try {
    $DBH = new PDO('mysql:host=localhost;dbname=pvpgn', 'username', 'password');
    $DBH->exec('SET NAMES utf8');
}
catch(PDOException $e) {
    //
}

function str2blks_pvpgn($str) { $nblk = ((strlen($str) + 8) >> 6) + 1; for($i = 0; $i < $nblk * 16; $i++) { $blks[$i] = 0; } for($i = 0; $i < strlen($str); $i++) { $blks[$i >> 2] |= ord(substr($str,$i,1)) << (($i % 4) * 8); } return $blks; } function safe_add($x,$y) { $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); return ($msw << 16) | ($lsw & 0xFFFF); } function safe_not($num) { $lsw = (~($num & 0xFFFF)) & 0xFFFF; $msw = (~($num >> 16)) & 0xFFFF; return ($msw << 16) | $lsw; } function safe_rol($num,$amt) { $leftmask = 0xffff | (0xffff << 16); $leftmask <<= 32 - $amt; $rightmask = 0xffff | (0xffff << 16); $rightmask <<= $amt; $rightmask = safe_not($rightmask); $remains = $num & $leftmask; $remains >>= 32 - $amt; $remains &= $rightmask; $res = ($num << $amt) | $remains; return $res; } function ft($t,$b,$c,$d) { if($t < 20) { return ($b & $c) | ((safe_not($b)) & $d); } if($t < 40) { return $d ^ $c ^ $b; } if($t < 60) { return ($c & $b) | ($d & $c) | ($d & $b); } return $d ^ $c ^ $b; } function kt($t) { if($t < 20) { return 0x5a82 << 16 | 0x7999; } elseif($t < 40) { return 0x6ed9 << 16 | 0xeba1; } elseif($t < 60) { return 0x8f1b << 16 | 0xbcdc; } else { return 0xca62 << 16 | 0xc1d6; } } function pvpgn_hash($str) { for($i = 0;$i < strlen($str);$i++) { if(ord($str[$i]) < 128) { $str[$i] = strtolower($str[$i]); } } $x = str2blks_pvpgn($str); $a = 0x6745 << 16 | 0x2301; $b = 0xefcd << 16 | 0xab89; $c = 0x98ba << 16 | 0xdcfe; $d = 0x1032 << 16 | 0x5476; $e = 0xc3d2 << 16 | 0xe1f0;     for($i = 0; $i < count($x); $i += 16) { $olda = $a; $oldb = $b; $oldc = $c; $oldd = $d; $olde = $e; for($j = 0; $j < 16; $j++) { $w[$j] = $x[$i + $j]; } for($j = 0; $j < 64; $j++) { $ww = $w[$j] ^ $w[$j + 8] ^ $w[$j + 2] ^ $w[$j + 13]; $w[$j + 16] = 1 << ($ww % 32); } for($j = 0; $j < 80; $j++) { if($j < 20) { $t = safe_add(safe_add(safe_rol($a,5), ft($j,$b,$c,$d)),safe_add(safe_add($e,$w[$j]),kt($j))); } else { $t = safe_add(safe_add(safe_rol($t,5), ft($j,$b,$c,$d)),safe_add(safe_add($e,$w[$j]),kt($j))); } $e = $d; $d = $c; $c = safe_rol($b,30); $b = $a; $a = $t; } $a = (safe_add($t,$olda) & 0xffffffff); $b = (safe_add($b,$oldb) & 0xffffffff); $c = (safe_add($c,$oldc) & 0xffffffff); $d = (safe_add($d,$oldd) & 0xffffffff); $e = (safe_add($e,$olde) & 0xffffffff); } return sprintf("%08x%08x%08x%08x%08x",$a&0xffffffff,$b&0xffffffff,$c&0xffffffff,$d&0xffffffff,$e&0xffffffff); }

if($_POST) {
    $STH = $DBH->prepare("SELECT uid FROM pvpgn_BNET WHERE acct_username=:acct_username OR acct_email=:acct_email LIMIT 0,1");
    $STH->execute(array(
        'acct_username' => $_POST['username'],
        'acct_email' => $_POST['email'],
    ));

    if($STH->rowCount() == 1) {
        $alert['danger'] = 'Account with this username/email already exist.';
    }
    else if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $alert['danger'] = 'Please enter valid email address.';
    }
    else if(strlen($_POST['username']) < 3 || strlen($_POST['username']) > 20) {
        $alert['danger'] = 'Please enter username between 3 and 20 characters.';
    }
    else if(preg_match("/[^A-Za-z0-9]/", $_POST['username'])) {
        $alert['danger'] = 'Invalid username symbols (letters/digits only allowed).';
    }
    else if(strlen($_POST['password']) < 3 || strlen($_POST['password']) > 20) {
        $alert['danger'] = 'Please enter password between 3 and 20 characters.';
    }
    else if(preg_match("/[^A-Za-z0-9]/", $_POST['password'])) {
        $alert['danger'] = 'Invalid password symbols (letters/digits only allowed).';
    }
    else {
        $STH = $DBH->prepare("SELECT uid FROM pvpgn_BNET ORDER BY uid DESC LIMIT 0,1");
        $STH->execute();

        while($row = $STH->fetch()) {
            $_POST['id'] = $row['uid'] + 1;
        }

        $data = array(
            'uid' => $_POST['id'],
            'acct_username' => $_POST['username'],
            'username' => $_POST['username'],
            'acct_userid' => $_POST['id'],
            'acct_passhash1' => pvpgn_hash($_POST['password']),
            'acct_email' => $_POST['email'],
        );

        $STH = $DBH->prepare("INSERT INTO pvpgn_BNET (uid, acct_username, username, acct_userid, acct_passhash1, acct_email) VALUES (:uid, :acct_username, :username, :acct_userid, :acct_passhash1, :acct_email)");

        if($STH->execute($data)) {
            $alert['success'] = 'Your account has been created.';
        }
        else {
            $alert['danger'] = 'Something went wrong - please, try again.';
        }
    }
}
?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>PvPGN</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />
</head>

<body>
    <nav class="navbar navbar-dark bg-dark">
        <div class="container">
            <span class="navbar-brand mb-0 h1">PvPGN</span>
        </div>
    </nav>
    <div class="container mt-5">
        <?php echo (isset($alert) ? '<div class="alert alert-' . (isset($alert['success']) ? 'success' : 'danger') . ' alert-dismissible fade show" role="alert"><strong>' . (isset($alert['success']) ? 'Success' : 'Danger') . '!</strong> ' . (isset($alert['success']) ? $alert['success'] : $alert['danger']) . ' <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button></div>' : ''); ?>
        <div class="card">
            <div class="card-header">
                Registration
            </div>
            <div class="card-body">
                <form action="" method="POST">
                    <div class="form-group">
                        <label for="email">Email address</label>
                        <input type="email" class="form-control" id="email" name="email" aria-describedby="emailHelp" placeholder="Your email address" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : ''); ?>" autofocus />
                        <small id="emailHelp" class="form-text text-muted">If you forgot your password, we'll send you a new one.</small>
                    </div>
                    <hr />
                    <div class="form-group">
                        <label for="username">Username</label>
                        <input type="text" class="form-control" id="username" name="username" placeholder="Desired username" value="<?php echo (isset($_POST['username']) ? $_POST['username'] : ''); ?>" />
                    </div>
                    <div class="form-group">
                        <label for="password">Password</label>
                        <input type="password" class="form-control" id="password" name="password" placeholder="Desired password" value="<?php echo (isset($_POST['password']) ? $_POST['password'] : ''); ?>" />
                    </div>
                    <button type="submit" class="btn btn-primary btn-block">Register</button>
                </form>
            </div>
            <div class="card-footer small">
                Want support? <a href="https://discord.com" target="_blank">Join in Discord!</a>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>

Posts: 1

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 1 guest, 0 registered users

forums.pvpgn.pro → 3d Party Tools → [Script] Registration