-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokento.php
More file actions
executable file
·39 lines (36 loc) · 911 Bytes
/
Copy pathtokento.php
File metadata and controls
executable file
·39 lines (36 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require "./vendor/autoload.php";
use \Firebase\JWT\JWT;
//$skey = md5("FMyNTYiLCJ0eX5180112");
$skey = md5("FMyNTYiLCJ0eX5".date("ymd"));
if($_SERVER['REQUEST_METHOD']=='OPTIONS') die();
$head = getallheaders();
// file_put_contents('udaa.txt', print_r($head, true), FILE_APPEND );
if(isset($head['Authorization'])){
$token = $head['Authorization'];
}
else{
if(isset($_GET['au-token'])){
$token = $_GET['au-token'];
}
else{
if(isset($_POST['au-token'])){
$token = $_POST['au-token'];
}
else{
require_once "echoErr.php";
echoErr( (object)[ 'error' => 'tokenator', 'code' => 401, 'message' => 'Unauthorized nema go' ] );
die();
}
}
}
try{
$decoded = JWT::decode($token ,$skey, ['HS256']);
}
catch(Exception $err) {
echoErr( (object)[ 'error' => 'tokenator', 'code' => 401, 'message' => 'Unauthorized, bad token!' ] );
die();
}
// print_r($decoded);
return $decoded;
?>