Guest User

Untitled

a guest
Dec 3rd, 2017
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.94 KB | None | 0 0
  1.  <!DOCTYPE html>
  2. <html>
  3.   <head>    
  4.     <title>PenguinX :: Registration</title>
  5. <?php
  6. //Make sure regconfig.php is in the same folder as this, or else it will not work!
  7. include "regconfig.php";
  8. $dbhost = "$mysqlhost";
  9. $dbname = "$database";
  10. $dbuser = "$mysqluser";
  11. $dbpass = "$mysqlpass";
  12. $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";
  13. $email = "thisisafakeinvalidemailanddoesnotworksoenteryouremailwhensigningup";
  14. $colour = 1;
  15.  
  16. function check_email_address($email) {
  17.   if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
  18.     return false;
  19.   }
  20.   $email_array = explode("@", $email);
  21.   $local_array = explode(".", $email_array[0]);
  22.   for ($i = 0; $i < sizeof($local_array); $i++) {
  23.     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
  24. ?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
  25. $local_array[$i])) {
  26.       return false;
  27.     }
  28.   }
  29.     if (!ereg("^[a-zA-Z0-9]*$", $_POST["username"]) ) {
  30.     error('Your username may only contain letters, numbers, and valid characters.');
  31. }
  32.  
  33.  
  34.   if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
  35.     $domain_array = explode(".", $email_array[1]);
  36.     if (sizeof($domain_array) < 2) {
  37.         return false;
  38.     }
  39.     for ($i = 0; $i < sizeof($domain_array); $i++) {
  40.       if
  41. (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
  42. ?([A-Za-z0-9]+))$",
  43. $domain_array[$i])) {
  44.         return false;
  45.       }
  46.     }
  47.   }
  48.   return true;
  49. }
  50. function error($error){
  51. $fullerror = "<h1> An Error Occurred</h1><p>".$error."</p>";
  52. die($fullerror);
  53. }
  54.  
  55.  
  56. mysql_connect($dbhost, $dbuser, $dbpass)or error("Could not connect: ".mysql_error());
  57. mysql_select_db($dbname) or error(mysql_error());
  58.  
  59.  if (isset($_POST['submit'])) {
  60.  
  61.  if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  62.         error('You did not complete all of the required fields');
  63.     }
  64.   if($_POST['colour'] >= 16){
  65. error('Incorrect Colour');
  66. }
  67.  
  68.     if (!get_magic_quotes_gpc()) {
  69.         $_POST['username'] = addslashes($_POST['username']);
  70.     }
  71. if(ereg("[^A-Za-z0-9_ #$%&'*+/=?^_`{|}~-<>]", $_POST['username'])){
  72. error("Your name is invalid. Please try using letters numbers, and a few special characters");
  73. }
  74. if(substr($_POST['username'], 0,1) == " " || substr(strrev($_POST['username']), 0,1) == " "){
  75. error('Error in Username');
  76. }
  77. $_POST['username'] =  mysql_real_escape_string($_POST['username']);
  78. $_POST['pass'] =  mysql_real_escape_string($_POST['pass']);
  79. $_POST['colour'] =  mysql_real_escape_string($_POST['colour']);
  80. $_POST['email'] =  mysql_real_escape_string($_POST['email']);
  81.     if (!get_magic_quotes_gpc()) {
  82.         $_POST['pass'] = addslashes($_POST['pass']);
  83. $_POST['email'] = addslashes($_POST['email']);
  84. $_POST['colour'] = addslashes($_POST['colour']);
  85.         $_POST['username'] = addslashes($_POST['username']);
  86.             }
  87.  $usercheck = $_POST['username'];
  88.  $check = mysql_query("SELECT username FROM $table WHERE username = '$usercheck'")
  89.  or error(mysql_error());
  90.  $check2 = mysql_num_rows($check);
  91.  /*
  92.  $ipcheck = $_SERVER['REMOTE_ADDR'];
  93.  $check5= mysql_query("SELECT ip FROM ip_bans WHERE ip = '$ipcheck'")
  94.  or error(mysql_error());
  95.  $check6 = mysql_num_rows($check5);
  96.  */
  97.  if(check_email_address($_POST['email']) == false){
  98. error("Invalid Email!");
  99. }
  100.  
  101.  if ($check2 != 0) {
  102.         error('Sorry, the username '.$_POST['username'].' is already in use.');
  103.                 }
  104. // if ($check6 != 0) {
  105.  //     error('Sorry, it seems that you are IP banned. If you believe this was a mistake, please contact a staff member on the chat.');
  106.  //             }
  107.  
  108.     if ($_POST['pass'] != $_POST['pass2']) {
  109.         error('Your passwords did not match. ');
  110.     }
  111. if(strlen($_POST['pass']) <= 3){
  112. error('Your password is too short! ');
  113. }
  114.  
  115.    
  116.     $_POST['pass'] = md5($_POST['pass']);
  117.  $ip = $_SERVER['REMOTE_ADDR'];
  118. if($ip == "78.144.144.168"){
  119. error("Sorry bro. You quit.");
  120. }
  121.  
  122. $insert = "INSERT INTO $table (`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."')";
  123. $log = "Username: ".$_POST['username']." Pass:".$_POST['pass']." Colour:".$_POST['colour']." Email:".$_POST['email']." IP:".$ip." \n";
  124.     $add_member = mysql_query($insert);
  125. ?>
  126.    
  127.  
  128.  <h1>You have been registered</h1>
  129.  <p>Thank you for registering! You may now login to the game </a>.</p>
  130.  <?php }
  131.  else {  ?>
  132.  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">        
  133.  <table border="0">
  134.  <tr><td>Username:</td><td>
  135.  <input type="text" name="username" maxlength="60">
  136.  </td></tr>
  137.  <tr><td>Email Address:</td><td>
  138.  <input type="text" name="email" maxlength="60">
  139.  </td></tr>
  140.  <tr><td>Password:</td><td>
  141.  <input type="password" name="pass" maxlength="10">
  142.  </td></tr>
  143.  <tr><td>Confirm Password:</td><td>
  144.  <input type="password" name="pass2" maxlength="10">
  145.  </td></tr>
  146.  <tr><td>Colour:</td><td>
  147. <select name="colour" id="colour">
  148.     <option value="1" selected="true">Blue</option>
  149.     <option value="2">Green</option>
  150.     <option value="3">Pink</option>
  151.     <option value="4">Black</option>
  152.     <option value="5">Red</option>
  153. <option value="6">Orange</option>
  154. <option value="7">Yellow</option>
  155. <option value="8">Dark Purple</option>
  156. <option value="9">Brown</option>
  157. <option value="10">Peach</option>
  158. <option value="11">Dark Green</option>
  159. <option value="12">Light Blue</option>
  160. <option value="13">Light Green</option>
  161. <option value="14">Gray</option>
  162. <option value="15">Aqua</option>
  163. </select>
  164.  </td></tr>
  165.  <tr><th colspan=2><input type="submit" name="submit"
  166. value="Register"></th></tr> </table>
  167.  </form>
  168.  <?php
  169.  } ?>
Add Comment
Please, Sign In to add comment