Skip to content

Commit

Permalink
[*] CORE : Use named constante for GeoLiteCity.dat
Browse files Browse the repository at this point in the history
  • Loading branch information
jnadaud committed Jan 15, 2015
1 parent 2c1910c commit f864b73
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions classes/controller/FrontController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
Expand Down Expand Up @@ -687,13 +687,13 @@ protected function geolocationManagement($default_country)
if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1')))
{
/* Check if Maxmind Database exists */
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
if (@filemtime(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_))
{
if (!isset($this->context->cookie->iso_code_country) || (isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
{
include_once(_PS_GEOIP_DIR_.'geoipcity.inc');

$gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
$gi = geoip_open(realpath(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_), GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());

if (is_object($record))
Expand Down
4 changes: 2 additions & 2 deletions config/defines.inc.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
Expand Down Expand Up @@ -91,6 +91,7 @@

define('_PS_TOOL_DIR_', _PS_CORE_DIR_.'/tools/');
define('_PS_GEOIP_DIR_', _PS_TOOL_DIR_.'geoip/');
define('_PS_GEOIP_CITY_FILE_', 'GeoLiteCity.dat');
define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/');
define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/');
define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/');
Expand Down Expand Up @@ -195,4 +196,3 @@
define('_PS_SMARTY_CONSOLE_OPEN_', 2);

define('_PS_JQUERY_VERSION_', '1.11.0');

8 changes: 4 additions & 4 deletions controllers/admin/AdminGeolocationController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
Expand Down Expand Up @@ -140,7 +140,7 @@ public function initContent()
{
$this->display = 'options';
if (!$this->isGeoLiteCityAvailable())
$this->displayWarning($this->l('In order to use Geolocation, please download').'
$this->displayWarning($this->l('In order to use Geolocation, please download').'
<a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.
$this->l('and extract it (using Winrar or Gzip) into the /tools/geoip/ directory.'));

Expand All @@ -149,9 +149,9 @@ public function initContent()

protected function isGeoLiteCityAvailable()
{
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
if (@filemtime(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_))
return true;

return false;
}
}

0 comments on commit f864b73

Please sign in to comment.