OpenCart 🇺🇦

Схема

public mixed download ( )

Аргументы

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

Описание

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

Исходный код

$this->load->model('sale/order');

if (isset($this->request->get['order_option_id'])) {
	$order_option_id = $this->request->get['order_option_id'];
} else {
	$order_option_id = 0;
}

$option_info = $this->model_sale_order->getOrderOption($this->request->get['order_id'], $order_option_id);

if ($option_info && $option_info['type'] == 'file') {
	$file = DIR_DOWNLOAD . $option_info['value'];
	$mask = basename(utf8_substr($option_info['value'], 0, utf8_strrpos($option_info['value'], '.')));

	if (!headers_sent()) {
		if (file_exists($file)) {
			header('Content-Type: application/octet-stream');
			header('Content-Description: File Transfer');
			header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
			header('Content-Transfer-Encoding: binary');
			header('Expires: 0');
			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
			header('Pragma: public');
			header('Content-Length: ' . filesize($file));

			readfile($file, 'rb');
			exit;
		} else {
			exit('Error: Could not find file ' . $file . '!');
		}
	} else {
		exit('Error: Headers already sent out!');
	}
} else {
	$this->language->load('error/not_found');

	$this->document->setTitle($this->language->get('heading_title'));

	$this->data['heading_title'] = $this->language->get('heading_title');

	$this->data['text_not_found'] = $this->language->get('text_not_found');

	$this->data['breadcrumbs'] = array();

	$this->data['breadcrumbs'][] = array(
		'text'      => $this->language->get('text_home'),
		'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
		'separator' => false
	);

	$this->data['breadcrumbs'][] = array(
		'text'      => $this->language->get('heading_title'),
		'href'      => $this->url->link('error/not_found', 'token=' . $this->session->data['token'], 'SSL'),
		'separator' => ' :: '
	);

	$this->template = 'error/not_found.tpl';
	$this->children = array(
		'common/header',
		'common/footer'
	);

	$this->response->setOutput($this->render());
}