From ceb1549b84773e307246d366843f095a5170b66b Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 21 Mar 2018 10:48:57 +0000 Subject: [PATCH] Support for account creation. Contributed by Liamxroy. --- Account_Manager/includes/.htaccess | 4 ++ Account_Manager/includes/config.php | 9 ++++ Account_Manager/includes/index.html | 19 +++++++ Account_Manager/index.php | 83 ++++++++++++++++++++++++----- 4 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 Account_Manager/includes/.htaccess create mode 100644 Account_Manager/includes/config.php create mode 100644 Account_Manager/includes/index.html diff --git a/Account_Manager/includes/.htaccess b/Account_Manager/includes/.htaccess new file mode 100644 index 0000000000..f18b579395 --- /dev/null +++ b/Account_Manager/includes/.htaccess @@ -0,0 +1,4 @@ + + Order allow,deny + Deny from all + diff --git a/Account_Manager/includes/config.php b/Account_Manager/includes/config.php new file mode 100644 index 0000000000..5c7c48ee68 --- /dev/null +++ b/Account_Manager/includes/config.php @@ -0,0 +1,9 @@ + diff --git a/Account_Manager/includes/index.html b/Account_Manager/includes/index.html new file mode 100644 index 0000000000..f265e0175e --- /dev/null +++ b/Account_Manager/includes/index.html @@ -0,0 +1,19 @@ + + + + + + +404 Page not Found + + + + +

 

+ + \ No newline at end of file diff --git a/Account_Manager/index.php b/Account_Manager/index.php index d9fd9714da..416b355ae2 100644 --- a/Account_Manager/index.php +++ b/Account_Manager/index.php @@ -1,3 +1,60 @@ +". mysqli_connect_error().""; + echo "Failed to connect to MySQL: " . mysqli_connect_error(); + exit(); + } + + $account = mysqli_real_escape_string($conn, $_POST['username']); + $password = base64_encode(sha1($_POST['password'], true)); + $username = $_POST['username']; + $email = $_POST['email']; + + if($_POST['password']!=$_POST['passwordVerify']){ + $error .= "Password does not match.
"; + } + + if(mb_strlen($account)<4 || mb_strlen($account)>14){ + $error .= "Account length must be 4 to 14 characters long."; + } + + if(mb_strlen($_POST['password'])<4 || mb_strlen($_POST['password'])>16){ + $error .= "Password length must be 4 to 16 characters long."; + } + + if(mb_strlen($email)<7 || mb_strlen($email)>100){ + $error .= "Email length must be 7 to 100 characters long."; + } + + $sql = "SELECT `login` FROM `accounts` WHERE `login`='".$account."'"; + $result = $conn->query($sql); + if ($result->num_rows!=0) { + $error .= "Account already exists.
"; + } + + if(empty($error)){ + echo ($account.$password.$email); + $sqlregister = "INSERT INTO `accounts` (`login`, `password`, `email`, `lastIP`) VALUES ('".$account."','".$password."','".$email."','".$_SERVER['REMOTE_ADDR']."')"; + if ($conn->query($sqlregister) === TRUE) { + $error = "Account created!"; + header( "refresh:5;url=index.php" ); + } else { + $error = "Something went wrong."; + } + } + + $conn->close(); + } +?> + @@ -22,7 +79,6 @@