OpenCart 🇺🇦

Схема

public mixed move ( )

Аргументы

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

Описание

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

Исходный код

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

$json = array();

if (isset($this->request->post['from']) && isset($this->request->post['to'])) {
	$from = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['from'], ENT_QUOTES, 'UTF-8')), '/');

	if (!file_exists($from)) {
		$json['error'] = $this->language->get('error_missing');
	}

	if ($from == DIR_IMAGE . 'data') {
		$json['error'] = $this->language->get('error_default');
	}

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

	if (!file_exists($to)) {
		$json['error'] = $this->language->get('error_move');
	}

	if (file_exists($to . '/' . basename($from))) {
		$json['error'] = $this->language->get('error_exists');
	}
} else {
	$json['error'] = $this->language->get('error_directory');
}

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

if (!isset($json['error'])) {
	rename($from, $to . '/' . basename($from));

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

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