summaryrefslogtreecommitdiffstats
path: root/apis/debugrequest.php
blob: f8e728e71c868a12da4474ea0c13b9fb60de5f6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$debug_settings = Property::getRemoteDebuggingConfig();
if ($debug_settings["enabled"] !== true) {
  http_response_code(403);
  exit;
}

$debug_request = split(":", file_get_contents("php://input"), 2);

$uuid = $debug_request[0];
$port = 5900 + $debug_request[1];

$validclient = Database::queryFirst("SELECT machineuuid, clientip FROM machine WHERE machineuuid = :uuid AND clientip = :ip", array(":uuid" => "$debug_request[0]", ":ip" => $_SERVER["REMOTE_ADDR"]));

if ($validclient == false) {
  http_response_code(400);
} else {
  http_response_code(200);
  $data = json_encode(array("hosts" => array($_SERVER["REMOTE_ADDR"], $debug_settings["debugServer"]), 
	"ports" => array($port, $debug_settings["port"])));
  Taskmanager::submit('DispatchRelay', $data, true);
}