HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/retile.ru/public_html/catalog/model/extension/module/iwatermark.php
<?php

class ModelExtensionModuleIwatermark extends Model {
    public function loadImageSymlink() {
        if (!$this->registry->has('watermark_image_symlink')) {
            $file = DIR_SYSTEM . 'library/vendor/isenselabs/watermark/OpenCartImageSymlink.php';

            if (class_exists('\\VQMod')) {
                include_once(\VQMod::modCheck(modification($file)));
            } else {
                include_once(modification($file));
            }

            $this->registry->set('watermark_image_symlink', new OpenCartImageSymlink($this->registry));
        }

        return $this->registry->get('watermark_image_symlink');
    }

    public function imageSymlinkLinkImage($product_id, $original, $is_additional = false, $with_prefix = true) {
        return $this->loadImageSymlink()->linkImage($product_id, $original, $is_additional, $with_prefix);
    }

    public function isWatermarkable($file, $width, $height) {
        if (!$this->config->get('module_iwatermark_status')) {
            return false;
        }

        $regex = '~/\d+-\d+/(\d+)/(main|additional)/.*~i';
        $matches = array();

        if (!preg_match($regex, $file, $matches)) {
            return false;
        }

        $product_id = $matches[1];

        $meets_category_condition = true;
        $meets_product_condition = true;

        if ($this->config->get('module_iwatermark_category_type') == 'specific') {
            if (is_array($this->config->get('module_iwatermark_category'))) {
                $meets_category_condition = $this->db->query("SELECT product_id FROM `" . DB_PREFIX . "product_to_category` WHERE product_id='" . (int)$product_id . "' AND category_id IN (" . implode(',', $this->config->get('module_iwatermark_category')) . ")")->num_rows > 0;
            } else {
                $meets_category_condition = false;
            }
        }

        if ($this->config->get('module_iwatermark_product_type') == 'specific') {
            if (is_array($this->config->get('module_iwatermark_product'))) {
                $meets_product_condition = in_array($product_id, $this->config->get('module_iwatermark_product'));
            } else {
                $meets_product_condition = false;
            }
        }

        if (!$meets_category_condition && !$meets_product_condition) {
            return false;
        }

        if ($this->config->get('module_iwatermark_dimension_type') == 'all' || 
            (
                $this->config->get('module_iwatermark_dimension_type') == 'bigger' && 
                (
                    $width > (int)$this->config->get('module_iwatermark_dimension_width') && !$this->config->get('module_iwatermark_dimension_height') || 
                    $height > (int)$this->config->get('module_iwatermark_dimension_height') && !$this->config->get('module_iwatermark_dimension_width') || 
                    $width > (int)$this->config->get('module_iwatermark_dimension_width') && $height > (int)$this->config->get('module_iwatermark_dimension_height')
                )
            )
            ||
            (
                $this->config->get('module_iwatermark_dimension_type') == 'smaller' && 
                (
                    $width < (int)$this->config->get('module_iwatermark_dimension_width') && !$this->config->get('module_iwatermark_dimension_height') || 
                    $height < (int)$this->config->get('module_iwatermark_dimension_height') && !$this->config->get('module_iwatermark_dimension_width') || 
                    $width < (int)$this->config->get('module_iwatermark_dimension_width') && $height < (int)$this->config->get('module_iwatermark_dimension_height')
                )
            )
        ) {
            return true;
        }

        return false;
    }

    public function getWatermarkSettings() {
        return array(
            'type' => $this->config->get('module_iwatermark_watermark_type'),
            'font_size' => $this->config->get('module_iwatermark_font_size'),
            'font' => $this->config->get('module_iwatermark_font'),
            'text' => $this->config->get('module_iwatermark_text'),
            'color' => $this->config->get('module_iwatermark_color'),
            'image_file' => $this->config->get('module_iwatermark_image_file'),
            'opacity_type' => $this->config->get('module_iwatermark_opacity_type'),
            'opacity' => $this->config->get('module_iwatermark_opacity'),
            'rotation' => $this->config->get('module_iwatermark_rotation'),
            'position' => $this->config->get('module_iwatermark_position')
        );
    }
}