index.php 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once 'action.php';
  3. require_once 'db.php';
  4. require_once 'token.php';
  5. require_once 'stats.php';
  6. $ip = ip2long(substr(trim($_GET['ip']),0,15));
  7. $token = substr(trim($_GET['token']),0,32);
  8. $action = substr(trim($_GET['action']),0,9);
  9. $clientIP = ip2long(substr(trim($_SERVER['REMOTE_ADDR']),0,15));
  10. $stats = true;
  11. $act = new action;
  12. if($act->isBlocked($clientIP)) {
  13. http_response_code(403);
  14. exit;
  15. }
  16. if (!(new token)->isReporter($token)) {
  17. $act->block($clientIP);
  18. echo "client access denied";
  19. exit;
  20. }
  21. if($stats == true) {
  22. (new stats)->log($clientIP,$ip,$action,$token);
  23. }
  24. switch($action) {
  25. case 'delist':
  26. if($act->delist($ip)){
  27. echo long2ip($ip) . " delisted\n";
  28. } else {
  29. echo long2ip($ip) . " not delisted\n";
  30. };
  31. break;
  32. default:
  33. if($act->list($ip)){
  34. echo " inserted " . long2ip($ip) ."\n";
  35. } else {
  36. echo " fehler\n";
  37. };
  38. }