From 8fe93618cd8f2320f81f3e14ac4c3e6c193f9c19 Mon Sep 17 00:00:00 2001 From: ICMathieu Date: Fri, 15 Nov 2024 16:59:11 +0100 Subject: [PATCH 01/68] FIX go back status #24944 --- htdocs/don/card.php | 12 ++++++++++++ htdocs/don/class/don.class.php | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1038cdb68d2..b730a7ff227 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -337,6 +337,15 @@ if (empty($reshook)) { $object->setProject($projectid); } + if ($action == 'set_validate' && $permissiontoadd) { + $object->fetch($id); + if ($object->reopen($user) >= 0) { + $action = ''; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + if ($action == 'update_extras' && $permissiontoadd) { $object->fetch($id); @@ -932,6 +941,9 @@ if (!empty($id) && $action != 'edit') { if ($object->status == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->hasRight('don', 'creer')) { print '
'.$langs->trans("ClassifyPaid")."
"; } + if ($object->status == $object::STATUS_PAID && $object->paid == 1 && $user->hasRight('don', 'creer')) { + print '
'.$langs->trans("ReOpen")."
"; + } // Delete if ($user->hasRight('don', 'supprimer')) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 9ba0ac8de98..a1988a2a2b3 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -859,9 +859,22 @@ class Don extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) { + if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_PAID) { return 0; } + if($this->statut == self::STATUS_PAID) { + $sql = "UPDATE " . MAIN_DB_PREFIX . "don SET paid = 0 WHERE rowid = " . ((int)$this->id); + + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->affected_rows($resql)) { + $this->paid = 0; + } else { + dol_print_error($this->db); + return -1; + } + } + } return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'DON_REOPEN'); } From 0bac63ffbca058e77dcb75651960abaff74ea2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20PASCAL?= Date: Sat, 16 Nov 2024 17:16:37 +0100 Subject: [PATCH 02/68] feat: add entity in custom translation with multicompany --- htdocs/admin/translation.php | 56 ++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 045c32ef64a..c35f486dc02 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -59,6 +59,10 @@ if ($mode == 'searchkey') { $transvalue = GETPOST('transvalue', 'restricthtml'); } +if (isModEnabled('multicompany') && !$user->entity) { + $entity = GETPOST('entity', 'int'); +} + // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -128,10 +132,19 @@ if ($action == 'update') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors'); $error++; } + if ($entity == '') { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Entity")), null, 'errors'); + $error++; + } if (!$error) { $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."overwrite_trans set transkey = '".$db->escape($transkey)."', transvalue = '".$db->escape($transvalue)."' WHERE rowid = ".(GETPOSTINT('rowid')); + $sql = "UPDATE " . MAIN_DB_PREFIX . "overwrite_trans set transkey = '" . $db->escape( + $transkey + ) . "', transvalue = '" . $db->escape($transvalue) . "', entity = '" . $db->escape( + $entity + ) . "' WHERE rowid = " . ((int) GETPOST('rowid', 'int')); + $result = $db->query($sql); if ($result) { $db->commit(); @@ -368,7 +381,9 @@ if ($mode == 'overwrite') { print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("TranslationKey", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder); - //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder); + if (isModEnabled('multicompany') && !$user->entity) { + print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'Entity', '', $param, '', $sortfield, $sortorder); + } print ''; print "\n"; @@ -376,21 +391,36 @@ if ($mode == 'overwrite') { // Line to add new record print "\n"; - print ''; + print ''; + + // Lang + print ''; print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, array(), 1, 0, $disablededit ? 1 : 0, 'maxwidth250', 1); print ''."\n"; + + // Trans key print ''; print ''; - print ''; + print ''; + + // Value + print ''; print ''; print ''; + + // Multi company + if (isModEnabled('multicompany') && !$user->entity) { + print ''; + print ''; + print ''; + } + print ''; print ''; print ''; print "\n"; print ''; - // Show constants $sql = "SELECT rowid, entity, lang, transkey, transvalue"; $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; @@ -411,7 +441,10 @@ if ($mode == 'overwrite') { print ''; + // Lang print ''.dol_escape_htmltag($obj->lang).''."\n"; + + // Trans key print ''; if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) { print ''; @@ -441,6 +474,19 @@ if ($mode == 'overwrite') { } print ''; + // Entity limit to superadmin + if (isModEnabled('multicompany') && empty($user->entity)) { + print ''; + if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) { + print ''; + } else { + print dol_escape_htmltag($obj->entity); + } + print ''; + } else { + print ''; + } + print ''; if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) { print ''; From bcf7031a0419a4a0387ac06cf8185dd85d638868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20PASCAL?= Date: Sat, 16 Nov 2024 17:32:30 +0100 Subject: [PATCH 03/68] fix: declare entity before using it --- htdocs/admin/translation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index c35f486dc02..78679cc16e5 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -59,6 +59,7 @@ if ($mode == 'searchkey') { $transvalue = GETPOST('transvalue', 'restricthtml'); } +$entity = $conf->entity; if (isModEnabled('multicompany') && !$user->entity) { $entity = GETPOST('entity', 'int'); } From f24ee650fcccd421a5cab898eb8e4b0ec4dea9cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Nov 2024 01:11:41 +0100 Subject: [PATCH 04/68] Update don.class.php --- htdocs/don/class/don.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index a1988a2a2b3..6a948061bd0 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -862,7 +862,7 @@ class Don extends CommonObject if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_PAID) { return 0; } - if($this->statut == self::STATUS_PAID) { + if ($this->statut == self::STATUS_PAID) { $sql = "UPDATE " . MAIN_DB_PREFIX . "don SET paid = 0 WHERE rowid = " . ((int)$this->id); $resql = $this->db->query($sql); From b6b53218c5d99b3144ef85a5bb322b1927f2b206 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Nov 2024 01:18:57 +0100 Subject: [PATCH 05/68] Update don.class.php --- htdocs/don/class/don.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 6a948061bd0..b7fecd8eefc 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -863,7 +863,7 @@ class Don extends CommonObject return 0; } if ($this->statut == self::STATUS_PAID) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "don SET paid = 0 WHERE rowid = " . ((int)$this->id); + $sql = "UPDATE " . MAIN_DB_PREFIX . "don SET paid = 0 WHERE rowid = " . ((int) $this->id); $resql = $this->db->query($sql); if ($resql) { From 101ee350d39317339843a307c3d51150f3093f4b Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 21 Nov 2024 19:51:29 +0100 Subject: [PATCH 06/68] new variable search_term to be more clear, term is only for terminal number --- htdocs/takepos/ajax/ajax.php | 15 ++++++++------- htdocs/takepos/index.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 1ebadc6541d..b90d55d2aa6 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -54,6 +54,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements' $action = GETPOST('action', 'aZ09'); $term = GETPOST('term', 'alpha'); +$search_term = GETPOST('search_term', 'alpha'); $id = GETPOSTINT('id'); $search_start = GETPOSTINT('search_start'); $search_limit = GETPOSTINT('search_limit'); @@ -130,11 +131,11 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { } else { echo 'Failed to load category with id='.dol_escape_htmltag($category); } -} elseif ($action == 'search' && $term != '' && $user->hasRight('takepos', 'run')) { +} elseif ($action == 'search' && $search_term != '' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); // Search barcode into thirdparties. If found, it means we want to change thirdparties. - $result = $thirdparty->fetch('', '', '', $term); + $result = $thirdparty->fetch('', '', '', $search_term); if ($result && $thirdparty->id > 0) { $rows = array(); @@ -187,7 +188,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $barcode_value_list = array(); $barcode_offset = 0; - $barcode_length = dol_strlen($term); + $barcode_length = dol_strlen($search_term); if ($barcode_length == $barcode_char_nb) { $rows = array(); @@ -195,7 +196,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { foreach ($barcode_rules_list as $barcode_rule_arr) { $code = $barcode_rule_arr['code']; $char_nb = $barcode_rule_arr['char_nb']; - $barcode_value_list[$code] = substr($term, $barcode_offset, $char_nb); + $barcode_value_list[$code] = substr($search_term, $barcode_offset, $char_nb); $barcode_offset += $char_nb; } @@ -209,7 +210,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { $sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))"; } $sql .= " AND tosell = 1"; - $sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($term) . "')"; + $sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($search_term) . "')"; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) == 1) { @@ -249,7 +250,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { 'label' => $obj->label, 'tosell' => $obj->tosell, 'tobuy' => $obj->tobuy, - 'barcode' => $term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product + 'barcode' => $search_term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'object' => 'product', @@ -317,7 +318,7 @@ if ($action == 'getProducts' && $user->hasRight('takepos', 'run')) { if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1 && getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) { $sql .= ' AND ps.reel > 0'; } - $sql .= natural_search(array('ref', 'label', 'barcode'), $term); + $sql .= natural_search(array('ref', 'label', 'barcode'), $search_term); // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 62a1d45ce34..0656fddcb97 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -744,7 +744,7 @@ function Search2(keyCodeForEnter, moreorless) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); var nbsearchresults = 0; - $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { + $.getJSON('/takepos/ajax/ajax.php?action=search&token=&search_term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prowatermark" + i).html(""); From e0be95f5315010292b1f16a13002c14c560a8bdf Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 29 Jan 2025 10:17:18 +0100 Subject: [PATCH 07/68] New westite security constants --- htdocs/core/website.inc.php | 16 +-- htdocs/website/index.php | 198 ++++++++++++++++++++++++++++- htdocs/website/lib/website.lib.php | 172 +++++++++++++++++++++++++ 3 files changed, 372 insertions(+), 14 deletions(-) create mode 100644 htdocs/website/lib/website.lib.php diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index e28082e208f..14194ca78fd 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -167,7 +167,7 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { } // Content-Security-Policy - if (!defined('WEBSITE_MAIN_SECURITY_FORCECSP')) { + if (!defined('WEBSITE_'.$object->id.'_SECURITY_FORCECSP')) { // A default security policy that keep usage of js external component like ckeditor, stripe, google, working // For example: to restrict to only local resources, except for css (cloudflare+google), and js (transifex + google tags) and object/iframe (youtube) // default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *; @@ -178,7 +178,7 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { // // $contentsecuritypolicy = "frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com;"; // $contentsecuritypolicy = "frame-ancestors 'self'; img-src * data:; font-src *; default-src *; script-src 'self' 'unsafe-inline' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com; style-src 'self' 'unsafe-inline'; connect-src 'self';"; - $contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP'); + $contentsecuritypolicy = getDolGlobalString('WEBSITE_'.$object->id.'_SECURITY_FORCECSP'); if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -200,32 +200,32 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { } // Referrer-Policy - if (!defined('WEBSITE_MAIN_SECURITY_FORCERP')) { + if (!defined('WEBSITE_'.$object->id.'_SECURITY_FORCERP')) { // The constant WEBSITE_MAIN_SECURITY_FORCERP should never be defined by page, but the variable used just after may be // For public web sites, we use the same default value than "strict-origin-when-cross-origin" - $referrerpolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', "strict-origin-when-cross-origin"); + $referrerpolicy = getDolGlobalString('WEBSITE_'.$object->id.'_SECURITY_FORCERP', "strict-origin-when-cross-origin"); header("Referrer-Policy: ".$referrerpolicy); } // Strict-Transport-Security - if (!defined('WEBSITE_MAIN_SECURITY_FORCESTS')) { + if (!defined('WEBSITE_'.$object->id.'_SECURITY_FORCESTS')) { // The constant WEBSITE_MAIN_SECURITY_FORCESTS should never be defined by page, but the variable used just after may be // Example: "max-age=31536000; includeSubDomains" - $sts = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCESTS'); + $sts = getDolGlobalString('WEBSITE_'.$object->id.'_SECURITY_FORCESTS'); if (!empty($sts)) { header("Strict-Transport-Security: ".$sts); } } // Permissions-Policy (old name was Feature-Policy) - if (!defined('WEBSITE_MAIN_SECURITY_FORCEPP')) { + if (!defined('WEBSITE_'.$object->id.'_SECURITY_FORCEPP')) { // The constant WEBSITE_MAIN_SECURITY_FORCEPP should never be defined by page, but the variable used just after may be // Example: "camera: 'none'; microphone: 'none';" - $pp = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCEPP'); + $pp = getDolGlobalString('WEBSITE_'.$object->id.'_SECURITY_FORCEPP'); if (!empty($pp)) { header("Permissions-Policy: ".$pp); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index bb683e00854..a6bd9f1260d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -40,6 +40,7 @@ if (!defined('DISABLE_JS_GRAHP')) { // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/website/lib/website.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php'; @@ -1939,6 +1940,47 @@ if ($action == 'updatecss' && $usercanedit) { } } +if ($action == "updatesecurity" && $usercanedit) { + $db->begin(); + $res1 = $res2 = $res3 = $res4 = 0; + $securityrp = GETPOST('WEBSITE_'.$object->id.'_SECURITY_FORCERP', 'alpha'); + $securitysts = GETPOST('WEBSITE_'.$object->id.'_SECURITY_FORCESTS', 'alpha'); + $securitypp = GETPOST('WEBSITE_'.$object->id.'_SECURITY_FORCEPP', 'alpha'); + $securitysp = GETPOST('WEBSITE_'.$object->id.'_SECURITY_FORCECSP', 'alpha'); + + if (!empty($securityrp)) { + $res1 = dolibarr_set_const($db, 'WEBSITE_'.$object->id.'_SECURITY_FORCERP', $securityrp, 'chaine', 0, '', $conf->entity); + } + if (!empty($securitysts)) { + $res2 = dolibarr_set_const($db, 'WEBSITE_'.$object->id.'_SECURITY_FORCESTS', $securitysts, 'chaine', 0, '', $conf->entity); + } + if (!empty($securitypp)) { + $res3 = dolibarr_set_const($db, 'WEBSITE_'.$object->id.'_SECURITY_FORCEPP', $securitypp, 'chaine', 0, '', $conf->entity); + } + if (!empty($securitysp)) { + $res4 = dolibarr_set_const($db, 'WEBSITE_'.$object->id.'_SECURITY_FORCECSP', $securitysp, 'chaine', 0, '', $conf->entity); + } + + if ($res1 >= 0 && $res2 >= 0 && $res3 >= 0 && $res4 >= 0 ) { + $db->commit(); + setEventMessages($langs->trans("Saved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("ErrorSavingChanges"), null, 'errors'); + } + + if (!GETPOSTISSET('updateandstay')) { // If we click on "Save And Stay", we don not make the redirect + $action = 'preview'; + if ($backtopage) { + $backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage); // Clean backtopage url + header("Location: ".$backtopage); + exit; + } + } else { + $action = 'editsecurity'; + } +} + // Update page if ($action == 'setashome' && $usercanedit) { $db->begin(); @@ -2946,6 +2988,9 @@ if ($action == 'file_manager') { if ($mode) { print ''; } +if ($action == 'editsecurity') { + print ''; +} print '
'."\n"; @@ -3258,8 +3303,8 @@ if (!GETPOST('hide_websitemenu')) { print ''; } - if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesiteconfirm')) || in_array($mode, array('replacesite'))) { - if ($action == 'editcss') { + if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesiteconfirm', 'editsecurity')) || in_array($mode, array('replacesite'))) { + if ($action == 'editcss' || $action == 'editsecurity') { // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers $stringforfirstkey = $langs->trans("KeyboardShortcut"); @@ -3290,8 +3335,8 @@ if (!GETPOST('hide_websitemenu')) { // Toolbar for pages // - if ($websitekey && $websitekey != '-1' && (!in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm'))) && (!in_array($mode, array('replacesite'))) && !$file_manager) { - print '
'."\n"; // Close current websitebar to open a new one + if ($websitekey && $websitekey != '-1' && (!in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm', 'editsecurity'))) && (!in_array($mode, array('replacesite'))) && !$file_manager) { + print ''; // Close current websitebar to open a new one print ''; print '
'."\n"; @@ -3754,7 +3799,7 @@ if (!GETPOST('hide_websitemenu')) { // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (!in_array($mode, array('replacesite')) && !in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) { + if (!in_array($mode, array('replacesite')) && !in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite', 'editsecurity'))) { if ($action == 'editsource' || $action == 'editmeta') { // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox // accesskey is for Mac: CTRL + key for all browsers @@ -3964,7 +4009,8 @@ if ($action == 'editcss') { //$readmecontent.=""; //} - print dol_get_fiche_head(); + $head = websiteconfigPrepareHead($object); + print dol_get_fiche_head($head, 'general', $langs->trans("General"), 0, 'website'); print ''."\n"; print ''; @@ -4161,6 +4207,146 @@ if ($action == 'editcss') { print '
'; } +if ($action == 'editsecurity') { + $selectarraySP = websiteGetContentPolicyDirectives(); + $selectarraySPlevel2 = websiteGetContentPolicySources(); + print '
'; + print '
'; + + $head = websiteconfigPrepareHead($object); + print dol_get_fiche_head($head, 'security', $langs->trans("General"), 0, 'website'); + + print '
'; + print '
'; + print ''; + print ''; + print ''."\n"; + print ''; + + // Force RP + print ''; + print ''; + print ''; + print ''; + // Force STS + print ''; + print ''; + print ''; + print ''; + // Force PP + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Parameter").'
'.$langs->trans('WebsiteSecurityForceRP').'id."_SECURITY_FORCERP").'">
'.$langs->trans('WebsiteSecurityForceSTS').'id."_SECURITY_FORCESTS").'">
'.$langs->trans('WebsiteSecurityForcePP').'id."_SECURITY_FORCEPP").'">
'; + print '
'; + + // Security Policy + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("SecurityPolicy").'
'.$langs->trans("Value").':id."_SECURITY_FORCECSP").'">
'.$form->selectarray("select_identifier_WEBSITE_SECURITY_FORCECSP", $selectarraySP, "select_identifier_WEBSITE_SECURITY_FORCECSP", 1, 0, 0, '', 0, 0, 0, '', 'minwidth300').''; + foreach ($selectarraySPlevel2 as $key => $values) { + print ''; + } + print '
'; + print '
'; + + + // TODO: liste sous page identifier pour supprimer + print ''; + + print dol_get_fiche_end(); + print ''; +} + if ($action == 'createsite') { print '
'; diff --git a/htdocs/website/lib/website.lib.php b/htdocs/website/lib/website.lib.php new file mode 100644 index 00000000000..045334dc771 --- /dev/null +++ b/htdocs/website/lib/website.lib.php @@ -0,0 +1,172 @@ + + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/website/lib/website.lib.php + * \ingroup website + * \brief Library files with common functions for WebsiteAccount + */ + + + /** + * Prepare array of tabs for Website + * + * @param Website $object Website + * @return array Array of tabs + */ +function websiteconfigPrepareHead($object) +{ + global $db, $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/website/index.php?websiteid='.$object->id.'&action=editcss'; + $head[$h][1] = $langs->trans("General"); + $head[$h][2] = 'general'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/website/index.php?websiteid='.$object->id.'&action=editsecurity'; + $head[$h][1] = $langs->trans("Security"); + $head[$h][2] = 'security'; + $h++; + + /*if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { + $nbNote = 0; + if(!empty($object->fields['note_private'])) $nbNote++; + if(!empty($object->fields['note_public'])) $nbNote++; + $head[$h][0] = dol_buildpath('/monmodule/websiteaccount_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + $head[$h][2] = 'note'; + $h++; + }*/ + + /* + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->monmodule->dir_output . "/websiteaccount/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/monmodule/websiteaccount_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.($nbFiles+$nbLinks).'' : ''); + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/monmodule/websiteaccount_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + */ + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website', 'remove'); + + return $head; +} + +/** + * Prepare array of directives for Website + * + * @return array Array of tabs + */ + +function websiteGetContentPolicyDirectives() +{ + return array( + // Fetch directives + "child-src" => array("label" => "child-src","data-directivetype" => "fetch"), + "connect-src" => array("label" => "connect-src","data-directivetype" => "fetch"), + "default-src" => array("label" => "default-src","data-directivetype" => "fetch"), + "fenced-frame-src" => array("label" => "fenced-frame-src","data-directivetype" => "fetch"), + "font-src" => array("label" => "font-src","data-directivetype" => "fetch"), + "frame-src" => array("label" => "frame-src","data-directivetype" => "fetch"), + "img-src" => array("label" => "img-src","data-directivetype" => "fetch"), + "manifest-src" => array("label" => "manifest-src","data-directivetype" => "fetch"), + "media-src" => array("label" => "media-src","data-directivetype" => "fetch"), + "object-src" => array("label" => "object-src","data-directivetype" => "fetch"), + "prefetch-src" => array("label" => "prefetch-src","data-directivetype" => "fetch"), + "script-src" => array("label" => "script-src","data-directivetype" => "fetch"), + "script-src-elem" => array("label" => "script-src-elem","data-directivetype" => "fetch"), + "script-src-attr" => array("label" => "script-src-attr","data-directivetype" => "fetch"), + "style-src" => array("label" => "style-src","data-directivetype" => "fetch"), + "style-src-elem" => array("label" => "style-src-elem","data-directivetype" => "fetch"), + "style-src-attr" => array("label" => "style-src-attr","data-directivetype" => "fetch"), + "worker-src" => array("label" => "worker-src","data-directivetype" => "fetch"), + // Document directives + "base-uri" => array("label" => "base-uri","data-directivetype" => "document"), + "sandbox" => array("label" => "sandbox","data-directivetype" => "document"), + // Navigation directives + "form-action" => array("label" => "form-action","data-directivetype" => "navigation"), + "frame-ancestors" => array("label" => "frame-ancestors","data-directivetype" => "navigation"), + // Reporting directives + "report-to" => array("label" => "report-to","data-directivetype" => "reporting"), + // Other directives + "require-trusted-types-for" => array("label" => "require-trusted-types-for","data-directivetype" => "other"), + "othertrusted-types", + "upgrade-insecure-requests" => array("label" => "upgrade-insecure-requests","data-directivetype" => "other"), + ); +} + +/** + * Prepare array of sources for Website + * + * @return array Array of tabs + */ + +function websiteGetContentPolicySources() +{ + return array( + // Fetch directives + "fetch" => array( + "*", + "data", + "self", + ), + // Document directives + "document" => array( + "base-uri", + "sandbox", + ), + // Navigation directives + "navigation" => array( + "self", + ), + // Reporting directives + "reporting" => array( + "report-to", + ), + // Other directives + "other" => array( + "require-trusted-types-for", + "trusted-types", + "upgrade-insecure-requests", + ), + ); +} From 180954eb16422ff8293f1a1840303e265b362990 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 29 Jan 2025 10:17:38 +0100 Subject: [PATCH 08/68] fix php typo --- htdocs/website/lib/website.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/website/lib/website.lib.php b/htdocs/website/lib/website.lib.php index 045334dc771..88f4cb834a2 100644 --- a/htdocs/website/lib/website.lib.php +++ b/htdocs/website/lib/website.lib.php @@ -96,7 +96,6 @@ function websiteconfigPrepareHead($object) * * @return array Array of tabs */ - function websiteGetContentPolicyDirectives() { return array( @@ -139,7 +138,6 @@ function websiteGetContentPolicyDirectives() * * @return array Array of tabs */ - function websiteGetContentPolicySources() { return array( From bd87aa005d6ce623ce83fd389a96796bd14dab3b Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:05:23 -0500 Subject: [PATCH 09/68] NEW CONSTANT: ORDER_TYPE_CONTACT_DEFAULT For example: Direct to SHIPPING --- htdocs/commande/card.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e60536c9bcb..0c726543905 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -15,7 +15,8 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023-2024 Benjamin Falière - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2025 Lenin Rivas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,6 +104,9 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility $rank = (GETPOSTINT('rank') > 0) ? GETPOSTINT('rank') : -1; +// Type Contact default +$type_contact_code = (getDolGlobalString('ORDER_TYPE_CONTACT_DEFAULT') ? getDolGlobalString('ORDER_TYPE_CONTACT_DEFAULT') : 'CUSTOMER'); + // PDF $hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0)); $hidedesc = (GETPOSTINT('hidedesc') ? GETPOSTINT('hidedesc') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0)); @@ -549,7 +553,8 @@ if (empty($reshook)) { // Insert default contacts if defined if ($object_id > 0) { if (GETPOSTINT('contactid')) { - $result = $object->add_contact(GETPOSTINT('contactid'), 'CUSTOMER', 'external'); + // $result = $object->add_contact(GETPOSTINT('contactid'), 'CUSTOMER', 'external'); + $result = $object->add_contact(GETPOSTINT('contactid'), $type_contact_code, 'external'); if ($result < 0) { setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); $error++; @@ -1995,7 +2000,10 @@ if ($action == 'create' && $usercancreate) { // Contact of order if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "".$langs->trans("DefaultContact").''; + // print "".$langs->trans("DefaultContact").''; + print ""; + print $form->textwithpicto($langs->trans("DefaultContact"), $langs->trans("TypeContact_commande_external_".$type_contact_code)); + print ''; print img_picto('', 'contact', 'class="pictofixedwidth"'); //print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, empty($srccontactslist) ? "" : $srccontactslist, '', 1, 'maxwidth300 widthcentpercentminusx'); print $form->select_contact($soc->id, $contactid, 'contactid', 1, empty($srccontactslist) ? "" : $srccontactslist, '', 1, 'maxwidth300 widthcentpercentminusx', true); From 5fb161260f4950ba5119c720d7dfd9ce492c689b Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 31 Jan 2025 14:42:34 +0100 Subject: [PATCH 10/68] add remove div --- htdocs/website/index.php | 72 +++++++++++++++++++++++++-- htdocs/website/lib/website.lib.php | 79 ++++++++++++++++++++---------- 2 files changed, 120 insertions(+), 31 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index a6bd9f1260d..8cfc688f3a9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -266,6 +266,8 @@ $filereadme = $pathofwebsite.'/README.md'; $filelicense = $pathofwebsite.'/LICENSE'; $filemaster = $pathofwebsite.'/master.inc.php'; +$forceCSP = getDolGlobalString("WEBSITE_".$object->id."_SECURITY_FORCECSP"); + // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -1978,6 +1980,7 @@ if ($action == "updatesecurity" && $usercanedit) { } } else { $action = 'editsecurity'; + $forceCSP = getDolGlobalString("WEBSITE_".$object->id."_SECURITY_FORCECSP"); } } @@ -2903,6 +2906,47 @@ if ($action == 'generatesitemaps' && $usercanedit) { $action = 'preview'; } +if ($action == 'removecspsource' && $usercanedit) { + $db->begin(); + $sourcecsp = explode("_", GETPOST("sourcecsp")); + $directive = $sourcecsp[0]; + $sourcekey = $sourcecsp[1]; + $forceCSPArr = websiteGetContentPolicyToArray($forceCSP); + if (!isset($directive) || !isset($sourcekey)) { + $error++; + } + + $securityspstring = ""; + if (!$error && !empty($forceCSPArr)) { + if (!empty($forceCSPArr[$directive][$sourcekey])) { + unset($forceCSPArr[$directive][$sourcekey]); + } + if (count($forceCSPArr[$directive]) == 0) { + unset($forceCSPArr[$directive]); + } + foreach ($forceCSPArr as $directive => $sourcekeys) { + if ($securityspstring != ""){ + $securityspstring .= "; "; + } + $securityspstring .= $directive . " " . implode(" ", $sourcekeys); + } + $res = dolibarr_set_const($db, 'WEBSITE_'.$object->id.'_SECURITY_FORCECSP', $securityspstring, 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } + } + + if (!$error) { + $db->commit(); + setEventMessages($langs->trans("SecurityPolicySucesfullyRemoved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("ErrorRemovingSecurityPolicy"), null, 'errors'); + } + header("Location: ".$_SERVER["PHP_SELF"].'?websiteid='.$websiteid."&action=editsecurity"); + exit(); +} + /* * View @@ -4245,14 +4289,14 @@ if ($action == 'editsecurity') { print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; @@ -4263,7 +4307,21 @@ if ($action == 'editsecurity') { print ''; - // TODO: liste sous page identifier pour supprimer + $forceCSPArr = websiteGetContentPolicyToArray($forceCSP); + print '
'; + print '
    '; + foreach ($forceCSPArr as $directive => $sources) { + print '
  • '.$directive.''; + print '
      '; + foreach ($sources as $key => $source) { + print '
    • '.$source.' '.img_delete().'
    • '; + } + print '
    '; + print '
  • '; + } + print '
