From 247c38923ff699f9934b496c2eaab076236419b5 Mon Sep 17 00:00:00 2001 From: kkhelifa-opendsi Date: Wed, 3 Sep 2025 16:36:18 +0200 Subject: [PATCH] FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call (#34717) * FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call * Modification to take into account the value saved in the cookie * Update invoice.php --------- Co-authored-by: Laurent Destailleur --- htdocs/takepos/invoice.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d2d92188662..29601c95dcf 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -78,6 +78,23 @@ if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->la } } +// When session has expired (selected terminal has been lost from session), redirect to the terminal selection. +if (empty($_SESSION["takeposterminal"])) { + if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) { + $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal + } elseif (!empty($_COOKIE["takeposterminal"])) { + $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session + } else { + print << +SCRIPT; + exit; + } +} /** * Abort invoice creationg with a given error message