Advertisement
xandr91

TemplatesX-Q2APHP-PRO-FIX

Aug 15th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.80 KB | None | 0 0
  1. public function createuseraccount($username, $password, $name, $surname, $email, $sex) {
  2.  
  3.         $pass = $password;
  4.         $username = strip_tags($username);
  5.         $password = strip_tags($password);
  6.         $name = strip_tags($name);
  7.         $surname = strip_tags($surname);
  8.         $email = strip_tags($email);
  9.         if(!empty($username) && !empty($password) && !empty($name) && !empty($email) && preg_match("/^[a-zA-Z0-9]+$/", $username)==1) {
  10.             $password = engine::crypts(engine::crypts(engine::crypts($password, "MD5", 0), 2, 0), "SHA1", 0);  
  11.             $rank = 0;
  12.             $website = 'http://'.SITE_DOMAIN.'/'.$username.'';
  13.             $location = getlanguage(78);
  14.             $about_me = getlanguage(79);
  15.             $what_ask = getlanguage(80);
  16.             $photo = "photo_default.png";
  17.             if(SIGNUP_CONFIRMATION==1) {
  18.                 $status = 10;
  19.             }
  20.             else {
  21.                 $status = 1;
  22.             }
  23.             $ip = USER_IP;
  24.             if($sex!=1 && $sex!=2) $sex=0;
  25.             $sex = $sex;
  26.             $protection = 1;
  27.             $reg_date = time();
  28.             if(!empty($username) && strlen($username)>3) {
  29.                 if(engine::usernameexists($username)=="Username Exists") {
  30.                     $_SESSION['msg']=2;
  31.                     engine::headerin("account/signup");
  32.                     exit;
  33.                 }
  34.             }
  35.             if(!empty($email) && strlen($email)>5) {
  36.                 if(engine::emailalreadyexists($email)=="Email Exists") {
  37.                     $_SESSION['msg']=1;
  38.                     engine::headerin("account/signup");
  39.                     exit;
  40.                 }
  41.             }
  42.             if(!empty($password) && strlen($password)<4) {
  43.                 $_SESSION['msg']=1;
  44.                 engine::headerin("account/signup");
  45.                 exit;
  46.             }
  47.             $mysqlmessage["user"] = "INSERT INTO users ";
  48.             $mysqlmessage["user"] .= "(username, password, real_name, real_surname, points, rank, verified, email, website, localization, bio, sex, what_ask, photo, cover, status, ip, anonymous_view, reg_date) ";
  49.             $mysqlmessage["user"] .= "VALUES ";
  50.             $mysqlmessage["user"] .= "(?, ?, ?, ?, '1', '0', '0', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  51.             $stmt = $this->conn->prepare($mysqlmessage["user"]);
  52.             $stmt->execute(array($username,$password,$name,$surname,$email,$website,$location,$about_me,$sex,$what_ask,$photo,'',$status,$ip,$protection,$reg_date));
  53.             if($stmt->rowCount()!=0) {
  54.                 if(SESSION_STATUS!=true) {
  55.                     if(SIGNUP_CONFIRMATION==1) {
  56.                         engine::send_confirmation($username);
  57.                         engine::headerin("site/signup");
  58.                         exit;
  59.                     }
  60.                     else {
  61.                         engine::checkcookies($username, $pass);
  62.                     }
  63.                 }
  64.             }
  65.         }
  66.     }
  67.    
  68.     public function createuseraccountsocial($username, $email, $network, $id, $name, $surname, $photo, $country, $city, $sex) {
  69.  
  70.         $username = strip_tags($username);
  71.         $email = strip_tags($email);
  72.         if(!empty($username) && preg_match("/^[a-zA-Z0-9]+$/", $username)==1) {
  73.             $rank = 0;  
  74.             $website = 'http://'.SITE_DOMAIN.'/'.$username;
  75.             $location = $country.' '.$city;
  76.             $about_me = getlanguage(79);
  77.             $what_ask = getlanguage(80);
  78.             $status = 1;
  79.             $ip = USER_IP;
  80.             if($sex!=1 && $sex!=2) $sex=0;
  81.             $sex = $sex;
  82.             $protection = 1;
  83.             $reg_date = time();
  84.             if(!empty($username) && strlen($username)>3) {
  85.                 if(engine::usernameexists($username)=="Username Exists") {
  86.                     $_SESSION['msg'] = 2;
  87.                     engine::headerin("account/signup");
  88.                     exit;
  89.                 }
  90.             }
  91.             if(!empty($email) && strlen($email)>5) {
  92.                 if(engine::emailalreadyexists($email)=="Email Exists") {
  93.                     $_SESSION['msg'] = 1;
  94.                     engine::headerin("account/signup");
  95.                     exit;
  96.                 }
  97.             }
  98.             if($photo!="") {
  99.                 if(substr($photo,0,8)=='https://') {
  100.                     $photo = substr($photo,8);
  101.                     $photo = "http://".$photo;
  102.                 }
  103.                 $photo_crypt_name = engine::crypts($username.time(), 1, 0).".jpg";
  104.                 $root = realpath($_SERVER["DOCUMENT_ROOT"]);
  105.                 $directory = IMG_PATH.$photo_crypt_name;   
  106.                 $image = file_get_contents($photo);
  107.                 file_put_contents($directory, $image);
  108.                 $photo = $photo_crypt_name;
  109.             }
  110.             else $photo = "photo_default.png";
  111.             $mysqlmessage["user"] = "INSERT INTO users ";
  112.             $mysqlmessage["user"] .= "(username, password, real_name, real_surname, points, rank, verified, email, website, localization, bio, sex, what_ask, photo, cover, status, ip, anonymous_view, reg_date, social) ";
  113.             $mysqlmessage["user"] .= "VALUES ";
  114.             $mysqlmessage["user"] .= "(?, '', ?, ?, '1', '0', '0', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  115.             $stmt = $this->conn->prepare($mysqlmessage["user"]);
  116.             $stmt->execute(array($username,$name,$surname,$email,$website,$location,$about_me,$sex,$what_ask,$photo,'',$status,$ip,$protection,$reg_date,$id));
  117.             if($stmt->rowCount()!=0) {
  118.                 if(SESSION_STATUS!=true) {
  119.                     engine::checkcookies("", "", $network, $id);
  120.                     unset($_SESSION['regnetwork']);
  121.                     unset($_SESSION['regid']);
  122.                     unset($_SESSION['regfirst_name']);
  123.                     unset($_SESSION['reglast_name']);
  124.                     unset($_SESSION['regbdate']);
  125.                     unset($_SESSION['regphoto_big']);
  126.                     unset($_SESSION['regcountry']);
  127.                     unset($_SESSION['regcity']);
  128.                     exit;
  129.                 }
  130.             }
  131.         }
  132.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement