Updated calls for user session
Users token session must be set for calls to work
This commit is contained in:
parent
5fafca6dd4
commit
c435d43137
17
calls.php
17
calls.php
|
@ -2,9 +2,11 @@
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once('class.php');
|
require_once('class.php');
|
||||||
$idle = new idlers();
|
$auth = new auth();
|
||||||
|
$auth->sessionStartIfNone();
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
if (isset($_SESSION['token'])) {
|
||||||
|
$idle = new idlers();
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
if (isset($_GET['type'])) {
|
if (isset($_GET['type'])) {
|
||||||
if ($_GET['type'] == 'server') {
|
if ($_GET['type'] == 'server') {
|
||||||
echo $idle->serverData($_GET['id']);
|
echo $idle->serverData($_GET['id']);
|
||||||
|
@ -52,7 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
echo $idle->compareTable($_GET['server1'], $_GET['server2']);
|
echo $idle->compareTable($_GET['server1'], $_GET['server2']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
if (isset($_POST['order_form'])) {
|
if (isset($_POST['order_form'])) {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo $idle->orderTable($_POST['order_by']);//Returns order table
|
echo $idle->orderTable($_POST['order_by']);//Returns order table
|
||||||
|
@ -97,4 +99,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
header('Location:index.php');
|
header('Location:index.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header('HTTP/1.1 401 Unauthorized');
|
||||||
|
echo json_encode(array(
|
||||||
|
'code' => 401,
|
||||||
|
'message' => 'Unauthorized'));
|
||||||
|
exit;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user