Your project must restrict allowed classes when using unserialize()
- Read doc
- Security
- Critical
More information: https://insight.symfony.com/what-we-analyse/php.use_unserialize_without_allowed_classes
- $redis = $redis_client;
- $raw = $redis->get($cache_key);
- // phpredis ne sérialise pas les tableaux : la valeur est stockée via serialize()
- if ($raw !== false) {
- $decoded = @unserialize($raw);
- if (is_array($decoded)) {
- $cached_config = $decoded;
- }
- }
Your project should use dedicated PHP string functions 30
- Read doc
- Productivity
- Info
More information: https://insight.symfony.com/what-we-analyse/php.use_string_function
- $module_active = $modules_shipping;
- $include_modules = [];
- foreach ($modules_shipping as $value) {
- if (strpos($value, '\\') !== false) {
- $class = Apps::getModuleClass($value, 'Shipping');
- $include_modules[] = ['class' => $value,
- 'file' => $class
- ];
- ];
- }
- }
- for ($i = 0, $n = \count($include_modules); $i < $n; $i++) {
- if (strpos($include_modules[$i]['class'], '\\') !== false) {
- Registry::set('Payment_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']);
- $module = Registry::get('Payment_' . str_replace('\\', '_', $include_modules[$i]['class']));
- ?>
- <div class="row">
- <div class="col-md-12">
- $module_active = $modules_payment;
- $include_modules = [];
- foreach ($modules_payment as $value) {
- if (strpos($value, '\\') !== false) {
- $class = Apps::getModuleClass($value, 'Payment');
- $include_modules[] = ['class' => $value,
- 'file' => $class
- ];
- ];
- }
- }
- for ($i = 0, $n = \count($include_modules); $i < $n; $i++) {
- if (strpos($include_modules[$i]['class'], '\\') !== false) {
- Registry::set('Shipping_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']);
- $module = Registry::get('Shipping_' . str_replace('\\', '_', $include_modules[$i]['class']));
- ?>
- <div class="row">
- <div class="col-md-5">
- $sessionId = $checkoutIdParam;
- }
- if ($method === 'POST' && ($hasCheckoutParam || strpos($path, '/checkout_sessions') !== false)) {
- if ($sessionId) {
- if ($hasCompleteParam || strpos($path, '/complete') !== false) {
- $validation = $CLICSHOPPING_getRetailers->validateAcpInput($input, 'complete', $input['items'] ?? []);
- if (!empty($validation)) {
- http_response_code(400);
- echo json_encode(['messages' => $validation], JSON_UNESCAPED_SLASHES);
- exit;
- echo json_encode($result['checkout_session'], JSON_UNESCAPED_SLASHES);
- } else {
- echo json_encode($result, JSON_UNESCAPED_SLASHES);
- }
- }
- } elseif ($hasCancelParam || strpos($path, '/cancel') !== false) {
- $result = $CLICSHOPPING_getRetailers->cancelSession($sessionId);
- if ($result === null) {
- http_response_code(404);
- echo json_encode(['error' => 'Session not found']);
- } else {
- // --------------------------------------------------------------------------------
- // GET /products - Returns product catalog
- // --------------------------------------------------------------------------------
- if ($method === 'GET' && ($hasProductsParam || strpos($path, '/products') !== false)) {
- // Return full product catalog
- $products = $CLICSHOPPING_getRetailers->getProducts();
- echo json_encode(['products' => $products], JSON_UNESCAPED_SLASHES);
- exit;
- // POST /complete_and_order - Complete session then create order
- // --------------------------------------------------------------------------------
- $hasCompleteAndOrderParam = isset($_GET['complete_and_order']);
- $completeSessionIdParam = isset($_GET['session_id']) ? (string)$_GET['session_id'] : null;
- if ($method === 'POST' && ($hasCompleteAndOrderParam || strpos($path, '/complete_and_order') !== false)) {
- if (empty($completeSessionIdParam)) {
- http_response_code(400);
- echo json_encode(['error' => 'Session ID required']);
- exit;
- }
- // POST /create_order - Create ClicShopping order from session
- // --------------------------------------------------------------------------------
- $hasCreateOrderParam = isset($_GET['create_order']);
- $orderSessionIdParam = isset($_GET['session_id']) ? (string)$_GET['session_id'] : null;
- if ($method === 'POST' && ($hasCreateOrderParam || strpos($path, '/create_order') !== false)) {
- if (empty($orderSessionIdParam)) {
- http_response_code(400);
- echo json_encode(['error' => 'Session ID required']);
- exit;
- }
- } elseif (!empty($checkoutIdParam)) {
- // Fallback ou prise en compte du paramètre 'id' si l'ID n'est pas dans le chemin
- $sessionId = $checkoutIdParam;
- }
- if ($method === 'POST' && ($hasCheckoutParam || strpos($path, '/checkout_sessions') !== false)) {
- if ($sessionId) {
- if ($hasCompleteParam || strpos($path, '/complete') !== false) {
- $validation = $CLICSHOPPING_getRetailers->validateAcpInput($input, 'complete', $input['items'] ?? []);
- if (!empty($validation)) {
- http_response_code(400);
- // Simple routing
- // --------------------------------------------------------------------------------
- // POST /agentic_commerce/delegate_payment - Handle delegated payment vaulting
- // --------------------------------------------------------------------------------
- if ($method === 'POST' && ($hasDelegatePaymentParam || strpos($path, '/agentic_commerce/delegate_payment') !== false)) {
- $headers = [
- 'idempotency_key' => $_SERVER['HTTP_IDEMPOTENCY_KEY'] ?? null,
- 'request_id' => $_SERVER['HTTP_REQUEST_ID'] ?? null
- ];
- $result = $CLICSHOPPING_getRetailers->handleDelegatePayment($input, $headers);
- exit;
- }
- // --------------------------------------------------------------------------------
- // POST /stripe_webhook - Handle Stripe webhooks
- // --------------------------------------------------------------------------------
- if ($method === 'POST' && ($hasStripeWebhookParam || strpos($path, '/stripe_webhook') !== false)) {
- $CLICSHOPPING_getRetailers->handleStripeWebhook();
- exit;
- }
- // --------------------------------------------------------------------------------
- // Simple routing
- // --------------------------------------------------------------------------------
- // GET /products - Returns product catalog
- // --------------------------------------------------------------------------------
- if ($method === 'GET' && ($hasProductsParam || strpos($path, '/products') !== false)) {
- // Return full product catalog
- $products = $CLICSHOPPING_getRetailers->getProducts();
- echo json_encode(['products' => $products], JSON_UNESCAPED_SLASHES);
- exit;
- // POST /create_order - Create ClicShopping order from session
- // --------------------------------------------------------------------------------
- $hasCreateOrderParam = isset($_GET['create_order']);
- $orderSessionIdParam = isset($_GET['session_id']) ? (string)$_GET['session_id'] : null;
- if ($method === 'POST' && ($hasCreateOrderParam || strpos($path, '/create_order') !== false)) {
- if (empty($orderSessionIdParam)) {
- http_response_code(400);
- echo json_encode(['error' => 'Session ID required']);
- exit;
- }
- } elseif (!empty($checkoutIdParam)) {
- // Fallback ou prise en compte du paramètre 'id' si l'ID n'est pas dans le chemin
- $sessionId = $checkoutIdParam;
- }
- if ($method === 'POST' && ($hasCheckoutParam || strpos($path, '/checkout_sessions') !== false)) {
- if ($sessionId) {
- // Completion: POST /checkout_sessions/{id}
- // Choose Delegated Payment or Stripe based on payload
- if (!empty($input['delegated_payment'])) {
- $session = $CLICSHOPPING_getRetailers->completeSessionWithDelegatedPayment($sessionId, $input);
- // POST /complete_and_order - Complete session then create order
- // --------------------------------------------------------------------------------
- $hasCompleteAndOrderParam = isset($_GET['complete_and_order']);
- $completeSessionIdParam = isset($_GET['session_id']) ? (string)$_GET['session_id'] : null;
- if ($method === 'POST' && ($hasCompleteAndOrderParam || strpos($path, '/complete_and_order') !== false)) {
- if (empty($completeSessionIdParam)) {
- http_response_code(400);
- echo json_encode(['error' => 'Session ID required']);
- exit;
- }
- exit;
- }
- // --------------------------------------------------------------------------------
- // POST /stripe_webhook - Handle Stripe webhooks
- // --------------------------------------------------------------------------------
- if ($method === 'POST' && ($hasStripeWebhookParam || strpos($path, '/stripe_webhook') !== false)) {
- $CLICSHOPPING_getRetailers->handleStripeWebhook();
- exit;
- }
- // --------------------------------------------------------------------------------
- 'action' => 'products'
- ]);
- exit;
- }
- if ($method === 'POST' && ($hasCheckoutParam || strpos($path, '/checkout_sessions') !== false)) {
- if (($hasCompleteParam || strpos($path, '/complete') !== false) && (($checkoutIdParam !== null) || preg_match('#/checkout_sessions/([^/]+)/complete#', $path, $matches))) {
- $sessionId = $checkoutIdParam ?? $matches[1] ?? null;
- if (!$sessionId) {
- $errorResponse('VALIDATION_ERROR', 'Missing session id');
- }
- ]);
- exit;
- }
- if ($method === 'POST' && ($hasCheckoutParam || strpos($path, '/checkout_sessions') !== false)) {
- if (($hasCompleteParam || strpos($path, '/complete') !== false) && (($checkoutIdParam !== null) || preg_match('#/checkout_sessions/([^/]+)/complete#', $path, $matches))) {
- $sessionId = $checkoutIdParam ?? $matches[1] ?? null;
- if (!$sessionId) {
- $errorResponse('VALIDATION_ERROR', 'Missing session id');
- }
- $result = $ucp->completeSession($sessionId, $input);
- $hasCheckoutParam = isset($_GET['checkout_sessions']) || isset($_GET['retailers/checkout_sessions']);
- $checkoutIdParam = isset($_GET['id']) ? (string)$_GET['id'] : null;
- $hasCompleteParam = isset($_GET['complete']);
- $hasWebhookParam = isset($_GET['webhook']);
- if ($method === 'GET' && ($hasProductsParam || strpos($path, '/products') !== false)) {
- $filters = [
- 'page' => $_GET['page'] ?? 1,
- 'limit' => $_GET['limit'] ?? 100,
- 'category' => $_GET['category'] ?? null,
- 'min_price' => $_GET['min_price'] ?? null,
- 'action' => 'checkout_sessions.update'
- ]);
- exit;
- }
- if ($method === 'POST' && ($hasWebhookParam || strpos($path, '/webhook') !== false)) {
- $result = $ucp->handleWebhook($input);
- echo json_encode($result, JSON_UNESCAPED_SLASHES);
- $logger->info('UCP response', [
- 'request_id' => $requestId,
- 'status' => 200,
- ];
- }
- }
- for ($i = 0, $n = \count($include_modules); $i < $n; $i++) {
- if (strpos($include_modules[$i]['class'], '\\') !== false) {
- Registry::set('Shipping_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']);
- $module = Registry::get('Shipping_' . str_replace('\\', '_', $include_modules[$i]['class']));
- ?>
- <div class="row">
- <div class="col-md-12">
- $modules_payment = explode(';', $Qconfiguration_payment->value('configuration_value'));
- $include_modules = [];
- foreach ($modules_payment as $value) {
- if (strpos($value, '\\') !== false) {
- $class = Apps::getModuleClass($value, 'Payment');
- $include_modules[] = ['class' => $value,
- 'file' => $class
- ];
- ];
- }
- }
- for ($i = 0, $n = \count($include_modules); $i < $n; $i++) {
- if (strpos($include_modules[$i]['class'], '\\') !== false) {
- Registry::set('Payment_' . str_replace('\\', '_', $include_modules[$i]['class']), new $include_modules[$i]['file']);
- $module = Registry::get('Payment_' . str_replace('\\', '_', $include_modules[$i]['class']));
- ?>
- <div class="row">
- <div class="col-md-12">
- $modules_shipping = explode(';', $Qconfiguration_shipping->value('configuration_value'));
- $include_modules = [];
- foreach ($modules_shipping as $value) {
- if (strpos($value, '\\') !== false) {
- $class = Apps::getModuleClass($value, 'Shipping');
- $include_modules[] = ['class' => $value,
- 'file' => $class
- ];
- if ((substr($spider, strlen($spider) - 1, 1) == ' ') || (substr($spider, strlen($spider) - 1, 1) == "\n")) {
- $spider = substr($spider, 0, strlen($spider) - 1);
- }
- if (!empty($spider)) {
- if (strpos($user_agent, $spider) !== false) {
- $parameters['can_start'] = false;
- break;
- }
- }
- }
- $content = file($spiders_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- foreach ($content as $line) {
- $line = trim($line);
- // Ignore empty lines and comments starting with '#'
- if (!empty($line) && strpos($line, '#') !== 0) {
- $spiders_array[] = strtolower($line);
- }
- }
- // Save processed list to cache for future requests
- 'text' => $Qproducts->valueInt('customers_basket_quantity') . ' x ' . $Qproducts->value('products_name')
- ];
- $attributes = [];
- if (strpos($Qproducts->valueInt('products_id'), '{') !== false) {
- $combos = [];
- preg_match_all('/(\{[0-9]+\}[0-9]+){1}/', $Qproducts->valueInt('products_id'), $combos);
- foreach ($combos[0] as $combo) {
- $att = [];
- while ($Qcols->fetch()) {
- if ($Qcols->hasValue('Collation') && !\is_null($Qcols->value('Collation'))) {
- // Skip VECTOR columns - they are binary data and cannot be converted to UTF8
- $columnType = strtolower($Qcols->value('Type'));
- if (strpos($columnType, 'vector') !== false) {
- continue;
- }
- if ($_POST['from_charset'] == 'auto') {
- $old_charset = substr($Qcols->value('Collation'), 0, strpos($Qcols->value('Collation'), '_'));
- $module_key = $CLICSHOPPING_CfgModule->get($set, 'key');
- $appModuleType = $CLICSHOPPING_ModulesAdmin->getSwitchModules($module_type);
- if (strpos($_GET['module'], '\\') !== false) {
- $class = Apps::getModuleClass($_GET['module'], $appModuleType);
- if (class_exists($class)) {
- $file_extension = '';
- $module = new $class();