Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class register_class extends database_class {
- // Class constructor
- function __construct($username, $password, $password_comfirm, $email, $pin, $gender){
- $this->username = $username;
- $this->password = $password;
- $this->password_comfirm = $password_comfirm;
- $this->email = $email;
- $this->pin = $pin;
- $this->gender = $gender;
- $this->salt = 'xxx';
- $this->hashed_password = md5($this->salt.$this->password);
- $this->key = $this->create_verify_code();
- }
- // Function to create the verify link
- function create_verify_code(){
- $chars = array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
- $verify_code = '';
- $max = count($chars)-1;
- for($i = 0; $i < 20; $i++){
- $verify_code .= (!($i % 5) && $i ? '-' : '') . $chars[rand(0, $max)];
- }
- return $verify_code;
- }
- // Function to check if a username already exists in our database
- function check_username(){
- $this->connect();
- $userrname_check = $this->execute_query("SELECT * FROM Users WHERE username = '" . $this->username . "'");
- if($userrname_check && mysqli_num_rows($userrname_check) > 0){
- return true;
- }else{
- return false;
- }
- }
- // Function to register the account
- function register_account(){
- $this->connect();
- $register_account = $this->execute_query("INSERT INTO Users (username, password, email, gender, ip, pin, activate_key) VALUES ('" . $this->username . "', '" . $this->hashed_password . "', '" . $this->email . "', '" . $this->gender . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $this->pin . "', '" . $this->key . "')");
- return $register_account;
- }
- // Function to send registration mail to user
- function send_registration_mail(){
- $subject = 'Signup | Verification';
- $message = '
- Thanks for signing up! Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
- ------------------------
- username: ' . $this->username . '
- Password: ' . $this->password . '
- ------------------------
- Please click this link to activate your account:
- http://www.pr0b.com/verify.php?key='. $this->key .'
- ';
- $headers = 'From: noreply@pr0b.com' . "rn";
- mail($this->email, $subject, $message, $headers);
- }
- // Function to create the outfit xml file
- function create_outfit_json(){
- if (!file_exists('../user/' . $this->username)) {
- mkdir('../user/' . $this->username, 0777, true);
- }
- $json['outfits']['0'] = [
- 'outfit' => [
- 'url' => 'placeholder',
- 'default' => 1,
- 'name' => 'New outfit',
- 'c' => '#bb9977',
- 'mood' => 3,
- 'species' => 'male'
- ]
- ];
- $fp = fopen('../user/' . $this->username . '/outfits.json', 'w');
- fwrite($fp, json_encode($json));
- fclose($fp);
- if (file_exists('../user/' . $this->username . '/outfits.json')) {
- return true;
- }else{
- return false;
- }
- }
- // Function to create the purchase xml file
- function create_purchased_json(){
- if (!file_exists('../user/' . $this->username)) {
- mkdir('../user/' . $this->username, 0777, true);
- }
- $json['purchased'] = [
- 'item' => [
- 'url' => 'placeholder',
- 'name' => 'placeholder',
- 'category' => 'placeholder',
- 'c' => 'placeholder',
- 'c2' => 'placeholder',
- 'species' => 'placeholder'
- ]
- ];
- $fp = fopen('../user/' . $this->username . '/purchased.json', 'w');
- fwrite($fp, json_encode($json));
- fclose($fp);
- if (file_exists('../user/' . $this->username . '/purchased.json')) {
- return true;
- }else{
- return false;
- }
- }
- // Function to create current outfit xml file
- function create_current_outfit_json(){
- if (!file_exists('../user/' . $this->username)) {
- mkdir('../user/' . $this->username, 0777, true);
- }
- $json['outfit'] = [];
- $json['outfit'] = [
- 'outfit' => [
- 'url' => 'placeholder',
- 'default' => 1,
- 'name' => 'New outfit',
- 'c' => '#bb9977',
- 'mood' => 3,
- 'species' => 'male'
- ],
- 'head' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'face' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'midsection' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'leg' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'hair' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'shirt' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'jacket' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'bottom' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'electronic' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'hat' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'earrings' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'belt' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'bracelet' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'necklace' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'facialhair' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'food' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ],
- 'facialdecorations' => [
- 'url' => 'placeholder',
- 'c' => '#bb9977',
- 'c2' => '#bb9977',
- 'z' => 1
- ]
- ];
- $fp = fopen('../user/' . $this->username . '/currentOutfit.json', 'w');
- fwrite($fp, json_encode($json));
- fclose($fp);
- if (file_exists('../user/' . $this->username . '/currentOutfit.json')) {
- return true;
- }else{
- return false;
- }
- }
- // Function to execute the class
- function class_handler(){
- if(!$this->username){
- return 'Error: username is required. Please enter a valid username.';
- }else if(!$this->password){
- return 'Error: Password is required. Please enter a valid password.';
- }else if($this->password !== $this->password_comfirm){
- return 'Error: The Passwords doesnt match. Please try again.';
- }else if(!$this->email){
- return 'Error: Email is required. Please enter a valid email.';
- }else if(!$this->pin){
- return 'Error: Pin is required. Please enter a pin code.';
- }else{
- $username_check = $this->check_username();
- if($username_check == true){
- return 'The username: ' . $this->username . ' is already in use. Please pick another username.';
- }else{
- $register_account = $this->register_account();
- if($register_account == false){
- return 'Error: The following account could not be created: ' . $this->username . '. Please try later again.';
- }else{
- $this->send_registration_mail();
- $create_outfit_json = $this->create_outfit_json();
- $create_purchased_json = $this->create_purchased_json();
- $create_current_outfit_json = $this->create_current_outfit_json();
- if($create_outfit_json == true || $create_purchased_json == true || $create_current_outfit_json == true){
- return 'The following account was succesful created: ' . $this->username;
- }else {
- return 'Error: The following account could not be created: ' . $this->username . '. Please try later again.';
- }
- }
- }
- }
- }
- }
- ?>
- <?php
- if (!file_exists('../user/testusername')) {
- mkdir('../user/testusername', 0777, true);
- }
- $json['outfits']['0'] = [
- 'outfit' => [
- 'url' => 'placeholder',
- 'default' => 1,
- 'name' => 'New outfit',
- 'c' => '#bb9977',
- 'mood' => 3,
- 'species' => 'male'
- ]
- ];
- $fp = fopen('../user/testusername/outfits.json', 'w');
- fwrite($fp, json_encode($json));
- fclose($fp);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement