Guest User

Untitled

a guest
Feb 21st, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.51 KB | None | 0 0
  1. <?php
  2. class User
  3. {
  4.     public $user_active = 0;
  5.     private $clean_email;
  6.     public $status = false;
  7.     private $clean_password;
  8.     private $clean_username;
  9.     private $unclean_username;
  10.     public $sql_failure = false;
  11.     public $mail_failure = false;
  12.     public $email_taken = false;
  13.     public $username_taken = false;
  14.     public $activation_token = 0;
  15.     private $clean_ip;
  16.     private $clean_sponsor;
  17.     private $dob;
  18.     private $gender;
  19.     private $terms;
  20.    
  21.     function __construct($user,$pass,$email,$sponsor,$ip,$bmonth,$bday,$byear,$gender,$terms)
  22.     {
  23.         //Used for display only
  24.         $this->unclean_username = $user;
  25.        
  26.         //Sanitize
  27.         $this->clean_email = sanitize($email);
  28.         $this->clean_password = trim($pass);
  29.         $this->clean_username = sanitize($user);
  30.         $this->clean_sponsor = sanitize($sponsor);
  31.         $this->clean_ip = sanitize($ip);
  32.         $this->dob = sanitize($bmonth/$bday/$byear);
  33.         $this->gender = sanitize($gender);
  34.         $this->terms = sanitize($terms);
  35.         if(usernameExists($this->clean_username))
  36.         {
  37.             $this->username_taken = true;
  38.         }
  39.         else if(emailExists($this->clean_email))
  40.         {
  41.             $this->email_taken = true;
  42.         }
  43.         else
  44.         {
  45.             //No problems have been found.
  46.             $this->status = true;
  47.         }
  48.     }
  49.    
  50.     public function userCakeAddUser()
  51.     {
  52.         global $db,$emailActivation,$websiteUrl,$db_table_prefix;
  53.    
  54.         //Prevent this function being called if there were construction errors
  55.         if($this->status)
  56.         {
  57.             //Construct a secure hash for the plain text password
  58.             $secure_pass = generateHash($this->clean_password);
  59.            
  60.             //Construct a unique activation token
  61.             $this->activation_token = generateActivationToken();
  62.    
  63.             //Do we need to send out an activation email?
  64.             if($emailActivation == '1')
  65.             {
  66.                 //User must activate their account first
  67.                 $this->user_active = 0;
  68.            
  69.                 $mail = new userCakeMail();
  70.            
  71.                 //Build the activation message
  72.                 $activation_message = lang("ACTIVATION_MESSAGE",array($websiteUrl,$this->activation_token));
  73.                
  74.                 //Define more if you want to build larger structures
  75.                 $hooks = array(
  76.                     "searchStrs" => array("#ACTIVATION-MESSAGE","#ACTIVATION-KEY","#USERNAME#"),
  77.                     "subjectStrs" => array($activation_message,$this->activation_token,$this->unclean_username)
  78.                 );
  79.                
  80.                 /* Build the template - Optional, you can just use the sendMail function
  81.                 Instead to pass a message. */
  82.                 if(!$mail->newTemplateMsg("new-registration.txt",$hooks))
  83.                 {
  84.                     $this->mail_failure = true;
  85.                 }
  86.                 else
  87.                 {
  88.                     //Send the mail. Specify users email here and subject.
  89.                     //SendMail can have a third parementer for message if you do not wish to build a template.
  90.                    
  91.                     if(!$mail->sendMail($this->clean_email,"New User"))
  92.                     {
  93.                         $this->mail_failure = true;
  94.                     }
  95.                 }
  96.             }
  97.             else
  98.             {
  99.                 //Instant account activation
  100.                 $this->user_active = 1;
  101.             }  
  102.    
  103.    
  104.             if(!$this->mail_failure)
  105.             {
  106.                     //Insert the user into the database providing no errors have been found.
  107.                     $sql = "INSERT INTO `".$db_table_prefix."Users` (
  108.                             `Username`,
  109.                             `Username_Clean`,
  110.                             `Password`,
  111.                             `Email`,
  112.                             `ActivationToken`,
  113.                             `LastActivationRequest`,
  114.                             `LostPasswordRequest`,
  115.                             `Active`,
  116.                             `Group_ID`,
  117.                             `SignUpDate`,
  118.                             `LastSignIn`,
  119.                             `UplineUser`,
  120.                             `Joined_IP`,
  121.                             `Last_IP`,
  122.                             `cashBal`,
  123.                             `pointBal`,
  124.                             `totalWithdrawn`,
  125.                             `offersDone`,
  126.                             `paypal_Account`,
  127.                             `alertpay_Account`,
  128.                             `terms`
  129.                             )
  130.                             VALUES (
  131.                             '".$db->sql_escape($this->unclean_username)."',
  132.                             '".$db->sql_escape($this->clean_username)."',
  133.                             '".$secure_pass."',
  134.                             '".$db->sql_escape($this->clean_email)."',
  135.                             '".$this->activation_token."',
  136.                             '".time()."',
  137.                             '0',
  138.                             '".$this->user_active."',
  139.                             '1',
  140.                             '".time()."',
  141.                             '0',
  142.                             '".$this->clean_sponsor."',
  143.                             '".$this->clean_ip."',
  144.                             '".$this->clean_ip."',
  145.                             '0.00',
  146.                             '0.00',
  147.                             '0.00',
  148.                             '0',
  149.                             '0',
  150.                             '0',
  151.                             '".$db->sql_escape($this->terms)."'
  152.                             )";
  153.                      
  154.                 $joined = $db->sql_query($sql);
  155.                 $newguy = mysql_insert_id();
  156.                 $prof = "INSERT INTO `".$db_table_prefix."profiles` (`acct_id`,firstname,lastname,addr,addr2,city,state,zip,bday,gender) VALUES (
  157.                  '".$db->sql_escape($newguy)."',
  158.                  '',
  159.                  '',
  160.                  '',
  161.                  '',
  162.                  '',
  163.                  '',
  164.                  '',
  165.                  '".$db->sql_escape($this->dob)."',
  166.                  '".$db->sql_escape($this->gender)."'
  167.                  )";
  168.             return $db->sql_query($prof);
  169.             }
  170.         }
  171.     }
  172. }
  173.  
  174. ?>
Add Comment
Please, Sign In to add comment