diff --git a/Repositories/statistics/scripts/eprints-usage_src.php b/Repositories/statistics/scripts/eprints-usage_src.php index 31619f0..366a00e 100755 --- a/Repositories/statistics/scripts/eprints-usage_src.php +++ b/Repositories/statistics/scripts/eprints-usage_src.php @@ -1,5 +1,9 @@ ip2long('139.80.0.0'), + 'upper' => ip2long('139.80.127.255'), + ), +); + ########################################### ## ## No configuration required below here. @@ -68,11 +82,31 @@ { $counter++; $country_code = ''; + $country_name = ''; $insertid = ''; $eprint_name = ''; $view_type = ''; $uniquebits = ''; $ip = $matches[1]; + + // Determine country code and name. + // If the number falls into the local intranet range, then + // use that instead of GeoIP. + $ip_long = ip2long($ip); + foreach ($local_IPs as $key => $range) + { + if (($ip_long >= $range['lower']) && ($ip_long <= $range['upper'])) + { + $country_code = 'T5'; + $country_name = $local_name; + } + else + { + $country_code = geoip_country_code_by_addr($gi, $ip); + $country_name = geoip_country_name_by_addr($gi, $ip); + } + } + $date = $matches[2]; $archive = $matches[3]; $uniquebits = $buffer;