$output["rows"][$ri] = array(); if (isset($row["acceptedshares"])) { $luck = 100 * ($row["network_difficulty"] / $row["acceptedshares"]); } else { $luck = 0; } if ($row["confirmations"] >= 120) { $row["confirmations"] = 120; } list($seconds, $minutes, $hours) = extractTime($row["duration"]); $seconds = sprintf("%02d", $seconds); $minutes = sprintf("%02d", $minutes); $hours = sprintf("%02d", $hours); $hashrate = $row["acceptedshares"] * 4294967296 / $row["duration"]; if (isset($row['keyhash'])) { $fulladdress = \Bitcoin::hash160ToAddress(bits2hex($row['keyhash'])); } else { $fulladdress = "UNKNOWN_USER"; } $output["rows"][$ri]["luck"] = $luck; $output["rows"][$ri]["confirmations"] = $row["confirmations"]; $output["rows"][$ri]["blockhash"] = $row["blockhash"]; $output["rows"][$ri]["height"] = $row["height"]; $output["rows"][$ri]["duration"] = $row["duration"]; $output["rows"][$ri]["age"] = $row["age"]; $output["rows"][$ri]["roundstart"] = $row["start_unix"]; $output["rows"][$ri]["roundend"] = $row["time_unix"]; $output["rows"][$ri]["hashrate"] = sprintf("%u", $hashrate); $output["rows"][$ri]["percent_of_network"] = 100 * ($hashrate / ($row["network_difficulty"] * 7158278.82667)); $output["rows"][$ri]["accepted_shares"] = sprintf("%u", $row["acceptedshares"]); $output["rows"][$ri]["network_difficulty"] = sprintf("%.4f", $row["network_difficulty"]);
function block_table_row($row, $isodd) { $blocks_row = ""; if (isset($row["acceptedshares"])) { $luck = 100 * ($row["network_difficulty"] / $row["acceptedshares"]); } else { $luck = 0; } if ($luck > 9000) { $luck = "<A STYLE=\"color:#3B4033;font-weight:normal;text-decoration:none;cursor:default\" HREF=\"9000.php\">>9,000%</A>"; } else { $luck = number_format(round($luck, 1), 1) . "%"; } $roundstart = substr($row["roundstart"], 0, 19); if ($row["confirmations"] >= 120) { $confs = "Confirmed"; } else { if ($row["confirmations"] == 0) { $confs = "Stale"; $luck = "n/a"; $roundstart = "<SMALL>(" . substr($row["time"], 0, 19); $roundstart .= ")</SMALL>"; } else { $confs = $row["confirmations"] . " of 120"; } } $dbid = $row["blockid"]; if ($row["confirmations"] == 0) { $blocks_row .= "<TR id=\"blockrow{$dbid}\" BGCOLOR=\"#FFDFDF\" class=\"{$isodd}" . "blockorphan\">"; } else { if ($row["confirmations"] >= 120) { $blocks_row .= "<TR id=\"blockrow{$dbid}\" class=\"{$isodd}" . "blockconfirmed\">"; } else { $rowcolour = $isodd ? array(0xd3, 0xeb, 0xe3) : array(0xeb, 0xed, 0xe9); $uccolour = array(0xff, 0x7f, 0); $rowcolour = blend_colours($uccolour, $rowcolour, $row["confirmations"] / 120); $blocks_row .= "<TR class=\"{$isodd}" . "blockunconfirmed\" id=\"blockrow{$dbid}\" style=\"background-color: " . csscolour($rowcolour) . "\">"; } } $blocks_row .= "<TD sorttable_customkey=\"" . $row["age"] . "\" style=\"font-size: 0.9em;\">" . prettyDuration($row["age"], false, 1) . "</TD>"; $blocks_row .= "<TD style=\"font-size: 0.8em;\">" . $roundstart . "</TD>"; if (isset($row["duration"])) { list($seconds, $minutes, $hours) = extractTime($row["duration"]); $seconds = sprintf("%02d", $seconds); $minutes = sprintf("%02d", $minutes); $hours = sprintf("%02d", $hours); $blocks_row .= "<td sorttable_customkey=\"" . $row["duration"] . "\" style=\"width: 1.5em; text-align: right;\">{$hours}:{$minutes}:{$seconds}</td>"; $hashrate = $row["acceptedshares"] * 4294967296 / $row["duration"]; $hashratenum = $hashrate; $hashrate = prettyHashrate($hashrate); $hashrate = substr($hashrate, 0, -2); $percentofnetwork = $hashratenum / ($row["network_difficulty"] * 7158278.82667); $percentofnetwork = sprintf("%.2f%% of network", $percentofnetwork * 100); $hashrate = "<span title=\"{$percentofnetwork}\">{$hashrate}</span>"; } else { $blocks_row .= "<td style=\"text-align: right;\">n/a</td>"; $hashrate = "n/a"; } $blocks_row .= "<TD style=\"text-align: right;\" sorttable_customkey=\"" . $row["acceptedshares"] . "\">" . ($row["acceptedshares"] > 0 ? number_format($row["acceptedshares"]) : "n/a") . "</TD>"; $blocks_row .= "<TD style=\"text-align: right;\" sorttable_customkey=\"" . $row["network_difficulty"] . "\">" . formatSI($row["network_difficulty"], 2) . "</TD>"; $blocks_row .= "<TD style=\"text-align: right;\">" . $luck . "</TD>"; $hashratenum = sprintf("%.0f", $hashratenum); $blocks_row .= "<TD style=\"text-align: right; font-size: 0.9em;\" sorttable_customkey=\"" . $hashratenum . "\" >" . $hashrate . "</TD>"; $blocks_row .= "<TD class=\"blockconfirms\" style=\"text-align: right;\">" . $confs . "</TD>"; if (isset($row['keyhash'])) { $fulladdress = \Bitcoin::hash160ToAddress(bits2hex($row['keyhash'])); $address = substr($fulladdress, 0, 10) . "..."; } else { $fulladdress = ""; $address = "(Unknown user)"; } $blocks_row .= "<TD style=\"font-family:monospace;\"><A HREF=\"userstats.php/" . $fulladdress . "\">" . $address . "</A></TD>"; if (isset($row["height"]) && $row["height"] > 0) { $ht = number_format($row["height"]); } else { $ht = "n/a"; } $blocks_row .= "<TD style=\"text-align: right;\">{$ht}</TD>"; $nicehash = "..." . substr($row["blockhash"], 46, 18); $blocks_row .= "<TD style=\"font-family:monospace;\"><A HREF=\"blockinfo.php/" . $row["blockhash"] . "\">" . $nicehash . "</A></TD>"; $blocks_row .= "</TR>"; return $blocks_row; }