Aokromes

webpage

Feb 19th, 2013
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.04 KB | None | 0 0
  1. <?php
  2.  
  3. // Configuration.
  4. // Realm database.
  5. $r_db = "realmd";
  6. // IP (and port).
  7. $ip = "127.0.0.1:3306";
  8. // Username.
  9. $user = "username";
  10. // Password.
  11. $pass = "password";
  12. // Site title.
  13. $title = "Servidor Privado de WoW. WoW Private Server.";
  14. $title2 = "server name";
  15. // End config.
  16.  
  17. function error_s ($text) {
  18. echo("<br><br><p style=\"color:#555555;font-family:Tahoma;font-size:13\">" . $text);
  19. };
  20.  
  21. $user_chars = "#[^a-zA-Z0-9_\-]#";
  22. //$email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
  23. $email_chars = "/^[^0-9][A-z0-9_\-]+([.][A-z0-9_\-]+)*[@][A-z0-9\-]+([.][A-z0-9\-]+)*[.][A-z]{2,4}$/";
  24.  
  25. $con = @mysql_connect($ip, $user, $pass);
  26. if (!$con) {
  27. error_s("Unable to connect to database: " . mysql_error());
  28. };
  29.  
  30. if (!empty($_POST)) {
  31. if ((empty($_POST["username"]))||(empty($_POST["password"]))||(empty($_POST["email"])) ) {
  32. error_s("No has introducido todos los campos necesarios. Please fill in all form fields.");
  33. exit();
  34. } else {
  35. $username = strtoupper($_POST["username"]);
  36. $password = strtoupper($_POST["password"]);
  37. $email = strtoupper($_POST["email"]);
  38. if (strlen($username) < 5) {
  39. error_s("Nombre de usuario demasiado corto. Username is too short. Tiene que ser minimo de 5 caracteres");
  40. exit();
  41. };
  42. if (strlen($username) > 14) {
  43. error_s("Nombre de usuario demasiado largo. Username is too long. Tiene que ser maximo de 14 caracteres");
  44. exit();
  45. };
  46. if (strlen($password) < 8) {
  47. error_s("Contraseña demasiado corta. Password is not long enough. Tiene que ser minimo de 8 caracteres");
  48. exit();
  49. };
  50. if (strlen($password) > 12) {
  51. error_s("Contraseña demasiado larga. Password is very long. Tiene que ser maximo de 12 caracteres");
  52. exit();
  53. };
  54. if (strlen($email) < 9) {
  55. error_s("Email demasiado corto. Is your email really that short?. Tiene que ser minimo de 9 caracteres");
  56. exit();
  57. };
  58. if (strlen($email) > 50) {
  59. error_s("Email demasiado largo. Is your email really that long?. Tiene que ser maximo de 50 caracteres");
  60. exit();
  61. };
  62. if (preg_match($user_chars,$username)) {
  63. error_s("El nombre de usuario contiene caracteres no permitidos. Invalid characters in username.");
  64. exit();
  65. };
  66. if (preg_match($user_chars,$password)) {
  67. error_s("La contraseña contiene caracteres no permitidos. Invalid characters in password.");
  68. exit();
  69. };
  70. if (!preg_match($email_chars,$email)) {
  71. error_s("El correo electronico tiene un formato erroneo. Email has a non-allowed format.");
  72. exit();
  73. };
  74. $tbc = "2";
  75. $username = mysql_real_escape_string($username);
  76. $password = mysql_real_escape_string($password);
  77. $email = mysql_real_escape_string($email);
  78. $qry = @mysql_query("select username from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con);
  79. if (!$qry) {
  80. error_s("Error querying database: " . mysql_error());
  81. };
  82. if ($existing_username = mysql_fetch_assoc($qry)) {
  83. foreach ($existing_username as $key => $value) {
  84. $existing_username = $value;
  85. };
  86. };
  87. $existing_username = strtoupper($existing_username);
  88. if ($existing_username == strtoupper($_POST['username'])) {
  89. error_s("Ese nombre de usuario ya existe. Username already exists.");
  90. exit();
  91. };
  92. unset($qry);
  93. $qry = @mysql_query("select email from " . mysql_real_escape_string($r_db) . ".account where email = '" . $email . "'", $con);
  94. if (!$qry) {
  95. error_s("Error querying database: " . mysql_error());
  96. };
  97. /* if ($existing_email = mysql_fetch_assoc($qry)) {
  98. foreach ($existing_email as $key => $value) {
  99. $existing_email = $value;
  100. };
  101. };
  102. if ($existing_email == $_POST['email']) {
  103. error_s("That email is already in use.");
  104. exit();
  105. }; */
  106. unset($qry);
  107. $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($password));
  108. $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".account (username, sha_pass_hash, email, expansion, last_login,last_ip) values (upper('" . $username . "'),'" . $sha_pass_hash . "','" . $email . "','" . $tbc . "', NOW(),'" . $_SERVER['REMOTE_ADDR'] ."')";
  109. $qry = @mysql_query($register_sql, $con);
  110. if (!$qry) {
  111. error_s("Error creating account: " . mysql_error());
  112. };
  113. echo("Cuenta creada. Account has been created. ");
  114. echo($username);
  115. unset($qry);
  116. $qry = @mysql_query("select id from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con);
  117. if (!$qry) {
  118. error_s("Error querying database: " . mysql_error());
  119. };
  120. if ($account_id = mysql_fetch_assoc($qry)) {
  121. foreach ($account_id as $key => $value) {
  122. $account_id = $value;
  123. };
  124. };
  125. $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".rbac_account_groups (accountId, groupId, realmId) SELECT ".$account_id.", groupId, -1 FROM " . mysql_real_escape_string($r_db) . ".rbac_security_level_groups WHERE secId = 0";
  126. $qry = @mysql_query($register_sql, $con);
  127. if (!$qry) {
  128. error_s("Error creating account: " . mysql_error());
  129. };
  130. exit();
  131. };
  132. } else {
  133. echo($page);
  134. };
  135.  
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment