merge: integrate client fixes from test-client-fixes into main

This commit is contained in:
nertyog 2026-09-05 17:27:21 +03:00
commit a26095323c
6 changed files with 441 additions and 68 deletions

View File

@ -16,9 +16,7 @@
$nat_pos = $this->config->get('module_img_opti_menu_position'); $nat_pos = $this->config->get('module_img_opti_menu_position');
if ($nat_pos == 'sidebar' || $nat_pos == 'both') { if ($nat_pos == 'sidebar' || $nat_pos == 'both') {
if ($this->user->hasPermission('access', 'module/img_opti')) { if ($this->user->hasPermission('access', 'module/img_opti')) {
$nat_item = array( $nat_token_str = 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '');
'name' => 'Image Optimizer',
$nat_token_str = isset($this->session->data['user_token']) ? ('user_token=' . $this->session->data['user_token']) : ('token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : ''));
$nat_item = array( $nat_item = array(
'name' => 'Image Optimizer', 'name' => 'Image Optimizer',
'href' => $this->url->link('module/img_opti', $nat_token_str, true), 'href' => $this->url->link('module/img_opti', $nat_token_str, true),
@ -87,7 +85,7 @@
if (!$exists) { if (!$exists) {
$data['nat_menus'][] = array( $data['nat_menus'][] = array(
'name' => 'Image Optimizer', 'name' => 'Image Optimizer',
'href' => $this->url->link('module/img_opti', (isset($this->session->data['user_token']) ? ('user_token=' . $this->session->data['user_token']) : ('token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : ''))), true) 'href' => $this->url->link('module/img_opti', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : ''), true)
); );
} }
} }
@ -97,7 +95,7 @@
</operation> </operation>
</file> </file>
<file path="admin/view/template/common/header.twig"> <file path="admin/view/template/common/header.tpl">
<operation error="skip"> <operation error="skip">
<search><![CDATA[</head>]]></search> <search><![CDATA[</head>]]></search>
<add position="before"><![CDATA[ <add position="before"><![CDATA[
@ -111,20 +109,20 @@ a.img-thumbnail img, a.thumbnail img {
]]></add> ]]></add>
</operation> </operation>
<operation error="skip"> <operation error="skip">
<search><![CDATA[<li><a href="{{ logout }}"]]></search> <search><![CDATA[<li><a href="<?php echo $logout; ?>"]]></search>
<add position="before"><![CDATA[ <add position="before"><![CDATA[
{% if nat_menus is defined and nat_menus and not nat_menu_rendered|default(false) %} <?php if (isset($nat_menus) && !empty($nat_menus) && empty($GLOBALS['nat_menu_rendered'])) { ?>
{% set nat_menu_rendered = true %} <?php $GLOBALS['nat_menu_rendered'] = true; ?>
<li class="dropdown" id="nat-ecosystem-menu"> <li class="dropdown" id="nat-ecosystem-menu">
<a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-rocket fa-lg" style="color:#e74c3c;"></i> <span class="hidden-xs hidden-sm hidden-md">[NAT]</span> <span class="caret"></span></a> <a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-rocket fa-lg" style="color:#e74c3c;"></i> <span class="hidden-xs hidden-sm hidden-md">[NAT]</span> <span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-right" id="nat-ecosystem-list"> <ul class="dropdown-menu dropdown-menu-right" id="nat-ecosystem-list">
<li class="dropdown-header">Ecosystem [NAT]</li> <li class="dropdown-header">Ecosystem [NAT]</li>
{% for n_menu in nat_menus %} <?php foreach ($nat_menus as $n_menu) { ?>
<li><a href="{{ n_menu.href }}"><i class="fa fa-angle-right"></i> {{ n_menu.name }}</a></li> <li><a href="<?php echo $n_menu['href']; ?>"><i class="fa fa-angle-right"></i> <?php echo $n_menu['name']; ?></a></li>
{% endfor %} <?php } ?>
</ul> </ul>
</li> </li>
{% endif %} <?php } ?>
]]></add> ]]></add>
</operation> </operation>
</file> </file>
@ -189,7 +187,10 @@ a.img-thumbnail img, a.thumbnail img {
if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_auto_fake_jpg_guard') && !empty($filename)) { if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_auto_fake_jpg_guard') && !empty($filename)) {
$this->load->model('module/img_opti'); $this->load->model('module/img_opti');
try { try {
$filename = $this->model_extension_module_img_opti->checkAndFixFakeJpgOnTheFly($filename); $opti_model = isset($this->model_module_img_opti) ? $this->model_module_img_opti : (isset($this->model_extension_module_img_opti) ? $this->model_extension_module_img_opti : null);
if ($opti_model) {
$filename = $opti_model->checkAndFixFakeJpgOnTheFly($filename);
}
} catch (\Exception $e) {} } catch (\Exception $e) {}
} }
if (empty($filename) || ($filename !== 'no_image.png' && $filename !== 'placeholder.png' && !is_file(DIR_IMAGE . $filename))) { if (empty($filename) || ($filename !== 'no_image.png' && $filename !== 'placeholder.png' && !is_file(DIR_IMAGE . $filename))) {
@ -226,7 +227,10 @@ a.img-thumbnail img, a.thumbnail img {
if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_wm_status')) { if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_wm_status')) {
$this->load->model('module/img_opti'); $this->load->model('module/img_opti');
try { try {
$this->model_extension_module_img_opti->applyDynamicWatermark(DIR_IMAGE . $image_new, $filename); $opti_model = isset($this->model_module_img_opti) ? $this->model_module_img_opti : (isset($this->model_extension_module_img_opti) ? $this->model_extension_module_img_opti : null);
if ($opti_model) {
$opti_model->applyDynamicWatermark(DIR_IMAGE . $image_new, $filename);
}
} catch (\Exception $e) {} } catch (\Exception $e) {}
} }
]]></add> ]]></add>
@ -240,7 +244,10 @@ a.img-thumbnail img, a.thumbnail img {
if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_wm_status')) { if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_wm_status')) {
$this->load->model('module/img_opti'); $this->load->model('module/img_opti');
try { try {
$this->model_extension_module_img_opti->applyDynamicWatermark(DIR_IMAGE . $image_new, $filename); $opti_model = isset($this->model_module_img_opti) ? $this->model_module_img_opti : (isset($this->model_extension_module_img_opti) ? $this->model_extension_module_img_opti : null);
if ($opti_model) {
$opti_model->applyDynamicWatermark(DIR_IMAGE . $image_new, $filename);
}
} catch (\Exception $e) {} } catch (\Exception $e) {}
} }
}]]></add> }]]></add>
@ -255,7 +262,10 @@ a.img-thumbnail img, a.thumbnail img {
if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_auto_fake_jpg_guard') && !empty($filename)) { if ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_auto_fake_jpg_guard') && !empty($filename)) {
$this->load->model('module/img_opti'); $this->load->model('module/img_opti');
try { try {
$filename = $this->model_extension_module_img_opti->checkAndFixFakeJpgOnTheFly($filename); $opti_model = isset($this->model_module_img_opti) ? $this->model_module_img_opti : (isset($this->model_extension_module_img_opti) ? $this->model_extension_module_img_opti : null);
if ($opti_model) {
$filename = $opti_model->checkAndFixFakeJpgOnTheFly($filename);
}
} catch (\Exception $e) {} } catch (\Exception $e) {}
} }
if (empty($filename) || ($filename !== 'no_image.png' && $filename !== 'placeholder.png' && !is_file(DIR_IMAGE . $filename))) { if (empty($filename) || ($filename !== 'no_image.png' && $filename !== 'placeholder.png' && !is_file(DIR_IMAGE . $filename))) {
@ -690,6 +700,20 @@ document.addEventListener("DOMContentLoaded", function() {
} }
]]></add> ]]></add>
</operation> </operation>
<operation error="skip">
<search><![CDATA[if ($product_info['image']) {
$data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
} else {
$data['popup'] = '';
}]]></search>
<add position="replace"><![CDATA[
if ($product_info['image'] || ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_broken_fallback') && $this->config->get('module_img_opti_fallback_image'))) {
$data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
} else {
$data['popup'] = '';
}
]]></add>
</operation>
<operation error="skip"> <operation error="skip">
<search><![CDATA[if ($product_info['image']) { <search><![CDATA[if ($product_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height')); $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));
@ -704,8 +728,30 @@ document.addEventListener("DOMContentLoaded", function() {
} }
]]></add> ]]></add>
</operation> </operation>
<operation error="skip">
<search><![CDATA[if ($product_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
} else {
$data['thumb'] = '';
}]]></search>
<add position="replace"><![CDATA[
if ($product_info['image'] || ($this->config->get('module_img_opti_status') && $this->config->get('module_img_opti_broken_fallback') && $this->config->get('module_img_opti_fallback_image'))) {
$data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
} else {
$data['thumb'] = '';
}
]]></add>
</operation>
</file> </file>
<file path="index.php">
<operation error="skip">
<search><![CDATA[$registry = new Registry();]]></search>
<add position="after"><![CDATA[
$GLOBALS['registry'] = $registry;
]]></add>
</operation>
</file>
<file path="system/framework.php"> <file path="system/framework.php">
<operation error="skip"> <operation error="skip">
<search><![CDATA[$registry = new Registry();]]></search> <search><![CDATA[$registry = new Registry();]]></search>

View File

@ -77,7 +77,9 @@ class ControllerModuleImgOpti extends Controller {
break; break;
} }
} }
$this->request->post['img_opti_status'] = $this->request->post['module_img_opti_status'];
$this->model_setting_setting->editSetting('module_img_opti', $this->request->post); $this->model_setting_setting->editSetting('module_img_opti', $this->request->post);
$this->model_setting_setting->editSetting('img_opti', array('img_opti_status' => $this->request->post['module_img_opti_status']));
$this->cache->delete('img_opti_disk_stats'); $this->cache->delete('img_opti_disk_stats');
if ($quality_changed) { if ($quality_changed) {
$cache_file = DIR_CACHE . 'img_opti_optimized.json'; $cache_file = DIR_CACHE . 'img_opti_optimized.json';
@ -86,7 +88,7 @@ class ControllerModuleImgOpti extends Controller {
} }
} }
$this->session->data['success'] = $this->language->get('text_success'); $this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('module/img_opti', 'user_token=' . $this->session->data['user_token'], true)); $this->response->redirect($this->url->link('module/img_opti', 'token=' . $this->session->data['token'], true));
} }
if (isset($this->session->data['success'])) { if (isset($this->session->data['success'])) {
@ -106,16 +108,16 @@ class ControllerModuleImgOpti extends Controller {
$data['webp_enabled'] = function_exists('imagewebp'); $data['webp_enabled'] = function_exists('imagewebp');
$data['imagick_enabled'] = extension_loaded('imagick'); $data['imagick_enabled'] = extension_loaded('imagick');
$data['breadcrumbs'] = array(); $data['token'] = isset($this->session->data['token']) ? $this->session->data['token'] : '';
$data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)); $token_param = 'token=' . $data['token'];
$data['breadcrumbs'][] = array('text' => $this->language->get('text_extension'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
$data['breadcrumbs'][] = array('text' => $this->language->get('heading_title_raw'), 'href' => $this->url->link('module/img_opti', 'user_token=' . $this->session->data['user_token'], true));
$data['action'] = $this->url->link('module/img_opti', 'user_token=' . $this->session->data['user_token'], true); $data['breadcrumbs'] = array();
$ext_route = (version_compare(VERSION, '3.0.0.0', '>=')) ? 'marketplace/extension' : (version_compare(VERSION, '2.3.0.0', '>=') ? 'extension/extension' : 'extension/module'); $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', $token_param, true));
$token_param = isset($this->session->data['user_token']) ? ('user_token=' . $this->session->data['user_token']) : ('token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '')); $data['breadcrumbs'][] = array('text' => $this->language->get('text_extension'), 'href' => $this->url->link('extension/module', $token_param, true));
$data['breadcrumbs'][] = array('text' => $this->language->get('heading_title_raw'), 'href' => $this->url->link('module/img_opti', $token_param, true));
$data['action'] = $this->url->link('module/img_opti', $token_param, true);
$data['cancel'] = $this->url->link('extension/module', $token_param, true); $data['cancel'] = $this->url->link('extension/module', $token_param, true);
$data['token'] = isset($this->session->data['token']) ? $this->session->data['token'] : (isset($this->session->data['user_token']) ? $this->session->data['user_token'] : '');
$fields = array( $fields = array(
'module_img_opti_status' => 1, 'module_img_opti_status' => 1,
@ -517,7 +519,7 @@ class ControllerModuleImgOpti extends Controller {
$data['column_left'] = $this->load->controller('common/column_left'); $data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer'); $data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('module/img_opti', $data)); $this->response->setOutput($this->load->view('module/img_opti.tpl', $data));
} }
private function getModuleModel() { private function getModuleModel() {
@ -2464,6 +2466,8 @@ class ControllerModuleImgOpti extends Controller {
} }
$en_paths = array( $en_paths = array(
DIR_LANGUAGE . 'en-gb/module/img_opti.php',
DIR_LANGUAGE . 'english/module/img_opti.php',
DIR_LANGUAGE . 'en-gb/extension/module/img_opti.php', DIR_LANGUAGE . 'en-gb/extension/module/img_opti.php',
DIR_LANGUAGE . 'english/extension/module/img_opti.php' DIR_LANGUAGE . 'english/extension/module/img_opti.php'
); );
@ -2492,6 +2496,8 @@ class ControllerModuleImgOpti extends Controller {
$paths = array(); $paths = array();
if ($lang && $lang !== 'en-gb' && $lang !== 'english') { if ($lang && $lang !== 'en-gb' && $lang !== 'english') {
$paths[] = DIR_LANGUAGE . $lang . '/module/img_opti.php';
$paths[] = DIR_LANGUAGE . strtolower($lang) . '/module/img_opti.php';
$paths[] = DIR_LANGUAGE . $lang . '/extension/module/img_opti.php'; $paths[] = DIR_LANGUAGE . $lang . '/extension/module/img_opti.php';
$paths[] = DIR_LANGUAGE . strtolower($lang) . '/extension/module/img_opti.php'; $paths[] = DIR_LANGUAGE . strtolower($lang) . '/extension/module/img_opti.php';
} }
@ -2508,6 +2514,8 @@ class ControllerModuleImgOpti extends Controller {
if ($query_lang && $query_lang->num_rows) { if ($query_lang && $query_lang->num_rows) {
if (!empty($query_lang->row['directory'])) { if (!empty($query_lang->row['directory'])) {
$db_dir = $query_lang->row['directory']; $db_dir = $query_lang->row['directory'];
$paths[] = DIR_LANGUAGE . $db_dir . '/module/img_opti.php';
$paths[] = DIR_LANGUAGE . strtolower($db_dir) . '/module/img_opti.php';
$paths[] = DIR_LANGUAGE . $db_dir . '/extension/module/img_opti.php'; $paths[] = DIR_LANGUAGE . $db_dir . '/extension/module/img_opti.php';
$paths[] = DIR_LANGUAGE . strtolower($db_dir) . '/extension/module/img_opti.php'; $paths[] = DIR_LANGUAGE . strtolower($db_dir) . '/extension/module/img_opti.php';
} }

View File

@ -164,7 +164,7 @@ class ModelModuleImgOpti extends Model {
$catalog_url = (defined('HTTPS_CATALOG') && HTTPS_CATALOG) ? HTTPS_CATALOG : (defined('HTTP_CATALOG') ? HTTP_CATALOG : ''); $catalog_url = (defined('HTTPS_CATALOG') && HTTPS_CATALOG) ? HTTPS_CATALOG : (defined('HTTP_CATALOG') ? HTTP_CATALOG : '');
$query = $this->db->query("SELECT p.product_id, p.model, p.status, p.date_available, (SELECT p2s.store_id FROM `" . DB_PREFIX . "product_to_store` p2s WHERE p2s.product_id = p.product_id AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "product_description` pd WHERE pd.product_id = p.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "product` p WHERE p.image = '" . $escaped . "'"); $query = $this->db->query("SELECT p.product_id, p.model, p.status, p.date_available, (SELECT p2s.store_id FROM `" . DB_PREFIX . "product_to_store` p2s WHERE p2s.product_id = p.product_id AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "product_description` pd WHERE pd.product_id = p.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "product` p WHERE p.image = '" . $escaped . "'");
foreach ($query->rows as $row) { foreach ($query->rows as $row) {
$admin_link = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . (int)$row['product_id'], true); $admin_link = $this->url->link('catalog/product/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&product_id=' . (int)$row['product_id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id']; $catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id'];
@ -175,7 +175,7 @@ class ModelModuleImgOpti extends Model {
} }
$query = $this->db->query("SELECT pi.product_id, p.model, p.status, p.date_available, (SELECT p2s.store_id FROM `" . DB_PREFIX . "product_to_store` p2s WHERE p2s.product_id = pi.product_id AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "product_description` pd WHERE pd.product_id = pi.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "product_image` pi LEFT JOIN `" . DB_PREFIX . "product` p ON (pi.product_id = p.product_id) WHERE pi.image = '" . $escaped . "'"); $query = $this->db->query("SELECT pi.product_id, p.model, p.status, p.date_available, (SELECT p2s.store_id FROM `" . DB_PREFIX . "product_to_store` p2s WHERE p2s.product_id = pi.product_id AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "product_description` pd WHERE pd.product_id = pi.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "product_image` pi LEFT JOIN `" . DB_PREFIX . "product` p ON (pi.product_id = p.product_id) WHERE pi.image = '" . $escaped . "'");
foreach ($query->rows as $row) { foreach ($query->rows as $row) {
$admin_link = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . (int)$row['product_id'], true); $admin_link = $this->url->link('catalog/product/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&product_id=' . (int)$row['product_id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id']; $catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id'];
@ -186,7 +186,7 @@ class ModelModuleImgOpti extends Model {
} }
$query = $this->db->query("SELECT c.category_id, c.status, (SELECT c2s.store_id FROM `" . DB_PREFIX . "category_to_store` c2s WHERE c2s.category_id = c.category_id AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "category_description` cd WHERE cd.category_id = c.category_id AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "category` c WHERE image = '" . $escaped . "'"); $query = $this->db->query("SELECT c.category_id, c.status, (SELECT c2s.store_id FROM `" . DB_PREFIX . "category_to_store` c2s WHERE c2s.category_id = c.category_id AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id, (SELECT name FROM `" . DB_PREFIX . "category_description` cd WHERE cd.category_id = c.category_id AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' LIMIT 1) AS name FROM `" . DB_PREFIX . "category` c WHERE image = '" . $escaped . "'");
foreach ($query->rows as $row) { foreach ($query->rows as $row) {
$admin_link = $this->url->link('catalog/category/edit', 'user_token=' . $this->session->data['user_token'] . '&category_id=' . (int)$row['category_id'], true); $admin_link = $this->url->link('catalog/category/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&category_id=' . (int)$row['category_id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['category_id']; $catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['category_id'];
@ -197,7 +197,7 @@ class ModelModuleImgOpti extends Model {
} }
$query = $this->db->query("SELECT m.manufacturer_id, m.name, (SELECT m2s.store_id FROM `" . DB_PREFIX . "manufacturer_to_store` m2s WHERE m2s.manufacturer_id = m.manufacturer_id AND m2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id FROM `" . DB_PREFIX . "manufacturer` m WHERE image = '" . $escaped . "'"); $query = $this->db->query("SELECT m.manufacturer_id, m.name, (SELECT m2s.store_id FROM `" . DB_PREFIX . "manufacturer_to_store` m2s WHERE m2s.manufacturer_id = m.manufacturer_id AND m2s.store_id = '" . (int)$this->config->get('config_store_id') . "' LIMIT 1) AS store_id FROM `" . DB_PREFIX . "manufacturer` m WHERE image = '" . $escaped . "'");
foreach ($query->rows as $row) { foreach ($query->rows as $row) {
$admin_link = $this->url->link('catalog/manufacturer/edit', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . (int)$row['manufacturer_id'], true); $admin_link = $this->url->link('catalog/manufacturer/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&manufacturer_id=' . (int)$row['manufacturer_id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if ((isset($row['store_id']) && $row['store_id'] !== null)) { if ((isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['manufacturer_id']; $catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['manufacturer_id'];
@ -210,7 +210,7 @@ class ModelModuleImgOpti extends Model {
if ($table_query->num_rows) { if ($table_query->num_rows) {
$query_banner = $this->db->query("SELECT bi.banner_id, b.name FROM `" . DB_PREFIX . "banner_image` bi LEFT JOIN `" . DB_PREFIX . "banner` b ON (bi.banner_id = b.banner_id) WHERE bi.image = '" . $escaped . "'"); $query_banner = $this->db->query("SELECT bi.banner_id, b.name FROM `" . DB_PREFIX . "banner_image` bi LEFT JOIN `" . DB_PREFIX . "banner` b ON (bi.banner_id = b.banner_id) WHERE bi.image = '" . $escaped . "'");
foreach ($query_banner->rows as $row) { foreach ($query_banner->rows as $row) {
$admin_link = $this->url->link('design/banner/edit', 'user_token=' . $this->session->data['user_token'] . '&banner_id=' . (int)$row['banner_id'], true); $admin_link = $this->url->link('design/banner/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&banner_id=' . (int)$row['banner_id'], true);
$search_links = $this->getSearchLinks($row['name']); $search_links = $this->getSearchLinks($row['name']);
$entities[] = '<span class="label label-default">Banner</span> <a href="' . $admin_link . '" target="_blank">' . htmlspecialchars($row['name'] ? $row['name'] : 'Banner ID ' . $row['banner_id'], ENT_QUOTES, 'UTF-8') . '</a>' . $search_links; $entities[] = '<span class="label label-default">Banner</span> <a href="' . $admin_link . '" target="_blank">' . htmlspecialchars($row['name'] ? $row['name'] : 'Banner ID ' . $row['banner_id'], ENT_QUOTES, 'UTF-8') . '</a>' . $search_links;
} }
@ -236,7 +236,7 @@ class ModelModuleImgOpti extends Model {
try { try {
$query_blog = $this->db->query($sql); $query_blog = $this->db->query($sql);
foreach ($query_blog->rows as $row) { foreach ($query_blog->rows as $row) {
$admin_link = $this->url->link($cfg['route'], 'user_token=' . $this->session->data['user_token'] . '&' . $cfg['id'] . '=' . (int)$row[$cfg['id']], true); $admin_link = $this->url->link($cfg['route'], 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&' . $cfg['id'] . '=' . (int)$row[$cfg['id']], true);
$search_links = $this->getSearchLinks($row['name']); $search_links = $this->getSearchLinks($row['name']);
$entities[] = '<span class="label label-primary">' . $cfg['type'] . '</span> <a href="' . $admin_link . '" target="_blank">' . htmlspecialchars($row['name'] ? $row['name'] : $cfg['type'] . ' ID ' . $row[$cfg['id']], ENT_QUOTES, 'UTF-8') . '</a>' . $search_links; $entities[] = '<span class="label label-primary">' . $cfg['type'] . '</span> <a href="' . $admin_link . '" target="_blank">' . htmlspecialchars($row['name'] ? $row['name'] : $cfg['type'] . ' ID ' . $row[$cfg['id']], ENT_QUOTES, 'UTF-8') . '</a>' . $search_links;
} }
@ -410,7 +410,7 @@ class ModelModuleImgOpti extends Model {
$fullPath = DIR_IMAGE . $image_path; $fullPath = DIR_IMAGE . $image_path;
$realPath = realpath($fullPath); $realPath = realpath($fullPath);
if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) { if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) {
$admin_link = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/product/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&product_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['id'];
@ -441,7 +441,7 @@ class ModelModuleImgOpti extends Model {
$fullPath = DIR_IMAGE . $image_path; $fullPath = DIR_IMAGE . $image_path;
$realPath = realpath($fullPath); $realPath = realpath($fullPath);
if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) { if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) {
$admin_link = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . (int)$row['product_id'], true); $admin_link = $this->url->link('catalog/product/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&product_id=' . (int)$row['product_id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id']; $catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['product_id'];
@ -470,7 +470,7 @@ class ModelModuleImgOpti extends Model {
$fullPath = DIR_IMAGE . $image_path; $fullPath = DIR_IMAGE . $image_path;
$realPath = realpath($fullPath); $realPath = realpath($fullPath);
if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) { if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) {
$admin_link = $this->url->link('catalog/category/edit', 'user_token=' . $this->session->data['user_token'] . '&category_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/category/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&category_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['id'];
@ -500,7 +500,7 @@ class ModelModuleImgOpti extends Model {
$fullPath = DIR_IMAGE . $image_path; $fullPath = DIR_IMAGE . $image_path;
$realPath = realpath($fullPath); $realPath = realpath($fullPath);
if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) { if (!$realPath || strpos(str_replace('\\', '/', $realPath), $realImageDir) !== 0 || !is_file($realPath)) {
$admin_link = $this->url->link('catalog/manufacturer/edit', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/manufacturer/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&manufacturer_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if ((isset($row['store_id']) && $row['store_id'] !== null)) { if ((isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['id'];
@ -1717,7 +1717,7 @@ class ModelModuleImgOpti extends Model {
if (!$matched_image) continue; if (!$matched_image) continue;
$admin_link = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/product/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&product_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (empty($row['date_available']) || strtotime($row['date_available']) <= time()) && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/product&product_id=' . (int)$row['id'];
@ -1773,7 +1773,7 @@ class ModelModuleImgOpti extends Model {
if (!$matched_image) continue; if (!$matched_image) continue;
$admin_link = $this->url->link('catalog/category/edit', 'user_token=' . $this->session->data['user_token'] . '&category_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/category/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&category_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) { if (isset($row['status']) && (int)$row['status'] === 1 && (isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/category&path=' . (int)$row['id'];
@ -1829,7 +1829,7 @@ class ModelModuleImgOpti extends Model {
if (!$matched_image) continue; if (!$matched_image) continue;
$admin_link = $this->url->link('catalog/manufacturer/edit', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . (int)$row['id'], true); $admin_link = $this->url->link('catalog/manufacturer/edit', 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&manufacturer_id=' . (int)$row['id'], true);
$catalog_link_html = ''; $catalog_link_html = '';
if ((isset($row['store_id']) && $row['store_id'] !== null)) { if ((isset($row['store_id']) && $row['store_id'] !== null)) {
$catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['id']; $catalog_link = $catalog_url . 'index.php?route=product/manufacturer/info&manufacturer_id=' . (int)$row['id'];
@ -2751,7 +2751,7 @@ private function roundCornersGD($im, $radius) {
} }
} }
if (!$fullPath || strpos(str_replace('\\', '/', $fullPath), str_replace('\\', '/', $realImageDir)) !== 0 || !is_file($fullPath)) { if (!$fullPath || strpos(str_replace('\\', '/', $fullPath), str_replace('\\', '/', $realImageDir)) !== 0 || !is_file($fullPath)) {
$admin_link = $this->url->link($cfg['route'], 'user_token=' . $this->session->data['user_token'] . '&' . $cfg['param'] . '=' . (int)$row[$cfg['id']], true); $admin_link = $this->url->link($cfg['route'], 'token=' . (isset($this->session->data['token']) ? $this->session->data['token'] : '') . '&' . $cfg['param'] . '=' . (int)$row[$cfg['id']], true);
$search_links = $this->getSearchLinks($row[$cfg['name_field']], ($table === 'product_description' ? $row['model'] : '')); $search_links = $this->getSearchLinks($row[$cfg['name_field']], ($table === 'product_description' ? $row['model'] : ''));
$rows[] = array( $rows[] = array(
'id' => 'html_broken-' . $table . '-' . (int)$row[$cfg['id']] . '-' . md5($cleanRelPath), 'id' => 'html_broken-' . $table . '-' . (int)$row[$cfg['id']] . '-' . md5($cleanRelPath),

View File

@ -9,7 +9,7 @@
<h1><?php echo $heading_title; ?></h1> <h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb"> <ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?> <?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb[\'href\']; ?>"><?php echo $breadcrumb[\'text\']; ?></a></li> <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?> <?php } ?>
</ul> </ul>
</div> </div>
@ -62,10 +62,10 @@
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;"> <div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;">
<label><span data-toggle="tooltip" title="<?php echo $help_menu_position; ?>" style="cursor:help; border-bottom:1px dashed #999;"><?php echo $entry_menu_position; ?></span></label> <label><span data-toggle="tooltip" title="<?php echo $help_menu_position; ?>" style="cursor:help; border-bottom:1px dashed #999;"><?php echo $entry_menu_position; ?></span></label>
<select name="module_img_opti_menu_position" class="form-control"> <select name="module_img_opti_menu_position" class="form-control">
<option value="module_only" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == \'module_only\') { ?>selected="selected"<?php } ?>><?php echo $text_menu_module_only; ?></option> <option value="module_only" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == 'module_only') { ?>selected="selected"<?php } ?>><?php echo $text_menu_module_only; ?></option>
<option value="header" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == \'header\') { ?>selected="selected"<?php } ?>><?php echo $text_menu_header; ?></option> <option value="header" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == 'header') { ?>selected="selected"<?php } ?>><?php echo $text_menu_header; ?></option>
<option value="sidebar" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == \'sidebar\') { ?>selected="selected"<?php } ?>><?php echo $text_menu_sidebar; ?></option> <option value="sidebar" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == 'sidebar') { ?>selected="selected"<?php } ?>><?php echo $text_menu_sidebar; ?></option>
<option value="both" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == \'both\') { ?>selected="selected"<?php } ?>><?php echo $text_menu_both; ?></option> <option value="both" <?php if (isset($module_img_opti_menu_position) && $module_img_opti_menu_position == 'both') { ?>selected="selected"<?php } ?>><?php echo $text_menu_both; ?></option>
</select> </select>
</div> </div>
</div> </div>
@ -73,8 +73,8 @@
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;"> <div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;">
<label><span data-toggle="tooltip" title="<?php echo $help_engine; ?>" style="cursor:help; border-bottom:1px dashed #999;"><?php echo $entry_engine; ?></span></label> <label><span data-toggle="tooltip" title="<?php echo $help_engine; ?>" style="cursor:help; border-bottom:1px dashed #999;"><?php echo $entry_engine; ?></span></label>
<select name="module_img_opti_engine" class="form-control"> <select name="module_img_opti_engine" class="form-control">
<option value="gd" <?php if (isset($module_img_opti_engine) && $module_img_opti_engine == \'gd\') { ?>selected="selected"<?php } ?>><?php echo $text_engine_gd; ?></option> <option value="gd" <?php if (isset($module_img_opti_engine) && $module_img_opti_engine == 'gd') { ?>selected="selected"<?php } ?>><?php echo $text_engine_gd; ?></option>
<option value="imagick" <?php if (isset($module_img_opti_engine) && $module_img_opti_engine == \'imagick\') { ?>selected="selected"<?php } ?>><?php echo $text_engine_imagick; ?></option> <option value="imagick" <?php if (isset($module_img_opti_engine) && $module_img_opti_engine == 'imagick') { ?>selected="selected"<?php } ?>><?php echo $text_engine_imagick; ?></option>
</select> </select>
</div> </div>
</div> </div>
@ -136,19 +136,19 @@
<?php foreach ($module_img_opti_folder_rules as $rule) { ?> <?php foreach ($module_img_opti_folder_rules as $rule) { ?>
<tr id="rule-row<?php echo $rule_row; ?>"> <tr id="rule-row<?php echo $rule_row; ?>">
<td class="text-left"> <td class="text-left">
<input type="text" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][folder]" value="<?php echo $rule[\'folder\']; ?>" placeholder="catalog/banners/" class="form-control" /> <input type="text" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][folder]" value="<?php echo $rule['folder']; ?>" placeholder="catalog/banners/" class="form-control" />
</td> </td>
<td class="text-left"> <td class="text-left">
<input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][jpg_quality]" value="<?php echo $rule[\'jpg_quality\']; ?>" placeholder="72" min="1" max="100" class="form-control" /> <input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][jpg_quality]" value="<?php echo $rule['jpg_quality']; ?>" placeholder="72" min="1" max="100" class="form-control" />
</td> </td>
<td class="text-left"> <td class="text-left">
<input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][webp_quality]" value="<?php echo $rule[\'webp_quality\']; ?>" placeholder="80" min="1" max="100" class="form-control" /> <input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][webp_quality]" value="<?php echo $rule['webp_quality']; ?>" placeholder="80" min="1" max="100" class="form-control" />
</td> </td>
<td class="text-left"> <td class="text-left">
<input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][max_width]" value="<?php echo $rule[\'max_width\']; ?>" placeholder="1600" min="0" class="form-control" /> <input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][max_width]" value="<?php echo $rule['max_width']; ?>" placeholder="1600" min="0" class="form-control" />
</td> </td>
<td class="text-left"> <td class="text-left">
<input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][max_height]" value="<?php echo $rule[\'max_height\']; ?>" placeholder="1600" min="0" class="form-control" /> <input type="number" name="module_img_opti_folder_rules[<?php echo $rule_row; ?>][max_height]" value="<?php echo $rule['max_height']; ?>" placeholder="1600" min="0" class="form-control" />
</td> </td>
<td class="text-left"> <td class="text-left">
<button type="button" onclick="$('#rule-row<?php echo $rule_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $help_btn_remove_rule; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button> <button type="button" onclick="$('#rule-row<?php echo $rule_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $help_btn_remove_rule; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button>
@ -273,9 +273,9 @@
<?php foreach ($catalog_items as $item) { ?> <?php foreach ($catalog_items as $item) { ?>
<div class="checkbox" style="margin-left: 15px;"> <div class="checkbox" style="margin-left: 15px;">
<label> <label>
<input type="checkbox" name="selected_items[]" value="<?php echo $item[\'path\']; ?>"> <input type="checkbox" name="selected_items[]" value="<?php echo $item['path']; ?>">
<i class="fa fa-folder" style="color: #f39c12;"></i> <i class="fa fa-folder" style="color: #f39c12;"></i>
<?php echo $item[\'name\']; ?> <?php echo $item['name']; ?>
</label> </label>
</div> </div>
<?php } ?> <?php } ?>
@ -347,8 +347,8 @@
<div class="form-group"> <div class="form-group">
<label><?php echo $entry_log_level; ?></label> <label><?php echo $entry_log_level; ?></label>
<select name="module_img_opti_log_level" id="input-log-level" class="form-control"> <select name="module_img_opti_log_level" id="input-log-level" class="form-control">
<option value="changed" <?php if (isset($module_img_opti_log_level) && $module_img_opti_log_level == \'changed\') { ?>selected="selected"<?php } ?>><?php echo $text_log_changed_only; ?></option> <option value="changed" <?php if (isset($module_img_opti_log_level) && $module_img_opti_log_level == 'changed') { ?>selected="selected"<?php } ?>><?php echo $text_log_changed_only; ?></option>
<option value="all" <?php if (isset($module_img_opti_log_level) && $module_img_opti_log_level == \'all\') { ?>selected="selected"<?php } ?>><?php echo $text_log_all; ?></option> <option value="all" <?php if (isset($module_img_opti_log_level) && $module_img_opti_log_level == 'all') { ?>selected="selected"<?php } ?>><?php echo $text_log_all; ?></option>
</select> </select>
</div> </div>
</div> </div>
@ -477,9 +477,9 @@
<?php foreach ($catalog_items as $item) { ?> <?php foreach ($catalog_items as $item) { ?>
<div class="checkbox" style="margin-left: 15px;"> <div class="checkbox" style="margin-left: 15px;">
<label> <label>
<input type="checkbox" name="clean_items[]" value="<?php echo $item[\'path\']; ?>"> <input type="checkbox" name="clean_items[]" value="<?php echo $item['path']; ?>">
<i class="fa fa-folder" style="color: #f39c12;"></i> <i class="fa fa-folder" style="color: #f39c12;"></i>
<?php echo $item[\'name\']; ?> <?php echo $item['name']; ?>
</label> </label>
</div> </div>
<?php } ?> <?php } ?>
@ -909,7 +909,7 @@
<div class="tab-pane" id="tab-cron"> <div class="tab-pane" id="tab-cron">
<div class="alert alert-info" style="background: #2c3e50; color: white; border: none;"> <div class="alert alert-info" style="background: #2c3e50; color: white; border: none;">
<i class="fa fa-clock-o"></i> <b><?php echo $text_cron_title; ?></b> <?php echo $text_cron_desc; ?><br> <i class="fa fa-clock-o"></i> <b><?php echo $text_cron_title; ?></b> <?php echo $text_cron_desc; ?><br>
<code style="display:inline-block; margin-top:5px; background:#fff; padding:5px 10px; color:#333;">wget -q -O - "<?php echo str_replace(\'image/catalog\', \'\', $catalog_url); ?>index.php?route=module/img_opti_cron&amp;key=<?php echo $module_img_opti_token; ?>" &gt;/dev/null 2&gt;&amp;1</code> <code style="display:inline-block; margin-top:5px; background:#fff; padding:5px 10px; color:#333;">wget -q -O - "<?php echo str_replace('image/catalog', '', $catalog_url); ?>index.php?route=module/img_opti_cron&amp;key=<?php echo $module_img_opti_token; ?>" &gt;/dev/null 2&gt;&amp;1</code>
</div> </div>
<div class="row"> <div class="row">
@ -1050,8 +1050,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var urlParams = new URLSearchParams(window.location.search); var tokenParam = 'token=<?php echo $token; ?>';
var tokenParam = urlParams.has('token') ? 'token=' + urlParams.get('token') : 'token=' + urlParams.get('token');
var toolDescriptions = { var toolDescriptions = {
'broken_db': '<?php echo $help_tool_broken_db; ?>', 'broken_db': '<?php echo $help_tool_broken_db; ?>',
@ -1918,7 +1917,7 @@ $(document).ready(function() {
var statusText = task.status ? '<span class="label label-success"><?php echo $text_enabled; ?></span>' : '<span class="label label-danger"><?php echo $text_disabled; ?></span>'; var statusText = task.status ? '<span class="label label-success"><?php echo $text_enabled; ?></span>' : '<span class="label label-danger"><?php echo $text_disabled; ?></span>';
var escapedTaskName = encodeURIComponent(task.name); var escapedTaskName = encodeURIComponent(task.name);
var taskUrl = '<?php echo str_replace(\'image/catalog\', \'\', $catalog_url); ?>index.php?route=module/img_opti_cron&amp;key=<?php echo $module_img_opti_token; ?>&amp;task=' + escapedTaskName; var taskUrl = '<?php echo str_replace('image/catalog', '', $catalog_url); ?>index.php?route=module/img_opti_cron&amp;key=<?php echo $module_img_opti_token; ?>&amp;task=' + escapedTaskName;
html += '<tr>'; html += '<tr>';
html += ' <td><b>' + task.name + '</b><br><small class="text-muted">' + entitiesList + '</small></td>'; html += ' <td><b>' + task.name + '</b><br><small class="text-muted">' + entitiesList + '</small></td>';
@ -2047,15 +2046,15 @@ $(document).ready(function() {
var hint = ''; var hint = '';
if (mode === 'exclude') { if (mode === 'exclude') {
if (checkedCount === 0) { if (checkedCount === 0) {
hint = '{{ text_cron_folder_hint_exclude_all|escape("js") }}'; hint = '<?php echo $text_cron_folder_hint_exclude_all; ?>';
} else { } else {
hint = '{{ text_cron_folder_hint_exclude_some|escape("js") }}'.replace('%d', checkedCount); hint = '<?php echo $text_cron_folder_hint_exclude_some; ?>'.replace('%d', checkedCount);
} }
} else { } else {
if (checkedCount === 0) { if (checkedCount === 0) {
hint = '<span class="text-danger"><i class="fa fa-exclamation-triangle"></i> {{ text_cron_folder_hint_include_none|escape("js") }}</span>'; hint = '<span class="text-danger"><i class="fa fa-exclamation-triangle"></i> <?php echo $text_cron_folder_hint_include_none; ?></span>';
} else { } else {
hint = '{{ text_cron_folder_hint_include_some|escape("js") }}'.replace('%d', checkedCount); hint = '<?php echo $text_cron_folder_hint_include_some; ?>'.replace('%d', checkedCount);
} }
} }
$('.cron-task-folder-hint').html(hint); $('.cron-task-folder-hint').html(hint);
@ -3343,7 +3342,7 @@ $(document).ready(function() {
<select id="wm-rule-text-font" class="form-control"> <select id="wm-rule-text-font" class="form-control">
<option value=""><?php echo $text_no_fonts; ?></option> <option value=""><?php echo $text_no_fonts; ?></option>
<?php foreach ($ttf_fonts as $font) { ?> <?php foreach ($ttf_fonts as $font) { ?>
<option value="<?php echo $font[\'path\']; ?>"><?php echo $font[\'name\']; ?></option> <option value="<?php echo $font['path']; ?>"><?php echo $font['name']; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>

View File

@ -3,4 +3,164 @@ if (!defined('DIR_APPLICATION')) { exit; }
if (!class_exists('ModelModuleImgOpti')) { if (!class_exists('ModelModuleImgOpti')) {
require_once(DIR_APPLICATION . 'model/module/img_opti.php'); require_once(DIR_APPLICATION . 'model/module/img_opti.php');
} }
class ModelExtensionModuleImgOpti extends ModelModuleImgOpti {} class ModelExtensionModuleImgOpti extends ModelModuleImgOpti {
public function checkAndFixFakeJpgOnTheFly($filename) {
if (!$this->config->get('module_img_opti_status') || !$this->config->get('module_img_opti_auto_fake_jpg_guard')) {
return $filename;
}
$cleanFile = str_replace(array('../', '..\\', "\0"), '', (string)$filename);
$ext = strtolower(pathinfo($cleanFile, PATHINFO_EXTENSION));
if (!in_array($ext, array('jpg', 'jpeg'))) {
return $filename;
}
$fullPath = DIR_IMAGE . $cleanFile;
if (!is_file($fullPath)) {
return $filename;
}
$header = @file_get_contents($fullPath, false, null, 0, 8);
if ($header !== "\x89PNG\r\n\x1a\n") {
return $filename;
}
$mode = $this->config->get('module_img_opti_fake_jpg_mode');
if ($mode === 'png') {
$newRelPath = preg_replace('/\.(jpg|jpeg)$/i', '.png', $cleanFile);
$newFullPath = DIR_IMAGE . $newRelPath;
if (@copy($fullPath, $newFullPath)) {
$this->updateImagePathInDb($cleanFile, $newRelPath);
$this->deleteImageCache($cleanFile);
@unlink($fullPath);
return $newRelPath;
}
} else {
if ($this->convertPngToJpgClean($fullPath, 100)) {
$this->deleteImageCache($cleanFile);
}
}
return $filename;
}
public function convertPngToJpgClean($sourcePngPath, $targetJpgPath = null, $quality = 100, $bgColorHex = '#ffffff') {
if (is_numeric($targetJpgPath) && $quality === 100) {
$quality = (int)$targetJpgPath;
$targetJpgPath = null;
}
if ($targetJpgPath === null) {
$targetJpgPath = $sourcePngPath;
}
$img = @imagecreatefrompng($sourcePngPath);
if (!$img) return false;
$img = $this->normalizePngPalette($img);
$width = imagesx($img);
$height = imagesy($img);
$canvas = imagecreatetruecolor($width, $height);
if (!$canvas) {
imagedestroy($img);
return false;
}
$hex = ltrim($bgColorHex, '#');
if (strlen($hex) == 3) {
$r = hexdec(str_repeat(substr($hex, 0, 1), 2));
$g = hexdec(str_repeat(substr($hex, 1, 1), 2));
$b = hexdec(str_repeat(substr($hex, 2, 1), 2));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$bgColor = imagecolorallocate($canvas, $r, $g, $b);
imagefilledrectangle($canvas, 0, 0, $width, $height, $bgColor);
imagealphablending($canvas, true);
imagecopy($canvas, $img, 0, 0, 0, 0, $width, $height);
$res = @imagejpeg($canvas, $targetJpgPath, $quality);
imagedestroy($canvas);
imagedestroy($img);
return $res;
}
public function normalizePngPalette($img) {
if ($img && function_exists('imagepalettetotruecolor') && !imageistruecolor($img)) {
imagepalettetotruecolor($img);
}
return $img;
}
private function updateImagePathInDb($oldPath, $newPath) {
$escapedOld = $this->db->escape((string)$oldPath);
$escapedNew = $this->db->escape((string)$newPath);
$updated = 0;
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "product_image` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "category` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "manufacturer` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$table_query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "banner_image'");
if ($table_query->num_rows) {
$this->db->query("UPDATE `" . DB_PREFIX . "banner_image` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
}
$blog_tables = array('oct_blog_article', 'simple_blog_article', 'newsblog_article', 'information');
foreach ($blog_tables as $table) {
$table_query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . $table . "'");
if ($table_query->num_rows) {
$column_query = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . $table . "` LIKE 'image'");
if ($column_query->num_rows) {
try {
$this->db->query("UPDATE `" . DB_PREFIX . $table . "` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
} catch (\Exception $e) {}
}
}
}
return $updated;
}
private function deleteImageCache($relPath) {
$info = $this->mb_pathinfo($relPath);
if (!isset($info['filename'])) return;
$filename = $info['filename'];
$cache_dirs = array(realpath(DIR_IMAGE . 'cache'), realpath(DIR_IMAGE . 'cachewebp'));
foreach ($cache_dirs as $cache_dir) {
if (!$cache_dir || !is_dir($cache_dir)) continue;
try {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $file) {
if ($file->isFile()) {
$fn = $file->getFilename();
if (strpos($fn, $filename . '-') === 0 || strpos($fn, $filename . '.') === 0 || strpos($fn, $filename . '_') === 0) {
@unlink($file->getPathname());
}
}
}
} catch (\Exception $e) {}
}
}
}

View File

@ -669,4 +669,164 @@ private function hex2rgb($hex) {
$parts = explode('/', $path); $parts = explode('/', $path);
return end($parts); return end($parts);
} }
public function checkAndFixFakeJpgOnTheFly($filename) {
if (!$this->config->get('module_img_opti_status') || !$this->config->get('module_img_opti_auto_fake_jpg_guard')) {
return $filename;
}
$cleanFile = str_replace(array('../', '..\\', "\0"), '', (string)$filename);
$ext = strtolower(pathinfo($cleanFile, PATHINFO_EXTENSION));
if (!in_array($ext, array('jpg', 'jpeg'))) {
return $filename;
}
$fullPath = DIR_IMAGE . $cleanFile;
if (!is_file($fullPath)) {
return $filename;
}
$header = @file_get_contents($fullPath, false, null, 0, 8);
if ($header !== "\x89PNG\r\n\x1a\n") {
return $filename;
}
$mode = $this->config->get('module_img_opti_fake_jpg_mode');
if ($mode === 'png') {
$newRelPath = preg_replace('/\.(jpg|jpeg)$/i', '.png', $cleanFile);
$newFullPath = DIR_IMAGE . $newRelPath;
if (@copy($fullPath, $newFullPath)) {
$this->updateImagePathInDb($cleanFile, $newRelPath);
$this->deleteImageCache($cleanFile);
@unlink($fullPath);
return $newRelPath;
}
} else {
if ($this->convertPngToJpgClean($fullPath, 100)) {
$this->deleteImageCache($cleanFile);
}
}
return $filename;
}
public function convertPngToJpgClean($sourcePngPath, $targetJpgPath = null, $quality = 100, $bgColorHex = '#ffffff') {
if (is_numeric($targetJpgPath) && $quality === 100) {
$quality = (int)$targetJpgPath;
$targetJpgPath = null;
}
if ($targetJpgPath === null) {
$targetJpgPath = $sourcePngPath;
}
$img = @imagecreatefrompng($sourcePngPath);
if (!$img) return false;
$img = $this->normalizePngPalette($img);
$width = imagesx($img);
$height = imagesy($img);
$canvas = imagecreatetruecolor($width, $height);
if (!$canvas) {
imagedestroy($img);
return false;
}
$hex = ltrim($bgColorHex, '#');
if (strlen($hex) == 3) {
$r = hexdec(str_repeat(substr($hex, 0, 1), 2));
$g = hexdec(str_repeat(substr($hex, 1, 1), 2));
$b = hexdec(str_repeat(substr($hex, 2, 1), 2));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$bgColor = imagecolorallocate($canvas, $r, $g, $b);
imagefilledrectangle($canvas, 0, 0, $width, $height, $bgColor);
imagealphablending($canvas, true);
imagecopy($canvas, $img, 0, 0, 0, 0, $width, $height);
$res = @imagejpeg($canvas, $targetJpgPath, $quality);
imagedestroy($canvas);
imagedestroy($img);
return $res;
}
public function normalizePngPalette($img) {
if ($img && function_exists('imagepalettetotruecolor') && !imageistruecolor($img)) {
imagepalettetotruecolor($img);
}
return $img;
}
private function updateImagePathInDb($oldPath, $newPath) {
$escapedOld = $this->db->escape((string)$oldPath);
$escapedNew = $this->db->escape((string)$newPath);
$updated = 0;
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "product_image` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "category` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$this->db->query("UPDATE `" . DB_PREFIX . "manufacturer` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
$table_query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "banner_image'");
if ($table_query->num_rows) {
$this->db->query("UPDATE `" . DB_PREFIX . "banner_image` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
}
$blog_tables = array('oct_blog_article', 'simple_blog_article', 'newsblog_article', 'information');
foreach ($blog_tables as $table) {
$table_query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . $table . "'");
if ($table_query->num_rows) {
$column_query = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . $table . "` LIKE 'image'");
if ($column_query->num_rows) {
try {
$this->db->query("UPDATE `" . DB_PREFIX . $table . "` SET image = '" . $escapedNew . "' WHERE image = '" . $escapedOld . "'");
$updated += $this->db->countAffected();
} catch (\Exception $e) {}
}
}
}
return $updated;
}
private function deleteImageCache($relPath) {
$info = $this->mb_pathinfo($relPath);
if (!isset($info['filename'])) return;
$filename = $info['filename'];
$cache_dirs = array(realpath(DIR_IMAGE . 'cache'), realpath(DIR_IMAGE . 'cachewebp'));
foreach ($cache_dirs as $cache_dir) {
if (!$cache_dir || !is_dir($cache_dir)) continue;
try {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $file) {
if ($file->isFile()) {
$fn = $file->getFilename();
if (strpos($fn, $filename . '-') === 0 || strpos($fn, $filename . '.') === 0 || strpos($fn, $filename . '_') === 0) {
@unlink($file->getPathname());
}
}
}
} catch (\Exception $e) {}
}
}
} }