Esempio n. 1
0
 $sql = "select (sum(accepted_shares)*pow(2,32))/10800 as avghash, sum(accepted_shares) as sharecount, keyhash, min(users.id) as user_id from {$psqlschema}.stats_shareagg left join users on user_id=users.id where server={$serverid} and time > '{$stime}'::timestamp without time zone and accepted_shares > 0 group by keyhash order by avghash desc {$minilimit};";
 $result = pg_exec($link, $sql);
 $numrows = pg_numrows($result);
 $pdata = "<TABLE BORDER=1 class=\"contributors\">";
 $pdata .= "<TR class=\"contribhead\"><TD>Rank</TD><TD>Address</TD><TD>3-hr Avg Hashrate</TD><TD>3-hr Shares</TD><TD>Percentage of Pool</TD></TR>";
 $oe = 0;
 $rank = 1;
 for ($ri = 0; $ri < $numrows; $ri++) {
     $row = pg_fetch_array($result, $ri);
     $phash = prettyHashrate($row["avghash"]);
     $tpercent = $row["avghash"] / $poolhashrate3hr * 100;
     $tpercent = round($tpercent, 4);
     $user_id = $row["user_id"];
     if (isset($row['keyhash'])) {
         $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;
     }
Esempio 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;
Esempio n. 3
0
<?php 
$nouser = 0;
$reason = "";
if (!isset($_COOKIE["u"]) && !isset($_GET["u"]) || isset($_GET["u"]) && strlen($_GET["u"]) == 0) {
    $nouser = 1;
} else {
    $u = "";
    if (isset($_GET["u"])) {
        $u = $_GET["u"];
    } else {
        if (isset($_COOKIE["u"])) {
            $u = $_COOKIE["u"];
        }
    }
    $user_id = get_user_id_from_address($link, $u);
    if (!$user_id) {
        $nouser = 1;
        $reason = "{$u} was not found in database.<BR>";
    }
}
if ($cmd == "switchaddr") {
    $nouser = 1;
}
if ($nouser == 1) {
    if ($cmd != "switchaddr") {
        ?>

	<H2>No address sent for <I>My Stats</I> page</H2><BR>
	<?php 
    }