Esempio n. 1
0
function showcustompage($pagename, $systempage = false)
{
    global $customsummarypages;
    global $placebuttons;
    if ($placebuttons == 'top' || $placebuttons == 'both') {
        pagebuttons(null, $pagename);
    }
    if ($systempage === false && !isset($customsummarypages[$pagename])) {
        otherrow("<td colspan=100 class=bad>Unknown custom summary page '{$pagename}'</td>");
        return;
    }
    $csp = getcsp($pagename, $systempage);
    if ($csp === false) {
        otherrow("<td colspan=100 class=bad>Invalid custom summary page '{$pagename}'</td>");
        return;
    }
    degen($csp);
    $page = $csp[0];
    $namemap = array();
    foreach ($page as $name => $fields) {
        if ($fields === null) {
            $page[$name] = array();
        } else {
            foreach ($fields as $num => $field) {
                $pos = strpos($field, '=');
                if ($pos !== false) {
                    $names = explode('=', $field, 2);
                    if (strlen($names[1]) > 0) {
                        $namemap[$name . '.' . $names[0]] = $names[1];
                    }
                    $page[$name][$num] = $names[0];
                }
            }
        }
    }
    $ext = null;
    if (isset($csp[2])) {
        $ext = $csp[2];
    }
    $sum = $csp[1];
    if ($sum === null) {
        $sum = array();
    }
    // convert them to searchable via isset()
    foreach ($sum as $section => $fields) {
        $newfields = array();
        foreach ($fields as $field) {
            $newfields[$field] = 1;
        }
        $sum[$section] = $newfields;
    }
    if (count($page) <= 1) {
        otherrow("<td colspan=100 class=bad>Invalid custom summary page '{$pagename}' no content </td>");
        return;
    }
    processcustompage($pagename, $page, $sum, $ext, $namemap);
    if ($placebuttons == 'bot' || $placebuttons == 'both') {
        pagebuttons(null, $pagename);
    }
}
Esempio n. 2
0
function display()
{
    global $miner, $port;
    global $mcast, $mcastexpect;
    global $readonly, $notify, $rigs;
    global $ignorerefresh, $autorefresh;
    global $allowcustompages, $customsummarypages;
    global $placebuttons;
    global $userlist, $ses;
    $pagesonly = checklogin();
    if ($pagesonly === 'login') {
        return;
    }
    $mcerr = '';
    if ($rigs == null or count($rigs) == 0) {
        if ($mcast === true) {
            $action = 'found';
        } else {
            $action = 'defined';
        }
        minhead();
        otherrow("<td class=bad>No rigs {$action}</td>");
        return;
    } else {
        if ($mcast === true && count($rigs) < $mcastexpect) {
            $mcerr = othrow('<td class=bad>Found ' . count($rigs) . " rigs but expected at least {$mcastexpect}</td>");
        }
    }
    if ($ignorerefresh == false) {
        $ref = trim(getparam('ref', true));
        if ($ref != null && $ref != '') {
            $autorefresh = intval($ref);
        }
    }
    if ($pagesonly !== true) {
        $rig = trim(getparam('rig', true));
        $arg = trim(getparam('arg', true));
        $preprocess = null;
        if ($arg != null and $arg != '') {
            if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) {
                $parts = explode(':', $rigs[$rig], 3);
                if (count($parts) >= 2) {
                    $miner = $parts[0];
                    $port = $parts[1];
                    if ($readonly !== true) {
                        $preprocess = $arg;
                    }
                }
            }
        }
    }
    if ($allowcustompages === true) {
        $pg = trim(getparam('pg', true));
        if ($pagesonly === true) {
            if ($pg !== null && $pg !== '') {
                if ($userlist !== null && isset($userlist['def']) && !in_array($pg, $userlist['def'])) {
                    $pg = null;
                }
            } else {
                if ($userlist !== null && isset($userlist['def'])) {
                    foreach ($userlist['def'] as $pglook) {
                        if (isset($customsummarypages[$pglook])) {
                            $pg = $pglook;
                            break;
                        }
                    }
                }
            }
        }
        if ($pg !== null && $pg !== '') {
            htmlhead($mcerr, false, null, $pg);
            showcustompage($pg, $mcerr);
            return;
        }
    }
    if ($pagesonly === true) {
        onlylogin();
        return;
    }
    if (count($rigs) == 1) {
        $parts = explode(':', $rigs[0], 3);
        if (count($parts) >= 2) {
            $miner = $parts[0];
            $port = $parts[1];
            htmlhead($mcerr, true, 0);
            doOne(0, $preprocess);
        } else {
            minhead($mcerr);
            otherrow('<td class=bad>Invalid "$rigs" array</td>');
        }
        return;
    }
    if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) {
        $parts = explode(':', $rigs[$rig], 3);
        if (count($parts) >= 2) {
            $miner = $parts[0];
            $port = $parts[1];
            htmlhead($mcerr, true, 0);
            doOne($rig, $preprocess);
        } else {
            minhead($mcerr);
            otherrow('<td class=bad>Invalid "$rigs" array</td>');
        }
        return;
    }
    htmlhead($mcerr, false, null);
    if ($placebuttons == 'top' || $placebuttons == 'both') {
        pagebuttons(null, null);
    }
    if ($preprocess != null) {
        process(array($preprocess => $preprocess), $rig);
    }
    newtable();
    doforeach('version', 'rig summary', array(), array(), true);
    $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH', 'Work Utility', 'Diff1 Shares', 'Diff1 Work', 'Difficulty Accepted', 'Difficulty Rejected', 'Difficulty Stale');
    doforeach('summary', 'summary information', $sum, array(), false);
    endtable();
    otherrow('<td><br><br></td>');
    newtable();
    doforeach('devs', 'device list', $sum, array('' => '', 'ID' => '', 'Name' => ''), false);
    endtable();
    otherrow('<td><br><br></td>');
    newtable();
    doforeach('pools', 'pool list', $sum, array('' => ''), false);
    endtable();
    if ($placebuttons == 'bot' || $placebuttons == 'both') {
        pagebuttons(null, null);
    }
}
Esempio n. 3
0
function display()
{
    global $miner, $port;
    global $readonly, $notify, $rigs;
    global $ignorerefresh, $autorefresh;
    global $allowcustompages;
    global $placebuttons;
    if ($ignorerefresh == false) {
        $ref = trim(getparam('ref', true));
        if ($ref != null && $ref != '') {
            $autorefresh = intval($ref);
        }
    }
    $rig = trim(getparam('rig', true));
    $arg = trim(getparam('arg', true));
    $preprocess = null;
    if ($arg != null and $arg != '') {
        $num = null;
        if ($rig != null and $rig != '') {
            if ($rig >= 0 and $rig < count($rigs)) {
                $num = $rig;
            }
        } else {
            if (count($rigs) == 0) {
                $num = 0;
            }
        }
        if ($num != null) {
            $parts = explode(':', $rigs[$num], 3);
            if (count($parts) >= 2) {
                $miner = $parts[0];
                $port = $parts[1];
                $preprocess = $arg;
            }
        }
    }
    if ($rigs == null or count($rigs) == 0) {
        otherrow("<td>No rigs defined</td>");
        return;
    }
    if ($allowcustompages === true) {
        $pg = trim(getparam('pg', true));
        if ($pg != null && $pg != '') {
            showcustompage($pg);
            return;
        }
    }
    if (count($rigs) == 1) {
        $parts = explode(':', $rigs[0], 3);
        if (count($parts) >= 2) {
            $miner = $parts[0];
            $port = $parts[1];
            doOne(0, $preprocess);
        } else {
            otherrow('<td>Invalid "$rigs" array</td>');
        }
        return;
    }
    if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) {
        $parts = explode(':', $rigs[$rig], 3);
        if (count($parts) >= 2) {
            $miner = $parts[0];
            $port = $parts[1];
            doOne($rig, $preprocess);
        } else {
            otherrow('<td>Invalid "$rigs" array</td>');
        }
        return;
    }
    htmlhead(false, null);
    if ($placebuttons == 'top' || $placebuttons == 'both') {
        pagebuttons(null, null);
    }
    if ($preprocess != null) {
        process(array($preprocess => $preprocess), $rig);
    }
    newtable();
    doforeach('version', 'rig summary', array(), array(), true);
    $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH');
    doforeach('summary', 'summary information', $sum, array(), false);
    endtable();
    otherrow('<td><br><br></td>');
    newtable();
    doforeach('devs', 'device list', $sum, array('' => '', 'ID' => '', 'Name' => ''), false);
    endtable();
    otherrow('<td><br><br></td>');
    newtable();
    doforeach('pools', 'pool list', $sum, array('' => ''), false);
    endtable();
    if ($placebuttons == 'bot' || $placebuttons == 'both') {
        pagebuttons(null, null);
    }
}