예제 #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;
}
예제 #2
0
function allow_reset($error)
{
    $pg = '<br><br><table cellpadding=5 cellspacing=0 border=1><tr><td class=dc>';
    $pg .= '<h1>Password Reset</h1>';
    if ($error !== null) {
        $pg .= "<br><b>{$error} - please try again</b><br><br>";
    }
    $pg .= makeForm('reset');
    $pg .= "\n<table>\n<tr><td class=dc colspan=2>Enter a new password twice.<br>\n" . passrequires() . "\n<input type=hidden name=k value=reset></td></tr>\n<tr><td class=dr>Password:</td>\n <td class=dl><input type=password name=pass></td></tr>\n<tr><td class=dr>Retype Password:</td>\n <td class=dl><input type=password name=pass2></td></tr>\n<tr><td class=dr><span class=st1>*</span>2nd Authentication:</td>\n <td class=dl><input type=password name=2fa size=10></td></tr>\n<tr><td colspan=2 class=dc><br><font size=-1><span class=st1>*</span>\n Leave blank if you haven't enabled it</font></td></tr>\n<tr><td>&nbsp;</td>\n <td class=dl><input type=submit name=Update value=Update></td></tr>\n</table>\n</form>";
    $pg .= '</td></tr></table>';
    return $pg;
}
예제 #3
0
function uset($data, $user, $api, $err)
{
    $pg = '<h1>User Settings</h1>';
    if ($err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    $pg .= '<table cellpadding=20 cellspacing=0 border=1>';
    $pg .= '<tr class=dc><td><span class=nb>';
    $pg .= "<input type=checkbox id=minicb onclick='md(this)'>";
    $pg .= 'mini header</span></td></tr>';
    $pg .= '<tr class=dc><td><center>';
    $pg .= makeForm('userset');
    $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
    $pg .= '<tr class=dc><td>';
    if ($api === false) {
        $pg .= "You don't have an API Key setup yet";
    } else {
        $pg .= 'Your current API Key is:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>{$api}</span>";
    }
    $pg .= '</td></tr><tr class=dc><td>';
    $pg .= 'Click to generate a new API key';
    $pg .= ": <input type=submit name=Change value='API Key'>";
    $pg .= '</td></tr>';
    if ($api !== false) {
        $pg .= '<tr class=dc><td>&nbsp;</td></tr>';
        $pg .= '<tr class=dc><td>You can access the API via:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>/index.php?k=api&username="******"&api={$api}&json=y</span><br>";
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td>You can get your workers via:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>/index.php?k=api&username="******"&api={$api}&json=y&work=y</span><br>";
        $pg .= '</td></tr>';
    }
    $pg .= '</table></form>';
    $pg .= '</center></td></tr>';
    $pg .= '</table>';
    return $pg;
}
예제 #4
0
function doregres($data, $u)
{
    if (isset($data['data']['user'])) {
        $user = htmlspecialchars($data['data']['user']);
    } else {
        $user = '';
    }
    if (isset($data['data']['mail'])) {
        $mail = htmlspecialchars($data['data']['mail']);
    } else {
        $mail = '';
    }
    $pg = "<br><span class=urg>WARNING:</span>&nbsp;\n<b>Do not</b> give your username+password to anyone else.<br>\n<b>Do not</b> give your username+password to apps or web sites.<br>\nA monitoring app or web site will <b>ONLY</b> need your username+API key.<br>\nYou can setup an API key from the 'Account'->'User Settings' menu page after you login.<br>\nYour miner password should be '<b>x</b>' and <b>must not</b> use your login password.<br>";
    $pg .= makeForm('') . "<br>\n<table cellpadding=0 cellspacing=0 border=0><tr>\n<td>User:</td><td><input type=text name=User size=10 value=''></td>\n<td>&nbsp;Pass:</td><td><input type=password name=Pass size=10 value=''></td>\n<td>&nbsp;<input type=submit name=Login value=Login></td>\n</tr></table></form>";
    $pg .= '<br><h1>or choose one:</h1>';
    $pg .= '<table cellpadding=5 cellspacing=0 border=1><tr><td class=dc>';
    $pg .= '<h1>Login</h1>';
    if (isset($data['data']['error'])) {
        $pg .= "<br><b>" . $data['data']['error'] . " - please try again</b><br><br>";
    }
    $pg .= makeForm('');
    $pg .= "\n<table>\n<tr><td class=dr>Username:</td>\n <td class=dl><input name=User value=''></td></tr>\n<tr><td class=dr>Password:</td>\n <td class=dl><input type=password name=Pass value=''></td></tr>\n<tr><td class=dr><span class=st1>*</span>2nd Authentication:</td>\n <td class=dl><input type=password name=2fa size=10></td></tr>\n<tr><td colspan=2 class=dc><font size=-1><span class=st1>*</span>\n Leave blank if you haven't enabled it</font></td></tr>\n<tr><td>&nbsp;</td>\n <td class=dl><input type=submit name=Login value=Login></td></tr>\n</table>\n</form>";
    $pg .= '</td></tr><tr><td class=dc>';
    $pg .= '<h1>Register</h1>';
    if (isset($data['data']['error'])) {
        $pg .= "<br><b>" . $data['data']['error'] . " - please try again</b><br><br>";
    }
    $pg .= makeForm('');
    $pg .= "\n<table>\n<tr><td class=dr>Username:</td>\n <td class=dl><input name=user value=\"{$user}\"></td></tr>\n<tr><td class=dr>Email:</td>\n <td class=dl><input name=mail value=\"{$mail}\"></td></tr>\n<tr><td class=dr>Password:</td>\n <td class=dl><input type=password name=pass value=''></td></tr>\n<tr><td class=dr>Retype Password:</td>\n <td class=dl><input type=password name=pass2 value=''></td></tr>\n<tr><td>&nbsp;</td>\n <td class=dl><input type=submit name=Register value=Register></td></tr>\n<tr><td colspan=2 class=dc><br><font size=-1><span class=st1>*</span>\n All fields are required<br>Your Username can't be a BTC address</font></td></tr>\n<tr><td colspan=2 class=dc><font size=-1><br>Note: your username is upper/lowercase sensitive,<br>\nand you must also have upper/lowercase correct on all your miners<br><br>" . passrequires() . "</font></td></tr>\n</table>\n</form>";
    $pg .= '</td></tr><tr><td class=dc>';
    $pg .= '<h1>Password Reset</h1>';
    $pg .= makeForm('');
    $pg .= "\n<table>\n<tr><td class=dr>Username:</td>\n <td class=dl><input name=user value=\"{$user}\"></td></tr>\n<tr><td class=dr>Email:</td>\n <td class=dl><input name=mail value=''></td></tr>\n<tr><td>&nbsp;</td>\n <td class=dl><input type=submit name=Reset value=Reset></td></tr>\n<tr><td colspan=2 class=dc><br><font size=-1>\nIf you enter the details correctly,<br>\nan Email will be sent to you to let you reset your password</font></td></tr>\n</table>\n</form>";
    $pg .= '</td></tr></table>';
    return $pg;
}
예제 #5
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;
}
예제 #6
0
function uset($data, $user, $api, $err)
{
    $pg = '<h1>User Settings</h1>';
    if ($err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    $pg .= '<table cellpadding=20 cellspacing=0 border=1>';
    $pg .= '<tr class=dc><td><span class=nb>';
    $pg .= "<input type=checkbox id=minicb onclick='md(this)'>";
    $pg .= 'mini header</span></td></tr>';
    $pg .= '<tr class=dc><td><center>';
    $pg .= makeForm('userset');
    $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
    $pg .= '<tr class=dc><td>';
    if ($api === false) {
        $pg .= "You don't have an API Key setup yet";
        $draw = false;
    } else {
        addQR();
        $pg .= 'Your current API Key is:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>{$api}</span></td></tr>";
        $pg .= '<tr class=dc><td><div id=can0><canvas id=can width=1 height=1>';
        $pg .= 'A qrcode will show here if your browser supports html5/canvas';
        $pg .= "</canvas></div>";
        $draw = true;
    }
    $pg .= '</td></tr><tr class=dc><td>';
    $pg .= 'Click to generate a new API key';
    $pg .= ": <input type=submit name=Change value='API Key'>";
    $pg .= '</td></tr>';
    if ($api !== false) {
        $pg .= '<tr class=dc><td>&nbsp;</td></tr>';
        $pg .= '<tr class=dc><td>You can access the API via:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>/index.php?k=api&username="******"&api={$api}&json=y</span><br>";
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td>You can get your workers via:';
        $pg .= '</td></tr><tr class=dc><td>';
        $pg .= "<span class=hil>/index.php?k=api&username="******"&api={$api}&json=y&work=y</span><br>";
        $pg .= '</td></tr>';
    }
    $pg .= '</table></form>';
    $pg .= '</center></td></tr>';
    $pg .= '</table>';
    if ($draw !== false) {
        $qr = shell_exec("../pool/myqr.sh '{$api}'");
        if ($qr !== null and strlen($qr) > 30) {
            $pg .= "<script type='text/javascript'>\n";
            $pg .= "{$qr}qr(tw,fa,qrx,qry,qrd);</script>\n";
            if (strpos($qr, 'var tw=1,fa=0,qrx=') === false) {
                error_log("QR error for '{$user}' res='{$qr}'");
            }
        } else {
            if ($qr === null) {
                $qr = 'null';
            }
            error_log("QR failed for '{$user}' res='{$qr}'");
        }
    }
    return $pg;
}
예제 #7
0
파일: page.php 프로젝트: theuni/ckpool
function pgtop($info, $dotop, $user, $douser)
{
    global $site_title, $loginfailed;
    $phr = '?THs';
    $plb = '?';
    $nlb = '?';
    $pac = '0';
    $per = '0';
    $perset = false;
    $uhr = '?GHs';
    $u1hr = '';
    if ($info !== false) {
        $now = time();
        if (isset($info['p_hashrate5m'])) {
            $phr = $info['p_hashrate5m'];
        }
        //	if (isset($info['p_elapsed'])
        //	and isset($info['p_hashrate1hr'])
        //	and $info['p_elapsed'] > 3600)
        //		$phr = $info['p_hashrate1hr'];
        if ($phr == '?') {
            $phr = '?THs';
        } else {
            $phr = dsprate($phr);
        }
        if (isset($info['lastblock'])) {
            $plb = $info['lastblock'];
            if ($plb != '?') {
                $sec = $now - $plb;
                if ($sec < 60) {
                    $plb = $sec . 's';
                } else {
                    if ($sec < 3600) {
                        $min = round($sec / 60);
                        $plb = $min . 'm';
                    } else {
                        $min = round($sec / 60);
                        $hr = round($min / 60);
                        $min -= $hr * 60;
                        $plb = $hr . 'h';
                        if ($min > 0) {
                            $plb .= '&nbsp;' . $min . 'm';
                        }
                    }
                }
            }
        }
        if (isset($info['lastblockheight'])) {
            $plb .= ' (' . $info['lastblockheight'] . ')';
        }
        if (isset($info['lastbc'])) {
            $nlb = $info['lastbc'];
            if ($nlb != '?') {
                $sec = $now - $nlb;
                $min = round($sec / 60);
                $nlb = $min . 'm';
                $s = $sec - $min * 60;
                if ($s > 0) {
                    $nlb .= "&nbsp;{$s}s";
                }
            }
        }
        if (isset($info['lastheight'])) {
            $nlb .= ' (' . $info['lastheight'] . ')';
        }
        if (isset($info['blockacc'])) {
            $acc = $info['blockacc'];
            $pac = number_format($acc, 0);
            if (isset($info['currndiff'])) {
                $cur = $info['currndiff'];
                if ($cur != '?' && $cur > 0.0) {
                    $pac .= ' (' . number_format(100.0 * $acc / $cur, 2) . '%)';
                }
            }
        }
        if (isset($info['blockshareinv'])) {
            $shinv = $info['blockshareinv'];
            $per = siprefmt($shinv, 1);
            $perset = true;
            if (isset($info['blockshareacc'])) {
                $shacc = $info['blockshareacc'];
                if ($shacc + $shinv > 0) {
                    $amt = 100.0 * $shinv / ($shacc + $shinv);
                    if (round($amt, 2) > 9.99) {
                        $per .= ' (' . number_format($amt, 1) . '%)';
                    } else {
                        $per .= ' (' . number_format($amt, 2) . '%)';
                    }
                }
            }
        }
        if (isset($info['blockerr'])) {
            if ($perset == false) {
                $per = '';
            } else {
                $per .= ' &#183; ';
            }
            $inv = $info['blockerr'];
            $per .= siprefmt($inv, 1);
            if (isset($info['blockacc'])) {
                $acc = $info['blockacc'];
                if ($acc + $inv > 0) {
                    $amt = 100.0 * $inv / ($acc + $inv);
                    if (round($amt, 2) > 9.99) {
                        $per .= ' (' . number_format($amt, 1) . '%)';
                    } else {
                        $per .= ' (' . number_format($amt, 2) . '%)';
                    }
                }
            }
        }
        if (isset($info['u_hashrate5m'])) {
            $uhr = $info['u_hashrate5m'];
            if ($uhr == '?') {
                $uhr = '?GHs';
            } else {
                $uhr = dsprate($uhr);
            }
        }
        if (isset($info['u_hashrate1hr']) and isset($info['u_elapsed']) and $info['u_elapsed'] > 3600) {
            $u1hr = $info['u_hashrate1hr'];
            if ($u1hr == '?') {
                $u1hr = '';
            } else {
                $u1hr = '/' . dsprate($u1hr);
                // Remove the first XHs if they are the same
                if (substr($u1hr, -3) == substr($uhr, -3)) {
                    $uhr = substr($uhr, 0, -3);
                }
            }
        }
    }
    $top = "<noscript><div class=jst id=jst>&nbsp;Javascript isn't enabled.";
    $top .= " You need to enable javascript to use";
    $top .= " the {$site_title} web site.</div></noscript>";
    if ($loginfailed === true) {
        $top .= '<div class=accwarn>Login Failed</div>';
    }
    if (isset($info['u_nopayaddr'])) {
        $top .= '<div class=accwarn>Please set a payout address on your account!</div>';
    }
    if (isset($info['u_noemail'])) {
        $top .= '<div class=accwarn>Please set an email address on your account!</div>';
    }
    $top .= '<div class=topd>';
    if ($dotop === true) {
        $lh = '';
        $ls = '';
        $lw = '';
        if (isset($info['now']) && isset($info['lastsh']) && isset($info['lasthb']) && isset($info['lastwi'])) {
            $lsn = $info['now'] - $info['lastsh'];
            $lhn = $info['now'] - $info['lasthb'];
            $lwn = $info['now'] - $info['lastwi'];
            if ($lsn < 8) {
                $lsc = 'green.png';
            } else {
                if ($lsn < 10) {
                    $lsc = 'orange.png';
                } else {
                    $lsc = 'red.png';
                }
            }
            if ($lhn < 5) {
                $lhc = 'green.png';
            } else {
                if ($lhn < 10) {
                    $lhc = 'orange.png';
                } else {
                    $lhc = 'red.png';
                }
            }
            if ($lwn < 36) {
                $lwc = 'green.png';
            } else {
                if ($lwn < 46) {
                    $lwc = 'orange.png';
                } else {
                    $lwc = 'red.png';
                }
            }
            $img1 = '<img border=0 src=/';
            $img2 = '>';
            $ls = $img1 . $lsc . $img2;
            $lh = $img1 . $lhc . $img2;
            $lw = $img1 . $lwc . $img2;
        }
        if (!isset($info['users'])) {
            $info['users'] = '?';
        }
        if (!isset($info['workers'])) {
            $info['workers'] = '?';
        }
        $top .= '<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0>';
        $top .= "<tr><td class=topdes>{$lh}</td></tr>";
        $top .= "<tr><td class=topdes>{$ls}</td></tr>";
        $top .= "<tr id=mini0><td class=topdes>{$lw}</td></tr></table>";
        $top .= '</td><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>CKPool:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$phr}</td></tr>";
        $top .= '<tr><td class=topdes>Shares:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$pac}</td></tr>";
        $top .= '<tr id=mini1><td class=topdes>Invalids:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$per}</td></tr></table>";
        $top .= '</td><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>Last&nbsp;</td>';
        $top .= '<td class=topdesl>Block</td></tr>';
        $top .= '<tr><td class=topdes>Pool:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$plb}</td></tr>";
        $top .= '<tr id=mini2><td class=topdes>Network:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$nlb}</td></tr></table>";
        $top .= '</td><td id=mini3>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>Users:&nbsp;</td>';
        $top .= '<td class=topdat>&nbsp;' . $info['users'] . '</td></tr>';
        $top .= '<tr><td class=topdes>Workers:&nbsp;</td>';
        $top .= '<td class=topdat>&nbsp;' . $info['workers'] . '</td></tr></table>';
        $top .= '</td><td>';
        if ($douser === true) {
            $top .= '<span class=login>';
            list($who, $whoid) = validate();
            if ($who == false) {
                $top .= '<table cellpadding=0 cellspacing=0 border=0><tr><td>';
                $top .= '<a href="https://' . $_SERVER['SERVER_NAME'];
                $top .= '/index.php?Register=1">Login<br>Register</a>';
                $top .= '</td></tr></table>';
            } else {
                $extra = '';
                if (strlen($who) > 12) {
                    $who = substr($who, 0, 12);
                    $extra = '&#133;';
                }
                $top .= "<span class=topwho>" . htmlspecialchars($who) . "{$extra}&nbsp;</span>";
                $top .= makeForm('');
                $top .= "<input type=submit name=Logout value=Logout></form>";
                $top .= "<br><span class=topdes>Hash&nbsp;Rate:</span>";
                $top .= "<span class=topdat>{$uhr}{$u1hr}</span><br>";
            }
            $top .= '</span>';
        }
        $top .= '</td></tr></table>';
    } else {
        $top .= '&nbsp;';
    }
    $top .= '</div>';
    return $top;
}
예제 #8
0
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>User registration form from .json</title>
</head>
<body>

	<?php 
include "func.php";
$json = file_get_contents("data.json");
makeForm($json);
?>

</body>
</html>
예제 #9
0
function settings($data, $user, $email, $addr, $err)
{
    $pg = '<h1>Account Settings</h1>';
    if ($err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    $pg .= '<table cellpadding=20 cellspacing=0 border=1>';
    $pg .= '<tr class=dc><td><center>';
    $_SESSION['old_set_email'] = $email;
    $pg .= makeForm('settings');
    $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
    $pg .= '<tr class=dc><td class=dr colspan=2>';
    $pg .= 'To change your email, enter a new email address and your password';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr>';
    $pg .= 'EMail:';
    $pg .= '</td><td class=dl>';
    $pg .= "<input type=text name=email value='{$email}' size=20>";
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr>';
    $pg .= 'Password:'******'</td><td class=dl>';
    $pg .= '<input type=password name=pass size=20>';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr nowrap>';
    $pg .= '<span class=st1>*</span>2nd Authentication:';
    $pg .= '</td><td class=dl>';
    $pg .= '<input type=password name=2fa size=10>';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
    $pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr colspan=2>';
    $pg .= 'Change: <input type=submit name=Change value=EMail>';
    $pg .= '</td></tr>';
    $pg .= '</table></form>';
    $pg .= '</center></td></tr>';
    $pg .= '<tr class=dc><td><center>';
    if (!isset($data['info']['u_multiaddr'])) {
        $pg .= makeForm('settings');
        $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
        $pg .= '<tr class=dc><td class=dr colspan=2>';
        $pg .= 'To change your payout address, enter a new address and your password';
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td class=dr>';
        $pg .= 'BTC Address:';
        $pg .= '</td><td class=dl>';
        $pg .= "<input type=text name=baddr value='{$addr}' size=42>";
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td class=dr>';
        $pg .= 'Password:'******'</td><td class=dl>';
        $pg .= '<input type=password name=pass size=20>';
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td class=dr nowrap>';
        $pg .= '<span class=st1>*</span>2nd Authentication:';
        $pg .= '</td><td class=dl>';
        $pg .= '<input type=password name=2fa size=10>';
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
        $pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
        $pg .= '</td></tr>';
        $pg .= '<tr class=dc><td class=dr colspan=2>';
        $pg .= 'Change: <input type=submit name=Change value=Address>';
        $pg .= '</td></tr>';
        $pg .= '</table></form>';
        $pg .= '</center></td></tr>';
        $pg .= '<tr class=dc><td><center>';
    }
    $pg .= makeForm('settings');
    $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
    $pg .= '<tr class=dc><td class=dr colspan=2>';
    $pg .= 'To change your password, enter your old password and new password twice';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr nowrap>';
    $pg .= 'Old Password:'******'</td><td class=dl>';
    $pg .= "<input type=password name=oldpass size=20>";
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr nowrap>';
    $pg .= 'New Password:'******'</td><td class=dl>';
    $pg .= '<input type=password name=pass1 size=20>';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr nowrap>';
    $pg .= 'New Password again:';
    $pg .= '</td><td class=dl>';
    $pg .= '<input type=password name=pass2 size=20>';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr nowrap>';
    $pg .= '<span class=st1>*</span>2nd Authentication:';
    $pg .= '</td><td class=dl>';
    $pg .= '<input type=password name=2fa size=10>';
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
    $pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
    $pg .= '</td></tr>';
    $pg .= '<tr class=dc><td class=dr colspan=2>';
    $pg .= 'Change: <input type=submit name=Change value=Password>';
    $pg .= '</td></tr>';
    $pg .= '</table></form>';
    $pg .= '</center></td></tr>';
    $pg .= '</table>';
    return $pg;
}
예제 #10
0
파일: page_2fa.php 프로젝트: theuni/ckpool
function set_2fa($data, $user, $tfa, $ans, $err, $msg)
{
    $draw = false;
    $pg = '<h1>Two Factor Authentication Settings</h1>';
    if ($err !== null and $err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    if ($msg !== null and $msg != '') {
        $pg .= "<span class=notice>{$msg}<br><br></span>";
    }
    $pg .= '<table cellpadding=20 cellspacing=0 border=1>';
    $pg .= '<tr class=dc><td><center>';
    $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
    $pg .= '<tr class=dc><td>';
    switch ($tfa) {
        case '':
            $pg .= '<tr class=dl><td>';
            $pg .= "You don't have Two Factor Authentication (2FA) setup yet<br><br>";
            $pg .= 'To use 2FA you need an App on your phone/tablet<br>';
            $pg .= app_txt('ones');
            $pg .= makeForm('2fa');
            $pg .= 'Click here to begin the setup process for 2FA: ';
            $pg .= '<input type=submit name=Setup value=Setup>';
            $pg .= '</form></td></tr>';
            break;
        case 'test':
            $pg .= '<tr class=dc><td>';
            $pg .= '2FA is not yet enabled.<br>';
            $pg .= 'Your 2FA key has been created but needs testing.<br><br>';
            if (isset($ans['2fa_key'])) {
                $key = $ans['2fa_key'];
                $sfainfo = $ans['2fa_issuer'] . ': ' . $ans['2fa_auth'] . ' ' . $ans['2fa_hash'] . ' ' . $ans['2fa_time'] . 's';
                $who = substr($user, 0, 8);
                $sfaurl = 'otpauth://' . $ans['2fa_auth'] . '/' . $ans['2fa_issuer'] . ':' . htmlspecialchars($who) . '?secret=' . $ans['2fa_key'] . '&algorithm=' . $ans['2fa_hash'] . '&issuer=' . $ans['2fa_issuer'];
                $draw = true;
                addQR();
            } else {
                $key = 'unavailable';
                $sfainfo = 'unavailable';
                $sfaurl = 'unavailable';
            }
            $pg .= "Your <span class=urg>2FA Secret Key</span> is: {$key}<br>";
            $pg .= "2FA Settings are {$sfainfo}<br><br>";
            $pg .= "To setup 2FA in your App: <a href='{$sfaurl}'>Click here</a><br>";
            $pg .= "or scan the qrcode/barcode below with your App:<br><br>";
            $pg .= '<div id=can0><canvas id=can width=1 height=1>';
            $pg .= 'A qrcode will show here if your browser supports html5/canvas';
            $pg .= "</canvas></div><br>";
            $pg .= makeForm('2fa');
            $pg .= 'Then enter your App 2FA Value: <input name=Value value="" size=10> ';
            $pg .= '<input type=submit name=Test value=Test></form></td></tr>';
            $pg .= '<tr class=dl><td>';
            $pg .= app_txt('2FA apps');
            $pg .= '<span class=urg>N.B.</span> if you wish to setup 2FA on more than one device,<br>';
            $pg .= 'you should setup all devices before testing one of them.<br>';
            $pg .= 'If you have an old <span class=urg>2FA Secret Key</span> in your device for this web site,<br>';
            $pg .= 'delete it before scanning in the new <span class=urg>2FA Secret Key</span>.<br><br>';
            $pg .= '<span class=urg>WARNING:</span> if you lose your 2FA device you will need to know<br>';
            $pg .= 'the <span class=urg>2FA Secret Key</span> to manually setup a new device,<br>';
            $pg .= 'so your should copy it and store it somewhere securely.<br>';
            $pg .= 'For security reasons, the site will not show you an active <span class=urg>2FA Secret Key</span>.<br>';
            $pg .= '</td></tr>';
            $pg .= '<tr class=dl><td>';
            $pg .= makeForm('2fa');
            $pg .= '<br>If you wish to cancel setting up 2FA, click here: ';
            $pg .= '<input type=submit name=Cancel value=Cancel></form></td></tr>';
            break;
        case 'ok':
            $pg .= '<tr class=dc><td>';
            $pg .= '2FA is enabled on your account.<br><br>';
            $pg .= 'If you wish to replace your Secret Key with a new one:<br><br>';
            $pg .= makeForm('2fa');
            $pg .= 'Current 2FA Value: <input name=Value value="" size=10> ';
            $pg .= '<input type=submit name=New value=New><span class=st1>*</span>';
            $pg .= '</form><br><br>';
            $pg .= '<span class=st1>*</span>WARNING: replacing the Secret Key will disable 2FA<br>';
            $pg .= 'until you successfully test the new key,<br>';
            $pg .= 'thus getting a new key is effectively the same as disabling 2FA.<br><br>';
            $pg .= '</td></tr>';
            $pg .= '<tr class=dc><td>';
            $pg .= makeForm('2fa');
            $pg .= 'If you wish to remove 2FA from your account,<br>';
            $pg .= 'enter your App 2FA Value: <input name=Value value="" size=10><br>';
            $pg .= 'then click remove: <input type=submit name=Remove value=Remove>';
            $pg .= '</form></td></tr>';
            break;
    }
    $pg .= '</table>';
    $pg .= '</center></td></tr>';
    $pg .= '<tr class=dl><td>';
    $pg .= '2FA means that you need 2 codes to login to your account.<br>';
    $pg .= 'You will also need the 2FA code to modify any important settings in your account.<br>';
    $pg .= 'The 1st code is your current password.<br>';
    $pg .= 'The 2nd code is a number that your 2FA device will generate each time.<br>';
    $pg .= 'Your 2FA device would be, for example, your phone or tablet.<br><br>';
    $pg .= 'Each time you need a 2FA code, you use your device to generate a number<br>';
    $pg .= 'that you type into the "<span class=st1>*</span>2nd Authentication:" field on any page that has it.<br><br>';
    $pg .= '<b>IMPORTANT:</b> the TOTP algorithm uses the time on your device,<br>';
    $pg .= "so it is important that your device's clock is accurate within a few seconds.<br><br>";
    $pg .= app_time();
    $pg .= '<b>IMPORTANT:</b> you enter the value from your App at the time you submit data.<br>';
    $pg .= "The value is valid only once for a maximum of 30 seconds.<br>";
    $pg .= "In both the Apps it has a 'dial' that shows the 30 seconds running out.<br>";
    $pg .= "If you are close to running out, you can wait for the 30 seconds to run out<br>";
    $pg .= "and then enter the new value it will come up with.<br>";
    $pg .= "The pool checks your value using the time at the pool when you submit the data,<br>";
    $pg .= "it doesn't matter when you loaded the web page,<br>";
    $pg .= "it only matters when you clicked on the web page button to send the data to the pool.<br><br>";
    $pg .= '<span class=urg>WARNING:</span> once you have successfully tested and enabled 2FA,<br>';
    $pg .= 'you will be unable to access or even reset your account without 2FA.<br>';
    $pg .= 'There is no option to recover your 2FA from the web site,<br>';
    $pg .= 'and you must know your 2FA code in order to be able to disable 2FA.<br><br>';
    $pg .= '<span class=urg>WARNING:</span> it is important to <b>not</b> store your login password in your 2FA device.<br>';
    $pg .= 'These 2 together will give full access to your account.';
    $pg .= '</td></tr>';
    $pg .= '</table>';
    if ($draw !== false) {
        $qr = shell_exec("../pool/myqr.sh '{$sfaurl}'");
        if ($qr !== null and strlen($qr) > 30) {
            $pg .= "<script type='text/javascript'>\n";
            $pg .= "{$qr}qr(tw,fa,qrx,qry,qrd);</script>\n";
            if (strpos($qr, 'var tw=1,fa=0,qrx=') === false) {
                error_log("QR error for '{$user}' res='{$qr}'");
            }
        } else {
            if ($qr === null) {
                $qr = 'null';
            }
            error_log("QR failed for '{$user}' res='{$qr}'");
        }
    }
    return $pg;
}
예제 #11
0
<?php

/*РАБОТА С cookie*/
//cookie - это набор переменных которые хранятся браузере пользователя.
//setcookie("name", 15);
//Функция setcookie() - задает cookie, которое будет передано клиенту вместе с другими HTTP заголовками, как и другой заголовок, cookie должны передаваться до того как будут выведены какие-либо другие данные скрипта (1-наименование куки, 2-параметр куки)
//echo $_COOKIE["name"];
//Функция $_COOKIE[] - ассоциативный массив значений, переданных скрипту через HTTP Куки(1-указываем наименование куки)
//Конструкция javascript:document.cookie - прописываем в адресной строке браузера и показывает какие куки на данном сайте сохранены
if (!isset($_COOKIE['username'])) {
    makeForm();
} else {
    echo "Привет " . $_COOKIE['username'];
}
function makeForm()
{
    if (isset($_REQUEST['user'])) {
        setcookie("username", $_REQUEST['user']);
        echo "Привет " . $_REQUEST['user'];
        return;
    }
    echo "<form action=" . $_SERVER['SCRIPT_NAME'] . " method='post'>\n\t\t\tВведите Ваше имя: <input type='text' name='user'/>\n\t\t\t<input type='submit' value='Отправить'/>\n\t\t</form>";
}
//$_SERVER['SCRIPT_NAME'] - массив с таким значение возвращает имя текущего файла
/*Домашняя работа*/
if (isset($_REQUEST["color"])) {
    setcookie("sitecolor", $_REQUEST["color"]);
    echo "<style type='text/css'>\n\t\t\tbody{\n\t\t\t\tbackground:" . $_REQUEST["color"] . ";\n\t\t\t}\n\t\t</style>";
} else {
    if (isset($_COOKIE["sitecolor"])) {
        echo "<style type='text/css'>\n\t\t\tbody{\n\t\t\t\tbackground:" . $_COOKIE["sitecolor"] . ";\n\t\t\t}\n\t\t</style>";
예제 #12
0
function addrmgtuser($data, $user, $err)
{
    $pg = '<h1>Address Management</h1>';
    if ($err != '') {
        $pg .= "<span class=err>{$err}<br><br></span>";
    }
    $pg .= makeForm('addrmgt');
    $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
    $pg .= '<tr class=title>';
    $pg .= '<td class=dc>#</td>';
    $pg .= '<td class=dl>Address</td>';
    $pg .= '<td class=dl>ID</td>';
    $pg .= '<td class=dr>Ratio</td>';
    $pg .= '<td class=dr>%</td>';
    $pg .= '</tr>';
    # new row template for '+'
    $pg .= '<tr class=hid id=bs>';
    $pg .= '<td class=dc> </td>';
    $pg .= '<td class=dl>';
    $pg .= "<input type=text size=36 name='addr:' value=''>";
    $pg .= '</td>';
    $pg .= '<td class=dl>';
    $pg .= "<input type=text size=16 name='payname:' value=''>";
    $pg .= '</td>';
    $pg .= '<td class=dr>';
    $pg .= "<input type=text size=6 name='ratio:' value='0' id=rat onchange='repc()'>";
    $pg .= '</td>';
    $pg .= '<td class=dr>';
    $pg .= "<span id=per>0.00%</span>";
    $pg .= '</td>';
    $pg .= "</tr>\n";
    $ans = userSettings($user);
    $offset = 0;
    $count = 0;
    if ($ans['STATUS'] == 'ok') {
        if (isset($ans['limit'])) {
            $limit = $ans['limit'];
        } else {
            $limit = 1;
        }
        $count = $ans['rows'];
        # this will output any DB rows > limit but DB update will ignore extras
        for ($i = 0; $i < $count; $i++) {
            if ($offset % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row}>";
            $addr = $ans['addr:' . $i];
            $pg .= '<td class=dc>' . ($i + 1) . '</td>';
            $pg .= '<td class=dl>';
            $pg .= "<input type=text size=36 name='addr:{$i}' value='{$addr}'>";
            $pg .= '</td>';
            $nam = htmlspecialchars($ans['payname:' . $i]);
            $pg .= '<td class=dl>';
            $pg .= "<input type=text size=16 name='payname:{$i}' value='{$nam}'>";
            $pg .= '</td>';
            $ratio = intval($ans['ratio:' . $i]);
            $pg .= '<td class=dr>';
            $pg .= "<input type=text size=6 name='ratio:{$i}' value='{$ratio}' id=rat{$i} onchange='repc()'>";
            $pg .= '</td>';
            $pg .= '<td class=dr>';
            $pg .= "<span id=per{$i}>%</span>";
            $pg .= '</td>';
            $pg .= "</tr>\n";
            $offset++;
        }
        if ($offset < $limit) {
            if ($offset++ % 2 == 0) {
                $row = 'even';
            } else {
                $row = 'odd';
            }
            $pg .= "<tr class={$row} id=plus><td class=dc>";
            $pg .= "<input type=button value='+' onclick='return adrw({$limit});'>";
            $pg .= "</td><td colspan=4 class=dl><font size=-1>limit {$limit}</font></td></tr>";
        }
        if ($offset++ % 2 == 0) {
            $row = 'even';
        } else {
            $row = 'odd';
        }
        $pg .= "<tr class={$row}>";
        $pg .= '<td class=dr>&nbsp;</td>';
        $pg .= '<td class=dr>Password:</td>';
        $pg .= '<td class=dl><input type=password name=pass size=20></td>';
        $pg .= '<td colspan=2>&nbsp;</td></tr>';
        if ($offset++ % 2 == 0) {
            $row = 'even';
        } else {
            $row = 'odd';
        }
        $pg .= "<tr class={$row}>";
        $pg .= '<td class=dr>&nbsp;</td>';
        $pg .= '<td class=dr><span class=st1>*</span>2nd Authentication:</td>';
        $pg .= '<td class=dl><input type=password name=2fa size=10>';
        $pg .= ' <input type=submit name=OK value=Save></td>';
        $pg .= '<td colspan=3 class=dl>&nbsp;</td></tr>';
        $pg .= '<tr><td colspan=5 class=dc><font size=-1>';
        $pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it<br>";
        $pg .= 'You must enter your password to save changes<br>';
        $pg .= 'A ratio of 0, will remove the address from the payouts</td></tr>';
    }
    $pg .= "</table><input type=hidden name=rows value={$count} id=rows></form>\n";
    # TODO - adrw() update the odd/even class for the new row and rows below it
    # TODO - move the js functions into inc.php
    $pg .= "<script type='text/javascript'>\n";
    $pg .= "function adrw(l){var p=document.getElementById('plus');";
    $pg .= "var r=document.getElementById('rows');var c=parseInt(r.value);";
    $pg .= "var bs=document.getElementById('bs');var n=bs.cloneNode(true);n.id='z';";
    $pg .= "var ia=n.childNodes[1].firstChild;ia.name='addr:'+c;ia.value='';";
    $pg .= "var ipn=n.childNodes[2].firstChild;ipn.name='payname:'+c;ipn.value='';";
    $pg .= "var ir=n.childNodes[3].firstChild;ir.id='rat'+c;ir.name='ratio:'+c;ir.value='0';";
    $pg .= "var ip=n.childNodes[4].firstChild;ip.id='per'+c;ip.innerHTML='0.00%';";
    $pg .= "p.parentNode.insertBefore(n, p);";
    $pg .= "c++;r.value=c;if(c>=l){p.parentNode.removeChild(p)}";
    $pg .= "n.childNodes[0].innerHTML=''+c;n.className='odd';return true}\n";
    $pg .= "function repc(){var c=parseInt(document.getElementById('rows').value);";
    $pg .= "if(!isNaN(c)&&c>0&&c<1000){var v=[],tot=0;for(i=0;i<c;i++){";
    $pg .= "var o=document.getElementById('rat'+i);var ov=parseInt(o.value);if(!isNaN(ov)&&ov>0)";
    $pg .= "{tot+=ov;v[i]=ov}else{o.value='0';v[i]=0}";
    $pg .= "}for(i=0;i<c;i++){var p;var r=document.getElementById('per'+i);if(tot<=0)";
    $pg .= "{p=0}else{p=v[i]*100/tot};r.innerHTML=p.toFixed(2)+'%';";
    $pg .= "}}};\nrepc();</script>";
    return $pg;
}
예제 #13
0
function doevents($data, $user)
{
    $pg = '<h1>Event Information</h1>';
    $wh = getparam('what', false);
    if (nuem($wh)) {
        $wh = '';
    }
    $pg = '<br>' . makeForm('events') . "\nWhat: <input type=text name=what size=10 value='{$wh}'>\n&nbsp;<input type=submit name=Get value=Get>\n</form>";
    if ($wh == 'settings') {
        $ans = eventCmd($user, array('action' => 'settings'));
        $other = array('event_limits_hash_lifetime', 'ovent_limits_ipc_factor');
        $pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<thead><tr class=title>';
        $pg .= '<td class=dr>#</td>';
        $pg .= '<td class=dl>Name</td>';
        $pg .= '<td class=dr>Value</td>';
        $pg .= "</tr></thead>\n";
        if ($ans['STATUS'] == 'ok') {
            $pg .= '<tbody>';
            $i = 0;
            foreach ($other as $name) {
                if ($i % 2 == 0) {
                    $row = 'even';
                } else {
                    $row = 'odd';
                }
                $i++;
                $pg .= "<tr class={$row}>";
                $pg .= "<td class=dr>{$i}</td>";
                $pg .= "<td class=dl>{$name}</td>";
                $pg .= '<td class=dr>' . $ans[$name] . '</td>';
                $pg .= "</tr>\n";
            }
            $pg .= '</tbody>';
        }
        $pg .= "</table>\n";
        $flds = array('enabled' => 'Ena', 'user_low_time' => 'UserLo', 'user_low_time_limit' => 'UserLoLim', 'user_hi_time' => 'UserHi', 'user_hi_time_limit' => 'UserHiLim', 'ip_low_time' => 'IPLo', 'ip_low_time_limit' => 'IPLoLim', 'ip_hi_time' => 'IPHi', 'ip_hi_time_limit' => 'IPHiLim', 'lifetime' => 'Life');
        $pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<thead><tr class=title>';
        $pg .= '<td class=dr>#</td>';
        $pg .= '<td class=dl>Name</td>';
        foreach ($flds as $row => $nam) {
            $pg .= "<td class=dr>{$nam}</td>";
        }
        $pg .= "</tr></thead>\n";
        if ($ans['STATUS'] == 'ok') {
            $pg .= '<tbody>';
            $names = array();
            foreach ($ans as $name => $value) {
                $ex = explode('_', $name, 2);
                if (count($ex) == 2 && isset($flds[$ex[1]])) {
                    $names[$ex[0]] = 1;
                }
            }
            $i = 0;
            foreach ($names as $name => $one) {
                if ($i % 2 == 0) {
                    $row = 'even';
                } else {
                    $row = 'odd';
                }
                $i++;
                $pg .= "<tr class={$row}>";
                $pg .= "<td class=dr>{$i}</td>";
                $pg .= "<td class=dl>{$name}</td>";
                foreach ($flds as $fld => $nam) {
                    $pg .= '<td class=dr>' . $ans[$name . '_' . $fld] . '</td>';
                }
                $pg .= "</tr>\n";
            }
            $pg .= '</tbody>';
        }
        $pg .= "</table>\n";
    }
    if ($wh == 'all' || $wh == 'user' || $wh == 'ip' || $wh == 'ipc' || $wh == 'hash') {
        $ans = eventCmd($user, array('action' => 'events', 'list' => $wh));
        $pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<thead><tr class=title>';
        $pg .= '<td class=dr>#</td>';
        $pg .= '<td class=dl>List</td>';
        $pg .= '<td class=dr>ID</td>';
        $pg .= '<td class=dl>IDName</td>';
        $pg .= '<td class=dl>User</td>';
        $pg .= '<td class=dr>IP</td>';
        $pg .= '<td class=dr>IPc</td>';
        $pg .= '<td class=dr>Hash</td>';
        $pg .= '<td class=dr>UTC</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';
                }
                $j = $i + 1;
                $pg .= "<tr class={$row}>";
                $pg .= "<td class=dr>{$j}</td>";
                $pg .= '<td class=dl>' . $ans['list:' . $i] . '</td>';
                $pg .= '<td class=dr>' . $ans['id:' . $i] . '</td>';
                $pg .= '<td class=dl>' . $ans['idname:' . $i] . '</td>';
                $pg .= '<td class=dl>' . $ans['user:'******'</td>';
                $pg .= '<td class=dr>' . isans($ans, 'ip:' . $i) . '</td>';
                $pg .= '<td class=dr>' . isans($ans, 'ipc:' . $i) . '</td>';
                $pg .= '<td class=dr>' . isans($ans, 'hash:' . $i) . '</td>';
                $pg .= '<td class=dr>' . gmdate('j/M H:i:s', $ans['createdate:' . $i]) . '</td>';
                $pg .= "</tr>\n";
            }
            $pg .= '</tbody>';
        }
    }
    if ($wh == 'ovents') {
        $ans = eventCmd($user, array('action' => 'ovents'));
        $pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
        $pg .= '<thead><tr class=title>';
        $pg .= '<td class=dr>#</td>';
        $pg .= '<td class=dl>Key</td>';
        $pg .= '<td class=dr>ID</td>';
        $pg .= '<td class=dl>IDName</td>';
        $pg .= '<td class=dr>Hour UTC</td>';
        $pg .= '<td class=dl>Count</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';
                }
                $j = $i + 1;
                $pg .= "<tr class={$row}>";
                $pg .= "<td class=dr>{$j}</td>";
                $pg .= '<td class=dl>' . $ans['key:' . $i] . '</td>';
                $pg .= '<td class=dr>' . $ans['id:' . $i] . '</td>';
                $pg .= '<td class=dl>' . $ans['idname:' . $i] . '</td>';
                $pg .= '<td class=dr>' . gmdate('j/M H:i:s', $ans['hour:' . $i] * 3600) . '</td>';
                $co = '';
                for ($k = 0; $k < 60; $k++) {
                    if ($k < 10) {
                        $min = '0' . $k;
                    } else {
                        $min = $k;
                    }
                    if (isset($ans["min{$min}:{$i}"])) {
                        if ($co != '') {
                            $co .= ' ';
                        }
                        $co .= "{$min}=" . $ans["min{$min}:{$i}"];
                    }
                }
                $pg .= "<td class=dl>{$co}</td>";
                $pg .= "</tr>\n";
            }
            $pg .= '</tbody>';
        }
    }
    return $pg;
}
예제 #14
0
                    unset($_POST);
                    // display reset button so user can go back and enter different items
                    echo '
    
                    <form method="post" action="' . THIS_PAGE . '">
                    <input type="submit" name="reset" value="reset" />
    
                    </form>
                    ';
                    die;
                }
            }
        }
    }
    //call function displayOrder() to display the items the user picked and the total for their order
    echo displayOrder($itemsPurchased, $items);
    //reset $_POST data since 'submit' cached and need to reset to display form again
    unset($_POST);
    // display reset button so user can go back and enter different items
    echo '
    
    <form method="post" action="' . THIS_PAGE . '">
    <input type="submit" name="reset" value="reset" />
    
    </form>
    ';
} else {
    //call to makeForm() function using the items array that contains all the available items
    //makes a form dynamically based on the available items to display to user so they can select items to purchase
    echo makeForm($items);
}