diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index 98dcfd592a2..6e868d73728 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -393,7 +393,7 @@ foreach ($object->fields as $key => $val)
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '
';
- if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 4556ec80bff..488997b5b78 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -474,7 +474,7 @@ foreach ($object->fields as $key => $val)
if (!empty($arrayfields['t.'.$key]['checked']))
{
print ' | ';
- if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index e281cb21155..c97ccb182b8 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -281,7 +281,7 @@ if ($action == 'set' && $user->admin)
$form = new Form($db);
-//$morejs = array("/admin/dolistore/js/dolistore.js.php");
+$morejs = array();
$morecss = array("/admin/dolistore/css/dolistore.css");
// Set dir where external modules are installed
@@ -402,7 +402,7 @@ foreach ($modulesdir as $dir)
$arrayofwarningsext[$modName] = $objMod->warnings_activation_ext;
}
- $familyposition = $familyinfo[$familykey]['position'];
+ $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']);
$listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other');
if ($external && ! in_array($familykey, $listOfOfficialModuleGroups))
{
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index ef3ea4ce975..2a7271fed4a 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -386,7 +386,7 @@ foreach ($object->fields as $key => $val)
if (!empty($arrayfields['t.'.$key]['checked']))
{
print ' | ';
- if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';
diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index 7687ab250ac..02cee1c4d90 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -486,7 +486,7 @@ foreach ($object->fields as $key => $val)
if (!empty($arrayfields['t.'.$key]['checked']))
{
print ' | ';
- if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 4e5d28274a8..4a341ce2c8b 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -204,7 +204,7 @@ class BOM extends CommonObject
// Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
@@ -1145,7 +1145,7 @@ class BOMLine extends CommonObjectLine
// Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index b41e46aff76..55ad8914a9e 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -390,7 +390,7 @@ foreach ($object->fields as $key => $val)
if (!empty($arrayfields['t.'.$key]['checked']))
{
print ' | ';
- if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
else print '';
print ' | ';
}
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index e719a93533a..bb4a7e1d1a4 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -281,7 +281,7 @@ class Contact extends CommonObject
{
foreach($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach($val['arrayofkeyval'] as $key2 => $val2)
{
diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php
index 01cb85008bd..60d3b1d29a7 100644
--- a/htdocs/core/ajax/check_notifications.php
+++ b/htdocs/core/ajax/check_notifications.php
@@ -131,7 +131,7 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
- dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
+ dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before']));
$sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder';
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 5371b8078fa..ef062b8acaf 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6410,7 +6410,7 @@ abstract class CommonObject
$type = 'varchar'; // convert varchar(xx) int varchar
$size = $reg[1];
} elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
- if (is_array($val['arrayofkeyval'])) $type = 'select';
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $type = 'select';
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link';
$default = $val['default'];
@@ -6420,7 +6420,7 @@ abstract class CommonObject
$param = array();
$param['options'] = array();
- if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
{
$type = 'link';
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 3c094ff5a6b..dca7c123399 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -105,7 +105,7 @@ class HookManager
if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) // We instantiate action class only if initialized hook is handled by module
{
// Include actions class overwriting hooks
- if (!is_object($this->hooks[$context][$module])) // If set, class was already loaded
+ if (empty($this->hooks[$context][$module]) || !is_object($this->hooks[$context][$module])) // If set to an object value, class was already loaded
{
$path = '/'.$module.'/class/';
$actionfile = 'actions_'.$module.'.class.php';
@@ -167,6 +167,7 @@ class HookManager
'doActions',
'doMassActions',
'formatEvent',
+ 'formConfirm',
'formCreateThirdpartyOptions',
'formObjectOptions',
'formattachOptions',
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index bf52ff5871a..42468973a69 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -509,7 +509,6 @@ class Form
* @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only)
* @return string Code html du tooltip (texte+picto)
* @see textwithpicto() Use thisfunction if you can.
- * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip
*/
public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0)
{
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 5d3bd181753..7606779afe5 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -1152,6 +1152,7 @@ class FormOther
}
// Define boxlista and boxlistb
+ $boxlista = ''; $boxlistb = '';
$nbboxactivated = count($boxidactivatedforuser);
if ($nbboxactivated)
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index fea25df11c5..170fa42cde3 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -242,14 +242,13 @@ abstract class DoliDB implements Database
$fields=explode(',', $sortfield);
$orders=explode(',', $sortorder);
$i=0;
- foreach ($fields as $val)
- {
+ foreach ($fields as $val) {
if (!$return) $return .= ' ORDER BY ';
else $return .= ', ';
$return .= preg_replace('/[^0-9a-z_\.]/i', '', $val); // Add field
- $tmpsortorder = trim($orders[$i]);
+ $tmpsortorder = (empty($orders[$i]) ? '' : trim($orders[$i]));
// Only ASC and DESC values are valid SQL
if (strtoupper($tmpsortorder) === 'ASC') {
diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php
index 48b957b9e8a..a91d5a6afec 100644
--- a/htdocs/core/get_info.php
+++ b/htdocs/core/get_info.php
@@ -60,8 +60,6 @@ print ''."\n";
print '';
//print '
';
-$nbofsearch = 0;
-
// Define link to login card
$appli = constant('DOL_APPLICATION_TITLE');
if (!empty($conf->global->MAIN_APPLICATION_TITLE))
@@ -117,6 +115,11 @@ if (is_numeric($result))
else $toprightmenu = $hookmanager->resPrint; // replace
} else $toprightmenu .= $result; // For backward compatibility
+if (!isset($form) || !is_object($form)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+ $form = new Form($db);
+}
+
// Link to module builder
if (!empty($conf->modulebuilder->enabled))
{
@@ -124,7 +127,7 @@ if (!empty($conf->modulebuilder->enabled))
//$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"');
$text .= '';
$text .= '';
- $toprightmenu .= @Form::textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2);
+ $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2);
}
// Link to print main content area
@@ -144,7 +147,7 @@ if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OP
//$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"');
$text.='';
$text.='';
- $toprightmenu.=@Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2);
+ $toprightmenu .= $form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2);
}
*/
@@ -183,13 +186,13 @@ if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPT
//if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
$text.='';
//$toprightmenu.='
'."\n";
- $toprightmenu.=@Form::textwithtooltip('',$title,2,1,$text,'login_block_elem',2);
+ $toprightmenu .= $form->textwithtooltip('',$title,2,1,$text,'login_block_elem',2);
}
}
*/
// Logout link
-if (GETPOST('withlogout', 'int')) $toprightmenu .= @Form::textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2);
+if (GETPOST('withlogout', 'int')) $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2);
$toprightmenu .= '';
diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php
index ee212b4373f..23290f220bd 100644
--- a/htdocs/core/js/lib_notification.js.php
+++ b/htdocs/core/js/lib_notification.js.php
@@ -51,7 +51,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP
/* Launch timer */
// We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one.
//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds
- var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>;
+ var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>;
if (login != '') {
setTimeout(first_execution, time_first_execution * 1000);
time_js_next_test = nowtime + time_first_execution;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index df2eab61378..94e7ee85586 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -185,6 +185,7 @@ function getBrowserInfo($user_agent)
if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; }
// Name
+ $reg = array();
if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string
elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not.
elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end
@@ -3344,13 +3345,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
// This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only.
// class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes.
+ $morestyle = '';
$reg = array();
if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
$morecss .= ($morecss ? ' ' : '').$reg[1];
$moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt);
}
if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) {
- $morestyle = ' '.$reg[1];
+ $morestyle = $reg[1];
$moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt);
}
$moreatt = trim($moreatt);
@@ -6484,11 +6486,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$tmp4 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5 = dol_get_next_month($tmp['mon'], $tmp['year']);
+ $daytext = $outputlangs->trans('Day'.$tmp['wday']);
+
$substitutionarray = array_merge($substitutionarray, array(
'__DAY__' => (string) $tmp['mday'],
- '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
- '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon
- '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M
+ '__DAY_TEXT__' => $daytext, // Monday
+ '__DAY_TEXT_SHORT__' => dol_trunc($daytext, 3, 'right', 'UTF-8', 1), // Mon
+ '__DAY_TEXT_MIN__' => dol_trunc($daytext, 1, 'right', 'UTF-8', 1), // M
'__MONTH__' => (string) $tmp['mon'],
'__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])),
'__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])),
@@ -7198,8 +7202,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1)
global $soc; // For backward compatibility
//print $s."
\n";
- if ($returnvalue)
- {
+ if ($returnvalue) {
if ($hideerrors) return @eval('return '.$s.';');
else return eval('return '.$s.';');
} else {
@@ -7602,7 +7605,7 @@ function printCommonFooter($zone = 'private')
// A div to store page_y POST parameter so we can read it using javascript
print "\n\n";
- print ''.$_POST['page_y'].'
'."\n";
+ print ''.(empty($_POST['page_y']) ? '' : $_POST['page_y']).'
'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index 60b01b567f4..26987433568 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -450,15 +450,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
{
$max = strlen($lowercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
- $randomCode .= $lowercase[random_int(0, $max)];
+ $tmp = random_int(0, $max);
+ $randomCode .= $lowercase[$tmp];
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
- $randomCode .= $uppercase[random_int(0, $max)];
+ $tmp = random_int(0, $max);
+ $randomCode .= $uppercase[$tmp];
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < $nbofcharlast; $x++) {
- $randomCode .= $numbers[random_int(0, $max)];
+ $tmp = random_int(0, $max);
+ $randomCode .= $numbers[$tmp];
}
$generated_password = str_shuffle($randomCode);
@@ -466,15 +469,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
{
$max = strlen($lowercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
- $randomCode .= $lowercase[mt_rand(0, $max)];
+ $tmp = mt_rand(0, $max);
+ $randomCode .= $lowercase[$tmp];
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < $nbofchar; $x++) {
- $randomCode .= $uppercase[mt_rand(0, $max)];
+ $tmp = mt_rand(0, $max);
+ $randomCode .= $uppercase[$tmp];
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < $nbofcharlast; $x++) {
- $randomCode .= $numbers[mt_rand(0, $max)];
+ $tmp = mt_rand(0, $max);
+ $randomCode .= $numbers[$tmp];
}
$generated_password = str_shuffle($randomCode);
@@ -495,11 +501,12 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
{
$numbers = "ABCDEF";
$max = strlen($numbers) - 1;
- if (function_exists('random_int')) // Cryptographic random
- {
- $generated_password = str_replace($replaceambiguouschars, $numbers[random_int(0, $max)], $generated_password);
+ if (function_exists('random_int')) { // Cryptographic random
+ $tmp = random_int(0, $max);
+ $generated_password = str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
} else {
- $generated_password = str_replace($replaceambiguouschars, $numbers[mt_rand(0, $max)], $generated_password);
+ $tmp = mt_rand(0, $max);
+ $generated_password = str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
}
}
diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php
index 8f9c8ec83e2..dd39985e0d3 100644
--- a/htdocs/core/tpl/advtarget.tpl.php
+++ b/htdocs/core/tpl/advtarget.tpl.php
@@ -519,14 +519,11 @@ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attributes[$key]['param']['options'], $array_query['options_' . $key . '_cnct']);
print '' . "\n";
} else {
- print '';
- print ' | ';
if (is_array($array_query['options_' . $key . '_cnct'])) {
print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct');
} else {
print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct');
}
- print ' | ';
print ' | ' . "\n";
}
print ' | ' . "\n";
diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
index b1b31bc9154..2e11887360f 100644
--- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
+++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php
@@ -91,8 +91,8 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid
$info .= $langs->trans('Port').': '.$conf->global->MAIN_MAIL_SMTP_PORT.'
';
$info .= $langs->trans('ID').': '.$conf->global->MAIN_MAIL_SMTPS_ID.'
';
$info .= $langs->trans('Pwd').': '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
';
- $info .= $langs->trans('TLS/STARTTLS').': '.$conf->global->MAIN_MAIL_EMAIL_TLS.' / '.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'
';
- $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('Yes') : $langs->trans('No')).'
';
+ $info .= $langs->trans('TLS/STARTTLS').': '.(empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_TLS).' / '.(empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? '' : $conf->global->MAIN_MAIL_EMAIL_STARTTLS).'
';
+ $info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': '.(empty($conf->global->MAIN_DISABLE_ALL_MAILS) ? $langs->trans('No') : $langs->trans('Yes')).'
';
$info .= 'dolibarr_mailing_limit_sendbyweb = '.$dolibarr_mailing_limit_sendbyweb.'
';
return $info;
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index 943b7c73fb3..aed02f40531 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -227,7 +227,7 @@ class EmailCollector extends CommonObject
// Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php
index ed6942f34d6..604ed6a2d11 100644
--- a/htdocs/emailcollector/class/emailcollectoraction.class.php
+++ b/htdocs/emailcollector/class/emailcollectoraction.class.php
@@ -170,7 +170,7 @@ class EmailCollectorAction extends CommonObject
// Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php
index cb8db05fa34..217416cbe89 100644
--- a/htdocs/emailcollector/class/emailcollectorfilter.class.php
+++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php
@@ -139,7 +139,7 @@ class EmailCollectorFilter extends CommonObject
// Translate some data of arrayofkeyval
foreach ($this->fields as $key => $val)
{
- if (is_array($val['arrayofkeyval']))
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval']))
{
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
diff --git a/htdocs/index.php b/htdocs/index.php
index ebc343b5e8d..952ff525258 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -68,7 +68,7 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis
* View
*/
-if (!is_object($form)) $form = new Form($db);
+if (!isset($form) || !is_object($form)) $form = new Form($db);
// Title
$title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION;
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 2d28ac799d7..4f1266c0afd 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -255,6 +255,7 @@ if (!empty($conf->debugbar->enabled) && !GETPOST('dol_use_jmobile') && empty($_S
include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php';
$debugbar = new DolibarrDebugBar();
$renderer = $debugbar->getRenderer();
+ if (empty($conf->global->MAIN_HTML_HEADER)) $conf->global->MAIN_HTML_HEADER = '';
$conf->global->MAIN_HTML_HEADER .= $renderer->renderHead();
$debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)');
@@ -925,7 +926,7 @@ if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($user->conf->MAI
}
// set MAIN_OPTIMIZEFORCOLORBLIND for user
-$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = $user->conf->MAIN_OPTIMIZEFORCOLORBLIND;
+$conf->global->MAIN_OPTIMIZEFORCOLORBLIND = empty($user->conf->MAIN_OPTIMIZEFORCOLORBLIND) ? '' : $user->conf->MAIN_OPTIMIZEFORCOLORBLIND;
// Set terminal output option according to conf->browser.
if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) $conf->dol_hide_leftmenu = 1;
@@ -1162,8 +1163,8 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0)
// // A default security policy that keep usage of js external component like ckeditor, stripe, google, working
// $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' *.stripe.com; connect-src 'self';";
//}
- //else $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
- $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
+ //else
+ $contentsecuritypolicy = empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY) ? '': $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
if (!is_object($hookmanager)) $hookmanager = new HookManager($db);
$hookmanager->initHooks(array("main"));
@@ -1565,6 +1566,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
*/
if ((empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU')))
{
+ if (!isset($form) || !is_object($form)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+ $form = new Form($db);
+ }
+
print "\n".''."\n";
print '