summaryrefslogtreecommitdiffstats
path: root/apis/debugrequest.php
blob: d9f1a169f4fb9ef2ac64d703c0bc99c2d1deba6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

$debug_settings = Property::getRemoteDebuggingConfig();
if ($debug_settings["status"] !== "enabled") {
  http_response_code(403);
  exit;
}

$debug_request = json_decode(file_get_contents("php://input"));

$validclient = Database::queryFirst("SELECT * FROM machine WHERE machineuuid = :uuid AND clientip = :ip", array(":uuid" => $debug_request["uuid"], ":ip" => $_SERVER["REMOTE_ADDR"]));
if ($validclient == false) {
  http_response_code(400);
} else {
  http_response_code(200);
  $data = json_encode(array("uuid" => $debug_request["uuid"], "ip" => $_SERVER["REMOTE_ADDR"], "port" => $debug_request["port"]));
  Taskmanager::submit('relay', $data, true);
}