-
Notifications
You must be signed in to change notification settings - Fork 0
/
getServiceCheck.php
27 lines (20 loc) · 731 Bytes
/
getServiceCheck.php
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
<?php
error_reporting(0);
ignore_user_abort(true);
set_time_limit(300);
require_once 'autoloader.php';
use service\LogService;
use service\ServiceCheckService;
header('Content-Type: application/json; charset=utf-8');
if ($_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['SERVER_ADDR']) {
LogService::warning("Not allowed try to access by '{$_SERVER['HTTP_X_FORWARDED_FOR']}'");
exit('{"status": "success"}');
}
try {
$response = ServiceCheckService::checkEncryptedService($_GET['id'], $_SERVER['HTTP_DATE']);
if (!$response) throw new Exception();
} catch (Throwable $throwable) {
LogService::error("Error when checking service", $throwable);
exit('{"status": "unknown"}');
}
echo json_encode($response);