Advertisement
Guest User

Untitled

a guest
May 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. public function new_account($username,$email,$confirm_email,$password,$invite_code)
  2. {
  3. $form=array('username' => array(0 => trim($username),
  4. 1 => array(0 => 5,
  5. 1 => 1),
  6. 2 => 3,
  7. 3 => 25),
  8. 'email' => array(0 => trim($email),
  9. 1 => array(0 => 5,
  10. 1 => 3),
  11. 2 => 0,
  12. 3 => 100,
  13. 4 => 'confirm_email'),
  14. 'password' => array(0 => $password,
  15. 1 => array(0 => 5,
  16. 1 => 1),
  17. 2 => 4,
  18. 3 => 32,
  19. 4 => 'password'),
  20. 'confirm_email' => array(0 => $confirm_email,
  21. 1 => array(0 => 5,
  22. 1 => 3),
  23. 2 => 0,
  24. 3 => 100),
  25. 'invite_code' => array(0 => $invite_code,
  26. 1 => array(0 => 5,
  27. 1 => 1),
  28. 2 => 32,
  29. 3 => 32));
  30.  
  31. $validator=new form_validator();
  32. if(!$validator->validate($form)) return false; // validate the form data
  33.  
  34. if(!invitationsMysql::code_exists($invite_code)) //verify if invite code is valid
  35. {
  36. output::setError('The invitation code is invalid.');
  37. return false;
  38. }
  39.  
  40. if(usersMysql::user_exists($username,$email)) //checks wether user exists
  41. {
  42. output::setError('There is an existing account associated with this email or username.');
  43. return false;
  44. }
  45. //user information
  46. $this->username=$username;
  47. $this->email=$email;
  48. $this->password=md5($password);
  49. $this->reg_date=date("m/d/Y h:i A");
  50. $this->active=0;
  51. $this->code=$invite_code;
  52. $this->credits=cons('default_credits');
  53. $this->avatar=cons('default_avatar');
  54. $this->watching=0;
  55. $this->requests=0;
  56. $this->filled=0;
  57. $this->rank=rank(0);
  58. $id=$this->new_user(); //getting the id of the new account
  59.  
  60. $invitation=new invitationsMysql;
  61. $invitation->user_id=$id;
  62. for($i=1; $i<=cons('default_invitations'); $i++) $invitation->new_code($this->generate_code());
  63.  
  64. $activation=new activationMysql;
  65. $activation->date=date("m/d/Y h:i A");
  66. $activation->author_id=$id;
  67. $code=$this->generate_code();
  68. $activation->new_code($code); // insert the activation code into the database
  69.  
  70. invitationsMysql::delete_code($invite_code); // delete the invitation code if everything works well
  71.  
  72. output::setConfirm('Your account was created. An activation code was sent to your e-mail. You must activate your account within 24 hours.');
  73. mail_send($this->email,'Trackbeast - New account','Welcome to Trackbeast'."\r\n".
  74. 'Activation code: '.$code."\r\n".
  75. 'Copy the code above and click here '.cons('server').'index.php?do=activation to activate your account.');
  76.  
  77. return true;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement