2017-08-09 10:34:05 +02:00

26 lines
975 B
PHP

<?php
class addFileOrderGetFileModuleFrontController extends ModuleFrontController
{
public function initContent()
{
if(Tools::getValue('token') && Tools::getValue('token') == '5d4f496cffb54a296b2a539cc8fda9c19876cc43') {
header('Content-Type: application/pdf');
header('Content-disposition: attachment;filename='.Tools::getValue('nameFile'));
readfile(_PS_ROOT_DIR_.'/../files/order_'.Tools::getValue(id_order).'/'.Tools::getValue('nameFile'));
exit;
} else {
$order = new Order(Tools::getValue('id_order'));
if ($order->id_customer == Context::getContext()->customer->id) {
header('Content-Type: application/pdf');
header('Content-disposition: attachment;filename='.Tools::getValue('nameFile'));
readfile(_PS_ROOT_DIR_.'/../files/order_'.Tools::getValue(id_order).'/'.Tools::getValue('nameFile'));
exit;
} else {
http_response_code(403);
exit('403 Forbidden');
}
}
}
}