diff --git a/htdocs/accountancy/journal/treasuryjournal.php b/htdocs/accountancy/journal/treasuryjournal.php index c3a1cf26cf9..f7c0bc0762a 100644 --- a/htdocs/accountancy/journal/treasuryjournal.php +++ b/htdocs/accountancy/journal/treasuryjournal.php @@ -1402,7 +1402,7 @@ if (empty($action) || $action == 'view') { print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } - print '
| "; print " | ".$langs->trans("Date")." | "; print "".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").') | '; print "".$langs->trans("AccountAccounting")." | "; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 2c073942703..40f16558b20 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1292,14 +1292,14 @@ while ($i < $imaxinloop) { } // Technical ID if (!empty($arrayfields['d.rowid']['checked'])) { - print ''.$obj->rowid.' | '; + print ''.dolPrintHTML($obj->rowid).' | '; if (!$i) { $totalarray['nbfield']++; } } // Ref if (!empty($arrayfields['d.ref']['checked'])) { - print ""; + print ' | '; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); print " | \n"; if (!$i) { @@ -1309,7 +1309,7 @@ while ($i < $imaxinloop) { // Title/Civility if (!empty($arrayfields['d.civility']['checked'])) { print ""; - print dol_escape_htmltag($obj->civility); + print dolPrintHTML($obj->civility); print " | \n"; if (!$i) { $totalarray['nbfield']++; @@ -1348,13 +1348,13 @@ while ($i < $imaxinloop) { } // Company if (!empty($arrayfields['d.company']['checked'])) { - print ''; + print ' | '; print $companynametoshow; print " | \n"; } // Login if (!empty($arrayfields['d.login']['checked'])) { - print ''.$obj->login." | \n"; + print ''.dolPrintHTML($obj->login)." | \n"; if (!$i) { $totalarray['nbfield']++; } @@ -1382,7 +1382,7 @@ while ($i < $imaxinloop) { // Address if (!empty($arrayfields['d.address']['checked'])) { print ''; - print dol_escape_htmltag($obj->address); + print dolPrintHTML($obj->address); print ' | '; if (!$i) { $totalarray['nbfield']++; @@ -1391,7 +1391,7 @@ while ($i < $imaxinloop) { // Zip if (!empty($arrayfields['d.zip']['checked'])) { print ''; - print dol_escape_htmltag($obj->zip); + print dolPrintHTML($obj->zip); print ' | '; if (!$i) { $totalarray['nbfield']++; @@ -1400,7 +1400,7 @@ while ($i < $imaxinloop) { // Town if (!empty($arrayfields['d.town']['checked'])) { print ''; - print dol_escape_htmltag($obj->town); + print dolPrintHTML($obj->town); print ' | '; if (!$i) { $totalarray['nbfield']++; @@ -1409,7 +1409,7 @@ while ($i < $imaxinloop) { // State / County / Departement if (!empty($arrayfields['state.nom']['checked'])) { print ""; - print dol_escape_htmltag($obj->state_name); + print dolPrintHTML($obj->state_name); print " | \n"; if (!$i) { $totalarray['nbfield']++; @@ -1418,8 +1418,8 @@ while ($i < $imaxinloop) { // Country if (!empty($arrayfields['country.code_iso']['checked'])) { $tmparray = getCountry($obj->country, 'all'); - print ''; - print dol_escape_htmltag($tmparray['label']); + print ' | '; + print dolPrintHTML($tmparray['label']); print ' | '; if (!$i) { $totalarray['nbfield']++; @@ -1523,8 +1523,8 @@ while ($i < $imaxinloop) { } // Import key if (!empty($arrayfields['d.import_key']['checked'])) { - print ''; - print dol_escape_htmltag($obj->import_key); + print ' | '; + print dolPrintHTML($obj->import_key); print " | \n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 91178873230..ae69d06e801 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2317,7 +2317,7 @@ if ($id > 0) { $canbedisabled = 0; } } - if ($id == DICT_TYPE_CONTAINER && in_array($obj->code, array('banner', 'blogpost', 'menu', 'page', 'other', 'service', 'library'))) { + if ($id == DICT_TYPE_CONTAINER && $obj->module == 'system') { $iserasable = 0; $canbedisabled = 0; if (in_array($obj->code, array('banner'))) { diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 59c8c18732e..2252b72aacd 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -72,7 +72,7 @@ $search_user = GETPOST("search_user", "alpha"); $search_desc = GETPOST("search_desc", "alpha"); $search_ua = GETPOST("search_ua", "restricthtml"); $search_prefix_session = GETPOST("search_prefix_session", "restricthtml"); -$search_entity = ($user->entity > 0 ? $user->entity : GETPOSTINT('search_entity')); +$search_entity = ($user->entity > 0 ? $user->entity : GETPOSTINT('search_entity')); // TODO Replace with $search_entity = GETPOSTINT('search_entity') when the filter is available on screen for this page $now = dol_now(); $nowarray = dol_getdate($now); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ad461f0e919..795af8254ee 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -296,7 +296,8 @@ class Paiement extends CommonObject /** * Create payment of invoices into database. * It uses this->amounts and ->multicurrency_amounts to get the list of detail of payment for each invoices for the payment. - * For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative + * For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative. + * Can also close the invoice if remain to pay is 0. * This will set also ->amount and ->multicurrency_amount at end. * * @param User $user Object user diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 5ece55be81c..93900c30ae0 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -666,7 +666,6 @@ class FormAccounting extends Form public static function printJournalLine($langs, $date, $ref, $accountAccounting, $labelOperation, $paymentMode, $amount) { $out = '
| '; $out .= ' | '.$date.' | '; $out .= ''.$ref.' | '; // Ledger account diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4c7b884c3fc..a0da95da416 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10891,14 +10891,14 @@ function verifCond($strToEvaluate, $onlysimplestring = '1') /** * Replace eval function to add more security. - * This function is called by verifCond() or trans() and transnoentitiesnoconv(). + * This function is called by verifCond() for example. * * @param string $s String to evaluate * @param int<0,1> $returnvalue 0=No return (deprecated, used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)). * @param int<0,1> $hideerrors 1=Hide errors - * @param string $onlysimplestring '0' (deprecated, do not use it anymore)=Accept all chars, - * '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', - * '2' (used for example for the compute property of extrafields)=Accept also '<[]' + * @param string $onlysimplestring '0' (deprecated, do not use it anymore) = Accept all chars, + * '1' (most common use) = Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';', + * '2' (used for example for the compute property of extrafields) = Accept also '<[]' * @return string Return result of eval (even if type can be int, it is safer to assume string and find all potential typing issues as abs(dol_eval(...)). * @see verifCond(), checkPHPCode() to see sanitizing rules that should be very close. * @phan-suppress PhanPluginUnsafeEval @@ -11265,14 +11265,26 @@ function dol_eval_standard($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestr $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_GLOBAL', '_POST', '_REQUEST', 'ReflectionFunction')); // We list all forbidden function as keywords we don't want to see (we don't mind it if is "kewyord(" or just "keyword", we don't want "keyword" at all) + // We must exclude all functions that allow to execute another function. This includes all function that has a parameter with type "callable" to avoid things + // like we can do with array_map and its callable parameter: dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '0') $forbiddenphpfunctions = array(); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("override_function", "session_id", "session_create_id", "session_regenerate_id")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func", "call_user_func_array")); + + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("array_all", "array_any", "array_diff_ukey", "array_filter", "array_find", "array_find_key", "array_map", "array_reduce", "array_intersect_uassoc", "array_intersect_ukey", "array_walk", "array_walk_recursive")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("usort", "uasort", "uksort", "preg_replace_callback", "preg_replace_callback_array", "header_register_callback")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("set_error_handler", "set_exception_handler", "libxml_set_external_entity_loader", "register_shutdown_function", "register_tick_function", "unregister_tick_function")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("spl_autoload_register", "spl_autoload_unregister", "iterator_apply", "session_set_save_handler")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("forward_static_call", "forward_static_call_array", "register_postsend_function")); + + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("ob_start")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("exec", "passthru", "shell_exec", "system", "proc_open", "popen")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_eval", "dol_eval_new", "dol_eval_standard", "dol_concatdesc", "executeCLI", "verifCond", "GETPOST")); // native dolibarr functions $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("readline_completion_function", "readline_callback_handler_install")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask")); $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include")); diff --git a/htdocs/core/modules/accountancy/doc/pdf_balance.modules.php b/htdocs/core/modules/accountancy/doc/pdf_balance.modules.php index 15d7af0417c..4e0fba6d882 100644 --- a/htdocs/core/modules/accountancy/doc/pdf_balance.modules.php +++ b/htdocs/core/modules/accountancy/doc/pdf_balance.modules.php @@ -502,7 +502,7 @@ class pdf_balance extends ModelePdfAccountancy $curY, $nexY, $default_font_size, - $langs->trans('GrandTotals'), + $langs->transnoentities('GrandTotals'), $tab_top_newpage, $totalDebit, $totalCredit, diff --git a/htdocs/core/modules/accountancy/doc/pdf_bookkeeping.modules.php b/htdocs/core/modules/accountancy/doc/pdf_bookkeeping.modules.php index ba2c1465a15..cf2edf9a12a 100644 --- a/htdocs/core/modules/accountancy/doc/pdf_bookkeeping.modules.php +++ b/htdocs/core/modules/accountancy/doc/pdf_bookkeeping.modules.php @@ -511,7 +511,7 @@ class pdf_bookkeeping extends ModelePdfAccountancy $curY, $nexY, $default_font_size, - $langs->trans('GrandTotals'), + $langs->transnoentities('GrandTotals'), $tab_top_newpage, $totalDebit, $totalCredit, diff --git a/htdocs/core/modules/accountancy/doc/pdf_ledger.modules.php b/htdocs/core/modules/accountancy/doc/pdf_ledger.modules.php index 0d10bb36917..0e86d35a264 100644 --- a/htdocs/core/modules/accountancy/doc/pdf_ledger.modules.php +++ b/htdocs/core/modules/accountancy/doc/pdf_ledger.modules.php @@ -512,7 +512,7 @@ class pdf_ledger extends ModelePdfAccountancy $curY, $nexY, $default_font_size, - $langs->trans('GrandTotals'), + $langs->transnoentities('GrandTotals'), $tab_top_newpage, $totalDebit, $totalCredit, diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 69db5c89317..1286c42a87d 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -296,3 +296,7 @@ ALTER TABLE llx_mrp_mo ADD COLUMN extraparams varchar(255) DEFAULT NULL; UPDATE llx_actioncomm set code = 'AC_PAYMENT_STRIPE_IPN_SEPA_KO' where code = 'AC_IPN' and label like 'Payment error (SEPA%'; ALTER TABLE llx_blockedlog ADD COLUMN debuginfo mediumtext; + +ALTER TABLE llx_webhook_history ADD COLUMN trigger_code text NOT NULL; +ALTER TABLE llx_webhook_history ADD COLUMN error_message text; +ALTER TABLE llx_webhook_history MODIFY COLUMN url varchar(255); diff --git a/htdocs/install/mysql/tables/llx_webhook_history-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_history-webhook.sql index 6fcc304858a..da1077845fe 100644 --- a/htdocs/install/mysql/tables/llx_webhook_history-webhook.sql +++ b/htdocs/install/mysql/tables/llx_webhook_history-webhook.sql @@ -21,8 +21,8 @@ CREATE TABLE llx_webhook_history( trigger_code varchar(128) NOT NULL, trigger_data text NOT NULL, fk_target integer NOT NULL, - url integer NOT NULL, - error_messsage text, + url varchar(255) NOT NULL, + error_message text, --note_public text, note_private text, date_creation datetime NOT NULL, diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index b8b75a137f5..0bcf1f9ccad 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -40,6 +40,11 @@ define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1); include_once 'inc.php'; + +/** + * @var string $conffile + */ + if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } @@ -48,6 +53,11 @@ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; global $langs; +/** + * @var Conf $conf + * @var Translate $langs + */ + $grant_query = ''; $step = 2; $ok = 0; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 543edde9fd4..0830888bb94 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -43,6 +43,11 @@ define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1); include_once 'inc.php'; + +/** + * @var string $conffile + */ + if (!file_exists($conffile)) { print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").'; } @@ -59,13 +64,17 @@ require_once $dolibarr_main_document_root.'/core/lib/files.lib.php'; global $langs; +/** + * @var Conf $conf + * @var Translate $langs + */ + $grant_query = ''; $step = 2; $error = 0; -// Cette page peut etre longue. On augmente le delai autorise. -// Ne fonctionne que si on est pas en safe_mode. +// This page can be long. We increase the allowed delay, but this does not work when we are in safe_mode. $err = error_reporting(); error_reporting(0); if (getDolGlobalString('MAIN_OVERRIDE_TIME_LIMIT')) { @@ -230,17 +239,23 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $db->begin(); foreach ($listofentities as $entity) { + dol_syslog("Process upgrade2 for entity ".$entity); + // Set $conf context for entity $conf->setEntityValues($db, $entity); + // Reset forced setup after the setValues if (defined('SYSLOG_FILE')) { $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); } - $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; + + $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Add also log into conf->logbuffer. $versiontoarray = array(); $versionranarray = array(); + dol_syslog("Process upgrade2 d for entity ".$entity); + if (!$error) { if (count($listofentities) > 1) { print '||||||||||||||||||
| *** '.$langs->trans("Entity").' '.$entity.' | ||||||||||||||||||||