Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // set the config values for connecting to the db
- $dbhost = "127.0.0.1";
- $dbuser = "root";
- $dbpassword = "P@ssw0rd";
- $db = "arcemu_logon";
- // misc config
- $accountcreated = "<div style='background-color:green; color:white; font-weight:bold;'>Your account ".$login." has been created!</div>";
- $allow_multi_email = true;
- $allow_multi_ip = true;
- echo '
- <html>
- <head>
- <title>WoWPS Account Creation</title>
- </head>
- <body>
- ';
- if (!isset($_POST['login'])) {
- form();
- } else {
- // connect to the db
- $dbcon = mysql_connect($dbhost,$dbuser,$dbpassword) or die(mysql_error());
- mysql_select_db($db,$dbcon) or die(mysql_error());
- // get login, password, email from form
- $login = !get_magic_quotes_gpc() ? mysql_real_escape_string($_POST['login']) : $_POST['login'];
- $password = !get_magic_quotes_gpc() ? mysql_real_escape_string($_POST['password']) : $_POST['password'];
- $email = !get_magic_quotes_gpc() ? mysql_real_escape_string($_POST['email']) : $_POST['email'];
- $ip = $_SERVER['REMOTE_ADDR'];
- if (valid_info($login,$password,$email,$ip,$allow_multi_email,$allow_multi_ip)) {
- // encrypt the password for putting in to db
- $sha1pass = sha1(strtoupper($login).":".strtoupper($password));
- // make sure data gets put in or display error
- if (mysql_query("INSERT INTO accounts(login,password,encrypted_password,gm,email,flags,lastip) VALUES('$login','$password','$sha1pass',0,'$email',24,'$ip')")) {
- mysql_close($dbcon);
- echo $accountcreated;
- } else {
- switch(mysql_errno()) {
- case 1062 :
- echo "<div style='background-color:red; color:white; font-weight:bold;'>This accounts already exist !</div> ".form();
- break;
- default :
- echo "Mysql Error : ".mysql_errno()."<br />".form();
- break;
- }
- }
- }
- }
- echo '
- </body>
- </html>
- ';
- function form() {
- echo '
- <form action="./" method="post">
- <table>
- <tr><td>Login : (6 chars min) </td><td><input name="login" value="" type="text"></td></tr>
- <tr><td>Password : (6 chars min) </td><td><input name="password" value="" type="password"></td></tr>
- <tr><td>Email : </td><td><input name="email" value="" type="text"></td></tr>
- <tr><td colspan="2" align="center"><input type="submit"></td></tr>
- </table>
- </form>
- ';
- }
- function valid_info($login,$password,$email,$ip,$allow_multi_email,$allow_multi_ip) {
- // check for valid password and login
- if (preg_match('/[^0-9A-Za-z]/',$login)) {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>Login is invalid. Only a-z, A-Z, and numbers allowed!</div>".form();
- return false;
- }
- // check for blank login or password or email
- if ($login == "" || $password == "" || $email == "") {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>Login, password, or email is blank, please fill them out! !</div>".form();
- return false;
- }
- // check if login and password is over 5 characters long
- if (strlen($login) <= 5 || strlen($password) <= 5) {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>Login or password was under 6 characters long !</div>".form();
- return false;
- }
- // check for valid email
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>Invalid email address!</div>".form();
- return false;
- }
- // if we don't allow an email to be used on more then one account warn the user
- if (!$allow_multi_email) {
- if (mysql_num_rows(mysql_query("SELECT email FROM accounts WHERE email = '$email'")) > 0) {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>Email already in use!</div>".form();
- return false;
- }
- }
- // if we don't allow an ip to be on more then one account then warn the user
- if (!$allow_multi_ip) {
- if (mysql_num_rows(mysql_query("SELECT * FROM accounts WHERE lastip = '$ip'")) > 0) {
- echo "<div style='background-color:red; color:white; font-weight:bold;'>This IP has already made an account!</div>".form();
- return false;
- }
- }
- return true;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement