Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $bad_ips = array('23.103.144.', '23.103.149.', '23.103.155.', '69.167.');
- $bad_uas = array('Wget', 'python', 'Python', 'Go-http-client', 'Twisted', "'", "{", 'Microsoft', 'Java');
- $bad_ccs = array('CN');
- function BlockByIp($ip)
- {
- global $bad_ips;
- foreach ($bad_ips as $bip)
- {
- if (strpos($ip, $bip) === 0) die();
- }
- return;
- }
- function BlockByUserAgent($ua)
- {
- global $bad_uas;
- foreach ($bad_uas as $bua)
- {
- if (strpos($ua, $bua) === 0) die();
- }
- return;
- }
- function BlockByCountryCode($cc)
- {
- global $bad_ccs;
- foreach ($bad_ccs as $cci)
- {
- if (strpos($cc, $cci) === 0) die();
- }
- return;
- }
- function GetIp()
- {
- if (isset($_SERVER['X_FORWARDED_FOR']))
- {
- $ip = $_SERVER['X_FORWARDED_FOR'];
- } else {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- return $ip;
- }
- function GetUserAgent()
- {
- return $_SERVER['HTTP_USER_AGENT'];
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement