Advertisement
Guest User

test

a guest
Dec 31st, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html >
  3. <head>
  4. <body>
  5.  
  6.  
  7. <style>
  8.  
  9. form.form {
  10. border: 3px grey solid;
  11. width: 32%;
  12. padding: 10px;
  13. background-color: #fff;
  14. }
  15.  
  16. input[type="text"] {
  17. margin: 10px;
  18. }
  19.  
  20. input {
  21. margin: 10px;
  22. border: 1px solid gray;
  23. padding: 10px;
  24. width: 70%;
  25. }
  26.  
  27. select {
  28. width: 50%;
  29. padding: 9px;
  30. margin-top: 5px;
  31. }
  32.  
  33.  
  34. </style>
  35. <meta charset="UTF-8">
  36. <title>Tropica Penguin - Register</title>
  37. <?php
  38.  
  39. require 'recaptcha/src/autoload.php';
  40. require 'config.php';
  41.  
  42. function domain_exists($strEmail, $strRecord = 'MX'){
  43. list($strUser, $strDomain) = explode('@', $strEmail);
  44. return checkdnsrr($strDomain, $strRecord);
  45. }
  46.  
  47. function sendError($strErr) {
  48. $strMsg = "<center><h2>Error: " . $strErr . "</h2></center>";
  49. die($strMsg);
  50. }
  51.  
  52. $resDBCon= mysqli_connect($strDBHost, $strDBUser, $strDBPass, $strDBName) or sendError('Failed to connect to MySQL: ' . mysqli_connect_error());
  53.  
  54. if (isset($_POST['submit'])) {
  55. $strUsername = $_POST['username'];
  56. $strPassword = $_POST['pass'];
  57. $strPasswordTwo = $_POST['passtwo'];
  58. $strColor = $_POST['color'];
  59. $strEmail = $_POST['email'];
  60. $intPin = $_POST['spin'];
  61.  
  62. if (empty($strEmail) || empty($strUsername) || empty($strPassword) || empty($strPasswordTwo) || empty($strColor) || empty($intPin)) {
  63. sendError('One or more fields has not been completed, please complete them');
  64. }
  65.  
  66. $strUsername = mysqli_real_escape_string($resDBCon, $strUsername);
  67. $strPassword = mysqli_real_escape_string($resDBCon, $strPassword);
  68. $strPasswordTwo = mysqli_real_escape_string($resDBCon, $strPasswordTwo);
  69. $strColor = mysqli_real_escape_string($resDBCon, $strColor);
  70. $strEmail = mysqli_real_escape_string($resDBCon, $strEmail);
  71. $intPin = mysqli_real_escape_string($resDBCon, $intPin);
  72.  
  73. $strUsername = addslashes($strUsername);
  74. $strPassword = addslashes($strPassword);
  75. $strPasswordTwo = addslashes($strPasswordTwo);
  76. $strColor = addslashes($strColor);
  77. $strEmail = addslashes($strEmail);
  78. $intPin = addslashes($intPin);
  79.  
  80. if (!filter_var($strEmail, FILTER_VALIDATE_EMAIL)) {
  81. sendError('Invalid email address! Please recheck your email');
  82. } elseif (!domain_exists($strEmail)) {
  83. sendError('Invalid domain for email address! Please use a valid domain');
  84. } elseif (!ctype_alnum($strUsername) && strlen($strUsername) > 10 && strlen($strUsername) <= 3) {
  85. sendError('Invalid username! Please make sure the username is alphanumeric and not too long or short');
  86. } elseif (strlen($strColor) > 6) {
  87. sendError('Invalid color! Please use a valid color');
  88. } elseif ($strPassword != $strPasswordTwo) {
  89. sendError('Password does not match! Please make sure the passwords match');
  90. } elseif (strlen($strPassword) > 15 && strlen($strPassword) < 5 && strlen($strPasswordTwo) > 15 && strlen($strPasswordTwo) < 5) {
  91. sendError('Password is either too long or too short');
  92. } elseif (!is_numeric($intPin) && $intPin < 6 && $intPin > 6) {
  93. sendError('Invalid pin number, pin must be 6 digits long');
  94. }
  95.  
  96. $strColor = '0x' . $strColor;
  97.  
  98. $arrExistUsers = mysqli_query($resDBCon, "SELECT username FROM users WHERE username = '$strUsername'");
  99. $intUsers = mysqli_num_rows($arrExistUsers);
  100.  
  101. if ($intUsers != 0) {
  102. sendError('Username already exists, please try another name');
  103. }
  104.  
  105. $arrExistEmails = mysqli_query($resDBCon, "SELECT email FROM users WHERE email = '$strEmail'");
  106. $intEmails = mysqli_num_rows($arrExistEmails);
  107.  
  108. if ($intEmails != 0) {
  109. sendError('Email is already in use, please try another email');
  110. }
  111.  
  112. $strIP = mysqli_real_escape_string($resDBCon, $_SERVER['REMOTE_ADDR']);
  113.  
  114. $arrExistIPS = mysqli_query($resDBCon, "SELECT ipAddr FROM users WHERE ipAddr = '$strIP'");
  115. $intIPS = mysqli_num_rows($arrExistIPS);
  116.  
  117. if ($intPS >= 2) {
  118. sendError('You cannot create more than two accounts using this IP');
  119. }
  120.  
  121. $strMD5 = md5($strPassword);
  122.  
  123. $recaptcha = new \ReCaptcha\ReCaptcha($strSecretKey);
  124. $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $strIP);
  125.  
  126. if (!$resp->isSuccess()) {
  127. sendError('You are a bot, get the fuck out');
  128. } else {
  129. $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 . "')");
  130. $intPID = mysqli_insert_id($resDBCon);
  131. mysqli_query($resDBCon, "INSERT INTO igloos (`ID`, `username`) VALUES ('" . $intPID . "', '" . $strUsername . "')");
  132. mysqli_query($resDBCon, "INSERT INTO postcards (`recepient`, `mailerID`, `mailerName`, `postcardType`) VALUES ('" . $intPID . "', '0', 'Luna', '125')");
  133. echo "<center><h2>You have successfully registered with Tropical Penguin, $strUsername ! You may now login to the game :-)</h2></center>";
  134. }
  135.  
  136. } else {
  137.  
  138. ?>
  139. </style>
  140. <body background="http://tropicalpengu.in/register/images/bg.jpg">
  141. <center>
  142. <img src="http://tropicalpengu.in/register/images/logo.png">
  143. </center>
  144. <center>
  145. <form class="form" name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  146. <center><input type="text" name="username" maxlength="10" placeholder="Enter Your Username"></center>
  147. <center><input type="text" name="email" maxlength="25" placeholder="Enter Your Email"></center>
  148. <center><input type="password" name="pass" maxlength="15" placeholder="Enter Your Password"></center>
  149. <center><input type="password" name="passtwo" maxlength="15" placeholder="Enter Your Password Again"></center>
  150. <center><input type="password" name="spin" maxlength="6" placeholder="Enter Your Secret Pin"></center>
  151. <center><label for="color">Penguin Color</label></center>
  152. <select name="color" id="color">
  153. <option value="">Color</option>
  154. <option value="1">Blue</option>
  155. <option value="2">Green</option>
  156. <option value="3">Pink</option>
  157. <option value="4">Black</option>
  158. <option value="5">Red</option>
  159. <option value="6">Orange</option>
  160. <option value="7">Yellow</option>
  161. <option value="8">Dark Purple</option>
  162. <option value="9">Brown</option>
  163. <option value="10">Peach</option>
  164. <option value="11">Dark Green</option>
  165. <option value="12">Light Blue</option>
  166. <option value="13">Light Green</option>
  167. <option value="14">Grey</option>
  168. <option value="15">Aqua</option>
  169. </select>
  170. <br><br>
  171. <div class="g-recaptcha" data-sitekey="6LeXOBAUAAAAAJ013stSH9iz5RXZePr-MDgTtgJl"></div>
  172. <script type="text/javascript" src='https://www.google.com/recaptcha/api.js'></script>
  173. <br>
  174. <input type="submit" id="login-button" name="submit" value="Sign Up">
  175. <div>&copy; 2016-2017 Tropical Penguin &#8482; All Rights Reserved</div>
  176.  
  177. </form>
  178. </center>
  179.  
  180. <?php
  181. }
  182. ?>
  183.  
  184. </div>
  185. <center>
  186. </center>
  187. </div>
  188. </body>
  189. <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
  190. <script src="js/jscolor.js"></script>
  191. <script src="js/index.js"></script>
  192. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement