Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $file_to_update = './geo-country.conf';
- set_time_limit(10000);
- // Ищем все диапазоны адресов
- $db = file_get_contents('cidr_optim.txt');
- $db = mb_convert_encoding($db, 'utf8', 'cp1251');
- $db = explode("\n", $db);
- $addrs = array();
- foreach ($db as $key=>$row){
- $rowset = explode("\t", $row);
- if (!isset ($rowset[3]))
- continue;
- $addrs[$rowset[3]][] = str_replace (' ', '', $rowset[2]);
- }
- $config = '';
- foreach ($addrs as $country=>$ips){
- foreach ($ips as $ip){
- $config .= $ip . "\t" . $country . ";\n";
- }
- }
- file_put_contents($file_to_update, $config);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement