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/storage/modification/catalog/model/tool/image.php
<?php
class ModelToolImage extends Model {
	public function resize($filename, $width, $height) {

                if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
                    $server = HTTPS_SERVER;
                } else {
                    $server = HTTP_SERVER;
                }

                if ($filename) {
                    $image_info = @getimagesize(DIR_IMAGE . $filename);
                    if (!$image_info) {
                        return $server . 'image/' . $filename;
                    }
                } else {
                    $filename = "no_image.png";
                }
                
		if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != str_replace('\\', '/', DIR_IMAGE)) {
			return;
		}

		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		$image_old = $filename;
		$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

		if (!is_file(DIR_IMAGE . $image_new) || (filemtime(DIR_IMAGE . $image_old) > filemtime(DIR_IMAGE . $image_new))) {
			list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);
				 
			if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) { 
				return DIR_IMAGE . $image_old;
			}
						
			$path = '';

			$directories = explode('/', dirname($image_new));

			foreach ($directories as $directory) {
				$path = $path . '/' . $directory;

				if (!is_dir(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}
			}

			if ($width_orig != $width || $height_orig != $height) {
				$image = new Image(DIR_IMAGE . $image_old);
				$image->resize($width, $height);
                // Begin WaterMark - from from the modification "WaterMark by iSenseLabs"
                $this->load->model('extension/module/iwatermark');

                if ($this->model_extension_module_iwatermark->isWatermarkable(DIR_IMAGE . $image_old, $width, $height)) {
                    $image->iwatermark($this->registry, $this->model_extension_module_iwatermark->getWatermarkSettings());
                }
                // End WaterMark - from from the modification "WaterMark by iSenseLabs"
				$image->save(DIR_IMAGE . $image_new);
			} else {
				copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
                // Begin WaterMark - from from the modification "WaterMark by iSenseLabs"
                $this->load->model('extension/module/iwatermark');

                if ($this->model_extension_module_iwatermark->isWatermarkable(DIR_IMAGE . $image_old, $width, $height)) {
                    $image = new Image(DIR_IMAGE . $image_new);
                    $image->iwatermark($this->registry, $this->model_extension_module_iwatermark->getWatermarkSettings());
                    $image->save(DIR_IMAGE . $image_new);
                }
                // End WaterMark - from from the modification "WaterMark by iSenseLabs"
			}
		}
		
		$image_new = str_replace(' ', '%20', $image_new);  // fix bug when attach image on email (gmail.com). it is automatic changing space " " to +
		
		if ($this->request->server['HTTPS']) {
			return $this->config->get('config_ssl') . 'image/' . $image_new;
		} else {
			return $this->config->get('config_url') . 'image/' . $image_new;
		}
	}
}