connection = $db; } public function read_api_auth(){ // $bearer = $this->bearer_token; if(!function_exists('getallheaders')){ return false; } $headers = []; foreach (getallheaders() as $name => $value) { // echo "$name: $value
" . PHP_EOL; $headers[$name] = $value; } $check = array_key_exists('Authorization', $headers); if ($check == false) { return false; } list($type, $bearer_token) = explode(" ", $headers['Authorization'], 2); $query = 'SELECT id, name FROM auth_users WHERE bearer_token = ? LIMIT 0,1'; $statement = $this->connection->prepare($query); $statement->bindParam(1, $bearer_token); $statement->execute(); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row == false) { return false; } else{ return true; } } }