1
0

ami4get.php 892 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. header("Content-Type: application/json");
  3. header("Access-Control-Allow-Origin: *");
  4. include "data/config.php";
  5. // get request count in last 24 hours
  6. $bot_requests = 0;
  7. $real_requests = 0;
  8. $time = time();
  9. for($i=0; $i<24; $i++){
  10. $bot_requests += apcu_fetch(intdiv($time - (3600 * $i), 3600) . ".bot_requests");
  11. }
  12. for($i=0; $i<24; $i++){
  13. $real_requests += apcu_fetch(intdiv($time - (3600 * $i), 3600) . ".real_requests");
  14. }
  15. echo json_encode(
  16. [
  17. "status" => "ok",
  18. "service" => "4get",
  19. "server" => [
  20. "name" => config::SERVER_NAME,
  21. "description" => config::SERVER_LONG_DESCRIPTION,
  22. "bot_protection" => config::BOT_PROTECTION,
  23. "real_requests" => $real_requests,
  24. "bot_requests" => $bot_requests,
  25. "api_enabled" => config::API_ENABLED,
  26. "alt_addresses" => config::ALT_ADDRESSES,
  27. "version" => config::VERSION
  28. ],
  29. "instances" => config::INSTANCES
  30. ]
  31. );