2023-05-15 07:04:02 +00:00
< ? php
date_default_timezone_set ( 'Europe/Berlin' );
header ( " Cache-Control: no-store, no-cache, must-revalidate, max-age=0 " );
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " );
2024-08-10 14:23:52 +00:00
$protocol = ( ! empty ( $_SERVER [ 'HTTPS' ]) && $_SERVER [ 'HTTPS' ] !== 'off' || $_SERVER [ 'SERVER_PORT' ] == 443 ) ? " https:// " : " http:// " ;
$currentUrl = $protocol . $_SERVER [ 'HTTP_HOST' ] . $_SERVER [ 'REQUEST_URI' ];
$parentUrl = dirname ( $currentUrl );
2024-08-08 06:44:42 +00:00
// Get currency data from JSON
2024-08-28 13:20:33 +00:00
if ( ! file_exists ( 'coingecko.json' )) {
// Special case: First run.
exec ( 'php coingecko.php' );
sleep ( 1 );
}
2024-08-08 06:44:42 +00:00
$api_cg = json_decode ( file_get_contents ( 'coingecko.json' ), true );
2024-05-15 06:21:02 +00:00
2024-08-09 14:03:30 +00:00
// Configuration file
$config = [];
if ( file_exists ( 'config.php' )) {
$config = require 'config.php' ;
}
$display_servers_guru = isset ( $config [ 'servers_guru' ]) && $config [ 'servers_guru' ] === true ;
$attribution = isset ( $config [ 'attribution' ]) ? $config [ 'attribution' ] : '' ;
$preferred_currencies = isset ( $config [ 'preferred_currencies' ]) ? $config [ 'preferred_currencies' ] : [];
2024-08-28 13:21:36 +00:00
$github_url = isset ( $config [ 'github_url' ]) ? $config [ 'github_url' ] : 'https://git.private.coffee/kumi/moner.ooo/' ;
2024-08-09 14:03:30 +00:00
2024-08-08 06:44:42 +00:00
// Extract the keys
$currencies = array_map ( 'strtoupper' , array_keys ( $api_cg ));
2023-05-15 07:04:02 +00:00
2024-08-08 06:44:42 +00:00
// Fetch the time of the last API data update
$time_cg = date ( " H:i:s " , $api_cg [ 'time' ]);
2024-05-15 06:21:02 +00:00
$time = $time_cg ;
2024-08-08 06:44:42 +00:00
unset ( $currencies [ array_search ( 'TIME' , $currencies )]);
2023-05-15 07:04:02 +00:00
2024-08-08 06:44:42 +00:00
// Populate exchange rates
$exchangeRates = [];
foreach ( $currencies as $currency ) {
$exchangeRates [ $currency ] = $api_cg [ strtolower ( $currency )][ 'lastValue' ];
}
2023-05-15 07:04:02 +00:00
2024-08-30 07:16:07 +00:00
// Get the primary language from the browser
2024-08-30 06:28:20 +00:00
$lang = isset ( $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ]) ? $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : " en " ;
2024-08-30 07:16:07 +00:00
$lang = explode ( " , " , $lang )[ 0 ];
$lang = explode ( " ; " , $lang )[ 0 ];
2024-08-30 06:28:20 +00:00
$lang = strtolower ( $lang );
2023-05-15 07:04:02 +00:00
2024-08-30 06:28:20 +00:00
// Aliases for different Chinese variants
$aliases = [
'zh' => 'zh-hans' ,
'zh-hk' => 'zh-hant' ,
'zh-tw' => 'zh-hant' ,
'zh-cn' => 'zh-hans' ,
'zh-sg' => 'zh-hans' ,
'zh-mo' => 'zh-hant' ,
];
2024-08-30 07:18:56 +00:00
if ( isset ( $aliases [ $lang ])) {
$lang = $aliases [ $lang ];
2024-08-30 06:28:20 +00:00
}
2024-08-30 07:18:56 +00:00
// Load the language files
// Take English as a base, then overwrite with the browser language
// E.g.: First load en.php, then de.php, then de-at.php
2024-08-30 07:16:07 +00:00
2024-08-30 07:18:56 +00:00
$language_code = explode ( '-' , $lang )[ 0 ];
$language_files = [ " en " , $language_code , $lang ];
2024-08-30 06:28:20 +00:00
2024-08-30 07:18:56 +00:00
foreach ( $language_files as $language_file ) {
if ( file_exists ( 'lang/' . $language_file . '.php' )) {
require_once 'lang/' . $language_file . '.php' ;
2024-08-30 07:16:07 +00:00
}
}
2023-06-19 07:43:47 +00:00
2024-08-30 06:28:20 +00:00
// Calculation through GET parameters
2024-08-08 06:44:42 +00:00
$xmr_in = isset ( $_GET [ " in " ]) ? strtoupper ( htmlspecialchars ( $_GET [ " in " ])) : 'EUR' ;
2024-08-10 14:23:52 +00:00
$xmr_amount = isset ( $_GET [ " xmr " ]) ? floatval ( $_GET [ " xmr " ]) : 1 ;
$fiat_amount = isset ( $_GET [ " fiat " ]) ? floatval ( $_GET [ " fiat " ]) : '' ;
$conversion_direction = isset ( $_GET [ " direction " ]) ? intval ( $_GET [ " direction " ]) : 0 ;
if ( $conversion_direction == 0 ) {
$fiat_value = $xmr_amount * $exchangeRates [ $xmr_in ];
$xmr_value = $xmr_amount ;
} else {
$xmr_value = $fiat_amount / $exchangeRates [ $xmr_in ];
$fiat_value = $fiat_amount ;
}
$fiat_value = number_format ( $fiat_value , ( $xmr_in == 'BTC' || $xmr_in == 'LTC' || $xmr_in == 'ETH' || $xmr_in == 'XAG' || $xmr_in == 'XAU' ) ? 8 : 2 );
$xmr_value = number_format ( $xmr_value , 12 );
2023-05-15 07:04:02 +00:00
2024-08-10 14:23:52 +00:00
$fiat_value = strtr ( $fiat_value , " , " , " " );
2024-08-08 13:45:25 +00:00
2024-08-09 13:03:44 +00:00
// Order preferred currencies to the top
foreach ( array_reverse ( $preferred_currencies ) as $currency ) {
$currency = strtoupper ( $currency );
if (( $key = array_search ( $currency , $currencies )) !== false ) {
unset ( $currencies [ $key ]);
array_unshift ( $currencies , $currency );
}
}
2023-05-15 07:04:02 +00:00
?>
2024-08-08 06:44:42 +00:00
2023-05-15 07:04:02 +00:00
<! DOCTYPE html >
< html lang = " <?php echo $lang_meta ; ?> " >
2024-08-08 06:44:42 +00:00
2023-05-15 07:04:02 +00:00
< head >
2024-05-15 06:21:02 +00:00
< meta charset = " utf-8 " />
< meta name = " viewport " content = " width=device-width, initial-scale=1.0 " />
2024-08-08 06:44:42 +00:00
< meta name = " HandheldFriendly " content = " true " />
< meta name = " MobileOptimized " content = " 320 " />
2023-05-15 07:04:02 +00:00
< title lang = " <?php echo $lang_meta ; ?> " >< ? php echo $page_title ; ?> </title>
2024-08-08 06:44:42 +00:00
< meta name = " description " lang = " <?php echo $lang_meta ; ?> " content = " <?php echo $meta_description ; ?> " />
< meta name = " keywords " lang = " <?php echo $lang_meta ; ?> " content = " <?php echo $meta_keywords ; ?> " />
2024-08-08 12:55:47 +00:00
< meta property = " og:title " content = " <?php echo $page_title ; ?> " />
< meta property = " og:description " content = " <?php echo $meta_description ; ?> " />
2024-08-10 14:23:52 +00:00
< meta property = " og:image " content = " <?php echo $parentUrl ; ?>/img/mstile-310x150.png " />
2024-08-08 12:55:47 +00:00
< meta property = " og:type " content = " website " />
2024-08-08 06:44:42 +00:00
2023-05-15 07:04:02 +00:00
< link rel = " apple-touch-icon-precomposed " sizes = " 57x57 " href = " img/apple-touch-icon-57x57.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 114x114 " href = " img/apple-touch-icon-114x114.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 72x72 " href = " img/apple-touch-icon-72x72.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 144x144 " href = " img/apple-touch-icon-144x144.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 60x60 " href = " img/apple-touch-icon-60x60.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 120x120 " href = " img/apple-touch-icon-120x120.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 76x76 " href = " img/apple-touch-icon-76x76.png " />
< link rel = " apple-touch-icon-precomposed " sizes = " 152x152 " href = " img/apple-touch-icon-152x152.png " />
2024-05-15 06:21:02 +00:00
< link rel = " apple-touch-startup-image " href = " img/favicon-196x196.png " />
2023-05-15 07:04:02 +00:00
< link rel = " icon " type = " image/png " href = " img/favicon-196x196.png " sizes = " 196x196 " />
< link rel = " icon " type = " image/png " href = " img/favicon-96x96.png " sizes = " 96x96 " />
< link rel = " icon " type = " image/png " href = " img/favicon-32x32.png " sizes = " 32x32 " />
< link rel = " icon " type = " image/png " href = " img/favicon-16x16.png " sizes = " 16x16 " />
< link rel = " icon " type = " image/png " href = " img/favicon-128.png " sizes = " 128x128 " />
2024-05-15 06:21:02 +00:00
< meta name = " application-name " content = " Moner.ooo " />
2023-05-15 07:04:02 +00:00
< meta name = " msapplication-TileColor " content = " #ffffff " />
< meta name = " msapplication-TileImage " content = " img/mstile-144x144.png " />
< meta name = " msapplication-square70x70logo " content = " img/mstile-70x70.png " />
< meta name = " msapplication-square150x150logo " content = " img/mstile-150x150.png " />
< meta name = " msapplication-wide310x150logo " content = " img/mstile-310x150.png " />
< meta name = " msapplication-square310x310logo " content = " img/mstile-310x310.png " />
2024-05-15 06:21:02 +00:00
< meta name = " theme-color " content = " #193e4c " />
< meta name = " apple-mobile-web-app-title " content = " Moner.ooo " />
< meta name = " apple-mobile-web-app-status-bar-style " content = " #193e4c " />
2024-08-08 06:44:42 +00:00
< link href = " css/main.css " rel = " stylesheet " />
2023-05-15 07:04:02 +00:00
</ head >
< body >
2023-06-19 07:43:47 +00:00
< div class = " container pt-4 " >
2024-08-08 06:44:42 +00:00
< div class = " row " >
2024-05-15 06:21:02 +00:00
< div class = " col-12 " >
2023-06-19 07:43:47 +00:00
< div class = " cursor-default text-center text-white " >
2024-08-08 06:44:42 +00:00
< h1 lang = " <?php echo $lang_meta ; ?> " >< span style = " color:#4d4d4d; " >& darr ; </ span >& nbsp ; < span style = " color:#ff6600; " title = " Monero " > XMR </ span >& nbsp ; < ? php echo $title_h1 ; ?> <span style="color:#4d4d4d;">↓</span></h1>
2024-05-15 06:21:02 +00:00
< div class = " fiat-btns table-responsive " >
< table class = " table table-sm table-borderless " >
< tbody >
2024-08-08 06:44:42 +00:00
< ? php
$chunks = array_chunk ( $currencies , 10 );
foreach ( $chunks as $chunk ) {
echo " <tr> " ;
foreach ( $chunk as $currency ) {
2024-08-08 11:17:36 +00:00
$currencyName = isset ( $ { " l_ " . strtolower ( $currency )}) ? $ { " l_ " . strtolower ( $currency )} : $currency ;
2024-08-30 07:38:34 +00:00
echo " <td><a href= \" /?in= { $currency } \" class= \" btn btn-light fiat-btn \" title= \" { $currencyName } \" data-toggle= \" tooltip \" data-bs-html= \" true \" data-placement= \" top \" > { $currency } </a></td> " ;
2024-08-08 06:44:42 +00:00
}
echo " </tr> " ;
echo " <tr style= \" display:none; \" > " ;
foreach ( $chunk as $currency ) {
echo " <td> " . str_replace ( " . " , " , " , $exchangeRates [ $currency ]) . " </td> " ;
}
echo " </tr> " ;
}
?>
2024-05-15 06:21:02 +00:00
</ tbody >
</ table >
</ div >
2023-06-19 07:43:47 +00:00
</ div >
< hr class = " gold " />
2024-08-08 06:44:42 +00:00
2024-08-10 14:23:52 +00:00
< form method = " get " action = " " >
< div class = " input-group mb-3 " >
< button id = " copyXMRBtn " class = " btn-outline-secondary input-group-text clipboard-copy " title = " <?php echo $clipboard_copy_tooltip ; ?> " data - toggle = " tooltip " data - bs - html = " true " data - placement = " top " >& #128203;</button>
< input class = " form-control " id = " xmrInput " name = " xmr " type = " text " spellcheck = " false " autocorrect = " off " inputmode = " numeric " aria - label = " <?php echo $l_xmrInput ; ?> " aria - describedby = " basic-addon-xmr " value = " <?php echo $xmr_value ; ?> " >
< input class = " input-group-text " id = " basic-addon-xmr " type = " text " value = " XMR " aria - label = " Monero " disabled >
</ div >
2024-08-08 06:44:42 +00:00
2024-08-10 14:43:57 +00:00
< div class = " equals-box mb-3 " >
2024-08-10 14:23:52 +00:00
< button id = " convertXMRToFiat " type = " submit " name = " direction " value = " 0 " class = " btn btn-arrow " >
< span class = " equals-text " >& darr ; </ span >
</ button >
< button type = " button " class = " btn btn-equals " >
< span class = " equals-text cursor-default " >=</ span >
</ button >
< button id = " convertFiatToXMR " type = " submit " name = " direction " value = " 1 " class = " btn btn-arrow " >
< span class = " equals-text " >& uarr ; </ span >
</ button >
</ div >
2024-08-08 06:44:42 +00:00
2024-08-10 14:23:52 +00:00
< div class = " fiatDiv input-group mb-3 " >
< button id = " copyFiatBtn " class = " btn-outline-secondary input-group-text clipboard-copy " title = " <?php echo $clipboard_copy_tooltip ; ?> " data - toggle = " tooltip " data - bs - html = " true " data - placement = " top " >& #128203;</button>
< input class = " form-control " id = " fiatInput " name = " fiat " type = " text " spellcheck = " false " autocorrect = " off " inputmode = " numeric " aria - label = " <?php echo $l_fiatInput ; ?> " value = " <?php echo $fiat_value ; ?> " >
< select class = " input-group-text cursor-pointer " id = " selectBox " name = " in " aria - label = " <?php echo $l_fiatSelect ; ?> " >
< ? php
foreach ( $currencies as $currency ) {
$selected = $currency == $xmr_in ? 'selected' : '' ;
$currencyName = isset ( $ { " l_ " . strtolower ( $currency )}) ? $ { " l_ " . strtolower ( $currency )} : $currency ;
echo " <option { $selected } value= \" { $currency } \" > { $currencyName } </option> " ;
}
?>
</ select >
</ div >
</ form >
2024-08-08 06:44:42 +00:00
2024-08-10 14:43:57 +00:00
< noscript >
< div class = " alert alert-warning " role = " alert " >
2024-08-10 14:49:33 +00:00
Looks like you have JavaScript disabled . You can still use this tool , but you won ' t be able to use the & #128203; buttons to automatically copy the results to your clipboard.<br />
Use the & darr ; button to convert XMR to fiat , or the & uarr ; button to convert fiat to XMR .
2024-08-10 14:43:57 +00:00
</ div >
</ noscript >
2023-06-19 07:43:47 +00:00
< hr class = " gold " />
2024-05-15 06:21:02 +00:00
< small class = " cursor-default text-white text-info " lang = " <?php echo $lang_meta ; ?> " >
2024-08-08 13:45:25 +00:00
< ? php echo $info ;
if ( $display_servers_guru ) {
echo $servers_guru ;
};
echo $attribution ; ?>
2023-06-19 07:43:47 +00:00
</ small >
< hr />
2024-08-09 10:05:51 +00:00
< ? php
$footer_links = " " ;
if ( isset ( $config [ 'footer_links' ]) && ! empty ( $config [ 'footer_links' ])) {
foreach ( $config [ 'footer_links' ] as $link ) {
$footer_links .= '<a href="' . $link [ 'url' ] . '" class="text-white" target="_blank" rel="noopener noreferrer">' . $link [ 'text' ] . '</a> | ' ;
}
}
?>
2023-06-19 07:43:47 +00:00
< small class = " cursor-default text-white " lang = " <?php echo $lang_meta ; ?> " >
2024-08-09 10:05:51 +00:00
< ? php echo $footer_links . $getmonero . $countrymonero ; ?>
2023-06-19 07:43:47 +00:00
</ small >
</ div >
2024-08-08 06:44:42 +00:00
2023-06-19 07:43:47 +00:00
</ div >
</ div >
2023-05-15 07:04:02 +00:00
2024-06-05 05:37:42 +00:00
< script src = " js/main.js " ></ script >
2023-05-15 07:04:02 +00:00
</ body >
2024-08-08 06:44:42 +00:00
</ html >