Server IP : 66.29.132.124 / Your IP : 3.129.63.214 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/app/ |
Upload File : |
<?php namespace App; use Illuminate\Support\Facades\Session; class Currency { protected static $cached = []; public static function getAll() { $res = []; foreach (self::$currency_name as $code => $name) { //$code = strtolower($code); $res[strtolower($code)] = [ 'id' => strtolower($code), 'name' => $name . (isset(self::$currency_symbols[$code]) ? ' (' . html_entity_decode(self::$currency_symbols[$code]) . ')' : ''), 'raw_name' => $name, 'symbol' => isset(self::$currency_symbols[$code]) ? html_entity_decode(self::$currency_symbols[$code]) : '' ]; } return $res; } public static function getActiveCurrency(){ $extra = [ [ 'currency_main'=>setting_item('currency_main'), 'currency_format'=>setting_item('currency_format'), 'currency_thousand'=>setting_item('currency_thousand'), 'currency_no_decimal'=>setting_item('currency_no_decimal'), 'currency_decimal'=>setting_item('currency_decimal'), 'is_main'=>1, 'rate'=>1 ] ]; $extra = array_merge(setting_item_array('extra_currency'),$extra); return $extra; } public static function getCurrent($need = 'currency_main',$default = '',$main_currency = false) { $code = Session::get('bc_current_currency'); $code = $code ? $code : setting_item('currency_main'); if($main_currency){ $code = setting_item('currency_main'); } $active = static::getActiveCurrency(); foreach ($active as $item){ if($code == $item['currency_main']) { return $item[$need] ?? $default; } } return $default; } public static function getCurrency($code) { if (isset(static::$cached[$code])) return static::$cached[$code]; $all = self::getAll(); if (isset($all[$code])) { static::$cached[$code] = $all[$code]; return static::$cached[$code]; } return []; } public static function format($price,$main_currency = false) { $currency_main = static::getCurrent('currency_main',setting_item('currency_main'),$main_currency); $currency_format = static::getCurrent('currency_format',setting_item('currency_format'),$main_currency); $currency_decimal = static::getCurrent('currency_decimal',setting_item('currency_decimal'),$main_currency); $currency_thousand = static::getCurrent('currency_thousand',setting_item('currency_thousand'),$main_currency); $currency_no_decimal = static::getCurrent('currency_no_decimal',setting_item('currency_no_decimal'),$main_currency); $exchange_rate = $main_currency ? 1 : static::getCurrent('rate',1,$main_currency); $exchange_rate = (float) $exchange_rate; if(!$exchange_rate) $exchange_rate = 1; $price /= $exchange_rate; $s = number_format((float)$price, (int)$currency_no_decimal, $currency_decimal, $currency_thousand); $currency = self::getCurrency($currency_main); if (!empty($currency)) { switch ($currency_format) { case "right_space"; return $s . ' ' . $currency['symbol']; break; case "left"; return $currency['symbol'] . $s; break; case "left_space"; return $currency['symbol'] . ' ' . $s; break; default: return $s . $currency['symbol']; break; } } return $s; } public static function convertPrice($price,$main_currency = false) { $exchange_rate = $main_currency ? 1 : static::getCurrent('rate',1,$main_currency); $price /= $exchange_rate; return (float)$price; } public static $currency_name = array( 'ALL' => 'Albania Lek', 'AFN' => 'Afghanistan Afghani', 'ARS' => 'Argentina Peso', 'AWG' => 'Aruba Guilder', 'AUD' => 'Australia Dollar', 'AZN' => 'Azerbaijan New Manat', 'BSD' => 'Bahamas Dollar', 'BBD' => 'Barbados Dollar', 'BDT' => 'Bangladeshi taka', 'BYR' => 'Belarus Ruble', 'BZD' => 'Belize Dollar', 'BMD' => 'Bermuda Dollar', 'BOB' => 'Bolivia Boliviano', 'BAM' => 'Bosnia and Herzegovina Convertible Marka', 'BWP' => 'Botswana Pula', 'BGN' => 'Bulgaria Lev', 'BRL' => 'Brazil Real', 'BND' => 'Brunei Darussalam Dollar', 'KHR' => 'Cambodia Riel', 'CAD' => 'Canada Dollar', 'KYD' => 'Cayman Islands Dollar', 'CLP' => 'Chile Peso', 'CNY' => 'China Yuan Renminbi', 'COP' => 'Colombia Peso', 'CRC' => 'Costa Rica Colon', 'HRK' => 'Croatia Kuna', 'CUP' => 'Cuba Peso', 'CZK' => 'Czech Republic Koruna', 'DKK' => 'Denmark Krone', 'DOP' => 'Dominican Republic Peso', 'XCD' => 'East Caribbean Dollar', 'EGP' => 'Egypt Pound', 'SVC' => 'El Salvador Colon', 'EEK' => 'Estonia Kroon', 'EUR' => 'Euro Member Countries', 'FKP' => 'Falkland Islands (Malvinas) Pound', 'FJD' => 'Fiji Dollar', 'GHC' => 'Ghana Cedis', 'GIP' => 'Gibraltar Pound', 'GTQ' => 'Guatemala Quetzal', 'GGP' => 'Guernsey Pound', 'GYD' => 'Guyana Dollar', 'HNL' => 'Honduras Lempira', 'HKD' => 'Hong Kong Dollar', 'HUF' => 'Hungary Forint', 'ISK' => 'Iceland Krona', 'INR' => 'India Rupee', 'IDR' => 'Indonesia Rupiah', 'IRR' => 'Iran Rial', 'IMP' => 'Isle of Man Pound', 'ILS' => 'Israel Shekel', 'JMD' => 'Jamaica Dollar', 'JPY' => 'Japan Yen', 'JEP' => 'Jersey Pound', 'KZT' => 'Kazakhstan Tenge', 'KPW' => 'Korea (North) Won', 'KRW' => 'Korea (South) Won', 'KGS' => 'Kyrgyzstan Som', 'LAK' => 'Laos Kip', 'LVL' => 'Latvia Lat', 'LBP' => 'Lebanon Pound', 'LRD' => 'Liberia Dollar', 'LTL' => 'Lithuania Litas', 'MKD' => 'Macedonia Denar', 'MYR' => 'Malaysia Ringgit', 'MUR' => 'Mauritius Rupee', 'MXN' => 'Mexico Peso', 'MNT' => 'Mongolia Tughrik', 'MZN' => 'Mozambique Metical', 'NAD' => 'Namibia Dollar', 'NPR' => 'Nepal Rupee', 'ANG' => 'Netherlands Antilles Guilder', 'NZD' => 'New Zealand Dollar', 'NIO' => 'Nicaragua Cordoba', 'NGN' => 'Nigeria Naira', 'NOK' => 'Norway Krone', 'OMR' => 'Oman Rial', 'PKR' => 'Pakistan Rupee', 'PAB' => 'Panama Balboa', 'PYG' => 'Paraguay Guarani', 'PEN' => 'Peru Nuevo Sol', 'PHP' => 'Philippines Peso', 'PLN' => 'Poland Zloty', 'QAR' => 'Qatar Riyal', 'RON' => 'Romania New Leu', 'RUB' => 'Russia Ruble', 'SHP' => 'Saint Helena Pound', 'SAR' => 'Saudi Arabia Riyal', 'RSD' => 'Serbia Dinar', 'SCR' => 'Seychelles Rupee', 'SGD' => 'Singapore Dollar', 'SBD' => 'Solomon Islands Dollar', 'SOS' => 'Somalia Shilling', 'ZAR' => 'South Africa Rand', 'LKR' => 'Sri Lanka Rupee', 'SEK' => 'Sweden Krona', 'CHF' => 'Switzerland Franc', 'SRD' => 'Suriname Dollar', 'SYP' => 'Syria Pound', 'TWD' => 'Taiwan New Dollar', 'THB' => 'Thailand Baht', 'TTD' => 'Trinidad and Tobago Dollar', 'TRY' => 'Turkey Lira', 'TRL' => 'Turkey Lira', 'TVD' => 'Tuvalu Dollar', 'UAH' => 'Ukraine Hryvna', 'GBP' => 'United Kingdom Pound', 'USD' => 'United States Dollar', 'UYU' => 'Uruguay Peso', 'UZS' => 'Uzbekistan Som', 'VEF' => 'Venezuela Bolivar', 'VND' => 'Viet Nam Dong', 'YER' => 'Yemen Rial', 'ZWD' => 'Zimbabwe Dollar', "KES" => "Kenyan shilling", "AED" => "Emirati Dirham", "TND" =>'Dinar Tunisien', "MAD" =>'Moroccan Dirham', "MVR" =>'Maldivian Ruffiya', "DZD"=>"Algerian Dinar (DZD)", 'XAF'=>"Central African CFA franc", 'XOF'=>"West African CFA franc", 'GEL'=>"Georgian", 'BIF'=>"Burundian Franc", 'AMD'=>"Armenian dram", 'TUL'=>"Turkish Lira", ); public static $currency_symbols = array( 'AED' => 'د.إ', // ? 'AFN' => 'Af', 'ALL' => 'Lek', 'AMD' => 'դ', 'ANG' => 'ƒ', 'AOA' => 'Kz', // ? 'ARS' => '$', 'AUD' => '$', 'AWG' => 'ƒ', 'AZN' => '₼', 'BAM' => 'KM', 'BBD' => '$', 'BDT' => '৳', // ? 'BGN' => 'лв', 'BHD' => '.د.ب', // ? 'BIF' => 'FBu', // ? 'BMD' => '$', 'BND' => '$', 'BOB' => '$b', 'BRL' => 'R$', 'BSD' => '$', 'BTN' => 'Nu.', // ? 'BWP' => 'P', 'BYR' => 'p.', 'BZD' => 'BZ$', 'CAD' => '$', 'CDF' => 'FC', 'CHF' => 'CHF', 'CLF' => 'UF', // ? 'CLP' => '$', 'CNY' => '¥', 'COP' => '$', 'CRC' => '₡', 'CUP' => '⃌', 'CVE' => '$', // ? 'CZK' => 'Kč', 'DJF' => 'Fdj', // ? 'DKK' => 'kr', 'DOP' => 'RD$', 'DZD' => 'دج', // ? 'EGP' => 'E£', 'ETB' => 'Br', 'EUR' => '€', 'FJD' => '$', 'FKP' => '£', 'GBP' => '£', 'GEL' => 'ლ', // ? 'GHS' => '¢', 'GIP' => '£', 'GMD' => 'D', // ? 'GNF' => 'FG', // ? 'GTQ' => 'Q', 'GYD' => '$', 'HKD' => '$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', // ? 'HUF' => 'Ft', 'IDR' => 'Rp', 'ILS' => '₪', 'INR' => '₹', 'IQD' => 'ع.د', // ? 'IRR' => '﷼', 'ISK' => 'kr', 'JEP' => '£', 'JMD' => 'J$', 'JOD' => 'JD', // ? 'JPY' => '¥', 'KES' => 'KSh', // ? 'KGS' => 'лв', 'KHR' => '៛', 'KMF' => 'CF', // ? 'KPW' => '₩', 'KRW' => '₩', 'KWD' => 'د.ك', // ? 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => '£', 'LKR' => '₨', 'LRD' => '$', 'LSL' => 'L', // ? 'LTL' => 'Lt', 'LVL' => 'Ls', 'LYD' => 'ل.د', // ? 'MAD' => 'د.م.', //? 'MDL' => 'L', 'MGA' => 'Ar', // ? 'MKD' => 'ден', 'MMK' => 'K', 'MNT' => '₮', 'MOP' => 'MOP$', // ? 'MRO' => 'UM', // ? 'MUR' => '₨', // ? 'MVR' => '.ރ', // ? 'MWK' => 'MK', 'MXN' => '$', 'MYR' => 'RM', 'MZN' => 'MT', 'NAD' => '$', 'NGN' => '₦', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => '₨', 'NZD' => '$', 'OMR' => '﷼', 'PAB' => 'B/.', 'PEN' => 'S/.', 'PGK' => 'K', // ? 'PHP' => '₱', 'PKR' => '₨', 'PLN' => 'zł', 'PYG' => 'Gs', 'QAR' => '﷼', 'RON' => 'lei', 'RSD' => 'Дин.', 'RUB' => '₽', 'RWF' => 'ر.س', 'SAR' => '﷼', 'SBD' => '$', 'SCR' => '₨', 'SDG' => '£', // ? 'SEK' => 'kr', 'SGD' => '$', 'SHP' => '£', 'SLL' => 'Le', // ? 'SOS' => 'S', 'SRD' => '$', 'STD' => 'Db', // ? 'SVC' => '$', 'SYP' => '£', 'SZL' => 'L', // ? 'THB' => '฿', 'TJS' => 'TJS', // ? TJS (guess) 'TMT' => 'm', 'TND' => 'DT', 'TOP' => 'T$', 'TRY' => '₤', // New Turkey Lira (old symbol used) 'TTD' => '$', 'TWD' => 'NT$', 'TZS' => 'TSh', 'UAH' => '₴', 'UGX' => 'USh', 'USD' => '$', 'UYU' => '$U', 'UZS' => 'сум', 'VEF' => 'Bs', 'VND' => '₫', 'VUV' => 'VT', 'WST' => 'WS$', 'XAF' => 'FCFA', 'XCD' => '$', 'XDR' => 'SDR', 'XOF' => 'FCFA', 'XPF' => 'F', 'YER' => '﷼', 'ZAR' => 'R', 'ZMK' => 'ZK', // ? 'ZWL' => 'Z$', 'TUL' => '₺', ); }