Exemplo n.º 1
0
        $pline .= $row["balance"] / 100000000 + $row["everpaid"] / 100000000 . ",";
        $pline .= $row["credit"] / 100000000 + $row["balance"] / 100000000 + $row["everpaid"] / 100000000 . ",";
        $pline .= $startbalance / 100000000 + $row["everpaid"] / 100000000;
        print $pline . "\n";
        $tdata .= $pline . "\n";
        $lastrowbalance = $row["balance"];
        $lastctime = $thisctime;
    }
    set_stats_cache($link, 1, $query_hash, $tdata, 675);
    exit;
}
if ($cmd == "hashgraph") {
    $wherein = get_wherein_list_from_worker_data($worker_data);
    $sql = "select *,date_part('epoch',time) as ctime from wizkid057.stats_shareagg where server={$serverid} and user_id in {$wherein} and time > NOW()-'{$sstart} seconds'::interval-'43200 seconds'::interval order by time desc;";
    $query_hash = hash("sha256", $sql);
    $cacheddata = get_stats_cache($link, 2, $query_hash);
    if ($cacheddata != "") {
        # this output is cached!
        print $cacheddata;
        exit;
    }
    $result = pg_exec($link, $sql);
    $numrows = pg_numrows($result);
    $data = array();
    $firstctime = pow(2, 32);
    $lastctime = 0;
    $workercount = 0;
    $activeworkers = array();
    for ($ri = 0; $ri < $numrows; $ri++) {
        # make associative array for data based on time and userid
        $row = pg_fetch_array($result, $ri);
Exemplo n.º 2
0
<?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;
Exemplo n.º 3
0
}
print "<div id=\"ugraphdiv2\" style=\"width:750px; height:375px;\"></div>";
print "<INPUT TYPE=\"BUTTON\" onClick=\"showmax();\" VALUE=\"Toggle Graphing of Maximum Reward\"><BR>";
print "<div id=\"ugraphdiv3\" style=\"width:750px; height:375px;\"></div>";
#if (!isset($_GET["timemachine"])) {
#	print "<A HREF=\"?timemachine=1\">(Click for up to 60 days of hashrate/balance data)</A><BR>";
#}
# script for dygraphs
print "<script type=\"text/javascript\">\n\n\tvar blockUpdateA = 0;\n\tvar blockUpdateB = 0;\n\n\tg2 = new Dygraph(document.getElementById(\"ugraphdiv2\"),\"{$givenuser}?cmd=hashgraph&start=0&back={$secondsback}&res=1\",{ \n\t\tstrokeWidth: 1.5,\n\t\tfillGraph: true,\n\t\t'675 second': { color: '#408000' },\n\t\t'3 hour': { fillGraph: false, strokeWidth: 2.25, color: '#400080' },\n\t\t'12 hour': { fillGraph: false, strokeWidth: 2.25, color: '#008080' },\n\t\tlabelsDivStyles: { border: '1px solid black' },\n\t\ttitle: 'Hashrate Graph ({$givenuser})',\n\t\txlabel: 'Date',\n\t\tylabel: 'Mh/sec',\n\t\tanimatedZooms: true,\n\t\tdrawCallback: function(dg, is_initial) {\n\t\tif (is_initial) {\n\t\t\t\tvar rangeA = g2.xAxisRange();\n\t\t\t\tg3.updateOptions( { dateWindow: rangeA } );\n\t\t\t} else {\n\t\t\t\tif (!blockUpdateA) {\n\t\t\t\t\tblockUpdateB = 1;\n\t\t\t\t\tvar rangeA = g2.xAxisRange();\n\t\t\t\t\tg3.updateOptions( { dateWindow: rangeA } );\n\t\t\t\t\tblockUpdateB = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t});\n\n\tvar mrindex = 0;\n\tvar mrhidden = 1;\n\tg3 = new Dygraph(\n\tdocument.getElementById(\"ugraphdiv3\"),\"{$givenuser}?cmd=balancegraph&start=0&back={$secondsback}&res=1\",{ \n\t\tstrokeWidth: 2.25,\n\t\tfillGraph: true,\n\t\tlabelsDivStyles: { border: '1px solid black' },\n\t\ttitle: 'Balance Graph ({$givenuser})',\n\t\txlabel: 'Date',\n\t\tylabel: 'BTC',\n\t\tanimatedZooms: true,\n\t\tdrawCallback: function(dg, is_initial) {\n\t\t\tif (is_initial) {\n\t\t\t\tmrindex = dg.indexFromSetName(\"maximum reward\") - 1;\n\t\t\t\tdg.setVisibility(mrindex, 0);\n\t\t\t\tvar rangeB = g3.xAxisRange();\n\t\t\t\tg2.updateOptions( { dateWindow: rangeB } );\n\t\t\t} else {\n\t\t\t\tif (!blockUpdateB) {\n\t\t\t\t\tblockUpdateA = 1;\n\t\t\t\t\tvar rangeB = g3.xAxisRange();\n\t\t\t\t\tg2.updateOptions( { dateWindow: rangeB } );\n\t\t\t\t\tblockUpdateA = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tvar showmax = function() {\n\t\tif (mrhidden) {\n\t\t\tg3.setVisibility(mrindex, 1);\n\t\t\tmrhidden = 0;\n\t\t} else {\n\t\t\tg3.setVisibility(mrindex, 0);\n\t\t\tmrhidden = 1;\n\t\t}\n\t}\n</script>\n";
print "</div>";
# right side
print "<div id=\"userstatsright\">";
print "<B>Latest Payouts</B>";
if ($everpaid > 0) {
    $query_hash = hash("sha256", "userstats.php latest payouts for {$givenuser} with id {$user_id} and latest everpaid of {$everpaid} v2");
    $latestpayouts = get_stats_cache($link, 12, $query_hash);
    if ($latestpayouts != "") {
        print $latestpayouts;
    } else {
        $sql = "select stats_transactions.time as time, stats_payouts.amount as amount, stats_transactions.hash as txhash, stats_transactions.coinbase as coinbase, stats_blocks.blockhash as blockhash from {$psqlschema}.stats_payouts left join {$psqlschema}.stats_transactions on stats_transactions.id=transaction_id left join {$psqlschema}.stats_blocks on block_id=stats_blocks.id where stats_payouts.user_id={$user_id} order by time desc limit 10;";
        $result = pg_exec($link, $sql);
        $numrows = pg_numrows($result);
        $xdata = "";
        for ($i = 0; $i < $numrows; $i++) {
            $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>";
Exemplo n.º 4
0
if ($_SERVER['PATH_INFO'] == "/blockinfo.json") {
    if (!isset($_GET["height"]) && !isset($_GET["dbid"])) {
        exit;
    }
    $link = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}");
    if (isset($_GET["height"])) {
        $cleanvar = $_GET["height"];
        $prepname = "instant_blockinfo1";
        $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 height=\$1::integer");
    }
    if (isset($_GET["dbid"])) {
        $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 {
Exemplo n.º 5
0
    $roundduration = $instantjsondec["roundduration"];
    $sharesperunit = $instantjsondec["sharesperunit"];
    $netdiff = $instantjsondec["network_difficulty"];
    $roundshares = $instantjsondec["roundsharecount"];
    $blockheight = $instantjsondec["lastblockheight"];
    $latestconfirms = $instantjsondec["lastconfirms"];
    $datanew = 0;
} else {
    $sql = "select pg_try_advisory_lock(1000002) as l";
    $result = pg_exec($link, $sql);
    $row = pg_fetch_array($result, 0);
    $lock = $row["l"];
    if ($lock == "f") {
        for ($t = 0; $t < 15; $t++) {
            sleep(2);
            $livedata = get_stats_cache($link, 5, "livedata.json");
            if ($livedata != "") {
                $instantjsondec = json_decode($livedata, true);
                $phash = $instantjsondec["hashratepretty"];
                $roundduration = $instantjsondec["roundduration"];
                $sharesperunit = $instantjsondec["sharesperunit"];
                $netdiff = $instantjsondec["network_difficulty"];
                $roundshares = $instantjsondec["roundsharecount"];
                $blockheight = $instantjsondec["lastblockheight"];
                $latestconfirms = $instantjsondec["lastconfirms"];
                $datanew = 0;
                $t = 100;
            }
        }
        if ($t < 100) {
            # Error!
Exemplo n.º 6
0
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
require_once 'includes.php';
if (!isset($link)) {
    $link = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}");
}
if (!isset($subcall)) {
    $titleprepend = "Contributors - ";
    print_stats_top();
    $minilimit = "";
    $cachehash = "topcontributors.php v2 full call";
} else {
    $cachehash = "topcontributors.php v2 subcall {$minilimit}";
}
$cachehash = hash("sha256", $cachehash);
$cacheddata = get_stats_cache($link, 20, $cachehash);
if ($cacheddata != "") {
    print $cacheddata;
} else {
    if (!isset($link2)) {
        $link2 = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}");
    }
    # get total pool hashrate
    $sql = "select to_timestamp((date_part('epoch', (time))::integer / 675::integer)::integer * 675::integer)-'3 hours'::interval as stime from {$psqlschema}.stats_shareagg where server={$serverid} group by server,time order by time desc limit 1";
    $result = pg_exec($link, $sql);
    $row = pg_fetch_array($result, 0);
    $stime = $row["stime"];
    $sql = "select (sum(accepted_shares)*pow(2,32))/10800 as avghash from {$psqlschema}.stats_shareagg where server={$serverid} and time > '{$stime}'::timestamp without time zone";
    $result = pg_exec($link, $sql);
    $row = pg_fetch_array($result, 0);
    $poolhashrate3hr = $row["avghash"];