SHOW:
|
|
- or go back to the newest paste.
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 | $pass_chars = "/^(?=[a-z]*[0-9][a-z]*[0-9])^(?=[0-9]*[a-z][0-9]*[a-z])[a-z0-9]{8,16}$/i"; | |
25 | ||
26 | $con = @mysql_connect($ip, $user, $pass); | |
27 | if (!$con) { | |
28 | error_s("Unable to connect to database: " . mysql_error()); | |
29 | }; | |
30 | ||
31 | if (!empty($_POST)) { | |
32 | if ((empty($_POST["username"]))||(empty($_POST["password"]))||(empty($_POST["email"])) ) { | |
33 | error_s("No has introducido todos los campos necesarios. Please fill in all form fields."); | |
34 | exit(); | |
35 | } else { | |
36 | $username = strtoupper($_POST["username"]); | |
37 | $password = strtoupper($_POST["password"]); | |
38 | $email = strtoupper($_POST["email"]); | |
39 | if (strlen($username) < 5) { | |
40 | error_s("Nombre de usuario demasiado corto. Username is too short. Tiene que ser minimo de 5 caracteres"); | |
41 | exit(); | |
42 | }; | |
43 | if (strlen($username) > 14) { | |
44 | error_s("Nombre de usuario demasiado largo. Username is too long. Tiene que ser maximo de 14 caracteres"); | |
45 | exit(); | |
46 | }; | |
47 | if (strlen($password) < 8) { | |
48 | error_s("Contraseña demasiado corta. Password is not long enough. Tiene que ser minimo de 8 caracteres"); | |
49 | exit(); | |
50 | }; | |
51 | if (strlen($password) > 12) { | |
52 | error_s("Contraseña demasiado larga. Password is very long. Tiene que ser maximo de 12 caracteres"); | |
53 | exit(); | |
54 | }; | |
55 | if (strlen($email) < 9) { | |
56 | error_s("Email demasiado corto. Is your email really that short?. Tiene que ser minimo de 9 caracteres"); | |
57 | exit(); | |
58 | }; | |
59 | if (strlen($email) > 50) { | |
60 | error_s("Email demasiado largo. Is your email really that long?. Tiene que ser maximo de 50 caracteres"); | |
61 | exit(); | |
62 | }; | |
63 | if (preg_match($user_chars,$username)) { | |
64 | error_s("El nombre de usuario contiene caracteres no permitidos. Invalid characters in username."); | |
65 | exit(); | |
66 | }; | |
67 | ||
68 | if (ctype_digit($password) || ctype_alpha($password)) { | |
69 | error_s("La contraseña debe contener letras y números. Password must contain both letters and numbers."); | |
70 | exit(); | |
71 | } | |
72 | if (preg_match($pass_chars,$password)) { | |
73 | error_s("La contraseña contiene caracteres no permitidos. Invalid characters in password."); | |
74 | exit(); | |
75 | }; | |
76 | if (!preg_match($email_chars,$email)) { | |
77 | error_s("El correo electronico tiene un formato erroneo. Email has a non-allowed format."); | |
78 | exit(); | |
79 | }; | |
80 | $tbc = "2"; | |
81 | $username = mysql_real_escape_string($username); | |
82 | $password = mysql_real_escape_string($password); | |
83 | $email = mysql_real_escape_string($email); | |
84 | $qry = @mysql_query("select username from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con); | |
85 | if (!$qry) { | |
86 | error_s("Error querying database: " . mysql_error()); | |
87 | }; | |
88 | if ($existing_username = mysql_fetch_assoc($qry)) { | |
89 | foreach ($existing_username as $key => $value) { | |
90 | $existing_username = $value; | |
91 | }; | |
92 | }; | |
93 | $existing_username = strtoupper($existing_username); | |
94 | if ($existing_username == strtoupper($_POST['username'])) { | |
95 | error_s("Ese nombre de usuario ya existe. Username already exists."); | |
96 | exit(); | |
97 | }; | |
98 | unset($qry); | |
99 | $qry = @mysql_query("select email from " . mysql_real_escape_string($r_db) . ".account where email = '" . $email . "'", $con); | |
100 | if (!$qry) { | |
101 | error_s("Error querying database: " . mysql_error()); | |
102 | }; | |
103 | /* if ($existing_email = mysql_fetch_assoc($qry)) { | |
104 | foreach ($existing_email as $key => $value) { | |
105 | $existing_email = $value; | |
106 | }; | |
107 | }; | |
108 | if ($existing_email == $_POST['email']) { | |
109 | error_s("That email is already in use."); | |
110 | exit(); | |
111 | }; */ | |
112 | unset($qry); | |
113 | $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($password)); | |
114 | $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'] ."')"; | |
115 | $qry = @mysql_query($register_sql, $con); | |
116 | if (!$qry) { | |
117 | error_s("Error creating account: " . mysql_error()); | |
118 | }; | |
119 | echo("Cuenta creada. Account has been created. "); | |
120 | echo($username); | |
121 | unset($qry); | |
122 | $qry = @mysql_query("select id from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con); | |
123 | if (!$qry) { | |
124 | error_s("Error querying database: " . mysql_error()); | |
125 | }; | |
126 | if ($account_id = mysql_fetch_assoc($qry)) { | |
127 | foreach ($account_id as $key => $value) { | |
128 | $account_id = $value; | |
129 | }; | |
130 | }; | |
131 | $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"; | |
132 | $qry = @mysql_query($register_sql, $con); | |
133 | if (!$qry) { | |
134 | error_s("Error creating account: " . mysql_error()); | |
135 | }; | |
136 | exit(); | |
137 | }; | |
138 | } else { | |
139 | echo($page); | |
140 | }; | |
141 | ||
142 | ?> |