From c4390872cc4e959ccf2d029e5c0321333c8ef8ba Mon Sep 17 00:00:00 2001 From: LuizRamosPL <108962945+LuizRamosPL@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:41:39 -0300 Subject: [PATCH] Update funwritecookies.php Fix for suporte PHP 8.2.12 WHMCS Version 8.11 --- .../servers/product/views/funwritecookies.php | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/modules/servers/product/views/funwritecookies.php b/modules/servers/product/views/funwritecookies.php index 413e4fa..83a81cf 100644 --- a/modules/servers/product/views/funwritecookies.php +++ b/modules/servers/product/views/funwritecookies.php @@ -1,72 +1,73 @@ - client->currencyrel->prefix) ? $service->client->currencyrel->prefix : ''; -// // Find prefix or suffix from config -// $currencysymb = $service->client->currencyrel->prefix; + // find id for url + $id = isset($service->id) ? $service->id : ''; + $machineId = $id; + // find information to send to view + $userid = isset($service->userid) ? $service->userid : ''; + $productid = isset($service->id) ? $service->id : ''; -// // find id for url -// $id = $service->id; -// $machineId = $id; - -// // find infromation to send to view -// $userid = $service->userid; -// $productid = $service->id; - -// $productname = $service->product->name; -// $registrationdate = $service->regdate; -// $nextduedate = $service->nextduedate; -// $recurringpayment = $service->amount; -// $billingcycle = $service->billingcycle; - - -// // set value in cookies for the first time -// $datapairs = array( -// 'productname' => $productname, -// 'registrationdate' => $registrationdate, -// 'nextduedate' => $nextduedate, -// 'recurringpayment' => $recurringpayment, -// 'currencysymb' => $currencysymb, -// 'billingcycle' => $billingcycle -// ); - - - - -// // Delet all other machines -// $allCookies = $_COOKIE; - -// // Loop through all cookies and delete the ones that contain 'price' in their names -// foreach ($allCookies as $cookieName => $cookieValue) { -// if (strpos($cookieName, 'productname') !== false || strpos($cookieName, 'registrationdate') !== false || strpos($cookieName, 'nextduedate') !== false || strpos($cookieName, 'recurringpayment') !== false || strpos($cookieName, 'billingcycle') !== false || strpos($cookieName, 'currencysymb') !== false) { -// // Set the cookie with an expiration time in the past to delete it -// setcookie($cookieName, '', time() - 3600, '/'); - -// // Unset the cookie from the $_COOKIE superglobal array -// unset($_COOKIE[$cookieName]); -// } -// } - - - - -// // Loop through the data keys and write cookies -// foreach ($datapairs as $key => $value) { -// $dynamicKey = $key . $id; -// setcookie($dynamicKey, $value, time() + 3600 * 24 * 7, '/'); + $productname = isset($service->product->name) ? $service->product->name : ''; + $registrationdate = isset($service->regdate) ? $service->regdate : ''; + $nextduedate = isset($service->nextduedate) ? $service->nextduedate : ''; + $recurringpayment = isset($service->amount) ? $service->amount : ''; + $billingcycle = isset($service->billingcycle) ? $service->billingcycle : ''; -// } - - - - + // set value in cookies for the first time + $datapairs = array( + 'productname' => $productname, + 'registrationdate' => $registrationdate, + 'nextduedate' => $nextduedate, + 'recurringpayment' => $recurringpayment, + 'currencysymb' => $currencysymb, + 'billingcycle' => $billingcycle + ); + + // Delet all other machines + $allCookies = $_COOKIE; + + // Loop through all cookies and delete the ones that contain 'price' in their names + foreach ($allCookies as $cookieName => $cookieValue) { + if (strpos($cookieName, 'productname') !== false || strpos($cookieName, 'registrationdate') !== false || strpos($cookieName, 'nextduedate') !== false || strpos($cookieName, 'recurringpayment') !== false || strpos($cookieName, 'billingcycle') !== false || strpos($cookieName, 'currencysymb') !== false) { + // Set the cookie with an expiration time in the past to delete it + setcookie($cookieName, '', time() - 3600, '/'); + + // Unset the cookie from the $_COOKIE superglobal array + unset($_COOKIE[$cookieName]); + } + } + + // Loop through the data keys and write cookies + foreach ($datapairs as $key => $value) { + $dynamicKey = $key . $id; + setcookie($dynamicKey, $value, time() + 3600 * 24 * 7, '/'); + } + +} else { + // Se $service não estiver definido ou for nulo, defina variáveis padrão para evitar erros. + $id = ''; + $userid = ''; + $productid = ''; + $productname = ''; + $registrationdate = ''; + $nextduedate = ''; + $recurringpayment = ''; + $billingcycle = ''; + $currencysymb = ''; +} ?>