<?php
$module_css_path = ($line_domain['theme'] != "" && $line_domain['theme'] != "default") ? ($path . ('assets/themes/' . $line_domain['theme'] . '/')) : $path;

$optres['css'][] = $module_css_path . "amodules/rates-com/css/calculator.css";
$optres['js'][] = $path . "amodules/rates-com/js/calculator.js";
function get_content($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
$must_cache = false;
$mod_protocol = isset($protocol) ? $protocol : 'http://';
$mod_protocol = 'http://';
$file = "amodules/remote/rates-com.inc.php";
$file_timestamp = null;
if(file_exists(dirname(__FILE__) . "/../remote/rates-com.inc.php")) {
    $file_timestamp = filemtime(dirname(__FILE__) . "/../remote/rates-com.inc.php");
}

$rates = get_content("https://www.cypruswebsites.com/amodules/remote/rates-com.inc.php");
if($file_timestamp != null) {
    ?>
    <h2>Exchange rates</h2>
    <p>Check out today's exchange rates for foreign currency. The latest exchange rates of the EURO against all major currencies as taken by the Bank of Cyprus dealing room.</p>

    <div class="calculator">
        <h3>Exchange Rates Calculator</h3>
        <form method="post" id="calc-frm" class="form-horizontal" role="form">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-4">

                        <div class="input-group">
                            <input type="text" id="amount_f" class="form-control" aria-label="Amount">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span id="f_btn">EUR</span> <span class="caret"></span></button>
                                <ul class="dropdown-menu dropdown-menu-right currencies currency-list-f">
                                    <li class="active" id="f_EUR"><a href="#" class="f-currency-selector"v data-value="0" data-currency="EUR">EUR</a></li>
                                    <li role="separator" class="divider"></li>
                                </ul>
                            </div><!-- /btn-group -->

                        </div><!-- /input-group -->
                    </div><!-- /.col-lg-5 -->
                    <div class="col-sm-2 text-center">
                        <a href="#" id="exchange"><i class="fa fa-random fa-3x fa-fw"></i> </a>
                    </div>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <input type="text" readonly id="amount_t" class="form-control" aria-label="Converted Amount">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span id="t_btn">EUR</span> <span class="caret"></span></button>
                                <ul class="dropdown-menu dropdown-menu-right currencies currency-list-t">
                                    <li class="active" id="t_EUR"><a href="#" class="t-currency-selector" data-value="0" data-currency="EUR">EUR</a></li>
                                    <li role="separator" class="divider"></li>
                                </ul>
                            </div><!-- /btn-group -->
                        </div><!-- /input-group -->
                    </div><!-- /.col-lg-5 -->
                </div><!-- /.row -->

            </div>

        </form>
    </div>
    <div class="text-right">
        <small>Last updated on: <?= date("d/m/Y H:i:s", $file_timestamp); ?></small>
    </div>
    <?php
}
?>

<div class="table-responsive">
    <?=$rates;?>
</div>
