Advertisement
dizballanze

make country nginx

Oct 21st, 2011
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.     $file_to_update = './geo-country.conf';
  3.     set_time_limit(10000);
  4.    
  5.     // Ищем все диапазоны адресов
  6.     $db = file_get_contents('cidr_optim.txt');
  7.     $db = mb_convert_encoding($db, 'utf8', 'cp1251');
  8.     $db = explode("\n", $db);
  9.     $addrs = array();
  10.     foreach ($db as $key=>$row){
  11.         $rowset = explode("\t", $row);
  12.         if (!isset ($rowset[3]))
  13.             continue;
  14.         $addrs[$rowset[3]][] = str_replace (' ', '', $rowset[2]);
  15.     }
  16.    
  17.     $config = '';
  18.     foreach ($addrs as $country=>$ips){
  19.         foreach ($ips as $ip){
  20.             $config .= $ip . "\t" . $country . ";\n";
  21.         }
  22.     }
  23.     file_put_contents($file_to_update, $config);
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement