Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $gi = geoip_open("vendor/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
- $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
- $country = $record->country_code;
- geoip_close($gi);
- function BannedRedir(){
- global $rederict_url;
- header("Location: {$rederict_url}");
- die();
- }
- function WriteStat(){
- global $_SERVER, $_COOKIE, $country;
- if(!$_COOKIE['dont_write_stat']){
- $stat_string = time().']['.$_SERVER['REMOTE_ADDR'].']['.$_SERVER['HTTP_REFERER'].']['.$country.']['.$_SERVER['REQUEST_URI'].'||';
- @file_put_contents('file/stat.txt', $stat_string, FILE_APPEND | LOCK_EX);
- setcookie("dont_write_stat", '1', time()+84600, '/');
- }
- }
- if(!in_array($country, array_filter(explode(',', file_get_contents('file/country_ban.txt'))))){
- $ip_mask = explode('.', $_SERVER['REMOTE_ADDR']);
- $ip_array = array_filter(explode(',', file_get_contents('file/ip_ban.txt')));
- if( in_array($_SERVER['REMOTE_ADDR'], $ip_array) OR
- in_array($ip_mask[0].'.'.$ip_mask[1].'.*.*', $ip_array) OR
- in_array($ip_mask[0].'.'.$ip_mask[1].'.'.$ip_mask[2].'.*', $ip_array) ){
- BannedRedir();
- }
- else{
- WriteStat();
- }
- }else{
- BannedRedir();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement