index.php 997 B

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