Guest User

Untitled

a guest
Jun 25th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.02 KB | None | 0 0
  1.     function register($user,$pass,$email,$country,$dob,$sex,$code,$captcha,$ip) {
  2.     $mip = md5($this->conf['md5_key'] . $ip);
  3.     else {
  4.     //Required function fields cannot be blank..
  5.     if ( ($user == '') || ($pass == '') || ($email == '') || ($sex == '') || ($dob == '') || ($captcha == '') || ($code == '') ) echo 'One of the required values are blank.';
  6.     //Check Username for any abnormalness
  7.     else if ($this->check_string($user) != 'passed') echo 'Username is invalid';
  8.     else if (strlen($user) < $this->conf['uclow']) echo 'Username too short, Lowest: ' . $this->conf['uclow'] . ' You used: ' . strlen($user);
  9.     else if (strlen($user) > $this->conf['uchigh']) echo 'Username too long, Maximum: ' . $this->conf['uchigh'] . ' You used: ' . strlen($user);
  10.     //Check Password for anything out of the norm
  11.     else if ($this->check_string($pass) != 'passed') echo 'Password is invalid';
  12.     else if (strlen($pass) > $this->conf['pclimit') echo 'Password too long.. Max: ' . $this->conf['pclimit'] . ' You used: ' . strlen($pass);
  13.     else if (strlen($pass) < $this->conf['pclow') echo 'Password too short.. Lowest: ' . $this->conf['pclow'] . ' You used: ' . strlen($pass);
  14.     //Check for valid email
  15.     else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) echo 'Email is invalid';
  16.     //Check Captcha
  17.     else if ($this->captcha_check($code,$captcha,$ip) == false) echo 'Incorrect Captcha. Please try again.';
  18.     //Nothing abormal? Alright lets do some final checks then register..
  19.     else {
  20.     $userF = htmlspecialchars($user, ENT_QUOTES);
  21.     $passF = htmlspecialchars($user, ENT_QUOTES);
  22.     $sex = htmlspecialchars($sex, ENT_QUOTES);
  23.     $dob = htmlspecialchars($dob, ENT_QUOTES);
  24.     $country = htmlspecialchars($country, ENT_QUOTES);
  25.     //Does the username exist?
  26.     $check = "select username from " . $this->conf['sql_prefix'] . "users where username = '" . $userF . "'";
  27.     $cres = mysql_query($check);
  28.     $cuser = mysql_num_rows($cres);
  29.     if ($cuser > 0) echo 'Username exists.';
  30.     else {
  31.     //Have we got this email used in prior registrations more than the configured limit?
  32.     $check2 = "select email from " . $this->conf['sql_prefix'] . "users where email = '" . $email . "'";
  33.     $cres2 = mysql_query($check2);
  34.     $cemail = mysql_num_rows($cres2);
  35.     if ($cemail => $this->conf['emaillimit']) echo 'Too many accounts from that email address';
  36.     else {
  37.     //Finally the holy grail, everything passed, lets add them to the DB..
  38.     $insert = "insert into " . $this->conf['sql_prefix'] . "users (username,password,email,registered,country,dob,sex) values('" . $userF . "','" . $passF . "','" . $email . "','" . time() . "','" . $country . "','" . $dob . "','" . $sex . "')";
  39.     mysql_query($insert);
  40.     $activekey = $this->video_keygen() . rand(1,999) . $this->video_keygen();
  41.     $activation = "insert into " . $this->conf['sql_prefix'] . "activate (key,ip,username,life,email) values('" . $activekey . "','" . $mip . "','" . $userF . "','" . time() . "','" . $email . "')";
  42.     mysql_query($activation);
  43.     echo 'Registration Success! Check your email for the activation URL, May take a few minutes.';
  44.     }
  45.     }
  46.     }
  47.     }
  48.     }
Add Comment
Please, Sign In to add comment