#!/usr/bin/php &$xxx) { $country = strtolower($country); $xxx = ipv6_merge_address_blocks($xxx, "$country: Step 2 - "); // --- CIDR finden --- echo "$country: Step 3 - Analyze address ranges and write CIDR blocks\n"; $hf = fopen(DIR . "/out/ipv6_{$country}_cidr.new", 'w'); $hb = fopen(DIR . "/out/ipv6_{$country}_blocks.new", 'w'); foreach ($xxx as $baseip => &$topip) { fwrite($hb, "$baseip - $topip\n"); control_cache(); $rirstat_file = ipv6_range2cidr($baseip, $topip); foreach ($rirstat_file as $x) { fwrite($hf, "$x\n"); } } fclose($hb); fclose($hf); rename(DIR . "/out/ipv6_{$country}_cidr.new", DIR . "/out/ipv6_{$country}_cidr"); rename(DIR . "/out/ipv6_{$country}_blocks.new", DIR . "/out/ipv6_{$country}_blocks"); $written_files[] = DIR . "/out/ipv6_{$country}_cidr"; $written_files[] = DIR . "/out/ipv6_{$country}_blocks"; } $all_files = glob(DIR . "/out/ipv6_*"); foreach ($all_files as $file) { if (!in_array($file, $written_files)) { unlink($file); echo "Deleted because not touched: $file\n"; } } echo "Finished!\n"; # --- function control_cache() { $limit = 10000; global $cache_ipv6_cidr2range; if (count($cache_ipv6_cidr2range) > $limit) $cache_ipv6_cidr2range = array(); global $cache_ipv6_range2cidr; if (count($cache_ipv6_range2cidr) > $limit) $cache_ipv6_range2cidr = array(); global $cache_ipv6_in_cidr; if (count($cache_ipv6_in_cidr) > $limit) $cache_ipv6_in_cidr = array(); global $cache_ip2long6; if (count($cache_ip2long6) > $limit) $cache_ip2long6 = array(); global $cache_long2ip6; if (count($cache_long2ip6) > $limit) $cache_long2ip6 = array(); global $cache_ip2bin; if (count($cache_ip2bin) > $limit) $cache_ip2bin = array(); global $cache_bin2ip; if (count($cache_bin2ip) > $limit) $cache_bin2ip = array(); /* global $cache_ipv6_cidr2range; while (count($cache_ipv6_cidr2range) > $limit) array_shift($cache_ipv6_cidr2range); global $cache_ipv6_range2cidr; while (count($cache_ipv6_range2cidr) > $limit) array_shift($cache_ipv6_range2cidr); global $cache_ipv6_in_cidr; while (count($cache_ipv6_in_cidr) > $limit) array_shift($cache_ipv6_in_cidr); global $cache_ip2long6; while (count($cache_ip2long6) > $limit) array_shift($cache_ip2long6); global $cache_long2ip6; while (count($cache_long2ip6) > $limit) array_shift($cache_long2ip6); global $cache_ip2bin; while (count($cache_ip2bin) > $limit) array_shift($cache_ip2bin); global $cache_bin2ip; while (count($cache_bin2ip) > $limit) array_shift($cache_bin2ip); */ } ?>