Advertisement
Guest User

Untitled

a guest
Oct 31st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. <?php
  2. function domain_exists($strEmail, $strRecord = 'MX'){
  3. list($strUser, $strDomain) = explode('@', $strEmail);
  4. return checkdnsrr($strDomain, $strRecord);
  5. }
  6. function sendError($strErr) {
  7. $strMsg = "<center><h2>Error: " . $strErr . "</h2></center>";
  8. }
  9. $resDBCon= mysqli_connect('localhost', 'root', '', '') or sendError('Failed to connect to MySQL: ' . mysqli_connect_error());
  10. if (isset($_POST['submit'])) {
  11. $strUsername = $_POST['username'];
  12. $strPassword = $_POST['pass'];
  13.  
  14. if (empty($strUsername) || empty($strPassword) || empty($strPasswordTwo)) {
  15. sendError('One or more fields has not been completed, please complete them');
  16. }
  17.  
  18. $strUsername = mysqli_real_escape_string($resDBCon, $strUsername);
  19. $strPassword = mysqli_real_escape_string($resDBCon, $strPassword);
  20. $strPasswordTwo = mysqli_real_escape_string($resDBCon, $strPasswordTwo);
  21.  
  22. $strUsername = addslashes($strUsername);
  23. $strPassword = addslashes($strPassword);
  24. $strPasswordTwo = addslashes($strPasswordTwo);
  25.  
  26. if (!preg_match('/[^A-Za-z0-9]/', $strUsername)) {
  27. sendError('Invalid username! Please make sure the username is alphanumeric');
  28. } elseif (strlen($strUsername) > 10 || strlen($strUsername) <= 3) {
  29. sendError('Invalid username! Please make sure the username is not too long or too short');
  30. } elseif ($strPassword != $strPasswordTwo) {
  31. sendError('Password does not match! Please make sure the passwords match');
  32. } elseif (strlen($strPassword) > 15 || strlen($strPassword) < 5) {
  33. sendError('Password is either too long or too short');
  34. } elseif (strlen($strPasswordTwo) > 15 && strlen($strPasswordTwo) < 5) {
  35. sendError('Password Two is either too long or too short');
  36. } elseif (!(preg_match('/[A-Z]+/', $strPassword) && preg_match('/[a-z]+/', $strPassword) && preg_match('/[\d!$%^&]+/', $strPassword))) {
  37. sendError('Password needs to have one lowercase and uppercase letter, a number and a special character');
  38. }
  39.  
  40. $arrExistUsers = mysqli_query($resDBCon, "SELECT username FROM users WHERE username = '$strUsername'");
  41. $intUsers = mysqli_num_rows($arrExistUsers);
  42.  
  43. if ($intUsers != 0) {
  44. sendError('Username already exists, please try another name');
  45. }
  46.  
  47. $strIP = mysqli_real_escape_string($resDBCon, $_SERVER['REMOTE_ADDR']);
  48.  
  49. $arrExistIPS = mysqli_query($resDBCon, "SELECT ipAddr FROM users WHERE ipAddr = '$strIP'");
  50. $intIPS = mysqli_num_rows($arrExistIPS);
  51.  
  52. if ($intPS >= 3) {
  53. sendError('You cannot create more than three accounts using this IP address');
  54. }
  55.  
  56. $strMD5 = md5($strPassword);
  57.  
  58. $recaptcha = new \ReCaptcha\ReCaptcha(6LdJxAoUAAAAAPyEysemRuR91Od_vld4MnHmCxzu);
  59. $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $strIP);
  60.  
  61. if (!$resp->isSuccess()) {
  62. sendError('');
  63. } else {
  64. $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"')");
  65. $intPID = mysqli_insert_id($resDBCon);
  66. mysqli_query($resDBCon, "INSERT INTO igloos (`ID`, `username`) VALUES ('" . $intPID . "', '" . $strUsername . "')");
  67. mysqli_query($resDBCon, "INSERT INTO postcards (`recepient`, `mailerID`, `mailerName`, `postcardType`) VALUES ('" . $intPID . "', '0', 'Oura', '125')");
  68. 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'">";
  69. }
  70.  
  71. } else {
  72.  
  73. ?>
  74. <?php
  75. if(isset($_SESSION['login_user'])){
  76. header("location: home.php");
  77. }
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement