0)
{
$errs[] = "Sorry, current exchange direction is exists";
}
if ((isset($from_rate) && $from_rate != "" && !is_numeric($from_rate)) || (isset($to_rate) && $to_rate != "" && !is_numeric($to_rate)))
$errs[] = "Please enter correct exchange rate (numbers only)";
if (isset($fee) && $fee != "" && !is_numeric($fee))
$errs[] = "Please enter correct margin value";
/*if (isset($fee) && $fee != "" && !is_numeric($fee) && !strstr($fee, "%"))
$errs[] = "Please enter correct fee value";*/
if (isset($min_amount) && $min_amount != "" && !is_numeric($min_amount))
$errs[] = "Please enter correct minimum exchange value";
if (isset($max_amount) && $max_amount != "" && !is_numeric($max_amount))
$errs[] = "Please enter correct maximum exchange value";
if (isset($min_amount) && is_numeric($min_amount) && isset($max_amount) && is_numeric($max_amount) && $min_amount>$max_amount)
$errs[] = "Max exchange value cant be less than min value";
if ($auto_rate == 1)
{
$fsym = GetCurrencyCode($from_currency);
$tsyms = GetCurrencyCode($to_currency);
$url = "https://min-api.cryptocompare.com/data/price?fsym=".$fsym."&tsyms=".$tsyms;
$json = json_decode(file_get_contents($url), true);
if ($json["Response"] == "Error")
{
$errs[] = "Sorry, auto price update not available for these currencies";
}
}
}
if (count($errs) == 0)
{
$exchange_rate = $to_rate/$from_rate;
smart_mysql_query("UPDATE exchangerix_exdirections SET from_currency='$from_currency', to_currency='$to_currency', from_rate='$from_rate', to_rate='$to_rate', exchange_rate='$exchange_rate', auto_rate='$auto_rate', fee='$fee', min_amount='$min_amount', max_amount='$max_amount', user_instructions='$instructions', description='$description', is_manual='$is_manual', hide_from_visitors='$hide_from_visitors', allow_affiliate='$allow_affiliate', sort_order='$sort_order', status='$status', updated=NOW() WHERE exdirection_id='$did' LIMIT 1");
header("Location: exdirections.php?msg=updated");
exit();
}
else
{
$errormsg = "";
foreach ($errs as $errorname)
$errormsg .= $errorname."
";
}
}
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = (int)$_GET['id'];
$query = "SELECT * FROM exchangerix_exdirections WHERE exdirection_id='$id' LIMIT 1";
$rs = smart_mysql_query($query);
$total = mysqli_num_rows($rs);
}
$title = "Edit Exchange Direction";
require_once ("inc/header.inc.php");
?>