Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html >
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>EmpireCP - Register</title>
  6. <link rel="stylesheet" href="css/style.css">
  7. </head>
  8. <body>
  9.  
  10. <div class="overlay">
  11. <ul>
  12. <li><a href="index.php">Home</a></li>
  13. <li><a class="active" href="register.php">Register</a></li>
  14. <li><a href="play.php">Play</a></li>
  15. <li><a href="manager/index.php">Manager</a></li>
  16. <li><a href="commands.php">Commands</a></li>
  17. <li><a href="staff.php">Staff</a></li>
  18. <li><a href="contact.php">Contact Us</a></li>
  19. <li><a href="about.php">About Us</a></li>
  20. </ul>
  21.  
  22. <div class="container">
  23.  
  24. <?php
  25.  
  26. require 'recaptcha/src/autoload.php';
  27. require 'config.php';
  28.  
  29. function domain_exists($strEmail, $strRecord = 'MX'){
  30. list($strUser, $strDomain) = explode('@', $strEmail);
  31. return checkdnsrr($strDomain, $strRecord);
  32. }
  33.  
  34. function sendError($strErr) {
  35. $strMsg = "<center><h2>Error: " . $strErr . "</h2></center>";
  36. die($strMsg);
  37. }
  38.  
  39. $resDBCon= mysqli_connect($strDBHost, $strDBUser, $strDBPass, $strDBName) or sendError('Failed to connect to MySQL: ' . mysqli_connect_error());
  40.  
  41. if (isset($_POST['submit'])) {
  42. $strUsername = $_POST['username'];
  43. $strPassword = $_POST['pass'];
  44. $strPasswordTwo = $_POST['passtwo'];
  45. $strColor = $_POST['color'];
  46. $strEmail = $_POST['email'];
  47. $intPin = $_POST['spin'];
  48.  
  49. if (empty($strEmail) || empty($strUsername) || empty($strPassword) || empty($strPasswordTwo) || empty($strColor) || empty($intPin)) {
  50. sendError('One or more fields has not been completed, please complete them');
  51. }
  52.  
  53. $strUsername = mysqli_real_escape_string($resDBCon, $strUsername);
  54. $strPassword = mysqli_real_escape_string($resDBCon, $strPassword);
  55. $strPasswordTwo = mysqli_real_escape_string($resDBCon, $strPasswordTwo);
  56. $strColor = mysqli_real_escape_string($resDBCon, $strColor);
  57. $strEmail = mysqli_real_escape_string($resDBCon, $strEmail);
  58. $intPin = mysqli_real_escape_string($resDBCon, $intPin);
  59.  
  60. $strUsername = addslashes($strUsername);
  61. $strPassword = addslashes($strPassword);
  62. $strPasswordTwo = addslashes($strPasswordTwo);
  63. $strColor = addslashes($strColor);
  64. $strEmail = addslashes($strEmail);
  65. $intPin = addslashes($intPin);
  66.  
  67. if (!filter_var($strEmail, FILTER_VALIDATE_EMAIL)) {
  68. sendError('Invalid email address! Please recheck your email');
  69. } elseif (!domain_exists($strEmail)) {
  70. sendError('Invalid domain for email address! Please use a valid domain');
  71. } elseif (!ctype_alnum($strUsername) && strlen($strUsername) > 10 && strlen($strUsername) <= 3) {
  72. sendError('Invalid username! Please make sure the username is alphanumeric and not too long or short');
  73. } elseif (strlen($strColor) > 6) {
  74. sendError('Invalid color! Please use a valid color');
  75. } elseif ($strPassword != $strPasswordTwo) {
  76. sendError('Password does not match! Please make sure the passwords match');
  77. } elseif (strlen($strPassword) > 15 && strlen($strPassword) < 5 && strlen($strPasswordTwo) > 15 && strlen($strPasswordTwo) < 5) {
  78. sendError('Password is either too long or too short');
  79. } elseif (!is_numeric($intPin) && $intPin < 6 && $intPin > 6) {
  80. sendError('Invalid pin number, pin must be 6 digits long');
  81. }
  82.  
  83. $strColor = '0x' . $strColor;
  84.  
  85. $arrExistUsers = mysqli_query($resDBCon, "SELECT username FROM users WHERE username = '$strUsername'");
  86. $intUsers = mysqli_num_rows($arrExistUsers);
  87.  
  88. if ($intUsers != 0) {
  89. sendError('Username already exists, please try another name');
  90. }
  91.  
  92. $arrExistEmails = mysqli_query($resDBCon, "SELECT email FROM users WHERE email = '$strEmail'");
  93. $intEmails = mysqli_num_rows($arrExistEmails);
  94.  
  95. if ($intEmails != 0) {
  96. sendError('Email is already in use, please try another email');
  97. }
  98.  
  99. $strIP = mysqli_real_escape_string($resDBCon, $_SERVER['REMOTE_ADDR']);
  100.  
  101. $arrExistIPS = mysqli_query($resDBCon, "SELECT ipAddr FROM users WHERE ipAddr = '$strIP'");
  102. $intIPS = mysqli_num_rows($arrExistIPS);
  103.  
  104. if ($intPS >= 2) {
  105. sendError('You cannot create more than two accounts using this IP');
  106. }
  107.  
  108. $strMD5 = md5($strPassword);
  109.  
  110. $recaptcha = new \ReCaptcha\ReCaptcha($strSecretKey);
  111. $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $strIP);
  112.  
  113. if (!$resp->isSuccess()) {
  114. sendError('You are a bot, get the fuck out');
  115. } else {
  116. $resQuery = mysqli_query($resDBCon, "INSERT INTO users (`username`, `nickname`, `email`, `password`, `colour`, `ipAddr`, `stamps`, `spin`) VALUES ('" . $strUsername . "', '" . $strUsername . "', '" . $strEmail . "', '" . $strMD5 . "', '" . $strColor . "', '" . $strIP . "', '31|7|33|8|32|35|34|36|290|358|448', '" . $intPin . "')");
  117. $intPID = mysqli_insert_id($resDBCon);
  118. mysqli_query($resDBCon, "INSERT INTO igloos (`ID`, `username`) VALUES ('" . $intPID . "', '" . $strUsername . "')");
  119. mysqli_query($resDBCon, "INSERT INTO postcards (`recepient`, `mailerID`, `mailerName`, `postcardType`) VALUES ('" . $intPID . "', '0', 'Luna', '125')");
  120. echo "<center><h2>You have successfully registered with Luna, $strUsername ! You may now login to the game :-)</h2></center>";
  121. }
  122.  
  123. } else {
  124.  
  125. ?>
  126.  
  127. <center>
  128. <form class="form" name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  129. <input type="text" name="username" maxlength="10" placeholder="Enter Your Username">
  130. <input type="text" name="email" maxlength="25" placeholder="Enter Your Email">
  131. <input type="password" name="pass" maxlength="15" placeholder="Enter Your Password">
  132. <input type="password" name="passtwo" maxlength="15" placeholder="Enter Your Password Again">
  133. <input type="password" name="spin" maxlength="6" placeholder="Enter Your Secret Pin">
  134. <label for="color">Penguin Color</label>
  135. <input class="jscolor" type="text" name="color" maxlength="6">
  136. <br><br>
  137. <div class="g-recaptcha" data-sitekey="<?php echo $strSiteKey; ?>"></div>
  138. <script type="text/javascript" src='https://www.google.com/recaptcha/api.js?hl=en'></script>
  139. <br>
  140. <input type="submit" id="login-button" name="submit" value="Sign Up">
  141. </form>
  142. </center>
  143.  
  144. <?php
  145. }
  146. ?>
  147.  
  148. </div>
  149. <div class="footer">&copy; 2016-2017 EmpireCP &#8482; All Rights Reserved</div>
  150. </div>
  151. </body>
  152. <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
  153. <script src="js/jscolor.js"></script>
  154. <script src="js/index.js"></script>
  155. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement