Ejemplo n.º 1
0
function dockp($data, $user)
{
    $pg = '<h1>CKPool</h1>';
    $msg = msgEncode('stats', 'stats', array(), $user);
    $rep = sendsockreply('stats', $msg);
    if ($rep == false) {
        $ans = array();
    } else {
        $ans = repDecode($rep);
    }
    $pg .= 'TotalRAM: ' . stnum($ans['totalram']) . '<br>';
    $pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
    $pg .= '<thead><tr class=title>';
    $pg .= '<td class=dl>Name</td>';
    $pg .= '<td class=dr>Initial</td>';
    $pg .= '<td class=dr>Allocated</td>';
    $pg .= '<td class=dr>In&nbsp;Store</td>';
    $pg .= '<td class=dr>RAM</td>';
    $pg .= '<td class=dr>RAM2</td>';
    $pg .= '<td class=dr>Cull</td>';
    $pg .= "</tr></thead>\n";
    if ($ans['STATUS'] == 'ok') {
        $pg .= '<tbody>';
        $count = $ans['rows'];
        for ($i = 0; $i < $count; $i++) {
            if ($i % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $pg .= '<td class=dl>' . $ans['name:' . $i] . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['initial:' . $i]) . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['allocated:' . $i]) . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['instore:' . $i]) . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['ram:' . $i]) . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['ram2:' . $i]) . '</td>';
            $pg .= '<td class=dr>' . stnum($ans['cull:' . $i]) . '</td>';
            $pg .= "</tr>\n";
        }
        $pg .= '</tbody>';
    }
    $pg .= "</table>\n";
    return $pg;
}
Ejemplo n.º 2
0
function dopplns($data, $user)
{
    global $send_sep;
    $pg = '<h1>CKPool</h1>';
    $blk = getparam('blk', true);
    if (nuem($blk)) {
        $tx = '';
        # so can make a link
        $blkuse = getparam('blkuse', true);
        if (nuem($blkuse)) {
            $blkuse = '';
        } else {
            $tx = 'y';
        }
        $pg = '<br>' . makeForm('pplns') . "\nBlock: <input type=text name=blk size=10 value='{$blkuse}'>\n&nbsp; Tx: <input type=text name=tx size=1 value='{$tx}'>\n&nbsp; Dust (Satoshi): <input type=text name=dust size=5 value='10000'>\n&nbsp; Fee (BTC): <input type=text name=fee size=5 value='0.0'>\n&nbsp;<input type=submit name=Calc value=Calc>\n</form>";
    } else {
        $tx = getparam('tx', true);
        if (nuem($tx) || substr($tx, 0, 1) != 'y') {
            $dotx = false;
        } else {
            $dotx = true;
        }
        $flds = array('height' => $blk, 'allow_aged' => 'Y');
        if ($blk > 334106) {
            $flds['diff_times'] = '5';
        }
        $msg = msgEncode('pplns', 'pplns', $flds, $user);
        $rep = sendsockreply('pplns', $msg, 4);
        if ($rep == false) {
            $ans = array();
        } else {
            $ans = repDecode($rep);
        }
        if ($ans['ERROR'] != null) {
            return '<font color=red size=+1><br>' . $ans['STATUS'] . ': ' . $ans['ERROR'] . '</font>';
        }
        if (!isset($ans['pplns_last'])) {
            return '<font color=red size=+1><br>Partial data returned</font>';
        }
        $reward_sat = $ans['block_reward'];
        $miner_sat = round($reward_sat * 0.991);
        $ans['miner_sat'] = $miner_sat;
        $data = array('Block' => 'block', 'Block Status' => 'block_status', 'Block Hash' => 'block_hash', 'Block Reward (Satoshis)' => 'block_reward', 'Miner Reward (Satoshis)' => 'miner_sat', 'PPLNS Wanted' => '.diff_want', 'PPLNS Used' => '.diffacc_total', 'Elapsed Seconds' => ',pplns_elapsed', 'Users' => 'rows', 'Oldest Workinfoid' => 'begin_workinfoid', 'Oldest Time' => 'begin_stamp', 'Oldest Epoch' => 'begin_epoch', 'Block Workinfoid' => 'block_workinfoid', 'Block Time' => 'block_stamp', 'Block Epoch' => 'block_epoch', 'Newest Workinfoid' => 'end_workinfoid', 'Newest Share Time' => 'end_stamp', 'Newest Share Epoch' => 'end_epoch', 'Network Difficulty' => 'block_ndiff', 'PPLNS Factor' => 'diff_times', 'PPLNS Added' => 'diff_add', 'Accepted Share Count' => ',acc_share_count', 'Total Share Count' => ',total_share_count', 'ShareSummary Count' => ',ss_count', 'WorkMarkers Count' => ',wm_count', 'MarkerSummary Count' => ',ms_count');
        $pg = '<br><a href=https://blockchain.info/block-height/';
        $pg .= $ans['block'] . '>Blockchain ' . $ans['block'] . "</a><br>\n";
        if (strlen($ans['marks_status']) > 0) {
            $pg .= '<br><span class=err>';
            $msg = $ans['marks_status'];
            $pg .= str_replace(' ', '&nbsp;', $msg) . "</span><br>\n";
        }
        if (strlen($ans['block_extra']) > 0) {
            $pg .= '<br><span class=err>';
            $msg = $ans['block_status'] . ' - ' . $ans['block_extra'];
            $pg .= str_replace(' ', '&nbsp;', $msg) . "</span><br>\n";
        }
        if (strlen($ans['share_status']) > 0) {
            $pg .= '<br><span class=err>';
            $msg = $ans['share_status'] . " - Can't be paid out yet";
            $pg .= str_replace(' ', '&nbsp;', $msg) . "</span><br>\n";
        }
        $pg .= "<br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<tr class=title>';
        $pg .= '<td class=dl>Name</td>';
        $pg .= '<td class=dr>Value</td>';
        $pg .= "</tr>\n";
        $i = 0;
        foreach ($data as $dsp => $name) {
            if ($i++ % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $pg .= "<td class=dl>{$dsp}</td>";
            switch ($name[0]) {
                case ',':
                case '.':
                    $nm = substr($name, 1);
                    $fmt = fmtdata($name[0], $ans[$nm]);
                    break;
                default:
                    $fmt = $ans[$name];
                    break;
            }
            $pg .= "<td class=dr>{$fmt}</td>";
            $pg .= "</tr>\n";
        }
        $pg .= "</table><br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<tr class=title>';
        $pg .= '<td class=dl>User</td>';
        $pg .= '<td class=dr>Diff Accepted</td>';
        $pg .= '<td class=dr>%</td>';
        $pg .= '<td class=dr>Avg Hashrate</td>';
        $pg .= '<td class=dr>BTC -0.9%</td>';
        $pg .= '<td class=dr>Address</td>';
        $pg .= "</tr>\n";
        $diffacc_total = $ans['diffacc_total'];
        if ($diffacc_total == 0) {
            $diffacc_total = pow(10, 15);
        }
        $elapsed = $ans['pplns_elapsed'];
        $count = $ans['rows'];
        $tot_pay = 0;
        for ($i = 0; $i < $count; $i++) {
            $diffacc_user = $ans['diffacc_user:'******'%';
            $avg_hash = number_format($diffacc_user / $elapsed * pow(2, 32), 0);
            $pay_sat = floor($miner_sat * $diffacc_user / $diffacc_total);
            $payaddress = $ans['payaddress:' . $i];
            if ($i % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $pg .= '<td class=dl>' . $ans['user:'******'</td>';
            $pg .= "<td class=dr>{$diffacc_user}</td>";
            $pg .= "<td class=dr>{$diffacc_percent}</td>";
            $pg .= "<td class=dr>{$avg_hash}</td>";
            $pg .= '<td class=dr>' . btcfmt($pay_sat) . '</td>';
            $pg .= "<td class=dr>{$payaddress}</td>";
            $pg .= "</tr>\n";
            $tot_pay += $pay_sat;
        }
        if ($i % 2 == 0) {
            $row = 'even';
        } else {
            $row = 'odd';
        }
        $pg .= "<tr class={$row}>";
        $pg .= '<td class=dl colspan=3></td>';
        $pg .= '<td class=dr></td>';
        $pg .= '<td class=dr>' . btcfmt($tot_pay) . '</td>';
        $pg .= '<td class=dr></td>';
        $pg .= "</tr>\n";
        $pg .= "</table>\n";
        if ($dotx === true) {
            $pg .= calctx($ans, $count, $miner_sat, $diffacc_total);
        }
    }
    return $pg;
}
Ejemplo n.º 3
0
function getOpts($user, $optlist)
{
    if ($user == false) {
        showIndex();
    }
    $flds = array('username' => $user, 'optlist' => $optlist);
    $msg = msgEncode('getopts', 'getopts', $flds, $user);
    $rep = sendsockreply('getOpts', $msg);
    if (!$rep) {
        dbdown();
    }
    return repDecode($rep);
}
Ejemplo n.º 4
0
function eventCmd($user, $flds)
{
    if ($user == false) {
        showIndex();
    }
    $msg = msgEncode('events', 'events', $flds, $user);
    $rep = sendsockreply('eventCmd', $msg);
    if (!$rep) {
        dbdown();
    }
    return repDecode($rep);
}