OpenCart 🇺🇦

Схема

public mixed copy ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$this->language->load('common/filemanager');

$json = array();

if (isset($this->request->post['path']) && isset($this->request->post['name'])) {
	if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 255)) {
		$json['error'] = $this->language->get('error_filename');
	}

	$old_name = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

	if (!file_exists($old_name) || $old_name == DIR_IMAGE . 'data') {
		$json['error'] = $this->language->get('error_copy');
	}

	if (is_file($old_name)) {
		$ext = strrchr($old_name, '.');
	} else {
		$ext = '';
	}

	$new_name = dirname($old_name) . '/' . str_replace('../', '', html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8') . $ext);

	if (file_exists($new_name)) {
		$json['error'] = $this->language->get('error_exists');
	}
} else {
	$json['error'] = $this->language->get('error_select');
}

if (!$this->user->hasPermission('modify', 'common/filemanager')) {
	$json['error'] = $this->language->get('error_permission');
}

if (!isset($json['error'])) {
	if (is_file($old_name)) {
		copy($old_name, $new_name);
	} else {
		$this->recursiveCopy($old_name, $new_name);
	}

	$json['success'] = $this->language->get('text_copy');
}

$this->response->setOutput(json_encode($json));