From e97f021380cdcab2100553bd6a09bc7fe9cd0729 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Jun 2022 19:02:16 +0200 Subject: [PATCH] Fix #yogosha11295 --- htdocs/adherents/card.php | 9 ++- htdocs/admin/company.php | 10 +++ htdocs/admin/ihm.php | 5 ++ htdocs/comm/mailing/card.php | 5 ++ htdocs/contact/card.php | 9 ++- htdocs/contact/perso.php | 9 ++- htdocs/core/class/conf.class.php | 4 +- htdocs/core/class/html.form.class.php | 9 ++- htdocs/core/class/html.formfile.class.php | 61 ++--------------- htdocs/core/class/html.formmail.class.php | 5 ++ htdocs/core/class/html.formticket.class.php | 5 ++ htdocs/core/lib/security.lib.php | 67 +++++++++++++++++++ .../bom/doc/doc_generic_bom_odt.modules.php | 8 ++- .../doc/doc_generic_order_odt.modules.php | 8 ++- .../doc/doc_generic_contract_odt.modules.php | 8 ++- .../doc/doc_generic_shipment_odt.modules.php | 8 ++- .../doc/doc_generic_invoice_odt.modules.php | 8 ++- .../modules/mailings/xinputfile.modules.php | 5 ++ .../doc/doc_generic_member_odt.class.php | 8 ++- .../doc/doc_generic_product_odt.modules.php | 8 ++- .../doc/doc_generic_proposal_odt.modules.php | 8 ++- .../doc/doc_generic_reception_odt.modules.php | 8 ++- .../societe/doc/doc_generic_odt.modules.php | 8 ++- .../doc/doc_generic_stock_odt.modules.php | 8 ++- .../doc/doc_generic_ticket_odt.modules.php | 8 ++- .../user/doc/doc_generic_user_odt.modules.php | 8 ++- htdocs/core/tpl/ajax/fileupload_view.tpl.php | 7 ++ htdocs/imports/import.php | 8 ++- .../doc/doc_generic_myobject_odt.modules.php | 8 ++- htdocs/product/stock/massstockmove.php | 6 +- htdocs/societe/card.php | 9 ++- htdocs/website/index.php | 11 ++- 32 files changed, 275 insertions(+), 81 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d7e46749de3..6fc4c45574a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1280,7 +1280,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ' '.$langs->trans("Delete").'

'; } print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; } print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 86800eea947..4f46a2a32b5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -477,6 +477,11 @@ if (!empty($conf->barcode->enabled)) { // Logo print ''; print '
'; +$maxfilesizearray = getMaxFileSizeArray(); +$maxmin = $maxfilesizearray['maxmin']; +if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file +} print ''; print '
'; if (!empty($mysoc->logo_small)) { @@ -514,6 +519,11 @@ print ''; // Logo (squarred) print ''; print '
'; +$maxfilesizearray = getMaxFileSizeArray(); +$maxmin = $maxfilesizearray['maxmin']; +if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file +} print ''; print '
'; if (!empty($mysoc->logo_squarred_small)) { diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index d3afd4035e4..37d1757d783 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -636,6 +636,11 @@ if ($mode == 'login') { if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { $disabled = ' disabled="disabled"'; } + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } print ''; if ($disabled) { print '(' . $langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND") . ') '; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b3d3dd25e90..166aa4292be 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1249,6 +1249,11 @@ if ($action == 'create') { $out .= ''.$langs->trans("NoAttachedFiles").'
'; } // Add link to add file + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } $out .= ''; $out .= ' '; $out .= ''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 09d46d02b13..4762404af9c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1271,7 +1271,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ' '.$langs->trans("Delete").'

'; } //print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; print ''; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index e90f8b46bd0..230a8d148d3 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -159,7 +159,14 @@ if ($action == 'edit') { print ' '.$langs->trans("Delete").'

'; } print ''.$langs->trans("PhotoFile").''; - print ''; + print ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + print ''; + print ''; print ''; print ''; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 602e6b560d0..0a996018e97 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -746,8 +746,8 @@ class Conf $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text } - // Default max file size for upload - $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); + // Default max file size for upload (deprecated) + //$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); // By default, we propagate contacts if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 56990effeb2..be43b35f895 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9361,7 +9361,14 @@ class Form if ($object->photo) { $ret .= '

