fix(4.0): escape global classes (\ZipArchive, \Throwable, \Action, \Pagination), fix cron model loader

This commit is contained in:
nertyog 2026-10-12 05:28:36 +03:00
parent 0f031e5660
commit 45702f72b4
5 changed files with 28 additions and 14 deletions

View File

@ -614,9 +614,9 @@ class EasyImportNat extends \Opencart\System\Engine\Controller {
} }
$zip_file = DIR_CACHE . 'backup_prices_stock_' . date('Y-m-d_H-i-s') . '_' . uniqid() . '.zip'; $zip_file = DIR_CACHE . 'backup_prices_stock_' . date('Y-m-d_H-i-s') . '_' . uniqid() . '.zip';
$zip = new ZipArchive(); $zip = new \ZipArchive();
if ($zip->open($zip_file, ZipArchive::CREATE) !== TRUE) { if ($zip->open($zip_file, \ZipArchive::CREATE) !== TRUE) {
die('Cannot create zip file on server'); die('Cannot create zip file on server');
} }
@ -2426,8 +2426,8 @@ public function deleteCronProfile() {
private function extractCompressedFile($src_file, $original_filename, &$ext) { private function extractCompressedFile($src_file, $original_filename, &$ext) {
$temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true)); $temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true));
if ($ext === 'zip') { if ($ext === 'zip') {
if (class_exists('ZipArchive')) { if (class_exists('\\ZipArchive')) {
$zip = new ZipArchive; $zip = new \ZipArchive;
if ($zip->open($src_file) === TRUE) { if ($zip->open($src_file) === TRUE) {
$found_file = ''; $found_file = '';
$found_ext = ''; $found_ext = '';
@ -3975,7 +3975,7 @@ private function formatPriceImport($price) {
} }
// Pagination // Pagination
$pagination = new Pagination(); $pagination = new \Opencart\System\Library\Pagination();
$pagination->total = $total; $pagination->total = $total;
$pagination->page = $page; $pagination->page = $page;
$pagination->limit = $limit; $pagination->limit = $limit;
@ -4005,7 +4005,7 @@ private function formatPriceImport($price) {
public function downloadLogFile() { public function downloadLogFile() {
if (!isset($this->request->get['user_token']) || !isset($this->session->data['user_token']) || $this->request->get['user_token'] !== $this->session->data['user_token'] || !$this->user->hasPermission('access', 'extension/easy_import_nat/module/easy_import_nat')) { if (!isset($this->request->get['user_token']) || !isset($this->session->data['user_token']) || $this->request->get['user_token'] !== $this->session->data['user_token'] || !$this->user->hasPermission('access', 'extension/easy_import_nat/module/easy_import_nat')) {
return new Action('error/not_found'); return new \Opencart\System\Engine\Action('error/not_found');
} }
if (isset($this->request->get['file'])) { if (isset($this->request->get['file'])) {
$file = basename($this->request->get['file']); $file = basename($this->request->get['file']);

View File

@ -550,7 +550,7 @@ class EasyImportNat extends \Opencart\System\Engine\Model {
try { try {
$this->db->query("ALTER TABLE `" . $table_name . "` ADD `" . $column_name . "` VARCHAR(255) NOT NULL DEFAULT ''"); $this->db->query("ALTER TABLE `" . $table_name . "` ADD `" . $column_name . "` VARCHAR(255) NOT NULL DEFAULT ''");
self::$schema_cache[$table_name . '.' . $column_name] = true; self::$schema_cache[$table_name . '.' . $column_name] = true;
} catch (Exception $e) { } catch (\Throwable $e) {
return false; return false;
} }
} }
@ -603,7 +603,7 @@ class EasyImportNat extends \Opencart\System\Engine\Model {
} else { } else {
$this->db->query("INSERT INTO `" . $table_name . "` SET product_id = '" . (int)$product_id . "', `" . $column_name . "` = '" . $this->db->escape($value) . "'"); $this->db->query("INSERT INTO `" . $table_name . "` SET product_id = '" . (int)$product_id . "', `" . $column_name . "` = '" . $this->db->escape($value) . "'");
} }
} catch (Exception $e) { } catch (\Throwable $e) {
return false; return false;
} }
} }

View File

@ -67,15 +67,29 @@ class EasyImportNatCron extends \Opencart\System\Engine\Controller {
} }
}); });
$admin_model_path = DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php'; $$admin_model_path = '';
if (!file_exists($admin_model_path)) { if (defined('DIR_EXTENSION') && is_file(DIR_EXTENSION . 'easy_import_nat/admin/model/module/easy_import_nat.php')) {
$admin_model_path = DIR_EXTENSION . 'easy_import_nat/admin/model/module/easy_import_nat.php';
} elseif (is_file(DIR_APPLICATION . '../extension/easy_import_nat/admin/model/module/easy_import_nat.php')) {
$admin_model_path = DIR_APPLICATION . '../extension/easy_import_nat/admin/model/module/easy_import_nat.php';
} elseif (is_file(DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php')) {
$admin_model_path = DIR_APPLICATION . '../admin/model/extension/module/easy_import_nat.php';
}
if (!$admin_model_path || !file_exists($admin_model_path)) {
if ($lock_fp) { flock($lock_fp, LOCK_UN); fclose($lock_fp); } if ($lock_fp) { flock($lock_fp, LOCK_UN); fclose($lock_fp); }
if ($lock_file && file_exists($lock_file)) { @unlink($lock_file); } if ($lock_file && file_exists($lock_file)) { @unlink($lock_file); }
exit("Admin model file not found\n"); exit("Admin model file not found\n");
} }
require_once $admin_model_path; require_once $admin_model_path;
$model = new ModelExtensionModuleEasyImportNat($this->registry); if (class_exists('\\Opencart\\Admin\\Model\\Extension\\EasyImportNat\\Module\\EasyImportNat')) {
$model = new \Opencart\Admin\Model\Extension\EasyImportNat\Module\EasyImportNat($this->registry);
} elseif (class_exists('ModelExtensionModuleEasyImportNat')) {
$model = new \ModelExtensionModuleEasyImportNat($this->registry);
} else {
exit("Admin model class not found\n");
}
$profile = $model->getCronProfile($profile_id); $profile = $model->getCronProfile($profile_id);
if (!$profile || empty($profile['status'])) { if (!$profile || empty($profile['status'])) {
@ -2463,8 +2477,8 @@ class EasyImportNatCron extends \Opencart\System\Engine\Controller {
private function extractCompressedFile($src_file, $original_filename, &$ext) { private function extractCompressedFile($src_file, $original_filename, &$ext) {
$temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true)); $temp_extracted = DIR_CACHE . 'nat_extract_' . md5(uniqid('nat_', true));
if ($ext === 'zip') { if ($ext === 'zip') {
if (class_exists('ZipArchive')) { if (class_exists('\\ZipArchive')) {
$zip = new ZipArchive; $zip = new \ZipArchive;
if ($zip->open($src_file) === TRUE) { if ($zip->open($src_file) === TRUE) {
$found_file = ''; $found_file = '';
$found_ext = ''; $found_ext = '';

Binary file not shown.