Skip to content

Commit

Permalink
Removed autdated mysql geoip database
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorvansach committed Sep 5, 2022
1 parent 9a19a3b commit d9092bd
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 182,987 deletions.
34 changes: 9 additions & 25 deletions Block/Adminhtml/System/Config/Form/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,23 @@
/**
* Admin geoip configurations information block
*/
class Info extends \Magento\Config\Block\System\Config\Form\Field
class Info extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info
{
/**
* @var \Magento\Framework\Module\ModuleListInterface
*/
protected $moduleList;

/**
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
* Return extension url
* @return string
*/
public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->moduleList = $moduleList;
protected function getModuleUrl()
{
return 'https://mage' . 'fan.com?utm_source=m2admin_geo_ip_config&utm_medium=link&utm_campaign=regular';
}

/**
* Return info block html
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* Return extension title
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function getModuleTitle()
{
$m = $this->moduleList->getOne($this->getModuleName());
$html = '<div style="padding:10px;background-color:#f8f8f8;border:1px solid #ddd;margin-bottom:7px;">
GeoIp Database Extension v' . $m['setup_version'] . ' was developed by <a href="https://magefan.com?utm_source=m2admin_geo_ip_config&utm_medium=link&utm_campaign=regular" target="_blank">Magefan</a>.
</div>';

return $html;
return 'GeoIp Database Extension';
}
}
24 changes: 0 additions & 24 deletions Model/IpToCountry.php

This file was deleted.

50 changes: 15 additions & 35 deletions Model/IpToCountryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

namespace Magefan\GeoIp\Model;


use Magento\Store\Model\ScopeInterface;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Module\Dir as ModuleDir;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;

/**
* Class IpToCountryRepository
Expand All @@ -32,27 +36,22 @@ class IpToCountryRepository
const XML_PATH_SIMULATE_COUNTRY = 'mfgeoip/developer/simulate_country';

/**
* @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress
* @var RemoteAddress
*/
protected $remoteAddress;

/**
* @var ResourceModel\IpToCountry\CollectionFactory
*/
protected $ipToCountryCollectionFactory;

/**
* @var array
*/
protected $ipToCountry = [];

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
* @var ScopeConfigInterface
*/
protected $config;

/**
* @var \Magento\Framework\App\RequestInterface
* @var RequestInterface
*/
protected $request;

Expand All @@ -68,33 +67,24 @@ class IpToCountryRepository

/**
* IpToCountryRepository constructor.
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
* @param ResourceModel\IpToCountry\CollectionFactory $ipToCountryCollectionFactory
* @param RemoteAddress $remoteAddress
* @param DirectoryList $directoryList
* @param ModuleDir $moduleDir
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\RequestInterface $httpRequest
* @param ScopeConfigInterface $config
* @param RequestInterface $httpRequest
*/
public function __construct(
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
ResourceModel\IpToCountry\CollectionFactory $ipToCountryCollectionFactory,
RemoteAddress $remoteAddress,
DirectoryList $directoryList,
ModuleDir $moduleDir,
$config = null,
$httpRequest = null
ScopeConfigInterface $config,
RequestInterface $httpRequest
) {
$this->remoteAddress = $remoteAddress;
$this->ipToCountryCollectionFactory = $ipToCountryCollectionFactory;
$this->directoryList = $directoryList;
$this->moduleDir = $moduleDir;

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->config = $config ?: $objectManager->get(
\Magento\Framework\App\Config\ScopeConfigInterface::class
);
$this->request = $httpRequest ?: $objectManager->get(
\Magento\Framework\App\RequestInterface::class
);
$this->config = $config;
$this->request = $httpRequest;
}

/**
Expand Down Expand Up @@ -157,16 +147,6 @@ public function getCountryCode($ip)
}
} catch (\Exception $e) {}
}

if (!$this->ipToCountry[$ip]) {
$longIp = ip2long($ip);
$collection = $this->ipToCountryCollectionFactory->create();
$collection->addFieldToFilter('ip_from', ["lteq" => $longIp])
->addFieldToFilter('ip_to', ["gteq" => $longIp])
->setPageSize(1);
$ipInfo = $collection->getFirstItem();
$this->ipToCountry[$ip] = $ipInfo->getCountryCode() ?: false;
}
}

return $this->ipToCountry[$ip];
Expand Down
22 changes: 0 additions & 22 deletions Model/ResourceModel/IpToCountry.php

This file was deleted.

25 changes: 0 additions & 25 deletions Model/ResourceModel/IpToCountry/Collection.php

This file was deleted.

69 changes: 0 additions & 69 deletions Setup/InstallData.php

This file was deleted.

70 changes: 0 additions & 70 deletions Setup/InstallSchema.php

This file was deleted.

Loading

0 comments on commit d9092bd

Please sign in to comment.