Gazelle/sections/tools/finances/bitcoin_unproc.php

72 lines
2.1 KiB
PHP
Raw Normal View History

2013-08-31 08:00:54 +00:00
<?
if (!check_perms('users_mod')) {
error(403);
}
2013-10-01 23:08:42 +00:00
$Title = "Unprocessed Bitcoin Donations";
View::show_header($Title);
2013-08-31 08:00:54 +00:00
// 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);
?>
2013-10-01 23:08:42 +00:00
<div class="thin">
2013-08-31 08:00:54 +00:00
<div class="header">
2013-10-01 23:08:42 +00:00
<h2><?=$Title?></h2>
2013-08-31 08:00:54 +00:00
</div>
<div class="box2">
2013-10-01 23:08:42 +00:00
<div class="pad"><strong>Do not process these donations manually!</strong> The Bitcoin parser <em>will</em> get them sooner or later (poke a developer if something seems broken).</div>
2013-08-31 08:00:54 +00:00
</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">
2013-10-01 23:08:42 +00:00
<td>Bitcoin Address</td>
2013-09-05 08:00:49 +00:00
<td>User</td>
2013-10-01 23:08:42 +00:00
<td>Unprocessed Amount (Total: <?=$TotalUnproc ?: '0'?>)</td>
<td>Total Amount</td>
<td>Donor Rank</td>
<td>Special Rank</td>
2013-09-05 08:00:49 +00:00
</tr>
<?
2013-08-31 08:00:54 +00:00
if (!empty($NewDonations)) {
2013-09-20 08:00:56 +00:00
foreach (DonationsBitcoin::get_userids(array_keys($NewDonations)) as $Address => $UserID) {
2013-08-31 08:00:54 +00:00
?>
<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();