print "<script>document.location.href='connect.php?message=INIT_SESSION&return=" . $return_url . "'</script>;";
    die;
}
//Get to user id
$campaign_owner = $money_class->GetCampaignOwner($campaign_id);
//Check if user has balance
$account_balance = $user_class->GetBalance($user_logon_data['id']);
if ($account_balance >= $amount && $amount != '') {
    $from_user_currency = $user_logon_data['currency'];
    $to_user_currency = $user_class->GetUSerCurrency($campaign_owner['user_id']);
    //Substract money to user
    $substract = $money_class->SubtractMoney($user_logon_data['id'], $amount);
    if ($from_user_currency == $to_user_currency) {
        $amount = $amount;
    } else {
        $exchange = $money_class->CurrencyExchange($to_user_currency, $from_user_currency);
        $amount = round($amount * $exchange, 2);
        //var_dump($amount);die();
    }
    $add_money = $money_class->SumMoney($campaign_owner['user_id'], $amount);
    $redeemed = '1';
    $anonymous = '0';
    $trans_hash = md5($campaign_owner['user_id'] . $user_logon_data['id'] . time());
    $to_user_twitter_id = $user_class->GetTwitterIdFromUserId($campaign_owner['user_id']);
    $save_trans = mysql_query("INSERT INTO  `transactions` (`id` ,`from_user_id` ,`to_twitter_user_id` ,`date` ,`redeemed` ,`amount` ,`anonymous` , `hash`)VALUES (\nNULL ,  '" . $user_logon_data['id'] . "',  '" . $to_user_twitter_id . "', CURRENT_TIMESTAMP ,  '" . $redeemed . "',  '" . $amount . "',  '" . $anonymous . "' , '" . $trans_hash . "');");
    $save_trans_campaign = mysql_query("INSERT INTO  `campaign_transactions` (`id` ,`campaign_id` ,`amount` ,`currency` , `from_user_id`, `sent_time`)VALUES (\nNULL ,  '" . $campaign_id . "',  '" . $amount . "','" . $to_user_currency . "' , '" . $user_logon_data['id'] . "' , CURRENT_TIMESTAMP);");
} else {
    //Oops, no money, redirect to payment platform
    printf("<script>document.location.href='sum_balance.php?message=NO_MONEY&return='</script>;");
}
printf("<script>document.location.href='campaign.php?id=" . $campaign_id . "&INFO=THANKS_DONATE'</script>;");
Example #2
0
<?php

session_start();
require_once 'config.php';
require_once 'classes.php';
$m = new MoneyStuff();
$promo_code = $_GET['promo_code'];
//Validate promo code and user session
$validate = $m->ValidateVoucher($promo_code);
if ($validate == false) {
    printf("<script>document.location.href='index.php?error=ERR_CODE_NOT_VALID'</script>;");
    die("ERR_CODE_NOT_VALID");
}
$user_logon_data = $_SESSION['user_profile'];
if ($user_logon_data['id'] == '') {
    printf("<script>document.location.href='index.php?error=ERR_NO_SESSION'</script>;");
    die("ERR_NO_SESSION");
}
if ($user_logon_data['currency'] != $validate['currency']) {
    $amount = round($validate['amount'] * $m->CurrencyExchange($user_logon_data['currency'], $validate['currency']), 2);
} else {
    $amount = $validate['amount'];
}
$m->SumMoney($user_logon_data['id'], $amount);
$m->InsertPaymentVoucher($user_logon_data['id'], $validate['currency'], $validate['amount']);
$m->RedeemCode($promo_code);
printf("<script>document.location.href='index.php?message=VOUCHER_OK'</script>;");
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];
$money_class = new MoneyStuff();
$user_class = new Users();
$user_logon_data = $_SESSION['user_profile'];
$content = $_SESSION['content'];
$user_prof = get_object_vars($content);
$user_profile = $_SESSION['user_profile'];
if ($user_profile == '') {
    die('no session cowboy');
}
//Get user account balance
$currency = $user_profile['currency'];
$balance = $user_class->GetBalance($_SESSION['user_profile']['id']);
if ($currency == 'USD') {
    $conversion = $money_class->CurrencyExchange("USD", "EUR");
    $limit = round(PAYPAL_MIN_GET * $conversion, 2);
} else {
    $limit = PAYPAL_MIN_GET;
}
$amount = $_GET['amount'];
$paypal_to = $_GET['to'];
//print($amount." ".$currency." ".$paypal_to);
if ($amount > $balance) {
    die("ERR_NO_ENOUGH_BALANCE");
}
if ($amount < $limit) {
    die("ERR_MINIMUN_IS_" . $limit . $currency);
}
// Set request-specific fields.
$emailSubject = urlencode(vEmailSubject);