我有同樣的問題。看起來,自2.xx版本開始,OpenX使用自己的基於php的GeoIP數據庫讀取器(例如設置下的「flatfile」選項),而不是使用geoip模塊 - 它似乎不適用於當前的GeoIP.dat
爲了解決這個問題,我做了以下內容:
1)開放插件/地理位置定位的/ oxMaxMindGeoIP/oxMaxMindGeoIP.delivery.php
2)搜索:
if (isset($GLOBALS['_MAX']['GEO_IP'])) {
$ip = $GLOBALS['_MAX']['GEO_IP'];
OX_Delivery_logMessage('['.$ip.'] : ip from cookie. Plugin_geoTargeting_oxMaxMindGeoIP_oxMaxMindGeoIP_Delivery_getGeoInfo', 7);
} else {
$ip = $_SERVER['REMOTE_ADDR'];
OX_Delivery_logMessage('['.$ip.'] : ip from remote addr. Plugin_geoTargeting_oxMaxMindGeoIP_oxMaxMindGeoIP_Delivery_getGeoInfo', 7);
}
$aGeoConf = (is_array($conf['oxMaxMindGeoIP'])) ? $conf['oxMaxMindGeoIP'] : array();
3)下面插入:
$ret = array(
"country_code" => $_SERVER['GEOIP_COUNTRY_CODE']
);
return $ret;
4)保存&做
您將在函數頭找到可能的返回值:
* @return array An array(
* 'country_code',
* 'region',
* 'city',
* 'postal_code',
* 'latitude',
* 'longitude',
* 'dma_code',
* 'area_code',
* 'organisation',
* 'isp',
* 'netspeed'
* );
*/
讀你的模塊,文檔(的mod_geoip)如何從當前(或給定)IP獲取地理數據。在我上面的例子中,我使用了lighttpd 1.5 + mod_geoip(非官方模塊)。但此修補程序也應該與apache_note/pecl-geoip/mod_geoip env ...
哦,順便說一句。當然,它依靠mod_geoip在內存中緩存數據庫的速度要快得多,而不是在每次請求時都通過php來完成(就像openx一樣)。