ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+89
View File
@@ -0,0 +1,89 @@
<?php
/**
* @package Plumrocket_Base
* @copyright Copyright (c) 2021 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\Base\Model\External;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Serialize\SerializerInterface;
use Plumrocket\Base\Helper\Config;
class Connector
{
/**
* @var \Plumrocket\Base\Helper\Config
*/
private $config;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @var \Plumrocket\Base\Model\External\LastRequests
*/
private $lastRequests;
/**
* @param \Plumrocket\Base\Helper\Config $config
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Plumrocket\Base\Model\External\LastRequests $lastRequests
*/
public function __construct(
Config $config,
SerializerInterface $serializer,
LastRequests $lastRequests
) {
$this->config = $config;
$this->serializer = $serializer;
$this->lastRequests = $lastRequests;
}
/**
* Send POST request to url.
*
* @param string $url
* @param array $data
* @return array|bool|float|int|string|null
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function connect(string $url, array $data = [])
{
$data['v'] = 1;
$query = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
if (curl_errno($ch)) {
$errorMessage = 'cURL Error: ' . curl_error($ch);
$this->lastRequests->add($url, $data, ['error' => $errorMessage]);
if ($this->config->isDebugMode()) {
throw new \Exception($errorMessage, 1);
}
}
curl_close($ch);
if (false === $res) {
$this->lastRequests->add($url, $data, ['error' => "Cannot connect to $url"]);
throw new LocalizedException(__('Cannot connect to %1', $url));
}
$res = $this->serializer->unserialize($res);
$this->lastRequests->add($url, $data, $res);
return $res;
}
}
@@ -0,0 +1,62 @@
<?php
/**
* @package Plumrocket_Base
* @copyright Copyright (c) 2021 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\Base\Model\External;
/**
* Buffer for last external requests.
*
* Can be used for debugging store endpoint problems.
*
* @since 2.5.7
*/
class LastRequests
{
/**
* @var array[]
*/
private $data = [];
/**
* Add request response.
*
* @param string $url
* @param array $params
* @param array $response
*/
public function add(string $url, array $params, array $response): void
{
if (strpos($url, Urls::PINGBACK_URL . '/extension') !== false) {
$this->data[] = [
'request_url' => $url,
'request_params' => $params,
'response' => $response
];
}
}
/**
* Get saved data.
*
* @return array[]
*/
public function getList(): array
{
return $this->data;
}
/**
* Clear all saved requests data
*/
public function clear(): void
{
$this->data = [];
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
/**
* @package Plumrocket_Base
* @copyright Copyright (c) 2021 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\Base\Model\External;
/**
* Contains all external URLs that the extension calls.
*
* @since 2.5.0
*/
class Urls
{
/**
* Provides xml with extensions changelogs.
*/
public const CHANGELOGS_URL = 'plumrocket.com/media/info/changelogs_m2.xml';
/**
* Provides xml with the latest version of each extension.
*/
public const VERSIONS_URL = 'plumrocket.com/media/info/versions.xml';
/**
* Service for collections the extensions usage statistic.
*/
public const STATISTIC_URL = 'api.plumrocket.net/v1/statistic';
/**
* Base url for retrieving our notifications.
*/
public const NOTIFICATIONS_URL = 'plumrocket.com/notificationmanager/feed/index';
/**
* Service for collections the extensions pingbacks.
*/
public const PINGBACK_URL = 'plumrocket.com/ilg/pingback';
/**
* Service for collections the marketplace extensions pingbacks.
*/
public const MARKETPLACE_PINGBACK_URL = 'plumrocket.com/ilg/pingback/marketplace';
}