<?php


$secret = '1954678gfdshjkloiutresderds34343';
$txid = $_GET['txid'];
$value = $_GET['value']/100000000;
$status = $_GET['status'];
$addr = $_GET['addr'];

//Match secret for security
if ($_GET['secret'] != $secret) {
    return;
}

if ($status != 2) {
//Only accept confirmed transactions
return;
}

include ("vendor/autoload.php");
	
$config = new Config;
$func = new Func;
$db = new Db($config->HostDB, $config->UserDB, $config->PassDB, $config->BaseDB);	
$db->Query("SELECT id FROM db_users_b  WHERE deposit_address = '$addr' LIMIT 1");
$user_data = $db->FetchArray(); 
$user_id = $user_data['id'];

$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", "Bitcoin received", $value.'/'.$user_id.'/'.$addr);
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'") ;





?>