Updated calls for user session
Users token session must be set for calls to work
This commit is contained in:
parent
5fafca6dd4
commit
c435d43137
187
calls.php
187
calls.php
|
@ -2,99 +2,108 @@
|
||||||
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'])) {
|
||||||
if (isset($_GET['type'])) {
|
$idle = new idlers();
|
||||||
if ($_GET['type'] == 'server') {
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
echo $idle->serverData($_GET['id']);
|
if (isset($_GET['type'])) {
|
||||||
} elseif ($_GET['type'] == 'search') {
|
if ($_GET['type'] == 'server') {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
echo $idle->serverData($_GET['id']);
|
||||||
echo $idle->searchResults($_GET['value']);
|
} elseif ($_GET['type'] == 'search') {
|
||||||
} elseif ($_GET['type'] == 'shared_hosting') {
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo $idle->sharedHostingData($_GET['id']);
|
echo $idle->searchResults($_GET['value']);
|
||||||
} elseif ($_GET['type'] == 'domain') {
|
} elseif ($_GET['type'] == 'shared_hosting') {
|
||||||
echo $idle->domainData($_GET['id']);
|
echo $idle->sharedHostingData($_GET['id']);
|
||||||
} elseif ($_GET['type'] == 'yabsModal') {
|
} elseif ($_GET['type'] == 'domain') {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
echo $idle->domainData($_GET['id']);
|
||||||
echo $idle->showYabsModal($_GET['id']);//Not used anymore. Still here for debugging
|
} elseif ($_GET['type'] == 'yabsModal') {
|
||||||
} elseif ($_GET['type'] == 'infoCard') {
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
echo $idle->showYabsModal($_GET['id']);//Not used anymore. Still here for debugging
|
||||||
echo $idle->infoCard();//Info card for the "info" tab
|
} elseif ($_GET['type'] == 'infoCard') {
|
||||||
} elseif ($_GET['type'] == 'autocomplete') {
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
if ($_GET['input'] == 'location') {
|
echo $idle->infoCard();//Info card for the "info" tab
|
||||||
$idle->locationsAutoCompleteGET($_GET['value']);//Auto complete locations input
|
} elseif ($_GET['type'] == 'autocomplete') {
|
||||||
} elseif ($_GET['input'] == 'provider') {
|
if ($_GET['input'] == 'location') {
|
||||||
$idle->providersAutoCompleteGET($_GET['value']);//Auto complete providers input
|
$idle->locationsAutoCompleteGET($_GET['value']);//Auto complete locations input
|
||||||
|
} elseif ($_GET['input'] == 'provider') {
|
||||||
|
$idle->providersAutoCompleteGET($_GET['value']);//Auto complete providers input
|
||||||
|
}
|
||||||
|
} elseif ($_GET['type'] == 'view_more_modal') {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
if ($_GET['value'] == 'server') {
|
||||||
|
$idle->viewMoreModal($_GET['id']);//View more details modal
|
||||||
|
} elseif ($_GET['value'] == 'shared') {
|
||||||
|
$idle->viewMoreSharedHostingModal($_GET['id']);//View more details modal
|
||||||
|
} elseif ($_GET['value'] == 'domain') {
|
||||||
|
$idle->viewMoreDomainModal($_GET['id']);//View more details modal
|
||||||
|
}
|
||||||
|
} elseif ($_GET['type'] == 'dns_search') {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
echo $idle->getIpForDomain($_GET['hostname'], $_GET['dns_type']);
|
||||||
|
} elseif ($_GET['type'] == 'check_up') {
|
||||||
|
echo $idle->checkIsUp($_GET['host']);
|
||||||
|
} elseif ($_GET['type'] == 'object_cards') {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
echo $idle->objectCards();
|
||||||
|
} elseif ($_GET['type'] == 'object_tables') {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
echo $idle->objectTables();
|
||||||
|
} elseif ($_GET['type'] == 'compare_table') {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
echo $idle->compareTable($_GET['server1'], $_GET['server2']);
|
||||||
}
|
}
|
||||||
} elseif ($_GET['type'] == 'view_more_modal') {
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
if ($_GET['value'] == 'server') {
|
|
||||||
$idle->viewMoreModal($_GET['id']);//View more details modal
|
|
||||||
} elseif ($_GET['value'] == 'shared') {
|
|
||||||
$idle->viewMoreSharedHostingModal($_GET['id']);//View more details modal
|
|
||||||
} elseif ($_GET['value'] == 'domain') {
|
|
||||||
$idle->viewMoreDomainModal($_GET['id']);//View more details modal
|
|
||||||
}
|
|
||||||
} elseif ($_GET['type'] == 'dns_search') {
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
echo $idle->getIpForDomain($_GET['hostname'], $_GET['dns_type']);
|
|
||||||
} elseif ($_GET['type'] == 'check_up') {
|
|
||||||
echo $idle->checkIsUp($_GET['host']);
|
|
||||||
} elseif ($_GET['type'] == 'object_cards') {
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
echo $idle->objectCards();
|
|
||||||
} elseif ($_GET['type'] == 'object_tables') {
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
echo $idle->objectTables();
|
|
||||||
} elseif ($_GET['type'] == 'compare_table') {
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
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
|
} else {
|
||||||
} else {
|
if (isset($_POST['action']) && $_POST['action'] == 'insert') {//From an insert 'type' form
|
||||||
if (isset($_POST['action']) && $_POST['action'] == 'insert') {//From an insert 'type' form
|
$insert = new itemInsert($_POST);
|
||||||
$insert = new itemInsert($_POST);
|
if (isset($_POST['from_yabs'])) {//From add form YABs
|
||||||
if (isset($_POST['from_yabs'])) {//From add form YABs
|
$id = $insert->insertBasicWithYabs();//Insert basic data from form
|
||||||
$id = $insert->insertBasicWithYabs();//Insert basic data from form
|
$response_code = $insert->insertYabsData();//Insert YABs data from the form
|
||||||
$response_code = $insert->insertYabsData();//Insert YABs data from the form
|
if ($response_code != 1) {
|
||||||
if ($response_code != 1) {
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
$update = new itemUpdate(array('me_server_id' => $id));
|
||||||
$update = new itemUpdate(array('me_server_id' => $id));
|
$update->deleteObjectData();
|
||||||
|
echo $response_code;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} elseif (isset($_POST['manual'])) {//From add form manual
|
||||||
|
$insert->insertBasic();
|
||||||
|
} elseif (isset($_POST['shared_hosting_form'])) {//From shared hosting form
|
||||||
|
$insert->insertSharedHosting();
|
||||||
|
} elseif (isset($_POST['domain_form'])) {//From domain form
|
||||||
|
$insert->insertDomain();
|
||||||
|
}
|
||||||
|
} elseif (isset($_POST['action']) && $_POST['action'] == 'update') {
|
||||||
|
$update = new itemUpdate($_POST);
|
||||||
|
if (isset($_POST['me_delete']) || isset($_POST['sh_me_delete']) || isset($_POST['d_me_delete'])) {//Delete object
|
||||||
$update->deleteObjectData();
|
$update->deleteObjectData();
|
||||||
echo $response_code;
|
} elseif ($_POST['type'] == 'server_modal_edit') {//Update the server info
|
||||||
exit;
|
$update->updateServerFromModal();
|
||||||
|
$update->updateServerPricingFromModal();
|
||||||
|
if (!is_null($_POST['me_yabs']) && !empty($_POST['me_yabs'])) {
|
||||||
|
$update->updateYabsData();
|
||||||
|
}
|
||||||
|
} elseif ($_POST['type'] == 'shared_hosting_modal_edit') {//Update the shared hosting info
|
||||||
|
$update->updateSharedHostingFromModal();
|
||||||
|
$update->updateSharedHostingPricingFromModal();
|
||||||
|
} elseif ($_POST['type'] == 'domain_modal_edit') {//Update the domain info
|
||||||
|
$update->updateDomainFromModal();
|
||||||
|
$update->updateDomainPricingFromModal();
|
||||||
}
|
}
|
||||||
} elseif (isset($_POST['manual'])) {//From add form manual
|
|
||||||
$insert->insertBasic();
|
|
||||||
} elseif (isset($_POST['shared_hosting_form'])) {//From shared hosting form
|
|
||||||
$insert->insertSharedHosting();
|
|
||||||
} elseif (isset($_POST['domain_form'])) {//From domain form
|
|
||||||
$insert->insertDomain();
|
|
||||||
}
|
|
||||||
} elseif (isset($_POST['action']) && $_POST['action'] == 'update') {
|
|
||||||
$update = new itemUpdate($_POST);
|
|
||||||
if (isset($_POST['me_delete']) || isset($_POST['sh_me_delete']) || isset($_POST['d_me_delete'])) {//Delete object
|
|
||||||
$update->deleteObjectData();
|
|
||||||
} elseif ($_POST['type'] == 'server_modal_edit') {//Update the server info
|
|
||||||
$update->updateServerFromModal();
|
|
||||||
$update->updateServerPricingFromModal();
|
|
||||||
if (!is_null($_POST['me_yabs']) && !empty($_POST['me_yabs'])) {
|
|
||||||
$update->updateYabsData();
|
|
||||||
}
|
|
||||||
} elseif ($_POST['type'] == 'shared_hosting_modal_edit') {//Update the shared hosting info
|
|
||||||
$update->updateSharedHostingFromModal();
|
|
||||||
$update->updateSharedHostingPricingFromModal();
|
|
||||||
} elseif ($_POST['type'] == 'domain_modal_edit') {//Update the domain info
|
|
||||||
$update->updateDomainFromModal();
|
|
||||||
$update->updateDomainPricingFromModal();
|
|
||||||
}
|
}
|
||||||
|
header('Location:index.php');
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
header('Location:index.php');
|
|
||||||
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