-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_server.php
More file actions
38 lines (28 loc) · 871 Bytes
/
Copy pathauth_server.php
File metadata and controls
38 lines (28 loc) · 871 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
<?php
$method = strtoupper( $_SERVER['REQUEST_METHOD'] );
$token = "5d0937455b6744.68357201";
if ( $method === 'POST' ) {
if ( !array_key_exists( 'HTTP_X_CLIENT_ID', $_SERVER ) || !array_key_exists( 'HTTP_X_SECRET', $_SERVER ) ) {
http_response_code( 400 );
die( 'Faltan parametros' );
}
$clientId = $_SERVER['HTTP_X_CLIENT_ID'];
$secret = $_SERVER['HTTP_X_SECRET'];
if ( $clientId !== '1' || $secret !== 'SuperSecreto!' ) {
http_response_code( 403 );
die ( "No autorizado");
}
echo "$token";
} elseif ( $method === 'GET' ) {
if ( !array_key_exists( 'HTTP_X_TOKEN', $_SERVER ) ) {
http_response_code( 400 );
die ( 'Faltan parametros' );
}
if ( $_SERVER['HTTP_X_TOKEN'] == $token ) {
echo 'true';
} else {
echo 'false';
}
} else {
echo 'false';
}