Example #1
0
function workuser($data, $user, &$offset, &$totshare, &$totdiff, &$totshrate, &$totinvalid, &$totrate, &$blockacc, &$blockreward, $old = false, $srt = false, $one = false, &$title, &$instances)
{
    $ans = getWorkers($user);
    $pg = '';
    if ($ans['STATUS'] == 'ok') {
        if (isset($ans['blockacc'])) {
            $blockacc = $ans['blockacc'];
        }
        if (isset($ans['blockreward'])) {
            $blockreward = $ans['blockreward'];
        }
        if ($one === true && isset($ans['oldworkers'])) {
            $days = intval($ans['oldworkers']);
            if ($days != 0) {
                $title = ' (active during the last ' . $days . ' day' . ($days == 1 ? '' : 's') . ')';
            }
        }
        $all = array();
        $count = $ans['rows'];
        $now = $ans['STAMP'];
        for ($i = 0; $i < $count; $i++) {
            $lst = $now - $ans['w_lastshare:' . $i];
            if ($old !== false && $lst > $old) {
                continue;
            }
            if ($ans['w_elapsed:' . $i] > 3600) {
                $uhr = $ans['w_hashrate1hr:' . $i];
            } else {
                $uhr = $ans['w_hashrate5m:' . $i];
            }
            $all[] = array('workername' => $ans['workername:' . $i], 'w_lastshare' => $ans['w_lastshare:' . $i], 'w_lastshareacc' => $ans['w_lastshareacc:' . $i], 'w_lastdiff' => $ans['w_lastdiff:' . $i], 'w_shareacc' => $ans['w_shareacc:' . $i], 'w_diffacc' => $ans['w_diffacc:' . $i], 'w_diffinv' => $ans['w_diffinv:' . $i], 'w_diffsta' => $ans['w_diffsta:' . $i], 'w_diffdup' => $ans['w_diffdup:' . $i], 'w_diffhi' => $ans['w_diffhi:' . $i], 'w_diffrej' => $ans['w_diffrej:' . $i], 'w_sharesta' => $ans['w_sharesta:' . $i], 'w_sharedup' => $ans['w_sharedup:' . $i], 'w_sharehi' => $ans['w_sharehi:' . $i], 'w_sharerej' => $ans['w_sharerej:' . $i], 'w_lastdiff' => $ans['w_lastdiff:' . $i], 'w_active_diffacc' => $ans['w_active_diffacc:' . $i], 'w_active_start' => $ans['w_active_start:' . $i], 'w_uhr' => $uhr);
            $instances += $ans['w_instances:' . $i];
        }
        if ($srt) {
            usort($all, 'workhashorder');
        }
        foreach ($all as $arow) {
            $lst = $now - $arow['w_lastshare'];
            if ($old !== false && $lst > $old) {
                continue;
            }
            $lstacc = $now - $arow['w_lastshareacc'];
            if ($offset % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $pg .= '<td class=dl>' . htmlspecialchars($arow['workername']) . '</td>';
            if ($arow['w_lastdiff'] > 0) {
                $ld = difffmt($arow['w_lastdiff']);
            } else {
                $ld = '&nbsp;';
            }
            $pg .= "<td class=dr>{$ld}</td>";
            $pg .= "<td class=dr data-srt={$lstacc}>" . howlongago($lstacc) . '</td>';
            $shareacc = number_format($arow['w_shareacc'], 0);
            $totshare += $arow['w_shareacc'];
            $dacc = $arow['w_diffacc'];
            $diffacc = number_format($dacc, 0);
            $ds = round($dacc);
            $totdiff += $dacc;
            $pg .= "<td class=dr>{$shareacc}</td>";
            $pg .= "<td class=dr data-srt={$ds}>{$diffacc}</td>";
            $acthr = '0';
            $acthrv = 0;
            $actstt = $arow['w_active_start'];
            if ($actstt <= 0 || $now - $actstt < 0) {
                $actsin = '&nbsp;';
            } else {
                $actsin = howmanyhrs($now - $actstt);
                $elapsed = $now - $actstt;
                if ($elapsed > 0) {
                    $acthrv = $arow['w_active_diffacc'] * pow(2, 32) / $elapsed;
                    $acthr = dsprate($acthrv);
                    $totshrate += $acthrv;
                }
            }
            $pg .= "<td class=dr data-srt={$acthrv}>{$acthr}</td>";
            $pg .= "<td class=dr>{$actsin}</td>";
            $dinv = $arow['w_diffinv'];
            $dtot = $dacc + $dinv;
            if ($dtot > 0) {
                $rejf = $dinv / $dtot;
                $rej = number_format(100.0 * $rejf, 3);
            } else {
                $rejf = 0;
                $rej = '0';
            }
            $totinvalid += $dinv;
            $pg .= "<td class=dr data-srt={$rejf}>{$rej}%</td>";
            foreach (array('sta', 'dup', 'hi', 'rej') as $fld) {
                $shr = number_format($arow['w_share' . $fld]);
                $dif = $arow['w_diff' . $fld];
                $ddif = number_format($dif);
                $sdif = number_format($dif, 0, '', '');
                $pg .= "<td class=hid data-srt={$sdif} data-hid=dr>{$ddif}/{$shr}</td>";
            }
            if ($blockacc <= 0) {
                $blkpct = '&nbsp;';
            } else {
                $blkpct = number_format(100.0 * $dacc / $blockacc, 3) . '%';
            }
            $pg .= "<td class=dr>{$blkpct}</td>";
            $uhr = $arow['w_uhr'];
            if ($uhr == '?') {
                $uhr = '?GHs';
                $su = 0;
            } else {
                $su = round($uhr);
                $totrate += $uhr;
                $uhr = dsprate($uhr);
            }
            $pg .= "<td class=dr data-srt={$su}>{$uhr}</td>";
            $pg .= "</tr>\n";
            $offset++;
        }
    }
    return $pg;
}
Example #2
0
function dostats($data, $user)
{
    $pg = '<h1>Pool Stats</h1>';
    if (isset($data['info']) && $data['info'] !== false) {
        $info = $data['info'];
        $pe = false;
        if (isset($info['p_elapsed'])) {
            $dspel = howlongago($info['p_elapsed']);
            $pg .= "Pool&nbsp;Uptime:&nbsp;{$dspel}";
            $pe = true;
        }
        if (isset($info['ckdb_elapsed'])) {
            if ($pe) {
                $pg .= '&emsp;';
            }
            $dspel = howlongago($info['ckdb_elapsed']);
            $pg .= "CKDB&nbsp;Uptime:&nbsp;{$dspel}";
        }
        $dsp = '?THs';
        $dsp5m = '?THs';
        $dsp1hr = '?THs';
        $dsp24hr = '?THs';
        if (isset($info['p_hashrate'])) {
            $hr = $info['p_hashrate'];
            if ($hr != '?') {
                $dsp = dsprate($hr);
            }
        }
        if (isset($info['p_hashrate5m'])) {
            $hr = $info['p_hashrate5m'];
            if ($hr != '?') {
                $dsp5m = dsprate($hr);
            }
        }
        if (isset($info['p_hashrate1hr'])) {
            $hr = $info['p_hashrate1hr'];
            if ($hr != '?') {
                $dsp1hr = dsprate($hr);
            }
        }
        if (isset($info['p_hashrate24hr'])) {
            $hr = $info['p_hashrate24hr'];
            if ($hr != '?') {
                $dsp24hr = dsprate($hr);
            }
        }
        $pg .= '<table cellpadding=8 cellspacing=0 border=0><tr>';
        $pg .= "<td>Pool Hashrate: {$dsp}</td>";
        $pg .= "<td>5m: {$dsp5m}</td>";
        $pg .= "<td>1hr: {$dsp1hr}</td>";
        $pg .= "<td>24hr: {$dsp24hr}</td>";
        $pg .= '</tr></table><br>';
    }
    $ans = getAllUsers($user);
    $pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
    $pg .= '<thead><tr class=title>';
    $pg .= '<td class=dl>Username</td>';
    $pg .= '<td class=dr>Hash Rate 5m</td>';
    $pg .= "</tr></thead>\n";
    if ($ans['STATUS'] == 'ok') {
        $pg .= '<tbody>';
        $all = array();
        $count = $ans['rows'];
        for ($i = 0; $i < $count; $i++) {
            $all[] = array('username' => $ans['username:'******'userid' => $ans['userid:' . $i], 'u_hashrate5m' => $ans['u_hashrate5m:' . $i]);
        }
        usort($all, 'allusersort');
        for ($i = 0; $i < $count; $i++) {
            if ($i % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $pg .= '<td class=dl>' . htmlspecialchars($all[$i]['username']) . '</td>';
            $uhr = $all[$i]['u_hashrate5m'];
            if ($uhr == '?') {
                $dsp = '?GHs';
            } else {
                $dsp = dsprate($uhr);
            }
            $pg .= "<td class=dr>{$dsp}</td>";
            $pg .= "</tr>\n";
        }
        $pg .= '</tbody>';
    }
    $pg .= "</table>\n";
    return $pg;
}