isat.php 821 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. error_reporting(0);
  3. header('HTTP/1.1 404 Not Found');
  4. header('Access-Control-Allow-Origin: *');
  5. header('Cache-Control: private, no-cache, no-store, max-age=0');
  6. //
  7. // { Example API for IsAT }
  8. //
  9. define('JSON_DIR', 'listdata/');
  10. //
  11. //
  12. if (!file_exists(JSON_DIR) || !file_exists(JSON_DIR . 'antitor_e.json'))
  13. {
  14. die('File Not Found');
  15. }
  16. elseif ($_SERVER['REQUEST_METHOD'] != 'POST')
  17. {
  18. echo ('OK');
  19. exit;
  20. }
  21. header('Content-Type: application/json');
  22. $fqdn = htmlspecialchars($_POST['f']);
  23. if (!preg_match("/^([a-z0-9]{1})([a-z0-9.-]{0,254})\.([a-z]{2,50})$/", $fqdn))
  24. {
  25. echo ('[false,false]');
  26. exit;
  27. }
  28. $got = @json_decode(file_get_contents(JSON_DIR . 'antitor_' . $fqdn[0] . '.json') , true);
  29. if (!is_array($got))
  30. {
  31. die('File Error');
  32. }
  33. echo (isset($got[$fqdn]) ? '[true,true]' : '[true,false]');