Source for file LGeoIP.php
Documentation is available at LGeoIP.php
* @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
* @copyright 2005, diemeisterei GmbH. All rights reserved.
* @author $Author: schmunk $
* @version $Revision: 236 $ $Date: 2006-05-30 23:39:46 +0200 (Di, 30 Mai 2006) $ $HeadURL: https://svn.sourceforge.net/svnroot/lithron/trunk/packages/LContainer/LBrick.php $
* @package Phundament.Components
* Important: Order of Overrides
* User Role 'GeoIp.CODE' (most important)
* Session Value 'LGeoIP_OverrideIp'
* Parameter 'OverrideIp' in application.xml
Prado :: setPathOfAlias("LGeoIP", dirname(__FILE__ ));
Prado :: using("LGeoIP.LGeoIP.3rdParty.GeoIP");
$this->Instance= Net_GeoIP :: getInstance(Prado :: getPathOfAlias('LGeoIP') . '/LGeoIP/3rdParty/GeoIP.dat');
if ($ip= $this->Application->Session['LGeoIP_OverrideIp'])
elseif ($ip= $this->Application->Parameters['OverrideIp']) $addr= $ip;
$addr= $_SERVER['REMOTE_ADDR'];
Prado :: trace("Remote addr: $addr", "Lithron.LGeoIP");
$this->_d['CountryCode']= $this->Instance->lookupCountryCode($addr);
$this->_d['CountryName']= $this->Instance->lookupCountryName($addr);
if (empty ($this->_d['CountryCode']))
Prado :: trace("c" . $this->_d['CountryName'], "Lithron.LGeoIP");
Prado :: trace("Country could not be detected", "Lithron.LGeoIP");
$this->_d['CountryCode']= "INT";
$this->_d['CountryName']= "International";
// TODO - BIIIIG // remove this !!!
if (isset ($_REQUEST['LGeoIP_DebugPwd']))
if ($_REQUEST['LGeoIP_DebugPwd'] == "TEMP")
$this->_d['CountryCode']= $_REQUEST['LGeoIP_CountryCode'];
$this->_d['CountryName']= "A land named: " . $_REQUEST['LGeoIP_CountryCode'];
// init is too early :( TODO - Session Hack
elseif ($this->Application->User instanceof TUser) foreach ($this->Application->User->getRoles() AS $role)
$this->Session['LGeoIP.CountryCode']= $this->_d['CountryCode']= $_override;
$this->Session['LGeoIP.CountryName']= $this->_d['CountryName']= "Admin from " . $_override;
if ($this->Session['LGeoIP.CountryCode'])
$this->_d['CountryCode']= $this->Session['LGeoIP.CountryCode'];
$this->_d['CountryName']= $this->Session['LGeoIP.CountryName'];
return $this->_d['CountryCode'];
return $this->_d['CountryName'];
Prado::log($e->getMessage(),8,"Lithron.LGeoIP");
|