<?php
require_once('../../../../configuration.php');
require_once('../../../../functions.php');
require_once('../../../../dbhandle.php');
// Validate the Moneybookers signature
$concatFields = $_POST['merchant_id']
    .$_POST['transaction_id']
    .strtoupper(md5($skrill_2))
    .$_POST['mb_amount']
    .$_POST['mb_currency']
    .$_POST['status'];

$MBEmail = $skrill_1;

// Ensure the signature is valid, the status code == 2,
// and that the money is going to you
if (strtoupper(md5($concatFields)) == $_POST['md5sig']
    && $_POST['status'] == 2
    && $_POST['pay_to_email'] == $MBEmail)
{
    			$username = $_POST['detail2_text'];
				$email = $_POST['detail3_text'];
				$payment_status = $_POST['status'];
				$payment_amount = $_POST['amount2'];
				$payment_tax = $_POST['amount3'];
				$payment_full = $_POST['amount'];
				$payment_currency = $_POST['currency'];
				$receiver_email = $_POST['pay_to_email'];
				$payer_email = $_POST['pay_from_email'];
				$payer_username = $_POST['field 1'];
				$payer_accounttype = $_POST['field 2'];
					//UPDATING BALANCE	
					if($payer_accounttype == 'publisher') {
						$traceuser = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username = '$payer_username' ");
						$traceuserresult = mysql_fetch_array($traceuser);
	
						$FULbalanceold = $traceuserresult['balance'];
						$balancenew = $FULbalanceold + $payment_amount - $tax;
						$ownermail =  $skrill_1;
						$datero = date("F j, Y");
					
						if ($ownermail == $receiver_email){
							mysql_query("UPDATE Accounts_Classic_Publishers SET balance='$balancenew' WHERE username='$payer_username'");
						}
					}
					if($payer_accounttype == 'advertiser') {
						$traceuser = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username = '$payer_username' ");
						$traceuserresult = mysql_fetch_array($traceuser);
	
						$FULbalanceold = $traceuserresult['balance'];
						$balancenew = $FULbalanceold + $payment_amount - $tax;
						$ownermail =  $skrill_1;
						$datero = date("F j, Y");
					
						if ($ownermail == $receiver_email){
							mysql_query("UPDATE Accounts_Classic_Advertisers SET balance='$balancenew' WHERE username='$payer_username'");
						}
					}
}
else
{
    exit;
}

?>