if (!defined('TWIG_HELPER_LOADED')) { define('TWIG_HELPER_LOADED', true); if (isset($twig)) { $testFunc = new \Twig\TwigFunction('testFunc', function ($input) { return $input; }); $twig->addFunction($testFunc); if (!function_exists('checkPossibleRefillName')) { function checkPossibleRefillName($days, $string) { if (strpos($string, $days . 'daysguarantee') !== false || strpos($string, $days . 'daysrefill') !== false || strpos($string, $days . 'dayrefill') !== false || strpos($string, $days . 'dayrefills') !== false || strpos($string, $days . 'drefill') !== false || strpos($string, 'r' . $days) !== false || strpos($string, 'r' . $days . 'd') !== false || strpos($string, 'refill:' . $days . 'days') !== false || strpos($string, $days . 'daysautorefill') !== false || strpos($string, $days . 'd') !== false || strpos($string, $days . 'dauto') !== false) : return true; else : return false; endif; } } $refillDays = new \Twig\TwigFunction('refillDays', function ($string) { $string = preg_replace('/\s+/', '', strtolower($string)); $string = iconv('UTF-8', 'ISO-8859-15//IGNORE', $string); $string = preg_replace('/\s+/', ' ', $string); $string = iconv('ISO-8859-15', 'UTF-8', $string); //string can be sum of service_name + service_description $refillDays = [365, 180, 90, 60, 45, 30, 15, 7]; foreach ($refillDays as $days) { $res = checkPossibleRefillName($days, $string); if ($res) : return $days . " Days Refill"; elseif (strpos($string, preg_replace('/\s+/', '', strtolower('Lifetime Guarantee'))) !== false || strpos($string, preg_replace('/\s+/', '', strtolower('Lifetime refill'))) !== false) : return "Lifetime Refill"; endif; } return "No Refill"; }); $twig->addFunction($refillDays); $isPageActive = new \Twig\TwigFunction('isPageActive', function ($pageName) { global $active_menu; $active_menu = $active_menu == "login" ? "auth" : $active_menu; return $active_menu == trim($pageName); }); $twig->addFunction($isPageActive); $csrf_token = new \Twig\TwigFunction('csrf_token', function () { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); return $_SESSION['csrf_token']; }); $twig->addFunction($csrf_token); $show_date = new \Twig\TwigFunction('show_date', function ($dateTime) { global $user; global $timezones; global $conn; $new_timezone = $user["timezone"]; $old_timezone = date_default_timezone_get(); $supported_timezones = array_keys($timezones); if (empty($new_timezone) || !in_array($new_timezone, $supported_timezones)) : $new_timezone = "Asia/Kolkata"; $update = $conn->prepare("UPDATE clients SET timezone=:timezone WHERE client_id=:client_id"); $update = $update->execute(array("timezone" => $new_timezone, "client_id" => $user["client_id"])); endif; if (empty($old_timezone) || !in_array($new_timezone, $supported_timezones)) : $old_timezone = "Asia/Kolkata"; endif; $date = new DateTime($dateTime, new DateTimeZone($old_timezone)); $date->setTimezone(new DateTimeZone($new_timezone)); $time = $date->format('Y-m-d H:i:s'); return $time; }); $twig->addFunction($show_date); $updates_alert_class = new \Twig\TwigFunction('updates_alert_class', function ($alert_type) { switch ($alert_type) { case 1: $class = "btn-danger"; break; case 2: $class = "btn-success"; break; case 3: $class = "btn-warning"; break; case 4: $class = "btn-info"; break; case 5: $class = "btn-primary"; break; default: $class = "btn-black"; break; } return $class; }); $twig->addFunction($updates_alert_class); $refill_status_color = new \Twig\TwigFunction('refill_status_color', function ($status) { switch ($status) { case 'completed': $color = "#0e7f00"; break; case 'inprogress': $color = "#260bc1"; break; case 'pending': $color = "#42b7af"; break; case 'error': $color = "#F24C4C"; break; default: $color = "#f25800"; break; } return $color; }); $twig->addFunction($refill_status_color); $convert_currency = new \Twig\TwigFunction('convert_currency', function ($amount, $symbol = true) { //convert amount to preffered currency global $user; global $settings; if (!$user["client_id"] || $user["auth"] != 1) : //guest $_SESSION["guest_pref_curr"] = $settings["currency_converter"] == 0 ? $settings["site_currency"] : $_SESSION["guest_pref_curr"] ?? $settings["site_currency"]; $curr_symbol = $symbol ? getCurrencySymbol($_SESSION["guest_pref_curr"]) : null; $currency = $_SESSION["guest_pref_curr"]; $approxSymbol = $settings["site_currency"] != $_SESSION["guest_pref_curr"] ? "≈ " : null; else : //registered $user["user_pref_curr"] = $settings["currency_converter"] == 0 ? $settings["site_currency"] : $user["user_pref_curr"]; $curr_symbol = $symbol ? getCurrencySymbol($user["user_pref_curr"]) : null; $currency = $user["user_pref_curr"]; $approxSymbol = $settings["site_currency"] != $user["user_pref_curr"] ? "≈ " : null; endif; switch ($settings["currency_format"]) { case 1: $finalAmount = round(convertCurrencyUpdated($settings["site_currency"], $currency, $amount), $settings["rates_rounding"]); break; case 2: $finalAmount = round(convertCurrencyUpdated($settings["site_currency"], $currency, $amount), $settings["rates_rounding"]); $finalAmount = str_replace(".", ",", $finalAmount); break; case 3: $finalAmount = number_format(convertCurrencyUpdated($settings["site_currency"], $currency, $amount), $settings["rates_rounding"], ".", ","); break; case 4: $finalAmount = number_format(convertCurrencyUpdated($settings["site_currency"], $currency, $amount), $settings["rates_rounding"], ",", "."); break; default: $finalAmount = number_format(convertCurrencyUpdated($settings["site_currency"], $currency, $amount), $settings["rates_rounding"], ".", ","); break; } $finalAmount = rtrim($finalAmount, '0'); if ($finalAmount[strlen($finalAmount) - 1] === '.') $finalAmount .= "00"; return $approxSymbol . $curr_symbol . $finalAmount; }); $twig->addFunction($convert_currency); } } Panel temporarily unavailable

Panel temporarily unavailable