Darkness4869

StormySystem.php

Oct 16th, 2021
793
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // User Class
  2. class User {
  3.     // Class variables
  4.     private string $username;
  5.     private string $firstName;
  6.     private string $lastName;
  7.     private string $mailAddress;
  8.     private int $type;
  9.     private string $dateOfBirth;
  10.     private string $profilePicture;
  11.     private string $password;
  12.     // public string $domain = "http://stormy-systems.herokuapp.com/";
  13.     public string $domain = "http://stormysystem.ddns.net/";
  14.     protected $PHPMailer;
  15.     protected $API;
  16.     protected $Renderer;
  17.     // Contructor method
  18.     public function __construct() {
  19.         // Instantiating API
  20.         $this->API = new API();
  21.         // Instantiating Renderer
  22.         $this->Renderer = new Renderer();
  23.         // Instantiating PHPMailer
  24.         $this->PHPMailer = new PHPMailer\PHPMailer\PHPMailer(true);
  25.     }
  26.     // Username accessor method
  27.     public function getUsername() {
  28.         return $this->username;
  29.     }
  30.     // First Name accessor method
  31.     public function getFirstName() {
  32.         return $this->firstName;
  33.     }
  34.     // Last Name accessor method
  35.     public function getLastname() {
  36.         return $this->lastName;
  37.     }
  38.     // Mail Address accessor method
  39.     public function getMailAddress() {
  40.         return $this->mailAddress;
  41.     }
  42.     // Type accessor method
  43.     public function getType() {
  44.         return $this->type;
  45.     }
  46.     // Date Of Birth accessor method
  47.     public function getDateOfBirth() {
  48.         return $this->dateOfBirth;
  49.     }
  50.     // Profile Picture accessor method
  51.     public function getProfilePicture() {
  52.         return $this->profilePicture;
  53.     }
  54.     // Password accessor method
  55.     public function getPassword() {
  56.         return $this->password;
  57.     }
  58.     // Username mutator method
  59.     public function setUsername($username) {
  60.         $this->username = $username;
  61.     }
  62.     // First Name mutator method
  63.     public function setFirstName($firstName) {
  64.         $this->firstName = $firstName;
  65.     }
  66.     // Last Name mutator method
  67.     public function setLastname($lastName) {
  68.         $this->lastName = $lastName;
  69.     }
  70.     // Mail Address mutator method
  71.     public function setMailAddress($mailAddress) {
  72.         $this->mailAddress = $mailAddress;
  73.     }
  74.     // Type mutator method
  75.     public function setType($type) {
  76.         $this->type = $type;
  77.     }
  78.     // Date Of Birth mutator method
  79.     public function setDateOfBirth($dateOfBirth) {
  80.         $this->dateOfBirth = $dateOfBirth;
  81.     }
  82.     // Profile Picture mutator method
  83.     public function setProfilePicture($profilePicture) {
  84.         $this->profilePicture = $profilePicture;
  85.     }
  86.     // Password mutator method
  87.     public function setPassword($password) {
  88.         $this->password = $password;
  89.     }
  90.     // Register method
  91.     public function register() {
  92.         // Receiving the JSON from the POST Request
  93.         $userJSON[] = file_get_contents('php://input');
  94.         // // Decoding User JSON into a PHP Object
  95.         // $userObject = json_decode($userJSON, true);
  96.         // Printing the Object
  97.         var_dump(json_encode(file_get_contents('php://input')));
  98.         foreach ($userJSON as $string) {
  99.             echo 'Decoding: ' . $string;
  100.             json_decode($string);
  101.             switch (json_last_error()) {
  102.                 case JSON_ERROR_NONE:
  103.                     echo ' - No errors';
  104.                 break;
  105.                 case JSON_ERROR_DEPTH:
  106.                     echo ' - Maximum stack depth exceeded';
  107.                 break;
  108.                 case JSON_ERROR_STATE_MISMATCH:
  109.                     echo ' - Underflow or the modes mismatch';
  110.                 break;
  111.                 case JSON_ERROR_CTRL_CHAR:
  112.                     echo ' - Unexpected control character found';
  113.                 break;
  114.                 case JSON_ERROR_SYNTAX:
  115.                     echo ' - Syntax error, malformed JSON';
  116.                 break;
  117.                 case JSON_ERROR_UTF8:
  118.                     echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
  119.                 break;
  120.                 default:
  121.                     echo ' - Unknown error';
  122.                 break;
  123.             }
  124.        
  125.             echo PHP_EOL;
  126.         }
  127.     }
  128. }
RAW Paste Data