Merge branch 'w19_MDL-32793_m23_iplookup' of git://github.com/skodak/moodle
This commit is contained in:
+22
-34
@@ -71,46 +71,34 @@ function iplookup_find_location($ip) {
|
||||
} else {
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$ipdata = download_file_content('http://netgeo.caida.org/perl/netgeo.cgi?target='.$ip);
|
||||
if ($ipdata === false) {
|
||||
$info['error'] = get_string('cannotnetgeo', 'error');
|
||||
$ipdata = download_file_content('http://www.geoplugin.net/json.gp?ip='.$ip);
|
||||
if ($ipdata) {
|
||||
$ipdata = preg_replace('/^geoPlugin\((.*)\)\s*$/s', '$1', $ipdata);
|
||||
$ipdata = json_decode($ipdata, true);
|
||||
}
|
||||
if (!is_array($ipdata)) {
|
||||
$info['error'] = get_string('cannotgeoplugin', 'error');
|
||||
return $info;
|
||||
}
|
||||
$matches = null;
|
||||
if (!preg_match('/LAT:\s*(-?\d+\.\d+)/s', $ipdata, $matches)) {
|
||||
$info['error'] = get_string('iplookupfailed', 'error', $ip);
|
||||
return $info;
|
||||
}
|
||||
$info['latitude'] = (float)$matches[1];
|
||||
if (!preg_match('/LONG:\s*(-?\d+\.\d+)/s', $ipdata, $matches)) {
|
||||
$info['error'] = get_string('iplookupfailed', 'error', $ip);
|
||||
return $info;
|
||||
}
|
||||
$info['longitude'] = (float)$matches[1];
|
||||
$info['latitude'] = (float)$ipdata['geoplugin_latitude'];
|
||||
$info['longitude'] = (float)$ipdata['geoplugin_longitude'];
|
||||
$info['city'] = s($ipdata['geoplugin_city']);
|
||||
|
||||
if (preg_match('/CITY:\s*([^<]*)/', $ipdata, $matches)) {
|
||||
if (!empty($matches[1])) {
|
||||
$info['city'] = s($matches[1]);
|
||||
$info['title'][] = $info['city'];
|
||||
}
|
||||
$countrycode = $ipdata['geoplugin_countryCode'];
|
||||
$countries = get_string_manager()->get_list_of_countries(true);
|
||||
if (isset($countries[$countrycode])) {
|
||||
// prefer our localized country names
|
||||
$info['country'] = $countries[$countrycode];
|
||||
} else {
|
||||
$info['country'] = s($ipdata['geoplugin_countryName']);
|
||||
}
|
||||
|
||||
if (preg_match('/COUNTRY:\s*([^<]*)/', $ipdata, $matches)) {
|
||||
if (!empty($matches[1])) {
|
||||
$countrycode = $matches[1];
|
||||
$countries = get_string_manager()->get_list_of_countries(true);
|
||||
if (isset($countries[$countrycode])) {
|
||||
// prefer our localized country names
|
||||
$info['country'] = $countries[$countrycode];
|
||||
} else {
|
||||
$info['country'] = $countrycode;
|
||||
}
|
||||
$info['title'][] = $info['country'];
|
||||
}
|
||||
}
|
||||
$info['note'] = get_string('iplookupnetgeonote', 'admin');
|
||||
$info['note'] = get_string('iplookupgeoplugin', 'admin');
|
||||
|
||||
$info['title'][] = $info['country'];
|
||||
$info['title'][] = $info['city'];
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -585,11 +585,11 @@ $string['ipblocked'] = 'This site is not available currently.';
|
||||
$string['ipblocker'] = 'IP blocker';
|
||||
$string['ipblockersyntax'] = 'Put every entry on one line. Valid entries are either full IP address (such as <b>192.168.10.1</b>) which matches a single host; or partial address (such as <b>192.168.</b>) which matches any address starting with those numbers; or CIDR notation (such as <b>231.54.211.0/20</b>); or a range of IP addresses (such as <b>231.3.56.10-20</b>) where the range applies to the last part of the address. Text domain names (like \'example.com\') are not supported. Blank lines are ignored.';
|
||||
$string['iplookup'] = 'IP address lookup';
|
||||
$string['iplookupgeoplugin'] = '<a href="http://www.geoplugin.com">geoPlugin</a> service is currently being used to look up geographical information. For more accurate results we recommend installing a local copy of the MaxMind GeoLite database.';
|
||||
$string['iplookupinfo'] = 'By default Moodle uses the free online NetGeo (The Internet Geographic Database) server to lookup location of IP addresses, unfortunately this database is not maintained anymore and may return <em>wildly incorrect</em> data.
|
||||
It is recommended to install local copy of free GeoLite City database from MaxMind.<br />
|
||||
IP address location is displayed on simple map or using Google Maps. Please note that you need to have a Google account and apply for free Google Maps API key to enable interactive maps.';
|
||||
$string['iplookupmaxmindnote'] = 'This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com/">http://www.maxmind.com/</a>.';
|
||||
$string['iplookupnetgeonote'] = 'The NetGeo server is currently being used to look up geographical information. For more accurate results we recommend installing a local copy of the MaxMind GeoLite database.';
|
||||
$string['keeptagnamecase'] = 'Keep tag name casing';
|
||||
$string['lang'] = 'Default language';
|
||||
$string['langcache'] = 'Cache language menu';
|
||||
|
||||
+1
-1
@@ -85,6 +85,7 @@ $string['cannotfindinfo'] = 'Cannot find info for: "{$a}"';
|
||||
$string['cannotfindlang'] = 'Cannot find "{$a}" language pack!';
|
||||
$string['cannotfindteacher'] = 'Cannot find teacher';
|
||||
$string['cannotfinduser'] = 'Cannot find user named "{$a}"';
|
||||
$string['cannotgeoplugin'] = 'Cannot connect to geoPlugin server at http://www.geoplugin.com, please check proxy settings or better install MaxMind GeoLite City data file';
|
||||
$string['cannotgetblock'] = 'Could not retrieve blocks from the database';
|
||||
$string['cannotgetcats'] = 'Cannot get category record';
|
||||
$string['cannotgetdata'] = 'Cannot get data';
|
||||
@@ -104,7 +105,6 @@ $string['cannotmigratedatacomments'] = 'Cannot migrate data module comments';
|
||||
$string['cannotmodulename'] = 'Cannot get the module name in build navigation';
|
||||
$string['cannotmoduletype'] = 'Cannot get the module type in build navigation';
|
||||
$string['cannotmoverolewithid'] = 'Cannot move role with ID {$a}';
|
||||
$string['cannotnetgeo'] = 'Cannot connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file';
|
||||
$string['cannotopencsv'] = 'Cannot open CSV file';
|
||||
$string['cannotopenfile'] = 'Cannot open file ({$a})';
|
||||
$string['cannotopenforwrit'] = 'Cannot open for writing: {$a}';
|
||||
|
||||
Reference in New Issue
Block a user