Advertisement
JackStoping

Untitled

Sep 27th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. $gi = geoip_open("vendor/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
  2. $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
  3. $country = $record->country_code;
  4. geoip_close($gi);
  5.  
  6.  
  7.  
  8. function BannedRedir(){
  9. global $rederict_url;
  10. header("Location: {$rederict_url}");
  11. die();
  12. }
  13.  
  14. function WriteStat(){
  15. global $_SERVER, $_COOKIE, $country;
  16.  
  17. if(!$_COOKIE['dont_write_stat']){
  18. $stat_string = time().']['.$_SERVER['REMOTE_ADDR'].']['.$_SERVER['HTTP_REFERER'].']['.$country.']['.$_SERVER['REQUEST_URI'].'||';
  19. @file_put_contents('file/stat.txt', $stat_string, FILE_APPEND | LOCK_EX);
  20. setcookie("dont_write_stat", '1', time()+84600, '/');
  21. }
  22. }
  23.  
  24.  
  25. if(!in_array($country, array_filter(explode(',', file_get_contents('file/country_ban.txt'))))){
  26.  
  27. $ip_mask = explode('.', $_SERVER['REMOTE_ADDR']);
  28. $ip_array = array_filter(explode(',', file_get_contents('file/ip_ban.txt')));
  29.  
  30.  
  31. if( in_array($_SERVER['REMOTE_ADDR'], $ip_array) OR
  32. in_array($ip_mask[0].'.'.$ip_mask[1].'.*.*', $ip_array) OR
  33. in_array($ip_mask[0].'.'.$ip_mask[1].'.'.$ip_mask[2].'.*', $ip_array) ){
  34. BannedRedir();
  35. }
  36. else{
  37. WriteStat();
  38. }
  39.  
  40. }else{
  41. BannedRedir();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement