Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. <?php
  2. $dbhost = "localhost";
  3. $dbname = "iPS";
  4. $dbuser = "root";
  5. $dbpass = "jeneal4";
  6. $username = "This Name Is Too Long And Will Not Work With The Game So It Is Invalid So Enter A Real Username That Is Valid When Signing Up";
  7. $email = "thisisafakeinvalidemailanddoesnotworksoenteryouremailwhensigningup";
  8. $colour = 1;
  9.  
  10. function check_email_address($email) {
  11. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
  12. return false;
  13. }
  14. $email_array = explode("@", $email);
  15. $local_array = explode(".", $email_array[0]);
  16. for ($i = 0; $i < sizeof($local_array); $i++) {
  17. if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
  18. ?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
  19. $local_array[$i])) {
  20. return false;
  21. }
  22. }
  23.  
  24.  
  25. if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
  26. $domain_array = explode(".", $email_array[1]);
  27. if (sizeof($domain_array) < 2) {
  28. return false;
  29. }
  30. for ($i = 0; $i < sizeof($domain_array); $i++) {
  31. if
  32. (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
  33. ?([A-Za-z0-9]+))$",
  34. $domain_array[$i])) {
  35. return false;
  36. }
  37. }
  38. }
  39. return true;
  40. }
  41. function error($error){
  42. $fullerror = "<h1> An Error Occurred</h1><p>".$error."</p>";
  43. die($fullerror);
  44. }
  45.  
  46.  
  47. mysql_connect($dbhost, $dbuser, $dbpass)or error("Could not connect: ".mysql_error());
  48. mysql_select_db($dbname) or error(mysql_error());
  49.  
  50. if (isset($_POST['submit'])) {
  51.  
  52. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  53. error('You did not complete all of the required fields');
  54. }
  55. if($_POST['colour'] >= 14){
  56. error('Incorrect Colour');
  57. }
  58.  
  59. if (!get_magic_quotes_gpc()) {
  60. $_POST['username'] = addslashes($_POST['username']);
  61. }
  62. if(ereg("[^A-Za-z0-9_ #$%&'*+/=?^_`{|}~-<>]", $_POST['username'])){
  63. error("Your name is invalid. Please try using letters numbers, and a few special characters");
  64. }
  65. if(substr($_POST['username'], 0,1) == " " || substr(strrev($_POST['username']), 0,1) == " "){
  66. error('Error in Username');
  67. }
  68. $_POST['username'] = mysql_real_escape_string($_POST['username']);
  69. $_POST['pass'] = mysql_real_escape_string($_POST['pass']);
  70. $_POST['colour'] = mysql_real_escape_string($_POST['colour']);
  71. $_POST['email'] = mysql_real_escape_string($_POST['email']);
  72. if (!get_magic_quotes_gpc()) {
  73. $_POST['pass'] = addslashes($_POST['pass']);
  74. $_POST['email'] = addslashes($_POST['email']);
  75. $_POST['colour'] = addslashes($_POST['colour']);
  76. $_POST['username'] = addslashes($_POST['username']);
  77. }
  78. $usercheck = $_POST['username'];
  79. $check = mysql_query("SELECT username FROM ps_users WHERE username = '$usercheck'")
  80. or error(mysql_error());
  81. $check2 = mysql_num_rows($check);
  82. if(check_email_address($_POST['email']) == false){
  83. error("Invalid Email!");
  84. }
  85.  
  86. if ($check2 != 0) {
  87. error('Sorry, the username '.$_POST['username'].' is already in use.');
  88. }
  89.  
  90. if ($_POST['pass'] != $_POST['pass2']) {
  91. error('Your passwords did not match. ');
  92. }
  93. if(strlen($_POST['pass']) <= 3){
  94. error('Your password is too short! ');
  95. }
  96.  
  97.  
  98. $_POST['pass'] = md5($_POST['pass']);
  99. $ip = $_SERVER['REMOTE_ADDR'];
  100. if($ip == "98.200.218.241"){
  101. error("Haha, Feel The Pain iFlex...");
  102. }
  103.  
  104. $insert = "INSERT INTO ps_users (`id`, `username`, `nickname`, `email`, `password`, `active`, `ubdate`, `items`, `curhead`, `curface`, `curneck`, `curbody`, `curhands`, `curfeet`, `curphoto`, `curflag`, `colour`, `buddies`, `ignore`, `joindate`, `lkey`, `coins`, `ismoderator`, `rank`, `ips`) VALUES (NULL, '".$_POST['username']."', '".$_POST['username']."', '".$_POST['email']."', '".$_POST['pass']."', '1', '0', '', '0', '0', '0', '0', '0', '0', '0', '0', '".$_POST['colour']."', '', '', CURRENT_TIMESTAMP, '', '1000', '0', '1', '".$ip."')";
  105. $log = "Username: ".$_POST['username']." Pass:".$_POST['pass']." Colour:".$_POST['colour']." Email:".$_POST['email']." IP:".$ip." \n";
  106. file_put_contents("log.txt", $log, FILE_APPEND | LOCK_EX);
  107. $add_member = mysql_query($insert);
  108. ?>
  109.  
  110. <h1>You have been registered</h1>
  111. <p>Thank you, you have registered - You can now play! ~Credits to Myles</a>.</p>
  112. <?php }
  113. else { ?>
  114. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  115. <table border="0">
  116. <tr><td>Username:</td><td>
  117. <input type="text" name="username" maxlength="60">
  118. </td></tr>
  119. <tr><td>Email Address:</td><td>
  120. <input type="text" name="email" maxlength="60">
  121. </td></tr>
  122. <tr><td>Password:</td><td>
  123. <input type="password" name="pass" maxlength="10">
  124. </td></tr>
  125. <tr><td>Confirm Password:</td><td>
  126. <input type="password" name="pass2" maxlength="10">
  127. </td></tr>
  128. <tr><td>Colour:</td><td>
  129. <select name="colour" id="colour">
  130. <option value="1" selected="true">Blue</option>
  131. <option value="2">Green</option>
  132. <option value="3">Pink</option>
  133. <option value="4">Black</option>
  134. <option value="5">Red</option>
  135. <option value="6">Orange</option>
  136. <option value="7">Yellow</option>
  137. <option value="8">Dark Purple</option>
  138. <option value="9">Brown</option>
  139. <option value="10">Peach</option>
  140. <option value="11">Dark Green</option>
  141. <option value="12">Light Blue</option>
  142. <option value="13">Light Green</option>
  143. </select>
  144. </td></tr>
  145. <tr><th colspan=2><input type="submit" name="submit"
  146. value="Register"></th></tr> </table>
  147. </form>
  148. <?php
  149. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement