Advertisement
Darkness4869

User.php

Mar 23rd, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.11 KB | None | 0 0
  1. <?php
  2. require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/API.php";
  3. require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/PHPMailer.php";
  4. require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/Exception.php";
  5. require $_SERVER['DOCUMENT_ROOT'] . "/LibrarySystem/PHPMailer/src/SMTP.php";
  6. class User {
  7.     // Class variables
  8.     private int $id;
  9.     private string $mailAddress;
  10.     private string $password;
  11.     private string $studentId;
  12.     private int $type;
  13.     private string $profilePicture;
  14.     protected $API;
  15.     protected $Mail;
  16.     // Constructor method
  17.     public function __construct() {
  18.         $this->API = new API();
  19.         $this->Mail = new PHPMailer\PHPMailer\PHPMailer(true);
  20.     }
  21.     // ID accessor method
  22.     public function getId() {
  23.         return $this->id;
  24.     }
  25.     // Mail Address accessor method
  26.     public function getMailAddress() {
  27.         return $this->mailAddress;
  28.     }
  29.     // Password accessor method
  30.     public function getPassword() {
  31.         return $this->password;
  32.     }
  33.     // Student Id accessor method
  34.     public function getStudentId() {
  35.         return $this->studentId;
  36.     }
  37.     // Type accessor method
  38.     public function getType() {
  39.         return $this->type;
  40.     }
  41.     // Profile Picture accessor method
  42.     public function getProfilePicture() {
  43.         return $this->profilePicture;
  44.     }
  45.     // ID mutator method
  46.     public function setId($id) {
  47.         $this->id = $id;
  48.     }
  49.     // Mail Address mutator method
  50.     public function setMailAddress($mailAddress) {
  51.         $this->mailAddress = $mailAddress;
  52.     }
  53.     // Password mutator method
  54.     public function setPassword($password) {
  55.         $this->password = $password;
  56.     }
  57.     // Student ID mutator method
  58.     public function setStudentID($studentId) {
  59.         $this->studentId = $studentId;
  60.     }
  61.     // Type mutator method
  62.     public function setType($type) {
  63.         $this->type = $type;
  64.     }
  65.     // Profile Picture mutator method
  66.     public function setProfilePicture($profilePicture) {
  67.         $this->profilePicture = $profilePicture;
  68.     }
  69.     // Register method
  70.     public function register() {
  71.         // Setting the mail address from the register page as a parameter in the mutator.
  72.         $this->setMailAddress($_POST['mailAddress']);
  73.         // Setting the student ID from the register page as a parameter in the mutator.
  74.         $this->setStudentId($_POST['studentId']);
  75.         // Preparing the query to verify if the mail entered is already in the database.
  76.         $this->API->query("SELECT * FROM LibrarySystem.User WHERE UserMailAddress = :UserMailAddress");
  77.         // Binding the value returned by the User class for security purposes.
  78.         $this->API->bind(":UserMailAddress", $this->getMailAddress());
  79.         // Executing the query.
  80.         $this->API->execute();
  81.         // Verifying whether the result set is 0.  If, it is 0, then, another if-statement will verify if the mail entered belongs to Université Des Mascareignes.  In the condition that the mail belongs to UDM, another if-statement will verify if there is a student Id which has been entered.  In the condition that a student ID has been entered, the account type will be set to 1 else, it will be set to 2 where afterwards it can be changed by the administrator.
  82.         if (count($this->API->resultSet()) == 0) {
  83.             if (strpos($this->getMailAddress(), "@student.udm.ac.mu") == true or strpos($this->getMailAddress(), "@udm.ac.mu") == true) {
  84.                 if (!empty($this->getStudentId())) {
  85.                     $this->setType(1);
  86.                     $this->setPassword($this->generatePassword());
  87.                     $this->API->query("INSERT INTO LibrarySystem.User (UserMailAddress, UserPassword, UserStudentId, UserType) VALUES (:UserMailAddress, :UserPassword, :UserStudentId, :UserType)");
  88.                     $this->API->bind(":UserMailAddress", $this->getMailAddress());
  89.                     $this->API->bind(":UserPassword", $this->getPassword());
  90.                     $this->API->bind(":UserStudentId", $this->getStudentId());
  91.                     $this->API->bind(":UserType", $this->getType());
  92.                     $this->API->execute();
  93.                     $this->Mail->IsSMTP();
  94.                     $this->Mail->CharSet = "UTF-8";
  95.                     $this->Mail->Host = "ssl://smtp.gmail.com";
  96.                     $this->Mail->SMTPDebug = 0;
  97.                     $this->Mail->Port = 465;
  98.                     $this->Mail->SMTPSecure = 'ssl';
  99.                     $this->Mail->SMTPAuth = true;
  100.                     $this->Mail->IsHTML(true);$this->Mail->Username = "";
  101.                     $this->Mail->Password = "";
  102.                     $this->Mail->setFrom($this->Mail->Username);
  103.                     $this->Mail->addAddress($this->getMailAddress());
  104.                     $this->Mail->subject = "Library System: Notification";
  105.                     $this->Mail->Body = "Your password is " . $this->getPassword() . ".  Please consider to change your password after logging in!";
  106.                     $this->Mail->send();
  107.                     echo("<h1 id='success'>You have been registered into the system, you will be redirected to the login page.</h1>");
  108.                     header('refresh: 4; url = http://stormysystem.ddns.net/LibrarySystem/Login');
  109.                 } else {
  110.                     $this->setType(2);
  111.                     $this->setPassword($this->generatePassword());
  112.                     $this->API->query("INSERT INTO LibrarySystem.User (UserMailAddress, UserPassword, UserType) VALUES (:UserMailAddress, :UserPassword, :UserType)");
  113.                     $this->API->bind(":UserMailAddress", $this->getMailAddress());
  114.                     $this->API->bind(":UserPassword", $this->getPassword());
  115.                     $this->API->bind(":UserType", $this->getType());
  116.                     $this->API->execute();
  117.                     $this->Mail->IsSMTP();$this->Mail->CharSet = "UTF-8";
  118.                     $this->Mail->Host = "ssl://smtp.gmail.com";
  119.                     $this->Mail->SMTPDebug = 0;
  120.                     $this->Mail->Port = 465;
  121.                     $this->Mail->SMTPSecure = 'ssl';
  122.                     $this->Mail->SMTPAuth = true;
  123.                     $this->Mail->IsHTML(true);$this->Mail->Username = "";
  124.                     $this->Mail->Password = "";
  125.                     $this->Mail->setFrom($this->Mail->Username);
  126.                     $this->Mail->addAddress($this->getMailAddress());
  127.                     $this->Mail->subject = "Library System: Notification";
  128.                     $this->Mail->Body = "Your password is " . $this->getPassword() . ".  Please consider to change your password after logging in!";
  129.                     $this->Mail->send();
  130.                     echo("<h1 id='success'>You have been registered into the system, you will be redirected to the login page.</h1>");
  131.                     header('refresh: 4; url = http://stormysystem.ddns.net/LibrarySystem/Login');
  132.                 }
  133.                
  134.             } else {
  135.                 echo("<h1 id='failure'>You cannot have access to this service as you are not a member of this organization!</h1>");
  136.             }
  137.         } else {
  138.             echo "<h1 id='failure'>You already have an account on the system!  You will be redirected to the login page!</h1>";
  139.             header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Login');
  140.         }
  141.     }
  142.     // Login method
  143.     public function login() {
  144.         // Setting the mail address from the login page as a parameter in the mutator.
  145.         $this->setMailAddress($_POST['mailAddress']);
  146.         // Setting the password from the login page as a parameter in the mutator.
  147.         $this->setPassword($_POST['password']);
  148.          // Preparing the query to verify if the mail and password entered are already in the database.
  149.         $this->API->query("SELECT * FROM LibrarySystem.User WHERE UserMailAddress = :UserMailAddress AND UserPassword = :UserPassword");
  150.         // Binding the values returned by the User class for security purposes.
  151.         $this->API->bind(":UserMailAddress", $this->getMailAddress());
  152.         $this->API->bind(":UserPassword", $this->getPassword());
  153.         // Executing the query.
  154.         $this->API->execute();
  155.         // Verifying if, the results from the database is 0 and in the case that it is 0, the user will be redirected to the homepage, else, another if-statement will be called where it will verify whether there is a profile picture or a student ID given that in the end, Check Session method will be called.
  156.         if (empty($this->API->resultSet())) {
  157.             echo "<h1 id='failure'>Incorrect Credentials!</h1>";
  158.             header('refresh:1.2; url=http://stormysystem.ddns.net/LibrarySystem/Login');
  159.         } else {
  160.             if ($this->API->resultSet()[0]['UserProfilePicture'] != null) {
  161.                 if ($this->API->resultSet()[0]['UserStudentId'] != null) {
  162.                     $this->setId($this->API->resultSet()[0]['UserId']);
  163.                     $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  164.                     $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  165.                     $this->setStudentId($this->API->resultSet()[0]['UserStudentId']);
  166.                     $this->setProfilePicture($this->API->resultSet()[0]['UserProfilePicture']);
  167.                     $this->setType($this->API->resultSet()[0]['UserType']);
  168.                     session_start();
  169.                     $_SESSION["id"] = $this->getId();
  170.                     $this->checkSession();
  171.                 } else {
  172.                     $this->setId($this->API->resultSet()[0]['UserId']);
  173.                     $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  174.                     $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  175.                     $this->setProfilePicture($this->API->resultSet()[0]['UserProfilePicture']);
  176.                     $this->setType($this->API->resultSet()[0]['UserType']);
  177.                     session_start();
  178.                     $_SESSION["id"] = $this->getId();
  179.                     $this->checkSession();
  180.                 }
  181.             } else {
  182.                 if ($this->API->resultSet()[0]['UserStudentId'] != null) {
  183.                     $this->setId($this->API->resultSet()[0]['UserId']);
  184.                     $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  185.                     $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  186.                     $this->setStudentId($this->API->resultSet()[0]['UserStudentId']);
  187.                     $this->setType($this->API->resultSet()[0]['UserType']);
  188.                     session_start();
  189.                     $_SESSION["id"] = $this->getId();
  190.                     $this->checkSession();
  191.                 } else {
  192.                     $this->setId($this->API->resultSet()[0]['UserId']);
  193.                     $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  194.                     $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  195.                     $this->setType($this->API->resultSet()[0]['UserType']);
  196.                     session_start();
  197.                     $_SESSION["id"] = $this->getId();
  198.                     $this->checkSession();
  199.                 }
  200.             }
  201.         }
  202.     }
  203.     // Check Session method
  204.     public function checkSession() {
  205.         // Verifying if, the session ID is the same as the ID of the user and if, it is the case, another switch-statement will verify will check the account type so that the the system will redirect the user to its designated page.
  206.         if ($_SESSION["id"] = $this->getId()) {
  207.             switch ($this->getType()) {
  208.                 case '0':
  209.                     echo("<h1 id='failure'>You cannot have access to this service as you are currently banned from this service!  A mail will be sent to you!</h1>");
  210.                     $this->Mail->IsSMTP();$this->Mail->CharSet = "UTF-8";
  211.                     $this->Mail->Host = "ssl://smtp.gmail.com";
  212.                     $this->Mail->SMTPDebug = 0;
  213.                     $this->Mail->Port = 465;
  214.                     $this->Mail->SMTPSecure = 'ssl';
  215.                     $this->Mail->SMTPAuth = true;
  216.                     $this->Mail->IsHTML(true);$this->Mail->Username = "";
  217.                     $this->Mail->Password = "";
  218.                     $this->Mail->setFrom($this->Mail->Username);
  219.                     $this->Mail->addAddress($this->getMailAddress());
  220.                     $this->Mail->subject = "Library System: Notification";
  221.                     $this->Mail->Body = "You are currently banned from the system!  Before, you can actually get accessed to the system once again, you will have to get it unban by contacting an administrator.";
  222.                     $this->Mail->send();
  223.                     header('refresh:4.4; url=http://stormysystem.ddns.net/LibrarySystem');
  224.                     break;
  225.                 case '1':
  226.                     header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Member');
  227.                     break;
  228.                 case '2':
  229.                     header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Member');
  230.                     break;
  231.                 case '3':
  232.                     header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Member');
  233.                     break;
  234.                 case '4':
  235.                     header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Admin');
  236.                     break;
  237.                 default:
  238.                 echo("<h1 id='failure'>You cannot have access to this service as you are not a member of this organization!</h1>");
  239.                     header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem');
  240.                     break;
  241.             }
  242.         } else {
  243.             echo("<h1 id='failure'>You cannot have access to this service as you are not a member of this organization!</h1>");
  244.             header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem');
  245.         }
  246.     }
  247.     // Generate Password method
  248.     public function generatePassword() {
  249.         return uniqid();
  250.     }
  251.     // Forgot Password method
  252.     public function forgotPassword() {
  253.         // Setting the mail address entered from Reset_Password page as the parameter for the mutator.
  254.         $this->setMailAddress($_POST['mailAddress']);
  255.         // Preparing the query which will fetch data from the database.
  256.         $this->API->query("SELECT * FROM LibrarySystem.User WHERE UserMailAddress = :UserMailAddress");
  257.         // Binding the mail address which is returned from the accessor to prevent any SQL injection in the database.
  258.         $this->API->bind(":UserMailAddress", $this->getMailAddress());
  259.         // Executing the query.
  260.         $this->API->execute();
  261.         // If, the query does not return any value, the user will be redirected to the homepage, else, a mail will be sent to him with a new password and he will be redirected to the login page afterwards.
  262.         if (empty($this->API->resultSet())) {
  263.             echo"<h1 id='failure'>This mail is not registered in the system!</h1>";
  264.             header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem');
  265.         } else {
  266.             $this->setPassword($this->generatePassword());
  267.             $this->API->query("UPDATE LibrarySystem.User SET UserPassword = :UserPassword WHERE UserMailAddress = :UserMailAddress");
  268.             $this->API->bind(":UserMailAddress", $this->getMailAddress());
  269.             $this->API->bind(":UserPassword", $this->getPassword());
  270.             $this->API->execute();
  271.             $this->Mail->IsSMTP();
  272.             $this->Mail->CharSet = "UTF-8";
  273.             $this->Mail->Host = "ssl://smtp.gmail.com";
  274.             $this->Mail->SMTPDebug = 0;
  275.             $this->Mail->Port = 465;
  276.             $this->Mail->SMTPSecure = 'ssl';
  277.             $this->Mail->SMTPAuth = true;
  278.             $this->Mail->IsHTML(true);
  279.             $this->Mail->Username = "";
  280.             $this->Mail->Password = "";
  281.             $this->Mail->setFrom($this->Mail->Username);
  282.             $this->Mail->addAddress($this->getMailAddress());
  283.             $this->Mail->subject = "Library System: Notification";
  284.             $this->Mail->Body = "Your password has been resetted.  Your new password is " . $this->getPassword() . ".";
  285.             $this->Mail->send();
  286.             echo "<h1 id='success'>Your password have been resetted, you will be redirected to the login page.</h1>";
  287.             header('refresh:4; url=http://stormysystem.ddns.net/LibrarySystem/Login');
  288.         }
  289.     }
  290.     // Change Password method
  291.     public function changePassword() {
  292.         $this->API->query("SELECT * FROM LibrarySystem.User WHERE UserId = :UserId");
  293.         $this->API->bind(":UserId", $this->getId());
  294.         $this->API->execute();
  295.         if ($_POST['oldPassword'] == $this->API->resultSet()[0]['UserPassword']) {
  296.             if ($_POST['newPassword'] == $_POST['confirmNewPassword']) {
  297.                 $this->setPassword($_POST['newPassword']);
  298.                 $this->API->query("UPDATE User SET UserPassword = :UserPassword WHERE UserId = :UserId");
  299.                 $this->API->bind(":UserId", $this->getId());
  300.                 $this->API->bind(":UserPassword", $this->getPassword());
  301.                 $this->API->execute();$this->Mail->IsSMTP();
  302.                 $this->Mail->CharSet = "UTF-8";
  303.                 $this->Mail->Host = "ssl://smtp.gmail.com";
  304.                 $this->Mail->SMTPDebug = 0;
  305.                 $this->Mail->Port = 465;
  306.                 $this->Mail->SMTPSecure = 'ssl';
  307.                 $this->Mail->SMTPAuth = true;
  308.                 $this->Mail->IsHTML(true);
  309.                 $this->Mail->Username = "";
  310.                 $this->Mail->Password = "";
  311.                 $this->Mail->setFrom($this->Mail->Username);
  312.                 $this->Mail->addAddress($this->getMailAddress());
  313.                 $this->Mail->subject = "Library System: Notification";
  314.                 $this->Mail->Body = "Your password has been changed.  Your new password is " . $this->getPassword() . ".  If, you are not the one, please consider to reset your password on this link http://stormysystem.ddns.net/LibrarySystem/Reset_Password";
  315.                 $this->Mail->send();
  316.                 echo "<h1 id='success'>Your password has been successfully been changed.  You will be logged out of the system and your new password will be sent to you by mail.</h1>";
  317.                 header('refresh:4.4; url=http://stormysystem.ddns.net/LibrarySystem/Member/Logout');
  318.             } else {
  319.                 echo "<h1 id='failure'>The passwords entered, are not identical!</h1>";
  320.             }
  321.         } else {
  322.             echo "<h1 id='failure'>This is not your password!  You will be logged out of this account!</h1>";
  323.             header('refresh:0.2; url=http://stormysystem.ddns.net/LibrarySystem/Member/Logout');
  324.         }
  325.     }
  326.     // Change Profile Picture method
  327.     public function changeProfilePicture() {
  328.         $imageDirectory = "/LibrarySystem/Images/";
  329.         $imageFile = $imageDirectory . basename($_FILES['image']['name']);
  330.         $uploadedPath = $_SERVER["DOCUMENT_ROOT"] .  $imageFile;
  331.         if (move_uploaded_file($_FILES["image"]["tmp_name"], $uploadedPath)) {
  332.             $this->setProfilePicture($imageFile);
  333.             $this->API->query("UPDATE User SET UserProfilePicture = :UserProfilePicture WHERE UserId = :UserId");
  334.             $this->API->bind(":UserProfilePicture", $this->getProfilePicture());
  335.             $this->API->bind(":UserId", $this->getId());
  336.             $this->API->execute();
  337.             echo "<h1 id='success'>Your profile picture has been changed!</h1>";
  338.         }
  339.     }
  340.     // Freeze Membership method
  341.     public function freezeMembership() {
  342.         $this->setType(0);
  343.         $this->API->query("UPDATE User SET UserType = :UserType WHERE UserMail = :UserMail");
  344.         $this->API->bind(":UserType", $this->getType());
  345.         $this->API->bind(":UserMail", $this->getMailAddress());
  346.         $this->API->execute();
  347.         echo($this->getMail() . " has been banned!");
  348.     }
  349.     // Unfreeze Membership method
  350.     public function unfreezeMembership() {
  351.         if (strpos($this->getMailAddress(), "@student.udm.ac.mu") or strpos($this->getMail(), "@udm.ac.mu")) {
  352.             if (!empty($this->getStudentId())) {
  353.                 $this->setType(1);
  354.                 $this->API->query("UPDATE User SET UserType = :UserType WHERE UserMail = :UserMail");
  355.                 $this->API->bind(":UserType", $this->getType());
  356.                 $this->API->bind(":UserMail", $this->getMailAddress());
  357.                 $this->API->execute();
  358.                 echo($this->getMail() . " has been unbanned!");
  359.             } else {
  360.                 $this->setType(2);
  361.                 $this->API->query("UPDATE User SET UserType = :UserType WHERE UserMail = :UserMail");
  362.                 $this->API->bind(":UserType", $this->getType());
  363.                 $this->API->bind(":UserMail", $this->getMailAddress());
  364.                 $this->API->execute();
  365.                 echo($this->getMail() . " has been unbanned!");
  366.             }
  367.         } else {
  368.             echo("This is not a member of this organization!");
  369.         }
  370.     }
  371.     // Profile Checker method
  372.     public function profileChecker() {
  373.         // Setting the Session ID as a parameter in the User ID which will be used to verify if it exists in the database.
  374.         $this->setId($_SESSION['id']);
  375.         // Preparing the query.
  376.         $this->API->query("SELECT * FROM LibrarySystem.User WHERE UserId = :UserId");
  377.         // Binding the values which will be used in the query to prevent a sql injection.
  378.         $this->API->bind(":UserId", $this->getId());
  379.         // Executing the query
  380.         $this->API->execute();
  381.         // It will verify if there is a profile picture which is related to the User searched, when another if-statement will verify if the User has a student ID.
  382.         if ($this->API->resultSet()[0]['UserProfilePicture'] != null) {
  383.             if ($this->API->resultSet()[0]['UserStudentId'] != null) {
  384.                 $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  385.                 $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  386.                 $this->setStudentId($this->API->resultSet()[0]['UserStudentId']);
  387.                 $this->setProfilePicture($this->API->resultSet()[0]['UserProfilePicture']);
  388.                 $this->setType($this->API->resultSet()[0]['UserType']);
  389.             } else {
  390.                 $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  391.                 $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  392.                 $this->setProfilePicture($this->API->resultSet()[0]['UserProfilePicture']);
  393.                 $this->setType($this->API->resultSet()[0]['UserType']);
  394.             }
  395.         } else {
  396.             if ($this->API->resultSet()[0]['UserStudentId'] != null) {
  397.                 $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  398.                 $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  399.                 $this->setStudentId($this->API->resultSet()[0]['UserStudentId']);
  400.                 $this->setType($this->API->resultSet()[0]['UserType']);
  401.             } else {
  402.                 $this->setMailAddress($this->API->resultSet()[0]['UserMailAddress']);
  403.                 $this->setPassword($this->API->resultSet()[0]['UserPassword']);
  404.                 $this->setType($this->API->resultSet()[0]['UserType']);
  405.             }
  406.         }
  407.     }
  408.     // Profile Icon method
  409.     public function profileIcon() {
  410.         // Calling Profile Checker method
  411.         $this->profileChecker();
  412.         // The statement will verify there is a profile picture which is related to the user and if, it is the case, it will fetch the url of that picture, else, it will fetch an .svg file from a script.
  413.         if ($this->API->resultSet()[0]['UserProfilePicture'] != null) {
  414.             $pp = "http://stormysystem.ddns.net" . $this->getProfilePicture();
  415.             echo "<img src='{$pp}' />";
  416.         } else {
  417.             echo "<i class='fa fa-user faProfileCustom faProfileCustom1'></i>";
  418.         }
  419.     }
  420.     // Profile Mail method
  421.     public function profileMail() {
  422.         // Calling Profile Checker method
  423.         $this->profileChecker();
  424.         // Creating a h1 tag which will be rendered given that User.getMailAddress() is called.
  425.         $h1WelcomeText = "<h1>Hello, {$this->getMailAddress()}</h1>";
  426.         echo $h1WelcomeText;
  427.     }
  428.     // Profile Type Checker method
  429.     public function profileTypeChecker() {
  430.         // This statement will check for the value to print the type into a string given that it is saved in the system as an integer.
  431.         switch ($this->getType()) {
  432.             case 1:
  433.                 echo "Student";
  434.                 break;
  435.             case 2:
  436.                 echo "Non-Academical Staff";
  437.                 break;
  438.             case 3:
  439.                 echo "Academical Staff";
  440.                 break;
  441.             case 4:
  442.                 echo "Administrator";
  443.                 break;
  444.             default:
  445.                 echo "<h1 id='detail'>Banned</h1>";
  446.                 break;
  447.         }
  448.     }
  449. }
  450. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement