Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function domain_exists($strEmail, $strRecord = 'MX'){
- list($strUser, $strDomain) = explode('@', $strEmail);
- return checkdnsrr($strDomain, $strRecord);
- }
- function sendError($strErr) {
- $strMsg = "<center><h2>Error: " . $strErr . "</h2></center>";
- }
- $resDBCon= mysqli_connect('localhost', 'root', '', '') or sendError('Failed to connect to MySQL: ' . mysqli_connect_error());
- if (isset($_POST['submit'])) {
- $strUsername = $_POST['username'];
- $strPassword = $_POST['pass'];
- if (empty($strUsername) || empty($strPassword) || empty($strPasswordTwo)) {
- sendError('One or more fields has not been completed, please complete them');
- }
- $strUsername = mysqli_real_escape_string($resDBCon, $strUsername);
- $strPassword = mysqli_real_escape_string($resDBCon, $strPassword);
- $strPasswordTwo = mysqli_real_escape_string($resDBCon, $strPasswordTwo);
- $strUsername = addslashes($strUsername);
- $strPassword = addslashes($strPassword);
- $strPasswordTwo = addslashes($strPasswordTwo);
- if (!preg_match('/[^A-Za-z0-9]/', $strUsername)) {
- sendError('Invalid username! Please make sure the username is alphanumeric');
- } elseif (strlen($strUsername) > 10 || strlen($strUsername) <= 3) {
- sendError('Invalid username! Please make sure the username is not too long or too short');
- } elseif ($strPassword != $strPasswordTwo) {
- sendError('Password does not match! Please make sure the passwords match');
- } elseif (strlen($strPassword) > 15 || strlen($strPassword) < 5) {
- sendError('Password is either too long or too short');
- } elseif (strlen($strPasswordTwo) > 15 && strlen($strPasswordTwo) < 5) {
- sendError('Password Two is either too long or too short');
- } elseif (!(preg_match('/[A-Z]+/', $strPassword) && preg_match('/[a-z]+/', $strPassword) && preg_match('/[\d!$%^&]+/', $strPassword))) {
- sendError('Password needs to have one lowercase and uppercase letter, a number and a special character');
- }
- $arrExistUsers = mysqli_query($resDBCon, "SELECT username FROM users WHERE username = '$strUsername'");
- $intUsers = mysqli_num_rows($arrExistUsers);
- if ($intUsers != 0) {
- sendError('Username already exists, please try another name');
- }
- $strIP = mysqli_real_escape_string($resDBCon, $_SERVER['REMOTE_ADDR']);
- $arrExistIPS = mysqli_query($resDBCon, "SELECT ipAddr FROM users WHERE ipAddr = '$strIP'");
- $intIPS = mysqli_num_rows($arrExistIPS);
- if ($intPS >= 3) {
- sendError('You cannot create more than three accounts using this IP address');
- }
- $strMD5 = md5($strPassword);
- $recaptcha = new \ReCaptcha\ReCaptcha(6LdJxAoUAAAAAPyEysemRuR91Od_vld4MnHmCxzu);
- $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $strIP);
- if (!$resp->isSuccess()) {
- sendError('');
- } else {
- $resQuery = mysqli_query($resDBCon, "INSERT INTO users (`username`, `nickname`, `email`, `password`, `colour`, `ipAddr`, `stamps`, `spin`) VALUES ('" . $strUsername . "', '" . $strUsername . "', '"penguinemail@oura.pro"', '" . $strMD5 . "', '" "', '" . $strIP . "', '31|7|33|8|32|35|34|36|290|358|448', '"1337"')");
- $intPID = mysqli_insert_id($resDBCon);
- mysqli_query($resDBCon, "INSERT INTO igloos (`ID`, `username`) VALUES ('" . $intPID . "', '" . $strUsername . "')");
- mysqli_query($resDBCon, "INSERT INTO postcards (`recepient`, `mailerID`, `mailerName`, `postcardType`) VALUES ('" . $intPID . "', '0', 'Oura', '125')");
- echo "<center><h1>Your account has been created $strUsername! Redirecting to the play page...</h1></center><meta http-equiv="refresh" content="3; url='http://oura.pro/play.php'">";
- }
- } else {
- ?>
- <?php
- if(isset($_SESSION['login_user'])){
- header("location: home.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement