iplookup_find_location 函式,增加 countrycode 的回傳。
[root@dywang html]# diff -urN -wbBE moodle/iplookup/lib.php moodle23/iplookup/lib.php
--- moodle/iplookup/lib.php 2012-06-26 01:14:20.000000000 +0800
+++ moodle23/iplookup/lib.php 2014-01-19 19:28:36.000000000 +0800
@@ -34,7 +34,7 @@
function iplookup_find_location($ip) {
global $CFG;
- $info = array('city'=>null, 'country'=>null, 'longitude'=>null, 'latitude'=>null, 'error'=>null, 'note'=>”, 'title'=>array());
+ $info = array('city'=>null, 'country'=>null, 'countrycode'=>null, 'longitude'=>null, 'latitude'=>null, 'error'=>null, 'note'=>”, 'title'=>array()); //dywang
if (!empty($CFG->geoipfile) and file_exists($CFG->geoipfile)) {
require_once('Net/GeoIP.php');
@@ -57,6 +57,7 @@
if (isset($countries[$location->countryCode])) {
// prefer our localized country names
$info['country'] = $countries[$location->countryCode];
+ $info['countrycode'] = $location->countryCode;
} else {
$info['country'] = $location->countryName;
}
@@ -94,6 +95,7 @@
if (isset($countries[$countrycode])) {
// prefer our localized country names
$info['country'] = $countries[$countrycode];
+ $info['countrycode'] = $countrycode;
} else {
$info['country'] = s($ipdata['geoplugin_countryName']);
}
[root@dywang html]# diff -urN -wbBE moodle/iplookup/index.php moodle23/iplookup/index.php
--- moodle/iplookup/index.php 2010-08-10 08:01:12.000000000 +0800
+++ moodle23/iplookup/index.php 2014-01-19 21:25:33.000000000 +0800
@@ -93,7 +92,8 @@
echo '<img src="earth.jpeg" style="width:'.$imgwidth.'px; height:'.$imgheight.'px" alt="" />';
echo '<img src="marker.gif" style="width:'.$dotwidth.'px; height:'.$dotheight.'px; margin-left:'.$dx.'px; margin-bottom:'.$dy.'px;" alt="" />';
echo '</div>';
- echo '<div id="note">'.$info['note'].'</div>';
+ //echo '<div id="note">'.$info['note'].'</div>';
+ echo '<div id="note">'.$ip.' --- '.$info['city'].'/'.$info['country'].'</div>'; //dywang
} else {
$PAGE->requires->js(new moodle_url("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey"));