Merge branch 'Qloapps:develop' into gli-2943
This commit is contained in:
@@ -300,8 +300,8 @@
|
||||
{if $params.type == 'range'}
|
||||
{$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"}
|
||||
<div class="input_range">
|
||||
<input type="text" class="filter form-control" name="{$field_name}[0]" placeholder="{l s='From'}" value="{if isset($smarty.post[$field_name][0]) && $smarty.post[$field_name][0]}{$smarty.post[$field_name][0]}{elseif isset($params.value.0)}{$params.value.0}{/if}">
|
||||
<input type="text" class="filter form-control" name="{$field_name}[1]" placeholder="{l s='To'}" value="{if isset($smarty.post[$field_name][1]) && $smarty.post[$field_name][1]}{$smarty.post[$field_name][1]}{elseif isset($params.value.1)}{$params.value.1}{/if}">
|
||||
<input type="text" class="filter form-control" name="{$field_name}[0]" placeholder="{l s='From'}" value="{if isset($smarty.post[$field_name][0]) && $smarty.post[$field_name][0]}{$smarty.post[$field_name][0]|escape:'html':'UTF-8'}{elseif isset($params.value.0)}{$params.value.0}{/if}">
|
||||
<input type="text" class="filter form-control" name="{$field_name}[1]" placeholder="{l s='To'}" value="{if isset($smarty.post[$field_name][1]) && $smarty.post[$field_name][1]}{$smarty.post[$field_name][1]|escape:'html':'UTF-8'}{elseif isset($params.value.1)}{$params.value.1}{/if}">
|
||||
</div>
|
||||
{elseif $params.type == 'bool'}
|
||||
{$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"}
|
||||
@@ -314,14 +314,14 @@
|
||||
<div class="date_range">
|
||||
<div class="input-group center">
|
||||
<input type="text" class="filter datepicker date-input form-control" id="local_{$params.id_date}_0" name="local_{$params.name_date}[0]" placeholder="{l s='From'}" autocomplete="off"/>
|
||||
<input type="hidden" id="{$params.id_date}_0" name="{$params.name_date}[0]" value="{if isset($smarty.post[$params.name_date][0]) && $smarty.post[$params.name_date][0]}{$smarty.post[$params.name_date][0]}{elseif isset($params.value.0)}{$params.value.0}{/if}">
|
||||
<input type="hidden" id="{$params.id_date}_0" name="{$params.name_date}[0]" value="{if isset($smarty.post[$params.name_date][0]) && $smarty.post[$params.name_date][0]}{$smarty.post[$params.name_date][0]|escape:'html':'UTF-8'}{elseif isset($params.value.0)}{$params.value.0}{/if}">
|
||||
<span class="input-group-addon">
|
||||
<i class="icon-calendar"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="input-group center">
|
||||
<input type="text" class="filter datepicker date-input form-control" id="local_{$params.id_date}_1" name="local_{$params.name_date}[1]" placeholder="{l s='To'}" autocomplete="off"/>
|
||||
<input type="hidden" id="{$params.id_date}_1" name="{$params.name_date}[1]" value="{if isset($smarty.post[$params.name_date][1]) && $smarty.post[$params.name_date][1]}{$smarty.post[$params.name_date][1]}{elseif isset($params.value.1)}{$params.value.1}{/if}">
|
||||
<input type="hidden" id="{$params.id_date}_1" name="{$params.name_date}[1]" value="{if isset($smarty.post[$params.name_date][1]) && $smarty.post[$params.name_date][1]}{$smarty.post[$params.name_date][1]|escape:'html':'UTF-8'}{elseif isset($params.value.1)}{$params.value.1}{/if}">
|
||||
<span class="input-group-addon">
|
||||
<i class="icon-calendar"></i>
|
||||
</span>
|
||||
@@ -398,7 +398,7 @@
|
||||
{/if}
|
||||
{else}
|
||||
{$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"}
|
||||
<input type="text" id="filter_input_{$key}" class="filter" name="{$field_name}" value="{if isset($smarty.post.$field_name) && $smarty.post.$field_name}{$smarty.post.$field_name}{else}{$params.value|escape:'html':'UTF-8'}{/if}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
|
||||
<input type="text" id="filter_input_{$key}" class="filter" name="{$field_name}" value="{if isset($smarty.post.$field_name) && $smarty.post.$field_name}{$smarty.post.$field_name|escape:'html':'UTF-8'}{else}{$params.value|escape:'html':'UTF-8'}{/if}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4059,10 +4059,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = $this->l('Please select a file to upload.');
|
||||
} elseif ($objHotelBookingDocument->fileInfo['size'] > Tools::getMaxUploadSize()) {
|
||||
$this->errors[] = $this->l('Uploaded file size is too large.');
|
||||
} elseif(!(ImageManager::isRealImage($objHotelBookingDocument->fileInfo['tmp_name'])
|
||||
|| $objHotelBookingDocument->fileInfo['mime'] == 'application/pdf')
|
||||
) {
|
||||
$this->errors[] = $this->l('Please upload an image or a PDF file only. Allowed image formats: .gif, .jpg, .jpeg and .png');
|
||||
} else {
|
||||
$objHotelBookingDocument->setFileType();
|
||||
if (!$objHotelBookingDocument->file_type) {
|
||||
$this->errors[] = $this->l('Please upload an image or a PDF file only. Allowed image formats: .gif, .jpg, .jpeg and .png');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this order.');
|
||||
|
||||
@@ -133,16 +133,19 @@ class HotelBookingDocument extends ObjectModel
|
||||
|
||||
public function getDestinationFilePath()
|
||||
{
|
||||
$fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION);
|
||||
|
||||
return $this->documentFolder.$this->id.'.'.$fileExtension;
|
||||
return $this->documentFolder.$this->id.'.'.$this->getFileExtension();
|
||||
}
|
||||
|
||||
public function setFileType()
|
||||
{
|
||||
if (ImageManager::isRealImage($this->fileInfo['tmp_name'])) {
|
||||
$content = @file_get_contents($this->fileInfo['tmp_name']);
|
||||
$activeContentPattern = '/\/(JavaScript|JS|OpenAction|AA|Launch|SubmitForm|ImportData)\b/i';
|
||||
|
||||
$this->imageInfo = @getimagesize($this->fileInfo['tmp_name']);
|
||||
|
||||
if ($this->imageInfo && ImageManager::isRealImage($this->fileInfo['tmp_name'])) {
|
||||
$this->file_type = self::FILE_TYPE_IMAGE;
|
||||
} elseif ($this->fileInfo['mime'] == 'application/pdf') {
|
||||
} elseif ($content !== false && substr($content, 0, 5) === '%PDF-' && !preg_match($activeContentPattern, $content)) {
|
||||
$this->file_type = self::FILE_TYPE_PDF;
|
||||
} else {
|
||||
$this->file_type = 0;
|
||||
@@ -151,8 +154,22 @@ class HotelBookingDocument extends ObjectModel
|
||||
|
||||
public function setFileName()
|
||||
{
|
||||
$fileExtension = pathinfo($this->fileInfo['rename'], PATHINFO_EXTENSION);
|
||||
$this->file_name = $this->id.'.'.$fileExtension;
|
||||
$this->file_name = $this->id.'.'.$this->getFileExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension is derived from the file's real, validated content
|
||||
* (getimagesize()/PDF signature), captured once in setFileType(),
|
||||
* never from the uploaded filename or mime header (both are
|
||||
* attacker-controlled).
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
if ($this->file_type == self::FILE_TYPE_PDF) {
|
||||
return 'pdf';
|
||||
}
|
||||
|
||||
return image_type_to_extension($this->imageInfo[2], false);
|
||||
}
|
||||
|
||||
public function getContentType()
|
||||
|
||||
@@ -34,7 +34,11 @@ class AdminBookingDocumentController extends ModuleAdminController
|
||||
$contentLength = $objHotelBookingDocument->getContentLength();
|
||||
$filePath = $objHotelBookingDocument->getPhysicalPath();
|
||||
$downloadFileName = $objHotelBookingDocument->getDownloadFileName();
|
||||
$contentDisposition = Tools::getValue('is_preview') ? 'inline' : 'attachment';
|
||||
// Only images are safe to render inline; PDFs can carry embedded JavaScript
|
||||
// that executes when opened inline, so they always force a download instead.
|
||||
$contentDisposition = (Tools::getValue('is_preview')
|
||||
&& $objHotelBookingDocument->file_type == HotelBookingDocument::FILE_TYPE_IMAGE)
|
||||
? 'inline' : 'attachment';
|
||||
|
||||
if (Tools::file_exists_cache($filePath)) {
|
||||
if (ob_get_level() && ob_get_length() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user