Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function new_account($username,$email,$confirm_email,$password,$invite_code)
- {
- $form=array('username' => array(0 => trim($username),
- 1 => array(0 => 5,
- 1 => 1),
- 2 => 3,
- 3 => 25),
- 'email' => array(0 => trim($email),
- 1 => array(0 => 5,
- 1 => 3),
- 2 => 0,
- 3 => 100,
- 4 => 'confirm_email'),
- 'password' => array(0 => $password,
- 1 => array(0 => 5,
- 1 => 1),
- 2 => 4,
- 3 => 32,
- 4 => 'password'),
- 'confirm_email' => array(0 => $confirm_email,
- 1 => array(0 => 5,
- 1 => 3),
- 2 => 0,
- 3 => 100),
- 'invite_code' => array(0 => $invite_code,
- 1 => array(0 => 5,
- 1 => 1),
- 2 => 32,
- 3 => 32));
- $validator=new form_validator();
- if(!$validator->validate($form)) return false; // validate the form data
- if(!invitationsMysql::code_exists($invite_code)) //verify if invite code is valid
- {
- output::setError('The invitation code is invalid.');
- return false;
- }
- if(usersMysql::user_exists($username,$email)) //checks wether user exists
- {
- output::setError('There is an existing account associated with this email or username.');
- return false;
- }
- //user information
- $this->username=$username;
- $this->email=$email;
- $this->password=md5($password);
- $this->reg_date=date("m/d/Y h:i A");
- $this->active=0;
- $this->code=$invite_code;
- $this->credits=cons('default_credits');
- $this->avatar=cons('default_avatar');
- $this->watching=0;
- $this->requests=0;
- $this->filled=0;
- $this->rank=rank(0);
- $id=$this->new_user(); //getting the id of the new account
- $invitation=new invitationsMysql;
- $invitation->user_id=$id;
- for($i=1; $i<=cons('default_invitations'); $i++) $invitation->new_code($this->generate_code());
- $activation=new activationMysql;
- $activation->date=date("m/d/Y h:i A");
- $activation->author_id=$id;
- $code=$this->generate_code();
- $activation->new_code($code); // insert the activation code into the database
- invitationsMysql::delete_code($invite_code); // delete the invitation code if everything works well
- output::setConfirm('Your account was created. An activation code was sent to your e-mail. You must activate your account within 24 hours.');
- mail_send($this->email,'Trackbeast - New account','Welcome to Trackbeast'."\r\n".
- 'Activation code: '.$code."\r\n".
- 'Copy the code above and click here '.cons('server').'index.php?do=activation to activate your account.');
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement