diff --git a/Block/Adminhtml/Loginlog/Edit/Form.php b/Block/Adminhtml/Loginlog/Edit/Form.php index 80bf892..43110fa 100644 --- a/Block/Adminhtml/Loginlog/Edit/Form.php +++ b/Block/Adminhtml/Loginlog/Edit/Form.php @@ -87,10 +87,11 @@ protected function _prepareForm() 'name' => 'id', 'label' => __('ID'), ]); - $fieldset->addField('time', 'label', [ + $fieldset->addField('times', 'label', [ 'name' => 'time', 'label' => __('Time'), 'title' => __('Time'), + 'value' => $this->_helper->convertToLocaleTime($log->getTime()) ]); $fieldset->addField('user_name', 'label', [ 'name' => 'user_name', diff --git a/Helper/Data.php b/Helper/Data.php index 1b91317..21e6c11 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -21,6 +21,13 @@ namespace Mageplaza\Security\Helper; +use DateTime; +use DateTimeZone; +use Exception; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Store\Model\StoreManagerInterface; use Mageplaza\Core\Helper\AbstractData; use Sinergi\BrowserDetector\Browser; use Sinergi\BrowserDetector\Os; @@ -46,6 +53,30 @@ class Data extends AbstractData */ protected $osLib; + /** + * @var TimezoneInterface + */ + protected $timezone; + + /** + * Data constructor. + * + * @param Context $context + * @param ObjectManagerInterface $objectManager + * @param StoreManagerInterface $storeManager + * @param TimezoneInterface $timezone + */ + public function __construct( + Context $context, + ObjectManagerInterface $objectManager, + StoreManagerInterface $storeManager, + TimezoneInterface $timezone + ) { + $this->timezone = $timezone; + + parent::__construct($context, $objectManager, $storeManager); + } + /** * Get Brute Force Config * @@ -160,4 +191,23 @@ public function isReports() return $this->isModuleOutputEnabled('Mageplaza_Reports') && $this->getConfigValue('mageplaza_reports/general/enabled'); } + + /** + * @param string $time + * @param string $format + * + * @return string + */ + public function convertToLocaleTime($time, $format = 'Y-m-d H:i:s') + { + try { + $localTime = new DateTime($time, new DateTimeZone('UTC')); + $localTime->setTimezone(new DateTimeZone($this->timezone->getConfigTimezone())); + $currentTime = $localTime->format($format); + } catch (Exception $e) { + $currentTime = ''; + } + + return $currentTime; + } } diff --git a/composer.json b/composer.json index 86c27d7..b2cef49 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "sinergi/browser-detector": "*" }, "type": "magento2-module", - "version": "4.0.0", + "version": "4.0.1", "license": "proprietary", "authors": [ { diff --git a/view/adminhtml/templates/checklist/index.phtml b/view/adminhtml/templates/checklist/index.phtml index 5822af4..5b0a476 100644 --- a/view/adminhtml/templates/checklist/index.phtml +++ b/view/adminhtml/templates/checklist/index.phtml @@ -23,57 +23,57 @@ $unSecureNames = $block->checkAdminUserName(); ?>
= __('The following usernames are not secured: %1.', 'admin, root, test, magento') ?>
-= __('Hackers can guest username easily. Click on an user to change username.') ?>
+= $block->escapeHtml(__('The following usernames are not secured: %1.', 'admin, root, test, magento')) ?>
+= $block->escapeHtml(__('Hackers can guest username easily. Click on an user to change username.')) ?>
- checkFrontendCaptcha()): ?> + checkFrontendCaptcha()) : ?> - = __("Frontend captcha is not enabled. Hackers may carry out brute-force attacks on your customers' accounts") ?> - = __('Fix it') ?> - + = $block->escapeHtml(__("Frontend captcha is not enabled. Hackers may carry out brute-force attacks on your customers' accounts")) ?> + = $block->escapeHtml(__('Fix it')) ?> + - = __('Frontend captcha is enabled.') ?> + = $block->escapeHtml(__('Frontend captcha is enabled.')) ?>
- checkBackendCaptcha()): ?> + checkBackendCaptcha()) : ?>- = __('Backend captcha is not enabled. To protect your backend from brute-force attacks, you should enable it.') ?> - = __('Fix it') ?> + = $block->escapeHtml(__('Backend captcha is not enabled. To protect your backend from brute-force attacks, you should enable it.')) ?> + = $block->escapeHtml(__('Fix it')) ?>
- = __('Backend captcha is enabled.') ?> + = $block->escapeHtml(__('Backend captcha is enabled.')) ?>
- = ($_column->getRowField($_item) != '') ? $_column->getRowField($_item) : ' ' ?> + foreach ($block->getColumns() as $_column) : ?> + | + = ($_column->getRowField($_item) != '') ? $block->escapeHtml($_column->getRowField($_item)) : ' ' ?> |