| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- class token {
- private $db = null;
- public function __construct() {
- $this->db = new db();
- }
- private function getRole($token) {
- $dbAction = $this->db->prepare("SELECT role FROM clients WHERE token = ?");
- $dbAction->bind_param('s',$token);
- $dbAction->execute();
- $dbAction->store_result();
- $dbAction->bind_result($role);
- $dbAction->fetch();
- if ($dbAction->num_rows() == 1){
- return $role;
- }
- return false;
- }
- public function isAdmin($token) {
- if($this->getRole($token) == 'admin') {
- return true;
- }
- return false;
- }
- public function isClient($token) {
- if($this->getRole($token) == 'client') {
- return true;
- }
- return false;
- }
- }
|