ltsecurityinc安防产品在线商城代码
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_GeoIPLookup
|
||||
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\GeoIPLookup\Controller\Adminhtml\Import;
|
||||
|
||||
class Autoimport extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Controller\Result\JsonFactory
|
||||
*/
|
||||
private $resultJsonFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Helper\Data
|
||||
*/
|
||||
private $dataHelper;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Json\Helper\Data
|
||||
*/
|
||||
private $jsonHelper;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip
|
||||
*/
|
||||
private $maxmindgeoip;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry
|
||||
*/
|
||||
private $iptocountry;
|
||||
|
||||
/**
|
||||
* Autoimport constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
|
||||
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
|
||||
* @param \Plumrocket\GeoIPLookup\Helper\Data $dataHelper
|
||||
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindgeoip
|
||||
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $iptocountry
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
|
||||
\Magento\Framework\Json\Helper\Data $jsonHelper,
|
||||
\Plumrocket\GeoIPLookup\Helper\Data $dataHelper,
|
||||
\Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindgeoip,
|
||||
\Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $iptocountry
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->resultJsonFactory = $resultJsonFactory;
|
||||
$this->dataHelper = $dataHelper;
|
||||
$this->jsonHelper = $jsonHelper;
|
||||
$this->maxmindgeoip = $maxmindgeoip;
|
||||
$this->iptocountry = $iptocountry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
session_write_close();
|
||||
$resultJson = $this->resultJsonFactory->create();
|
||||
$dataId = $this->getRequest()->getParam('dataId');
|
||||
$modelName = $this->dataHelper->getModelNameByElementId($dataId, false);
|
||||
$importModel = $this->{$modelName};
|
||||
|
||||
if ($importModel->isLatestInstalledVersion()) {
|
||||
$result = [
|
||||
'status' => 'success',
|
||||
'error' => __('Geolocation Database Update'),
|
||||
'alert' => __(
|
||||
"You have the latest %1 Geolocation Database available on our server.
|
||||
Please check back later for the updates.",
|
||||
$importModel->getDataLabel()
|
||||
),
|
||||
'message' => $importModel->getInstalledMessage()
|
||||
];
|
||||
} else {
|
||||
$result = $importModel->autoImportData();
|
||||
}
|
||||
|
||||
return $resultJson->setData(
|
||||
$this->jsonHelper->jsonEncode($result)
|
||||
);
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_GeoIPLookup
|
||||
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\GeoIPLookup\Controller\Adminhtml\Import;
|
||||
|
||||
class Importprogress extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Controller\Result\JsonFactory
|
||||
*/
|
||||
private $resultJsonFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Helper\Data
|
||||
*/
|
||||
private $dataHelper;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Filesystem\Io\File
|
||||
*/
|
||||
private $ioFile;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Json\Helper\Data
|
||||
*/
|
||||
private $jsonHelper;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip
|
||||
*/
|
||||
private $maxmindgeoip;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry
|
||||
*/
|
||||
private $iptocountry;
|
||||
|
||||
/**
|
||||
* Importprogress constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
|
||||
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
|
||||
* @param \Plumrocket\GeoIPLookup\Helper\Data $dataHelper
|
||||
* @param \Magento\Framework\Filesystem\Io\File $ioFile
|
||||
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindgeoip
|
||||
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $iptocountry
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
|
||||
\Magento\Framework\Json\Helper\Data $jsonHelper,
|
||||
\Plumrocket\GeoIPLookup\Helper\Data $dataHelper,
|
||||
\Magento\Framework\Filesystem\Io\File $ioFile,
|
||||
\Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindgeoip,
|
||||
\Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $iptocountry
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->resultJsonFactory = $resultJsonFactory;
|
||||
$this->dataHelper = $dataHelper;
|
||||
$this->ioFile = $ioFile;
|
||||
$this->jsonHelper = $jsonHelper;
|
||||
$this->maxmindgeoip = $maxmindgeoip;
|
||||
$this->iptocountry = $iptocountry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Json
|
||||
* |\Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$resultJson = $this->resultJsonFactory->create();
|
||||
$dataId = $this->getRequest()->getParam('dataId');
|
||||
$modelName = $this->dataHelper->getModelNameByElementId($dataId, false);
|
||||
$importModel = $this->{$modelName};
|
||||
|
||||
$importProgress = $importModel->getProgress();
|
||||
if ($importProgress['status'] == 'success') {
|
||||
$this->ioFile->rm($importModel->getProgressFile());
|
||||
}
|
||||
|
||||
return $resultJson->setData(
|
||||
$this->jsonHelper->jsonEncode($importProgress)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Plumrocket Inc.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the End-user License Agreement
|
||||
* that is available through the world-wide-web at this URL:
|
||||
* http://wiki.plumrocket.net/wiki/EULA
|
||||
* If you are unable to obtain it through the world-wide-web, please
|
||||
* send an email to support@plumrocket.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Plumrocket_GeoIPLookup
|
||||
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
|
||||
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\GeoIPLookup\Controller\Adminhtml\Test;
|
||||
|
||||
class Index extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Controller\Result\JsonFactory
|
||||
*/
|
||||
private $resultJsonFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Json\Helper\Data
|
||||
*/
|
||||
private $jsonHelper;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Model\GeoIPLookup
|
||||
*/
|
||||
private $geoIPLookup;
|
||||
|
||||
/**
|
||||
* Index constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
|
||||
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
|
||||
* @param \Plumrocket\GeoIPLookup\Model\GeoIPLookup $geoIPLookup
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
|
||||
\Magento\Framework\Json\Helper\Data $jsonHelper,
|
||||
\Plumrocket\GeoIPLookup\Model\GeoIPLookup $geoIPLookup
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->resultJsonFactory = $resultJsonFactory;
|
||||
$this->jsonHelper = $jsonHelper;
|
||||
$this->geoIPLookup = $geoIPLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Json
|
||||
* |\Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$resultJson = $this->resultJsonFactory->create();
|
||||
$ip = $this->getRequest()->getParam('ip');
|
||||
$result = $this->geoIPLookup->geoIpLookupTest($ip);
|
||||
|
||||
return $resultJson->setData(
|
||||
$this->jsonHelper->jsonEncode($result)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_GeoIPLookup
|
||||
* @copyright Copyright (c) 2024 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\GeoIPLookup\Controller\Adminhtml\Test;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\HTTP\Client\Curl;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Plumrocket\GeoIPLookup\Helper\Config;
|
||||
|
||||
/**
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class IpapiEndpoint extends Action
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\GeoIPLookup\Helper\Config
|
||||
*/
|
||||
private $configHelper;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\HTTP\Client\Curl
|
||||
*/
|
||||
private $curl;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Serialize\Serializer\Json
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Plumrocket\GeoIPLookup\Helper\Config $configHelper
|
||||
* @param \Magento\Framework\HTTP\Client\Curl $curl
|
||||
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Config $configHelper,
|
||||
Curl $curl,
|
||||
Json $serializer
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->configHelper = $configHelper;
|
||||
$this->curl = $curl;
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$params = $this->getRequest()->getParams();
|
||||
$protocol = !empty($params['use_ssl']) ? 'https://' : 'http://';
|
||||
$baseUrl = $this->configHelper->getIpApiUrl(Config::DEFAULT_IP, false);
|
||||
$url = $protocol . $baseUrl . "?access_key={$params['access_key']}";
|
||||
|
||||
$this->curl->get($url);
|
||||
$response = $this->serializer->unserialize($this->curl->getBody());
|
||||
|
||||
$resultData = ['success' => false];
|
||||
if (isset($response['success'])) {
|
||||
if (isset($response['error']['info'])) {
|
||||
if (isset($response['error']['code']) && $response['error']['code'] !== 101) {
|
||||
$resultData['success'] = true;
|
||||
} else {
|
||||
$resultData['message'] = $response['error']['info'];
|
||||
}
|
||||
}
|
||||
} else if (isset($response['ip']) && $response['ip'] === Config::DEFAULT_IP) {
|
||||
$resultData['success'] = true;
|
||||
}
|
||||
|
||||
/** @var \Magento\Framework\Controller\Result\Json $result */
|
||||
$result = $this->resultFactory->create('json');
|
||||
|
||||
return $result->setData($resultData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user