Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const BLOCKED_COUNTRIES = [
- 'russia',
- 'indonesia',
- 'china',
- 'poland',
- ];
- const REDIRECT_URL = 'https://firmamaja.com/404.htm';
- header('Content-Type: application/json');
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? null;
- if (null === $ip) {
- echo json_encode([
- 'success' => false,
- ]);
- exit;
- }
- $query = @unserialize(file_get_contents("http://ip-api.com/php/$ip"));
- if (empty($query) || empty($query['status']) || $query['status'] !== 'success') {
- echo json_encode([
- 'success' => false,
- ]);
- exit;
- }
- echo json_encode([
- 'success' => in_array(strtolower($query['country']), BLOCKED_COUNTRIES),
- 'redirect_url' => REDIRECT_URL,
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement