Esempio n. 1
0
            $API->DB->query("INSERT INTO premium_purchases " . $API->DB->build_insert_query($to_db));
            $current_premium = $API->DB->query_row("SELECT premium_expired FROM accounts WHERE id={$to_db['account_id']}");
            $current_premium = $current_premium['premium_expired'];
            if ($current_premium <= $CONFIG['TIME']) {
                $current_premium = $CONFIG['TIME'];
            }
            $to_account = array('premium_expired' => $current_premium + $to_db['time_purchased']);
            $API->DB->query("UPDATE accounts SET {$API->DB->build_update_query($to_account)} WHERE id={$to_db['account_id']}");
            $API->TPL->assign('message', $API->LANG->_('Your transaction has been completed'));
            $API->TPL->assign('warning', $API->LANG->_('We already extended your account to premium') . ':)');
            $API->TPL->display('message.tpl');
            die;
        }
        die;
    } else {
        $purchase_ticket['amount'] = round($allowed_days[$days] / get_bitcoin_price(0), 4);
        //number_format(($allowed_days[$days] / get_bitcoin_price(0)) + get_satoshi_secret(), 8, '.', '');
        $purchase_ticket['account_id'] = $API->account['id'];
        $purchase_ticket['time_purchased'] = $days * 86400;
        $purchase_ticket['added'] = TIME;
        $purchase_ticket['expires'] = TIME + $_EXPIRES_TIME;
        $API->TPL->assign('purchase_ticket', encrypt(json_encode($purchase_ticket), $_BTC_PURCHASE_KEY));
        $API->TPL->assign('amount', $purchase_ticket['amount']);
        $API->TPL->assign('days', $days);
        $API->TPL->assign('address', $_RECEIVER_ADDRESS);
        $API->TPL->assign('expires_time', $_EXPIRES_TIME);
        $API->TPL->display('premium-bitcoin-purchase.tpl');
        die;
    }
} elseif ($from == 'money2btc') {
    // IPN handler
#!/usr/bin/env php
<?php 
function get_title($html_page)
{
    // split the page into 3 sections, with the <title> and </title> tags as delimiters.
    $split_page = preg_split("%</?title[^>]*>%", $html_page);
    return $split_page[1];
}
function get_bitcoin_price()
{
    $bitcoin_price_address = "http://www.bitcoinexchangerate.org/price";
    $html = fread(fopen($bitcoin_price_address, "r"), 100);
    return get_title($html);
}
$price = trim(get_bitcoin_price());
echo $price;