Gazelle/sections/tools/data/bitcoin_unproc.php

71 lines
2.0 KiB
PHP
Raw Normal View History

2013-08-31 08:00:54 +00:00
<?
if (!check_perms('users_mod')) {
error(403);
}
View::show_header('Unprocessed Bitcoin donations');
// Find all donors
$AllDonations = DonationsBitcoin::get_received();
$DB->query("
SELECT BitcoinAddress, SUM(Amount)
FROM donations_bitcoin
GROUP BY BitcoinAddress");
$OldDonations = G::$DB->to_pair(0, 1, false);
?>
<div id="thin">
<div class="header">
<h2>Unprocessed Bitcoin donations</h2>
</div>
<div class="box2">
<div class="pad">Do not process these donations manually! The bitcoin parser <em>will</em> get them sooner or later (poke a developer if something seems broken).</div>
</div>
<?
$NewDonations = array();
2013-09-05 08:00:49 +00:00
$TotalUnproc = 0;
2013-08-31 08:00:54 +00:00
foreach ($AllDonations as $Address => $Amount) {
if (isset($OldDonations[$Address])) {
if ($Amount == $OldDonations[$Address]) { // Direct comparison should be fine as everything comes from bitcoind
continue;
}
$Debug->log_var(array('old' => $OldDonations[$Address], 'new' => $Amount), "New donations from $Address");
// PHP doesn't do fixed-point math, and json_decode has already botched the precision
// so let's just round this off to satoshis and pray that we're on a 64 bit system
$Amount = round($Amount - $OldDonations[$Address], 8);
}
2013-09-05 08:00:49 +00:00
$TotalUnproc += $Amount;
2013-08-31 08:00:54 +00:00
$NewDonations[$Address] = $Amount;
}
2013-09-05 08:00:49 +00:00
?>
<table class="border" width="100%">
<tr class="colhead">
<td>Bitcoin address</td>
<td>User</td>
<td>Unprocessed amount (<?=$TotalUnproc ?: '0'?>)</td>
<td>Total amount</td>
<td>Donor rank</td>
<td>Special rank</td>
</tr>
<?
2013-08-31 08:00:54 +00:00
if (!empty($NewDonations)) {
foreach(DonationsBitcoin::get_userids(array_keys($NewDonations)) as $Address => $UserID) {
?>
<tr>
<td><?=$Address?></td>
<td><?=Users::format_username($UserID, true, false, false)?></td>
<td><?=$NewDonations[$Address]?></td>
<td><?=$AllDonations[$Address]?></td>
<td><?=(int)Donations::get_rank($UserID)?></td>
<td><?=(int)Donations::get_special_rank($UserID)?></td>
</tr>
<? }
} else { ?>
<tr>
<td colspan="7">No unprocessed Bitcoin donations</td>
</tr>
<? } ?>
</table>
</div>
<?
View::show_footer();