Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2010, 05:14 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default Updates to Account Creation Tool

Version 1.1

Fixes:

- Added password confirmation box to eqreg.php and the logic to support it to insert.php

- The script now emails the user as well as the admin so the user gets a confirmation. ** Make sure you change the Bcc: address to your email address. **

- Updated error handling so all errors have a link to direct the user back to the main eqreg.php page to try again.

The code:

eqreg.php

Code:
 
<!-- EQEMu SVN Loginserver PHP Account Registration Page - By: Cubber -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>EQEmu SVN Loginserver Account Registration Page</title>

<meta name="description" content="EQEmulator SVN Loginserver Account Registration Page.">

</head>

<body>

                        <h1>EQ Registration Form</h1>
                        <p>Please fill out the form below to create a new account.</p>
                        <br />
                                
                                        <form method="post" action="insert.php">
                                        Username: <i>(Max 16 chars)</i><br />
                                                <input name="username" type="text" id="username" maxlength="16" />
                                        <br /><br />
                                        Password: <i>(Max 16 chars)</i><br />
                                                <input name="pw" type="password" id="pw" maxlength="16" />
                                        <br /><br />
                                        Confirm Password: <i>(Max 16 chars)</i><br />
                                                <input name="cpw" type="password" id="cpw" maxlength="16" />
                                        <br /><br />
                                        Email:<br />
                                                <input name="email" type="text" id="email" maxlength="50" />
                                        <br /><br />
                                        <br />    
                                                <input name="Submit" type="submit" value="Create Account" />
                                        </form>
                                        <br />
                                                        
                                
</body>
</html>
insert.php

Code:
<!-- EQEMu SVN Loginserver PHP Account Registration Page - By: Cubber -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>>EQEmu SVN Loginserver Account Registration Page</title>

<meta name="description" content="EQEmulator SVN Loginserver Account Registration Page.">

<head>

