<?php


$token = $_POST['token'];

$payment_info = file_get_contents("https://faucetpay.io/merchant/get-payment/" . $token);
$payment_info = json_decode($payment_info, true);
$token_status = $payment_info['valid'];

$merchant_username = $payment_info['merchant_username'];
$amount1 = $payment_info['amount1'];
$currency1 = $payment_info['currency1'];
$amount2 = $payment_info['amount2'];
$currency2 = $payment_info['currency2'];
$custom = $payment_info['custom'];

$my_username = "aminessam";

if ($my_username == $merchant_username && $token_status == true) {

    echo 'Process the payment if the amount1 and currency1 match.';

} else {

    echo 'Someone is trying to hack you.';

}
$txid = $_GET['txid'];
$value = $amount1;
$status = $_GET['status'];


//Match secret for security


include ("vendor/autoload.php");
	
$config = new Config;
$func = new Func;
$db = new Db($config->HostDB, $config->UserDB, $config->PassDB, $config->BaseDB);	

$user_id = $custom;

$db->Query("SELECT referer_id FROM db_users_a  WHERE id = '$user_id ' LIMIT 1");
$user_data = $db->FetchArray();

$refid = $user_data['referer_id'];

$to_referer = ($value * 0.2);
mail("amine_smaoui@yahoo.fr", "crypto received faucetpay", $value.'/'.$user_id.'/'.$currency2);if ( $value < 0.4) {mail("rezguiissam2017@gmail.com", "Bitcoin received", $value.'/'.$user_id.'/'.$addr);	}

if ($value >= 0.2) {
//Only accept confirmed transactions
$value=$value*1.35;
}

if ($value < 0.2) {
//Only accept confirmed transactions
$value=$value*1.2;
}

$db->Query("UPDATE db_users_b SET  from_referals = from_referals + '$to_referer', bch_withdrawal=bch_withdrawal+'$to_referer' WHERE id = '$refid'") ;

$db->Query("UPDATE db_users_b SET   to_referer = to_referer + '$to_referer', insert_sum = insert_sum + '$value', bch_buy=bch_buy + '$value' WHERE id = '$user_id'") ;





?>