Browse Source

php - csv version of pblocks

master
kanoi 10 years ago
parent
commit
a3bd74eaa1
  1. 69
      pool/page_blocks.php

69
pool/page_blocks.php

@ -49,22 +49,31 @@ function doblocks($data, $user)
else else
$ans = getBlocks($user); $ans = getBlocks($user);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; if (nuem(getparam('csv', true)))
$pg .= "<tr class=title>"; $wantcsv = false;
$pg .= "<td class=dl>Height</td>"; else
if ($user !== null) $wantcsv = true;
$pg .= "<td class=dl>Who</td>";
$pg .= "<td class=dr>Reward</td>"; if ($wantcsv === false)
$pg .= "<td class=dc>When</td>"; {
$pg .= "<td class=dr>Status</td>"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<td class=dr>Diff</td>"; $pg .= "<tr class=title>";
$pg .= "<td class=dr>%</td>"; $pg .= "<td class=dl>Height</td>";
$pg .= "<td class=dr>CDF</td>"; if ($user !== null)
$pg .= "</tr>\n"; $pg .= "<td class=dl>Who</td>";
$pg .= "<td class=dr>Reward</td>";
$pg .= "<td class=dc>When</td>";
$pg .= "<td class=dr>Status</td>";
$pg .= "<td class=dr>Diff</td>";
$pg .= "<td class=dr>%</td>";
$pg .= "<td class=dr>CDF</td>";
$pg .= "</tr>\n";
}
$blktot = 0; $blktot = 0;
$nettot = 0; $nettot = 0;
$i = 0; $i = 0;
$orph = false; $orph = false;
$csv = "Height,Status,Timestamp,DiffAcc,NetDiff\n";
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
{ {
$count = $ans['rows']; $count = $ans['rows'];
@ -130,19 +139,35 @@ function doblocks($data, $user)
$cdf = '?'; $cdf = '?';
} }
$pg .= "<tr class=$row>"; if ($wantcsv === false)
$pg .= "<td class=dl$ex>$hifld</td>"; {
if ($user !== null) $pg .= "<tr class=$row>";
$pg .= "<td class=dl$ex>$hifld</td>";
if ($user !== null)
$pg .= "<td class=dl$ex>".htmlspecialchars($ans['workername:'.$i]).'</td>'; $pg .= "<td class=dl$ex>".htmlspecialchars($ans['workername:'.$i]).'</td>';
$pg .= "<td class=dr$ex>".btcfmt($ans['reward:'.$i]).'</td>'; $pg .= "<td class=dr$ex>".btcfmt($ans['reward:'.$i]).'</td>';
$pg .= "<td class=dl$ex>".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate:'.$i]).'</td>'; $pg .= "<td class=dl$ex>".gmdate('Y-m-d H:i:s+00', $ans['firstcreatedate:'.$i]).'</td>';
$pg .= "<td class=dr$ex>".$stat.'</td>'; $pg .= "<td class=dr$ex>".$stat.'</td>';
$pg .= "<td class=dr>$stara$acc</td>"; $pg .= "<td class=dr>$stara$acc</td>";
$pg .= "<td class=dr$bg>$bpct</td>"; $pg .= "<td class=dr$bg>$bpct</td>";
$pg .= "<td class=dr>$cdf</td>"; $pg .= "<td class=dr>$cdf</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
}
else
{
$csv .= "$hi,";
$csv .= "\"$stat\",";
$csv .= $ans['firstcreatedate:'.$i].',';
$csv .= "$diffacc,";
$csv .= "$netdiff\n";
}
} }
} }
if ($wantcsv === true)
{
echo $csv;
exit(0);
}
if ($nettot > 0) if ($nettot > 0)
{ {
if (($i % 2) == 0) if (($i % 2) == 0)

Loading…
Cancel
Save