'; + print '
'; + print ''; diff --git a/htdocs/website/lib/website.lib.php b/htdocs/website/lib/website.lib.php index a55150c6194..ba6039683ca 100644 --- a/htdocs/website/lib/website.lib.php +++ b/htdocs/website/lib/website.lib.php @@ -94,7 +94,7 @@ function websiteconfigPrepareHead($object) /** * Prepare array of directives for Website * - * @return array Array of tabs + * @return array Array of directives */ function websiteGetContentPolicyDirectives() { @@ -128,7 +128,7 @@ function websiteGetContentPolicyDirectives() "report-to" => array("label" => "report-to", "data-directivetype" => "reporting"), // Other directives "require-trusted-types-for" => array("label" => "require-trusted-types-for", "data-directivetype" => "other"), - "othertrusted-types", + "othertrusted-types" => array("label" => "othertrusted-types", "data-directivetype" => "other"), "upgrade-insecure-requests" => array("label" => "upgrade-insecure-requests", "data-directivetype" => "other"), ); } @@ -136,7 +136,7 @@ function websiteGetContentPolicyDirectives() /** * Prepare array of sources for Website * - * @return array Array of tabs + * @return array Array of sources */ function websiteGetContentPolicySources() { @@ -145,32 +145,43 @@ function websiteGetContentPolicySources() "fetch" => array( "*" => array("label" => "*", "data-sourcetype" => "select"), "data" => array("label" => "data", "data-sourcetype" => "data"), - "self" => array("label" => "self", "data-sourcetype" => "select"), + "self" => array("label" => "self", "data-sourcetype" => "quoted"), ), // Document directives "document" => array( - "base-uri", - "sandbox", + "base-uri" => array("label" => "base-uri", "data-sourcetype" => "select"), + "sandbox" => array("label" => "sandbox", "data-sourcetype" => "select"), ), // Navigation directives "navigation" => array( - "self", + "self" => array("label" => "self", "data-sourcetype" => "quoted"), ), // Reporting directives "reporting" => array( - "report-to", + "report-to" => array("label" => "report-to", "data-sourcetype" => "select"), ), // Other directives "other" => array( - "require-trusted-types-for", - "trusted-types", - "upgrade-insecure-requests", + "require-trusted-types-for" => array("label" => "require-trusted-types-for", "data-sourcetype" => "select"), + "trusted-types" => array("label" => "trusted-types", "data-sourcetype" => "select"), + "upgrade-insecure-requests" => array("label" => "upgrade-insecure-requests", "data-sourcetype" => "select"), ), ); } +/** + * Transform a Content Security Policy to an array + * @param string content security policy + * + * @return array Array of sources + */ function websiteGetContentPolicyToArray($forceCSP){ $forceCSPArr = array(); + $sourceCSPArr = websiteGetContentPolicySources(); + $sourceCSPArrflatten = array(); + foreach ($sourceCSPArr as $key => $arr) { + $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr)); + } $securitypolicies = explode(";", $forceCSP); foreach ($securitypolicies as $key => $securitypolicy) { if ($securitypolicy == "") continue; @@ -183,11 +194,29 @@ function websiteGetContentPolicyToArray($forceCSP){ continue; } $sources = $securitypolicyarr; + $issourcedata = 0; foreach ($sources as $key => $source) { - if (empty($forceCSPArr[$directive])) { - $forceCSPArr[$directive] = array($source); + $source = str_replace(":", "", $source); + $source = str_replace("'", "", $source); + + if ($source == "data") { + $issourcedata = 1; + if (empty($forceCSPArr[$directive])) { + $forceCSPArr[$directive] = array($source => array()); + } else { + $forceCSPArr[$directive][$source] = array(); + } + continue; + } + if ($issourcedata && !in_array($source, $sourceCSPArrflatten)) { + $forceCSPArr[$directive]["data"][] = $source; } else { - $forceCSPArr[$directive][] = $source; + $issourcedata = 0; + if (empty($forceCSPArr[$directive])) { + $forceCSPArr[$directive] = array($source); + } else { + $forceCSPArr[$directive][] = $source; + } } } } From b3f40b2c83a9727738c51b719736afc127f2b6a9 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 7 Feb 2025 12:21:44 +0100 Subject: [PATCH 13/68] fix some naming and add comment --- htdocs/website/index.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 18b9cc8790a..ae94a5b920e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -4343,8 +4343,9 @@ if ($action == 'editcss') { } if ($action == 'editsecurity') { - $selectarraySP = websiteGetContentPolicyDirectives(); - $selectarraySPlevel2 = websiteGetContentPolicySources(); + $selectarrayCSPDirectives = websiteGetContentPolicyDirectives(); + $selectarrayCSPSources = websiteGetContentPolicySources(); + $forceCSPArr = websiteGetContentPolicyToArray($forceCSP); print '
'; print '
'; @@ -4376,17 +4377,19 @@ if ($action == 'editsecurity') { print '
'.$langs->trans("SecurityPolicy").'
'.$langs->trans("Value").':id."_SECURITY_FORCECSP").'">
'.$langs->trans("Value").':
'.$form->selectarray("select_identifier_WEBSITE_SECURITY_FORCECSP", $selectarraySP, "select_identifier_WEBSITE_SECURITY_FORCECSP", 1, 0, 0, '', 0, 0, 0, '', 'minwidth300').''; foreach ($selectarraySPlevel2 as $key => $values) { print ''; } print '
'; print '
'; - // Security Policy + // Content Security Policy print '
'; print ''; print ''; print ''; + print ''; + print ''; - print ''; + print ''; print '
'.$langs->trans("SecurityPolicy").'
'.$langs->trans("Value").':
'.$form->selectarray("select_identifier_WEBSITE_SECURITY_FORCECSP", $selectarraySP, "select_identifier_WEBSITE_SECURITY_FORCECSP", 1, 0, 0, '', 0, 0, 0, '', 'minwidth300').''.$form->selectarray("select_identifier_WEBSITE_SECURITY_FORCECSP", $selectarrayCSPDirectives, "select_identifier_WEBSITE_SECURITY_FORCECSP", 1, 0, 0, '', 0, 0, 0, '', 'minwidth300').''; print ''; - foreach ($selectarraySPlevel2 as $key => $values) { + foreach ($selectarrayCSPSources as $key => $values) { print ''; @@ -4398,9 +4401,7 @@ if ($action == 'editsecurity') { print '
'; print '
'; - //TODO: add comment to explain + better look - - $forceCSPArr = websiteGetContentPolicyToArray($forceCSP); + // Content Security Policy list of selected rules print '
'; print '
    '; foreach ($forceCSPArr as $directive => $sources) { @@ -4424,7 +4425,7 @@ if ($action == 'editsecurity') { } print '
'; print '
'; - //TODO: add console.log in js + print '