Exemple #1
0
        $cleanvar = $_GET["dbid"];
        $prepname = "instant_blockinfo2";
        $sql = pg_prepare($link, $prepname, "select *,stats_blocks.id as blockid,date_part('epoch', NOW())::integer-date_part('epoch', time)::integer as age,date_part('epoch', time)::integer-date_part('epoch', roundstart)::integer as duration from {$psqlschema}.stats_blocks left join users on user_id=users.id where stats_blocks.id=\$1::integer");
    }
    $tline = get_stats_cache($link, 6, hash("sha256", $sql . $prepname . $cleanvar));
    if ($tline != "") {
        print $tline;
        exit;
    }
    $result = pg_execute($link, $prepname, array($cleanvar));
    $row = pg_fetch_array($result, 0);
    $dbid = $row["blockid"];
    if (isset($_GET["cclass"])) {
        $cclass = $_GET["cclass"];
    } else {
        $cclass = "";
    }
    if (substr($cclass, 0, 3) == "odd") {
        $isodd = "odd";
    } else {
        $isodd = "";
    }
    $line = block_table_row($row, $isodd);
    $line = json_encode($line);
    if ($dbid) {
        $tline = "{\"blockrow\":{$line}}";
        print $tline;
        # cache this data for 60 seconds ... should be plenty also, could probably be higher
        set_stats_cache($link, 6, hash("sha256", $sql), $tline, 60);
    }
}
Exemple #2
0
$numrows = pg_numrows($result);
if (isset($blocklimit)) {
    print block_table_start(0);
} else {
    print block_table_start(1);
}
print block_table_header();
$gc = 0;
$oc = 0;
for ($ri = 0; $ri < $numrows; $ri++) {
    $row = pg_fetch_array($result, $ri);
    if ($row["confirmations"] >= 120) {
        $gc++;
    }
    if ($row["confirmations"] == 0) {
        $oc++;
    }
    if ($ri % 2) {
        $isodd = "odd";
    } else {
        $isodd = "";
    }
    if ($row["confirmations"] > 0 || $row["confirmations"] == 0 && $blocks_show_stale) {
        print block_table_row($row, $isodd);
    }
}
print block_table_end();
if (!isset($subcall)) {
    print "<BR>Confirmed blocks: {$gc} blocks --- Stale blocks: {$oc} blocks\n";
    print_stats_bottom();
}