<body>

                <p>                             
                        <?php
                                $DB_ADDY = "localhost"; //address:port for the MySQL server
                                $DB_USER = "eqemu"; //username to login to MySQL with
                                $DB_PASS = "eqemu"; //password to login to MySQL with
                                $DB_DB = "peq"; //database name to use "peq" for default installation
                                $user = $_POST['username'];
                                $pass = $_POST['pw'];
                                $cpass = $_POST['cpw'];
                                $acct_email = $_POST['email'];
                                $headers = 'Bcc: admin@somewhere.com' . "\r\n";
                                $sendto = $acct_email;
                                $subject = "New EQ Account Created";
                                $message = "Your new account has been created on the EQEmulator Server.  Account details:\n  email: $acct_email\n  username: $user\n password: $pass\n";

                                function error_s($text) 
                                        {
                                                echo("<p>" . $text);
                                        };

                                $user_chars = "#[^a-zA-Z0-9_\-]#";
                                $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";

                                if ( !isset($_POST['username']) || !isset($_POST['pw']) || !isset($_POST['cpw']) || !isset($_POST['email']) )
                                        {
                                                echo "User/Pass/Email not passed. Click <a href=eqreg.php>here</a> and try again.";
                                                return;
                                        }

                                $con = @mysql_connect($DB_ADDY, $DB_USER, $DB_PASS);
                                if (!$con) 
                                        {
                                                error_s("Unable to connect to database: " . mysql_error());
                                        };

                                if (!empty($_POST)) 
                                        {
                                                if ((empty($_POST["username"]))||(empty($_POST["pw"]))||(empty($_POST["cpw"]))||(empty($_POST["email"])) ) 
                                                        {
                                                                error_s("You did not enter all the required information.  Click <a href=eqreg.php>here</a> and try again.");
                                                                exit();
                                                        } 
                                                else 
                                                        {

                                                                $username = ($_POST["username"]);
                                                                $pw = ($_POST["pw"]);
                                                                $cpw = ($_POST["cpw"]);
                                                                $email = ($_POST["email"]);

                                                                if (strlen($username) < 5) 
                                                                        {
                                                                                error_s("Username too short.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($username) > 16) 
                                                                        {
                                                                                error_s("Username too long.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($pw) < 6) 
                                                                        {
                                                                                error_s("Password too short.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($pw) > 16) 
                                                                        {
                                                                                error_s("Password too long.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };
                                                                if (strlen($cpw) < 6) 
                                                                        {
                                                                                error_s("Password too short.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($cpw) > 16) 
                                                                        {
                                                                                error_s("Password too long.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($email) < 10) 
                                                                        {
                                                                                error_s("Email was too short.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (strlen($email) > 50) 
                                                                        {
                                                                                error_s("Email was too long.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (preg_match($user_chars,$username)) 
                                                                        {
                                                                                error_s("Username contained illegal characters.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (preg_match($user_chars,$pw)) 
                                                                        {
                                                                                error_s("Password contained illegal characters.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };
                                                                if (preg_match($user_chars,$cpw)) 
                                                                        {
                                                                                error_s("Password contained illegal characters.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if (!preg_match($email_chars,$email)) 
                                                                        {
                                                                                error_s("Email was in an incorrect format.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };

                                                                if ($pw != $cpw)
                                                                        {
                                                                                error_s("Passwords do not match!  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        }

                                                                $username = mysql_real_escape_string($username);
                                                                $pw = mysql_real_escape_string($pw);
                                                                $email = mysql_real_escape_string($email);
                                                                $qry = @mysql_query("select AccountName from " . mysql_real_escape_string($DB_DB) . ".tblLoginServerAccounts where AccountName = '" . $username . "'", $con);
                                                                if (!$qry) 
                                                                        {
                                                                                error_s("Error querying database: " . mysql_error());
                                                                        };

                                                                if ($existing_username = mysql_fetch_assoc($qry)) 
                                                                        {
                                                                                foreach ($existing_username as $key => $value) 
                                                                                        {
                                                                                                $existing_username = $value;
                                                                                        };
                                                                        };

                                                                $existing_username = ($existing_username);
                                                                if ($existing_username == ($_POST['username'])) 
                                                                        {
                                                                                error_s("That username is already taken.  Click <a href=eqreg.php>here</a> and try again.");
                                                                                exit();
                                                                        };
                                                
                                                                unset($qry);

                                                                $sha_pass_hash = sha1(($pw));
                                                                $register_sql = "insert into " . mysql_real_escape_string($DB_DB) . ".tblLoginServerAccounts (AccountName,AccountPassword,AccountEmail) values ('" . $username . "','" . $sha_pass_hash . "','" . $email . "')";
                                                                $qry = @mysql_query($register_sql, $con);
                                                                if (!$qry) 
                                                                        {
                                                                                error_s("Error creating account: " . mysql_error());
                                                                        }

                                                                else 
                                                                        {
                                                                                mail($sendto, $subject, $message, $headers);
                                                                                echo("Your account was successfully created!");
                                                                        }

                                                                exit();
                                                        };

                                        } 

                                else 
                                        {
                                                echo($page);
                                        };

                        ?>
                </p>

</body>
</html>
Reply With Quote
  #2  
Old 05-15-2010, 10:25 AM
Dibzahab
Fire Beetle
 
Join Date: May 2010
Posts: 3
Default

Late to the party, I know, but I thought I'd note that there's bug in the state-machine tokenizer that the loginserver uses. It skips characters containing some punctuation marks. I don't have the code in front of me now, but I'm certain that exlamation marks, at least, are not being properly parsed. This is using the CVS that I pulled down yesterday (5/14/10).

Cheers
Reply With Quote
  #3  
Old 05-15-2010, 01:28 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Not a bug per se just not implemented into the lexical analyzer as valid input. If you throw down a small list of punctuation that should work I'll add it though.
Reply With Quote
  #4  
Old 05-18-2010, 01:21 AM
Dibzahab
Fire Beetle
 
Join Date: May 2010
Posts: 3
Default

Quote:
Originally Posted by KLS View Post
Not a bug per se just not implemented into the lexical analyzer as valid input. If you throw down a small list of punctuation that should work I'll add it though.
If it's invalid input, don't you think that it needs to be logged rather than silently discarded? Someone earlier in this thread thought it was voodoo that his password of 1111111 was the only one that worked. It's a bug.
Reply With Quote
  #5  
Old 05-18-2010, 02:59 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Could add logging, doesn't change the fact behind it. Acceptable characters were explicitly defined, which means if it doesn't work it's not bugged it's simply not implemented.

Now we can change that or you can continue to argue specifics.
Reply With Quote
  #6  
Old 05-18-2010, 01:29 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

PS I went and changed it.
Reply With Quote
  #7  
Old 07-31-2010, 01:41 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

I posted a diff that fixed the issue for me: http://www.eqemulator.org/forums/sho...71&postcount=2
Reply With Quote
  #8  
Old 07-31-2010, 03:43 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

That worked perfectly thanks!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:13 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3