Browse Source

php - csv version of pblocks

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

25
pool/page_blocks.php

@ -49,6 +49,13 @@ function doblocks($data, $user)
else else
$ans = getBlocks($user); $ans = getBlocks($user);
if (nuem(getparam('csv', true)))
$wantcsv = false;
else
$wantcsv = true;
if ($wantcsv === false)
{
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";
$pg .= "<td class=dl>Height</td>"; $pg .= "<td class=dl>Height</td>";
@ -61,10 +68,12 @@ function doblocks($data, $user)
$pg .= "<td class=dr>%</td>"; $pg .= "<td class=dr>%</td>";
$pg .= "<td class=dr>CDF</td>"; $pg .= "<td class=dr>CDF</td>";
$pg .= "</tr>\n"; $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,6 +139,8 @@ function doblocks($data, $user)
$cdf = '?'; $cdf = '?';
} }
if ($wantcsv === false)
{
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= "<td class=dl$ex>$hifld</td>"; $pg .= "<td class=dl$ex>$hifld</td>";
if ($user !== null) if ($user !== null)
@ -142,6 +153,20 @@ function doblocks($data, $user)
$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)
{ {

Loading…
Cancel
Save