if ($gdata[$i][2][$j]) { $buf .= "," . round($gdata[$i][2][$j] / 1000000, 3); } else { if ($gdata[$i - 1][2][$j] > 0) { $buf .= ",0"; } else { if ($i < $gline - 2 && $gdata[$i + 1][2][$j] > 0) { $buf .= ",0"; } else { $buf .= ","; } } } } } $buf .= "," . round($gdata[$i][1] / 1000000, 3) . "," . $avg3 . "," . $avg12; $buf .= "\n"; } if ($lastlinedate < time() - 675 * 2) { $buf .= date("Y-m-d H:i:s", time()); if ($wc > 1) { for ($j = 0; $j < $wc; $j++) { $buf .= ","; } } $buf .= ",,,\n"; } print $buf; set_stats_cache($link, 2, $query_hash, $buf, 675); exit; }
$row = pg_fetch_array($result, $i); if ($row["coinbase"] == "t") { $tid = "<A HREF=\"../blockinfo.php/{$row["blockhash"]}\">G</A>"; } else { $tid = "<A HREF=\"http://blockchain.info/search?search={$row["txhash"]}\">S</A>"; } $xdata .= "<TR><TD>{$row["time"]} ({$tid})</TD><TD>" . prettySatoshis($row["amount"]) . "</TD></TR>"; } if ($xdata != "") { $pdata = "<table id=\"paymentlist\"><THEAD><TR><TH>Date (<SPAN title=\"G = Payout from coinbase/generation; S = Payout from normal send/sendmany\" style=\"border-bottom: 1px dashed #888888\">Type</SPAN>)</TH><TH>Amount</TH></TR></THEAD>{$xdata}</table>"; } else { $pdata = "<BR>No recent data available.<BR>"; } print $pdata; # cache this data for 24 hours. if the user is paid, the hash will change and invalidate this forcing a rebuild. genius! set_stats_cache($link, 12, $query_hash, $pdata, 600); # just cache for 10 minutes so that updates dont cause caching of invalid data } } else { print "<BR>No data available.<BR>"; } print "All time total payout: " . prettySatoshis($everpaid); if ($donated > 0) { print "<BR><FONT SIZE=\"-1\">Total donated Eligius: " . prettySatoshis($donated) . " - <I>Thanks!</I></FONT>"; } print "<BR><BR><HR>"; if ($savedbal) { print "<BR><B>Estimated Position in Payout Queue</B><BR>"; if ($payoutqueue = apc_fetch('wizstats_payoutqueuetxt')) { } else { $payoutqueue = file_get_contents("/var/lib/eligius/{$serverid}/payout_queue.txt");
<?php require_once 'includes.php'; require_once 'hashrate.php'; if (!isset($_SERVER['PATH_INFO'])) { print json_encode(array("error" => "No username specified in URL path Please try again.")); exit; } $link = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}"); if (pg_connection_status($link) != PGSQL_CONNECTION_OK) { pg_close($link); $link = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}"); if (pg_connection_status($link) != PGSQL_CONNECTION_OK) { print json_encode(array("error" => "Unable to establish a connection to the stats database. Please try again later. If this issue persists, please report it to the pool operator.")); exit; } } $givenuser = substr($_SERVER['PATH_INFO'], 1, strlen($_SERVER['PATH_INFO']) - 1); $user_id = get_user_id_from_address($link, $givenuser); if (!$user_id) { print json_encode(array("error" => "Username {$givenuser} not found in database. Please try again later. If this issue persists, please report it to the pool operator.")); exit; } $cache_key = hash("sha256", "hashrate-json.php hashrate JSON for {$givenuser} with id {$user_id}"); $json = get_stats_cache($link, 11, $cache_key); if ($json == "") { $hashrate_info = get_hashrate_stats($link, $givenuser, $user_id); $json = json_encode($hashrate_info); set_stats_cache($link, 11, $cache_key, $json, 30); } print $json;
$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); } }
} if ($ri > 64) { $lagavg675[$lav] = $row["time"] . "," . $row["hr"] / 1000000000; if ($ri > 64 + 32) { $lavx = $lav - 32; if ($lavx < 0) { $lavx += 128; } $lavy = $lav - 24; if ($lavy < 0) { $lavy += 128; } $lavz = $lav - 0; if ($lavz < 0) { $lavz += 128; } $tline = $lagavg675[$lavx] . "," . $lagavg3[$lavy] . "," . $lagavg12[$lavz] . "\n"; $tdata .= $tline; print $tline; } } $lav++; if ($lav == 128) { $lav = 0; } } set_stats_cache($link, 4, $query_hash, $tdata, 675); exit; ?>
$sql = "select (sum(accepted_shares)*pow(2,32))/1350 as avghash,sum(accepted_shares) as share_total from {$psqlschema}.stats_shareagg where server={$serverid} and time > to_timestamp({$sql2res})-'1350 seconds'::interval"; $result = pg_exec($link, $sql); $row = pg_fetch_array($result, 0); $hashrate256 = $row["avghash"]; # note that cppsrb is not ok apc_store('cppsrb_ok', -1, 90); } } # get latest block height $sql = "select date_part('epoch',NOW() - time) as roundduration,height,confirmations from {$psqlschema}.stats_blocks where server={$serverid} and confirmations > 0 and height > 0 order by height desc limit 1;"; $result = pg_exec($link, $sql); $row = pg_fetch_array($result, 0); $blockheight = $row["height"]; $roundduration = $row["roundduration"]; $latestconfirms = $row["confirmations"]; $sharesperunit = $hashrate256 / 4294967296 / 20; $phash = prettyHashrate($hashrate256); $datanew = 1; $sql = "select pg_advisory_unlock(1000002) as l"; $result = pg_exec($link, $sql); $row = pg_fetch_array($result, 0); } } if (!($roundshares > 0)) { $roundshares = 0; } $tline = "{\"sharesperunit\":{$sharesperunit},\"roundsharecount\":{$roundshares},\"lastblockheight\":{$blockheight},\"lastconfirms\":{$latestconfirms},\"roundduration\":{$roundduration},\"hashratepretty\":\"{$phash}\",\"network_difficulty\":{$netdiff}}"; if ($datanew) { # cache this for 30 seconds, should be good enough set_stats_cache($link, 5, "livedata.json", $tline, 30); }
$address = \Bitcoin::hash160ToAddress(bits2hex($row['keyhash'])); $nickname = get_nickname($link2, get_user_id_from_address($link2, $address)); if ($nickname != "" && $nickname != $address) { $address = "<A HREF=\"userstats.php/{$address}\">{$nickname}<BR><FONT SIZE=\"-3\">({$address})</FONT></A>"; } else { $address = "<A HREF=\"userstats.php/{$address}\">{$address}</A>"; } } else { $address = "(Unknown users)"; } if ($oe == 1) { $oclass = "class=\"odd\""; $oe = 0; } else { $oclass = "class=\"notodd\""; $oe = 1; } $meshares = $row["sharecount"]; $pdata .= "<TR HEIGHT=\"38\" {$oclass}><TD class=\"rank\">#{$rank}</TD><TD>{$address}</TD><TD class=\"hash\">{$phash}</TD><TD class=\"shares\">{$meshares}</TD><TD class=\"percent\">{$tpercent}%</TD></TR>"; $rank++; } $pdata .= "</TABLE>"; set_stats_cache($link, 20, $cachehash, $pdata, 675); print $pdata; } if (!isset($subcall)) { print_stats_bottom(); } ?>
} else { $shelvedshares -= $myss; $unpaidbal += $myss; } } } else { # unlucky round $luck = $diff / $shares; $earned = $luck * $maxearn; $shelvedshares += $maxearn - $earned; $unpaidbal += $earned; } $thisctime = strtotime($row["time"]); $date = date("Y-m-d H:i:s", $thisctime - 1); if (isset($_GET["btc"])) { $tline = $date . "," . sprintf("%.8f", round($unpaidbal / 100000000, 8)) . "," . sprintf("%.8f", round($shelvedshares / 100000000, 8)) . "," . sprintf("%.8f", round($maxbal / 100000000, 8)) . "\n"; $tdata .= $tline; print $tline; } else { if ($ri > $ignorepoints) { $tline = $date . "," . sprintf("%.8f", round($unpaidbal / $maxbal * 100, 8)) . "%," . sprintf("%.8f", round($shelvedshares / $maxbal * 100, 8)) . "%\n"; $tdata .= $tline; print $tline; } } } set_stats_cache($link, 30, $query_hash, $tdata, 3600); exit; ?>