'; } - $ret .= ''; + $ret .= ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $ret .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $ret .= ''; + $ret .= ''; $ret .= ''; } } else { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 97f5eca5822..73a426323e3 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -148,64 +148,15 @@ class FormFile $out .= ''; - $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp = @ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) { - $maxphp = preg_replace('/k$/i', '', $maxphp); - $maxphp = $maxphp * 1; - } - if (preg_match('/m$/i', $maxphp)) { - $maxphp = preg_replace('/m$/i', '', $maxphp); - $maxphp = $maxphp * 1024; - } - if (preg_match('/g$/i', $maxphp)) { - $maxphp = preg_replace('/g$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp)) { - $maxphp = preg_replace('/t$/i', '', $maxphp); - $maxphp = $maxphp * 1024 * 1024 * 1024; - } - $maxphp2 = @ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) { - $maxphp2 = preg_replace('/k$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1; - } - if (preg_match('/m$/i', $maxphp2)) { - $maxphp2 = preg_replace('/m$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024; - } - if (preg_match('/g$/i', $maxphp2)) { - $maxphp2 = preg_replace('/g$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024; - } - if (preg_match('/t$/i', $maxphp2)) { - $maxphp2 = preg_replace('/t$/i', '', $maxphp2); - $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; - } - // Now $max and $maxphp and $maxphp2 are in Kb - $maxmin = $max; - $maxphptoshow = $maxphptoshowparam = ''; - if ($maxphp > 0) { - $maxmin = min($max, $maxphp); - $maxphptoshow = $maxphp; - $maxphptoshowparam = 'upload_max_filesize'; - } - if ($maxphp2 > 0) { - $maxmin = min($max, $maxphp2); - if ($maxphp2 < $maxphp) { - $maxphptoshow = $maxphp2; - $maxphptoshowparam = 'post_max_size'; - } - } - + $maxfilesizearray = getMaxFileSizeArray(); + $max = $maxfilesizearray['max']; + $maxmin = $maxfilesizearray['maxmin']; + $maxphptoshow = $maxfilesizearray['maxphptoshow']; + $maxphptoshowparam = $maxfilesizearray['maxphptoshowparam']; if ($maxmin > 0) { - // MAX_FILE_SIZE doit précéder le champ input de type file - $out .= ''; + $out .= ''; // MAX_FILE_SIZE must precede the field type=file } - $out .= 'global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic') ? ' name="userfile"' : ' name="userfile[]" multiple'); $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $disablemulti) ? ' name="userfile"' : ' name="userfile[]" multiple'); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= (!empty($accept) ? ' accept="'.$accept.'"' : ' accept=""'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 27ef700cd09..a345f023161 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -829,6 +829,11 @@ class FormMail extends Form $out .= ''.$langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } // Can add other files if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) { $out .= ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index f1c6e12e925..99a348b0374 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -491,6 +491,11 @@ class FormTicket $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { // Can add other files + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } $out .= ''; $out .= ' '; $out .= ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 056d28ab2cd..1d3f013e9f3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -977,3 +977,70 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho } exit(0); } + + +/** + * Return the max allowed for file upload. + * Analyze among: upload_max_filesize, post_max_size, MAIN_UPLOAD_DOC + * + * @return array Array with all max size for file upload + */ +function getMaxFileSizeArray() +{ + global $conf; + + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) { + $maxphp = preg_replace('/k$/i', '', $maxphp); + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = preg_replace('/m$/i', '', $maxphp); + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = preg_replace('/g$/i', '', $maxphp); + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = preg_replace('/t$/i', '', $maxphp); + $maxphp = $maxphp * 1024 * 1024 * 1024; + } + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = preg_replace('/k$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = preg_replace('/m$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = preg_replace('/g$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = preg_replace('/t$/i', '', $maxphp2); + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } + // Now $max and $maxphp and $maxphp2 are in Kb + $maxmin = $max; + $maxphptoshow = $maxphptoshowparam = ''; + if ($maxphp > 0) { + $maxmin = min($maxmin, $maxphp); + $maxphptoshow = $maxphp; + $maxphptoshowparam = 'upload_max_filesize'; + } + if ($maxphp2 > 0) { + $maxmin = min($maxmin, $maxphp2); + if ($maxphp2 < $maxphp) { + $maxphptoshow = $maxphp2; + $maxphptoshowparam = 'post_max_size'; + } + } + //var_dump($maxphp.'-'.$maxphp2); + //var_dump($maxmin); + + return array('max'=>$max, 'maxmin'=>$maxmin, 'maxphptoshow'=>$maxphptoshow, 'maxphptoshowparam'=>$maxphptoshowparam); +} diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 23917c4b79c..92b51ce70f4 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -174,7 +174,13 @@ class doc_generic_bom_odt extends ModelePDFBom $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 94e0a634328..36e8b66d788 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -181,7 +181,13 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 23ed4bec34a..e36e4a281ad 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -166,7 +166,13 @@ class doc_generic_contract_odt extends ModelePDFContract } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 209acf648d6..47a54cc4f5c 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -180,7 +180,13 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 07a1e3966a6..8d2be499fd2 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -179,7 +179,13 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 9a80484f83b..ddff17ee4ad 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -110,6 +110,11 @@ class mailing_xinputfile extends MailingTargets global $langs; $s = ''; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $s .= ''; // MAX_FILE_SIZE must precede the field type=file + } $s .= ''; return $s; } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index fb084f312fe..f1bfe706b41 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -169,7 +169,13 @@ class doc_generic_member_odt extends ModelePDFMember $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 090a45f4b3f..f11dfbe6a2d 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -177,7 +177,13 @@ class doc_generic_product_odt extends ModelePDFProduct $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 39ffd92ac5e..06bf201f8f6 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -211,7 +211,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales } } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 3e48aaf18bc..df015345671 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -173,7 +173,13 @@ class doc_generic_reception_odt extends ModelePdfReception $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 3a62eb22937..c4ef9135536 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -169,7 +169,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index f8733a8a8ff..8f7a2bdcd15 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -177,7 +177,13 @@ class doc_generic_stock_odt extends ModelePDFStock $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index d69da78aacc..3f0b0042f7f 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -166,7 +166,13 @@ class doc_generic_ticket_odt extends ModelePDFTicket $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $texte .= ' '; + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index a46503b6e2a..176dab4c093 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -197,7 +197,13 @@ class doc_generic_user_odt extends ModelePDFUser $texte .= '
'; } // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= '
'.$langs->trans("UploadNewTemplate"); + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $texte .= ' '; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/tpl/ajax/fileupload_view.tpl.php b/htdocs/core/tpl/ajax/fileupload_view.tpl.php index 70182a17dbc..d4ba594ee89 100644 --- a/htdocs/core/tpl/ajax/fileupload_view.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_view.tpl.php @@ -37,6 +37,13 @@ if (empty($conf) || !is_object($conf)) { trans('AddFiles'); ?> + 0) { + print ''; // MAX_FILE_SIZE must precede the field type=file + } + ?>