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 ' |
';
// Logo (squarred)
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 .= '';
}
// Add input to upload a new template file.
- $texte .= ' | ';
// Add input to upload a new template file.
- $texte .= '