Esempio n. 1
0
function workmgtuser($data, $user, $err)
{
    $pg = '<h1>Worker Management</h1>';
    if ($err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    $ans = getWorkers($user, 'N');
    if ($ans['STATUS'] == 'ok') {
        if (isset($ans['oldworkers']) && $ans['oldworkers'] == '0') {
            $chk = '';
        } else {
            $chk = ' checked';
        }
        $pg .= makeForm('workmgt');
        $pg .= '<span>Active workers (7 days)';
        $pg .= "<input type=checkbox name=seven{$chk}>";
        $pg .= '<input type=submit name=S value=Update>';
        $pg .= '</span></form><br><br>';
    }
    $pg .= makeForm('workmgt');
    $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
    $pg .= '<tr class=title>';
    $pg .= '<td class=dl>Worker Name</td>';
    $pg .= '<td class=dr>Minimum Diff</td>';
    $pg .= '</tr>';
    $offset = 0;
    if ($ans['STATUS'] == 'ok') {
        $count = $ans['rows'];
        for ($i = 0; $i < $count; $i++) {
            if ($offset % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $wn = htmlspecialchars($ans['workername:' . $i]);
            $wnv = urlencode($ans['workername:' . $i]);
            $pg .= '<td class=dl>';
            $pg .= "<input type=hidden name='workername:{$i}' value='{$wnv}'>";
            $pg .= $wn . '</td>';
            $md = intval($ans['difficultydefault:' . $i]);
            $pg .= '<td class=dr>';
            $pg .= "<input type=text size=6 name='difficultydefault:{$i}' value='{$md}'>";
            $pg .= "<input type=submit name=OK value=OK>";
            $pg .= "</td>";
            $pg .= "</tr>\n";
            $offset++;
        }
    }
    $pg .= '<tr><td colspan=2 class=dc><font size=-1><span class=st1>*</span>';
    $pg .= ' A value of 0, less than the pool minimum,<br>';
    $pg .= 'or less than the pool calculated value for you,<br>';
    $pg .= 'will use the pool calculated value</font></td></tr>';
    $pg .= "</table><input type=hidden name=rows value={$count}></form>\n";
    return $pg;
}
Esempio n. 2
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 = '&nbsp;(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;
}
Esempio n. 3
0
function show_api($info, $page, $menu, $name, $user)
{
    global $fld_sep;
    $u = getparam('username', true);
    if (nutem($u)) {
        no_api();
    }
    $api = getparam('api', true);
    if (nutem($api)) {
        no_api();
    }
    $jfu = getparam('json', true);
    $work = getparam('work', true);
    $ans = getAtts($u, 'KAPIKey.str');
    if ($ans['STATUS'] != 'ok') {
        no_api($jfu);
    }
    if (!isset($ans['KAPIKey.str'])) {
        no_api($jfu);
    }
    if ($ans['KAPIKey.str'] != $api) {
        no_api($jfu);
    }
    if (nuem($work)) {
        $info = homeInfo($u);
        if ($info === false) {
            no_api($jfu);
        }
        $rep = fldEncode($info, 'STAMP', true);
        $rep .= fldEncode($info, 'lastbc', false);
        $rep .= fldEncode($info, 'lastheight', false);
        $rep .= fldEncode($info, 'currndiff', false);
        $rep .= fldEncode($info, 'lastblock', false);
        $rep .= fldEncode($info, 'lastblockheight', false);
        $rep .= fldEncode($info, 'blockacc', false);
        $rep .= fldEncode($info, 'blockerr', false);
        $rep .= fldEncode($info, 'p_hashrate5m', false);
        $rep .= fldEncode($info, 'p_hashrate1hr', false);
        $rep .= fldEncode($info, 'u_hashrate5m', false);
        $rep .= fldEncode($info, 'u_hashrate1hr', false);
    } else {
        $info = homeInfo($u);
        if ($info === false) {
            no_api($jfu);
        }
        $per = false;
        if (is_array($info) && isset($info['u_multiaddr'])) {
            $percent = getparam('percent', true);
            if (!nuem($percent)) {
                $per = true;
            }
        }
        if ($per === true) {
            $ans = getPercents($u);
        } else {
            $ans = getWorkers($u);
        }
        if ($ans === false) {
            no_api($jfu);
        }
        $rep = fldEncode($ans, 'STAMP', true);
        $rep .= fldEncode($ans, 'rows', false);
        $rows = $ans['rows'];
        $flds = explode(',', $ans['flds']);
        $zeflds = '';
        for ($i = 0; $i < $rows; $i++) {
            foreach ($flds as $fld) {
                if (substr($fld, 0, 7) != 'idlenot') {
                    $rep .= fldEncode($ans, $fld . ':' . $i, false);
                    if ($i == 0) {
                        $zeflds .= "{$fld},";
                    }
                }
            }
        }
        $rep .= fldEncode($ans, 'arn', false);
        $rep .= fldEncode($ans, 'arp', false);
        $rep .= fldEncode(array(), 'flds', false);
        $rep .= substr($zeflds, 0, -1);
    }
    if (nuem($jfu)) {
        echo $rep;
    } else {
        $j = preg_replace("/([^=]+)=([^{$fld_sep}]*){$fld_sep}/", '"$1":"$2",', $rep . $fld_sep);
        echo '{' . substr($j, 0, -1) . '}';
    }
    exit(0);
}
Esempio n. 4
0
					<span><h2>Occupation</h2></span>
					<ul class="list-group">
						<?php 
getOccupation();
?>
					</ul>
					<span><h2>Genre</h2></span>
					<ul class="list-group">
						<?php 
getGenre();
?>
					</ul>
				</div>
				<div class ="col-md-9">
					<?php 
getWorkers();
?>
					<?php 
getOccWorker();
?>
					<?php 
getGenreWorker();
?>
				</div>
			</div>
		</div>
		<hr>
		
		<?php 
include "footer.php";
?>