0 //dev
$errs[] = "Please enter correct reserve value";
if (isset($min_reserve) && $min_reserve != "" && !is_numeric($min_reserve)) // > 0 //dev
$errs[] = "Please enter correct minimum reserve value";
if (isset($fee) && $fee != "" && !is_numeric($fee))
$errs[] = "Please enter correct fee value";
if (isset($min_reserve) && $min_reserve > 0 && $min_reserve >= $reserve)
$errs[] = "Min reserve value cant be less than reserve amount";
$check_query = smart_mysql_query("SELECT * FROM exchangerix_currencies WHERE currency_name='$currency_name' AND currency_code='$currency_code' AND status='active'");
if (mysqli_num_rows($check_query) > 0)
{
$errs[] = "Sorry, currency with same name and code is exists";
}
if ($default_send == 1 && $default_receive == 1)
$errs[] = "Sorry, one currency can't be default for send and receive payments";
if ($default_send == 1)
{
$check_query2 = smart_mysql_query("SELECT * FROM exchangerix_currencies WHERE default_send='1' AND status='active'");
if (mysqli_num_rows($check_query2) > 0)
{
$errs[] = "Sorry, only one currency can be default for sending";
}
}
if ($default_receive == 1)
{
$check_query3 = smart_mysql_query("SELECT * FROM exchangerix_currencies WHERE default_receive='1' AND status='active'");
if (mysqli_num_rows($check_query3) > 0)
{
$errs[] = "Sorry, only one currency can be default for receiving";
}
}
if (isset($site_code) && $site_code != "")
{
$check_query4 = smart_mysql_query("SELECT * FROM exchangerix_currencies WHERE site_code='$site_code'");
if (mysqli_num_rows($check_query4) > 0)
{
$errs[] = "Sorry, currency with same 'Site code' is exists";
}
}
if (isset($xml_code) && $xml_code != "")
{
$check_query5 = smart_mysql_query("SELECT * FROM exchangerix_currencies WHERE xml_code='$xml_code'");
if (mysqli_num_rows($check_query5) > 0)
{
$errs[] = "Sorry, currency with same 'Xml code' is exists";
}
}
}
if (count($errs) == 0)
{
if ($_FILES['logo_file']['tmp_name'])
{
if (is_uploaded_file($_FILES['logo_file']['tmp_name']))
{
list($width, $height, $type) = getimagesize($_FILES['logo_file']['tmp_name']);
if ($_FILES['logo_file']['size'][$key] > PROOF_MAX_SIZE)
{
$errs[] = "The $img_id image file size is too big. It exceeds 2Mb";
}
elseif (preg_match('/\\.(gif|jpg|png|jpeg)$/i', $_FILES['logo_file']['name']) != 1)
{
$errs[] = "Please upload PNG, JPG, GIF file only";
//$errs[] = "Please upload ".strtoupper(str_replace("|", ", .", PROOF_ALLOWED_FILES))." file only"; //PROOF_ALLOWED_FILES = dd|ddd
unlink($_FILES['logo_file']['tmp_name']);
}
else
{
$ext = substr(strrchr($_FILES['logo_file']['name'], "."), 1);
$upload_file_name = "logo_".mt_rand(1,100).time().".".$ext; //md5(substr($ip, 0, -5).mt_rand(1,10000).time()).".".$ext;
$img = $upload_file_name;
$upload_path = PUBLIC_HTML_PATH.'/images/currencies/'.$upload_file_name;
$resized_path = $upload_path; //PUBLIC_HTML_PATH.'/images/currencies/'.$upload_file_name_resized;
// upload file
move_uploaded_file($_FILES['logo_file']['tmp_name'], $upload_path);
$imgData = resize_image($resized_path, 48, 48);
imagepng($imgData, $upload_path);
}
}
}
else
{
$img = "no_image.png";
}
}
else
{
$errormsg = "";
foreach ($errs as $errorname)
$errormsg .= $errorname."
";
}
if (count($errs) == 0)
{
$insert_sql = "INSERT INTO exchangerix_currencies SET currency_name='$cname', currency_code='$currency', gateway_id='$gateway_id', image='$img', instructions='$instructions', website='$website', is_crypto='$is_crypto', reserve='$reserve', fee='$fee', min_reserve='$min_reserve', site_code='$site_code', xml_code='$xml_code', allow_send='$allow_send', allow_receive='$allow_receive', allow_affiliate='$allow_affiliate', default_send='$default_send', default_receive='$default_receive', sort_order='$sort_order', is_new_currency='$is_new_currency', hide_code='$hide_code', status='$status', added=NOW()";
$result = smart_mysql_query($insert_sql);
$new_insert_id = mysqli_insert_id($conn);
/*
if (count($category) > 0)
{
foreach ($category as $cat_id)
{
$cats_insert_sql = "INSERT INTO exchangerix_retailer_to_category SET retailer_id='$new_retailer_id', category_id='$cat_id'";
smart_mysql_query($cats_insert_sql);
}
}
if ($_POST['all_countries_check'] != 1 && count($country) > 0)
{
foreach ($country as $country_id)
{
$countries_insert_sql = "INSERT INTO exchangerix_retailer_to_country SET retailer_id='$new_retailer_id', country_id='$country_id'";
smart_mysql_query($countries_insert_sql);
}
}
*/
header("Location: currencies.php?msg=added");
exit();
}
else
{
$errormsg = "";
foreach ($errs as $errorname)
$errormsg .= $errorname."
";
}
}
$title = "Add Currency";
require_once ("inc/header.inc.php");
?>