function doworkmgt($data, $user) { $err = ''; $S = getparam('S', false); $chk = getparam('seven', false); if ($S == 'Update') { $settings = array(); if ($chk == 'on') { $settings['oldworkers'] = '7'; } else { $settings['oldworkers'] = '0'; } $ans = workerSet($user, $settings); if ($ans['STATUS'] != 'ok') { $err = $ans['ERROR']; } } else { $OK = getparam('OK', false); $count = getparam('rows', false); if ($OK == 'OK' && !nuem($count)) { if ($count > 0 && $count < 9999) { $settings = array(); for ($i = 0; $i < $count; $i++) { $wn = urldecode(getparam('workername:' . $i, false)); $md = getparam('difficultydefault:' . $i, false); if (!nuem($wn) && !nuem($md)) { $settings['workername:' . $i] = $wn; $settings['difficultydefault:' . $i] = $md; } } $ans = workerSet($user, $settings); if ($ans['STATUS'] != 'ok') { $err = $ans['ERROR']; } } } } $pg = workmgtuser($data, $user, $err); return $pg; }
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 Tx: <input type=text name=tx size=1 value='{$tx}'>\n Dust (Satoshi): <input type=text name=dust size=5 value='10000'>\n Fee (BTC): <input type=text name=fee size=5 value='0.0'>\n <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(' ', ' ', $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(' ', ' ', $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(' ', ' ', $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; }
function userSettings($user, $email = null, $addr = null, $pass = null, $twofa = null) { global $fld_sep; $tmo = false; $flds = array('username' => $user); if ($email != null) { $flds['email'] = $email; } if ($addr != null) { $rows = count($addr); $i = 0; foreach ($addr as $ar) { $flds['address:' . $i] = $ar['addr']; // optional - missing = blank if (isset($ar['payname'])) { $flds['payname:' . $i] = str_replace($fld_sep, ' ', trim($ar['payname'])); } // optional - missing = use default if (isset($ar['ratio'])) { $flds['ratio:' . $i] = $ar['ratio']; } $i++; } $flds['rows'] = $rows; $tmo = 3; # 3x the timeout } if ($pass != null) { $flds['passwordhash'] = myhash($pass); if (nuem($twofa)) { $twofa = 0; } $flds['2fa'] = $twofa; } $msg = msgEncode('usersettings', 'userset', $flds, $user); $rep = sendsockreply('userSettings', $msg, $tmo); if (!$rep) { dbdown(); } return repDecode($rep); }
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); }
function doaddrmgt($data, $user) { $err = ''; $OK = getparam('OK', false); $count = getparam('rows', false); $pass = getparam('pass', false); $twofa = getparam('2fa', false); if ($OK == 'Save' && !nuem($count) && !nuem($pass)) { if ($count > 0 && $count < 1000) { $addrarr = array(); for ($i = 0; $i < $count; $i++) { $addr = getparam('addr:' . $i, false); $nam = getparam('payname:' . $i, false); if (nuem($nam)) { $nam = ''; } $ratio = getparam('ratio:' . $i, false); if (!nuem($addr) && !nuem($ratio)) { $addrarr[] = array('addr' => $addr, 'payname' => $nam, 'ratio' => $ratio); } } $ans = userSettings($user, null, $addrarr, $pass, $twofa); if ($ans['STATUS'] != 'ok') { $err = $ans['ERROR']; } } } $pg = addrmgtuser($data, $user, $err); return $pg; }
function tryLogInOut() { global $loginfailed; // If already logged in, it will ignore User/Pass if (isset($_SESSION['ckpkey'])) { $logout = getparam('Logout', false); if (!nuem($logout) && $logout == 'Logout') { logout(); } } else { $login = getparam('Login', false); if (nuem($login)) { return; } $user = getparam('User', false); if ($user !== NULL) { $user = loginStr($user); } if (nuem($user)) { $loginfailed = true; return; } $pass = getparam('Pass', false); if (nuem($pass)) { $loginfailed = true; return; } $twofa = getparam('2fa', false); $valid = validUserPass($user, $pass, $twofa); if (!$valid) { $loginfailed = true; } } }
function doblocks($data, $user) { $blink = '<a href=https://www.blocktrail.com/BTC/block/'; $pg = ''; if ($user === null) { $ans = getBlocks('Anon'); } else { $ans = getBlocks($user); } if (nuem(getparam('csv', true))) { $wantcsv = false; } else { $wantcsv = true; } if ($wantcsv === false) { if ($ans['STATUS'] == 'ok' and isset($ans['s_rows']) and $ans['s_rows'] > 0) { $pg .= '<h1>Block Statistics</h1>'; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<tr class=title>"; $pg .= "<td class=dl>Description</td>"; $pg .= "<td class=dr>Time</td>"; $pg .= "<td class=dr>MeanTx%</td>"; $pg .= "<td class=dr>Diff%</td>"; $pg .= "<td class=dr>Mean%</td>"; $pg .= "<td class=dr>CDF[Erl]</td>"; $pg .= "<td class=dr>Luck%</td>"; $pg .= "</tr>\n"; $since = $data['info']['lastblock']; $count = $ans['s_rows']; for ($i = 0; $i < $count; $i++) { if ($i % 2 == 0) { $row = 'even'; } else { $row = 'odd'; } $desc = $ans['s_desc:' . $i]; $age = daysago($since - $ans['s_prevcreatedate:' . $i]); $diff = number_format(100 * $ans['s_diffratio:' . $i], 2); $mean = number_format(100 * $ans['s_diffmean:' . $i], 2); $cdferl = $ans['s_cdferl:' . $i]; list($fg, $bg) = erlcolour($cdferl); $cdferldsp = "<font color={$fg}>" . number_format($cdferl, 4) . '</font>'; $bg = " bgcolor={$bg}"; $luck = number_format(100 * $ans['s_luck:' . $i], 2); $txm = number_format(100 * $ans['s_txmean:' . $i], 1); $pg .= "<tr class={$row}>"; $pg .= "<td class=dl>{$desc} Blocks</td>"; $pg .= "<td class=dr>{$age}</td>"; $pg .= "<td class=dr>{$txm}%</td>"; $pg .= "<td class=dr>{$diff}%</td>"; $pg .= "<td class=dr>{$mean}%</td>"; $pg .= "<td class=dr{$bg}>{$cdferldsp}</td>"; $pg .= "<td class=dr>{$luck}%</td>"; $pg .= "</tr>\n"; } $pg .= "</table>\n"; } if ($ans['STATUS'] == 'ok') { $count = $ans['rows']; if ($count == 1) { $num = ''; $s = ''; } else { $num = " {$count}"; $s = 's'; } $pg .= "<h1>Last{$num} Block{$s}</h1>"; } else { $pg .= '<h1>Blocks</h1>'; } list($fg, $bg) = pctcolour(25.0); $pg .= "<span style='background:{$bg}; color:{$fg};'>"; $pg .= " Green </span> "; $pg .= 'is good luck. Lower Diff% and brighter green is better luck.<br>'; list($fg, $bg) = pctcolour(100.0); $pg .= "<span style='background:{$bg}; color:{$fg};'>"; $pg .= " 100% </span> "; $pg .= 'is expected average. '; list($fg, $bg) = pctcolour(400.0); $pg .= "<span style='background:{$bg}; color:{$fg};'>"; $pg .= " Red </span> "; $pg .= 'is bad luck. Higher Diff% and brighter red is worse luck.<br><br>'; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<tr class=title>"; $pg .= "<td class=dr>#</td>"; $pg .= "<td class=dl>Height</td>"; if ($user !== null) { $pg .= "<td class=dl>Who</td>"; } $pg .= "<td class=dr>Block Reward</td>"; $pg .= "<td class=dc>When</td>"; $pg .= "<td class=dr>Status</td>"; $pg .= "<td class=dr>Diff</td>"; $pg .= "<td class=dr>Diff%</td>"; $pg .= "<td class=dr>CDF</td>"; $pg .= "<td class=dr>B</td>"; $pg .= "</tr>\n"; } $blktot = 0; $nettot = 0; $i = 0; $cnt = 0; $orph = false; $csv = "Sequence,Height,Status,Timestamp,DiffAcc,NetDiff,Hash\n"; if ($ans['STATUS'] == 'ok') { $count = $ans['rows']; for ($i = 0; $i < $count; $i++) { if ($i % 2 == 0) { $row = 'even'; } else { $row = 'odd'; } $hi = $ans['height:' . $i]; $hifld = "{$blink}{$hi}>{$hi}</a>"; $ex = ''; $conf = $ans['confirmed:' . $i]; $stat = $ans['status:' . $i]; $inf = $ans['info:' . $i]; $tt = ''; if ($conf == 'O' or $conf == 'R') { $ex = 's'; $orph = true; $seq = ''; $nn = $cnt; if ($conf == 'R') { addTips(); $in = explode(':', $inf, 2); if (trim($in[0]) != '') { $stat = trim($in[0]); } if (count($in) < 2 or trim($in[1]) == '') { $tip = 'Share diff was VERY close<br>'; $tip .= 'so we tested it,<br>'; $tip .= "but it wasn't worthy<br>"; } else { $tip = str_replace('+', '<br>', trim($in[1])); } $tt = "<span class=q onclick='tip(\"btip{$i}\",6000)'>"; $tt .= '?</span><span class=tip0>'; $tt .= "<span class=notip id=btip{$i}>"; $tt .= "{$tip}</span></span>"; } } else { $seq = $ans['seq:' . $i]; $nn = ++$cnt; } if ($conf == '1') { if (isset($data['info']['lastheight'])) { $confn = 1 + $data['info']['lastheight'] - $hi; $stat = '+' . $confn . ' Confirms'; } else { $stat = 'Conf'; } } $stara = ''; if ($conf == 'O' or $conf == 'R') { $stara = '<span class=st1>*</span>'; } if (isset($ans['statsconf:' . $i])) { if ($ans['statsconf:' . $i] == 'Y') { $approx = ''; } else { $approx = '~'; } } else { $approx = ''; } $diffacc = $ans['diffacc:' . $i]; $acc = number_format($diffacc, 0); $netdiff = $ans['netdiff:' . $i]; $diffratio = $ans['diffratio:' . $i]; $cdf = $ans['cdf:' . $i]; $luck = $ans['luck:' . $i]; if ($diffratio > 0) { $pct = 100.0 * $diffratio; list($fg, $bg) = pctcolour($pct); $bpct = "<font color={$fg}>{$approx}" . number_format($pct, 3) . '%</font>'; $bg = " bgcolor={$bg}"; $blktot += $diffacc; if ($conf != 'O' and $conf != 'R') { $nettot += $netdiff; } $cdfdsp = number_format($cdf, 3); } else { $bg = ''; $bpct = '?'; $cdfdsp = '?'; } if ($wantcsv === false) { $pg .= "<tr class={$row}>"; $pg .= "<td class=dr{$ex}>{$seq}</td>"; $pg .= "<td class=dl{$ex}>{$hifld}</td>"; if ($user !== null) { $pg .= "<td class=dl{$ex}>" . htmlspecialchars($ans['workername:' . $i]) . '</td>'; } $pg .= "<td class=dr{$ex}>" . btcfmt($ans['reward:' . $i]) . '</td>'; $pg .= "<td class=dl{$ex}>" . utcd($ans['firstcreatedate:' . $i]) . '</td>'; $pg .= "<td class=dr{$ex}>{$tt}{$stat}</td>"; $pg .= "<td class=dr>{$stara}{$approx}{$acc}</td>"; $pg .= "<td class=dr{$bg}>{$bpct}</td>"; $pg .= "<td class=dr>{$cdfdsp}</td>"; $pg .= "<td class=dr>{$nn}</td>"; $pg .= "</tr>\n"; } else { $csv .= "{$seq},"; $csv .= "{$hi},"; $csv .= "\"{$stat}\","; $csv .= $ans['firstcreatedate:' . $i] . ','; $csv .= "{$diffacc},"; $csv .= "{$netdiff},"; $csv .= $ans['blockhash:' . $i] . "\n"; } } } if ($wantcsv === true) { echo $csv; exit(0); } if ($orph === true) { $pg .= '<tr><td colspan='; if ($user === null) { $pg .= '7'; } else { $pg .= '8'; } $pg .= ' class=dc><font size=-1><span class=st1>*</span>'; $pg .= 'Orphans/Rejects count as shares but not as a block in calculations'; $pg .= '</font></td></tr>'; } $pg .= "</table>\n"; return $pg; }
function doreset($data, $u) { // Slow this right down usleep(500000); if (isset($_SESSION['reset_user']) && isset($_SESSION['reset_hash']) && isset($_SESSION['reset_email'])) { return dbreset(); } $code = getparam('code', true); if (nuem($code)) { return resetfail(); } $codes = explode('_', $code, 2); if (sizeof($codes) != 2) { return resetfail(); } $userhex = $codes[0]; if (strlen($userhex) == 0 || strlen($userhex) % 2) { return resetfail(); } $user = loginStr(pack("H*", $userhex)); $hash = preg_replace('/[^A-Fa-f0-9]/', '', $codes[1]); if (!nuem($user) && !nuem($hash)) { $ans = getAtts($user, 'KReset.str,KReset.dateexp'); if ($ans['STATUS'] != 'ok') { return resetfail(); } if (!isset($ans['KReset.dateexp']) || $ans['KReset.dateexp'] == 'Y') { return resetfail(); } if (!isset($ans['KReset.str']) || $ans['KReset.str'] != $hash) { return resetfail(); } $ans = userSettings($user); if ($ans['STATUS'] != 'ok') { return resetfail(); } if (!isset($ans['email'])) { return resetfail(); } $email = $ans['email']; $_SESSION['reset_user'] = $user; $_SESSION['reset_hash'] = $hash; $_SESSION['reset_email'] = $email; return allow_reset(null); } return resetfail(); }
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 <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; }
function try_reset($info, $page, $menu, $name, $u) { $user = getparam('user', false); $mail = trim(getparam('mail', false)); $data = array(); if (!nuem($user)) { $user = loginStr($user); } if (!nuem($user) && !nuem($mail)) { $ans = userSettings($user); if ($ans['STATUS'] == 'ok' && isset($ans['email']) && $ans['email'] == $mail) { $data = array('user' => $user, 'email' => $mail); gopage($info, $data, 'doreset2', $page, $menu, $name, $u, true, true, false); } } gopage($info, $data, 'doregres', $page, $menu, $name, $u, true, true, false); }
function doaddrmgt($data, $user) { $err = ''; $OK = getparam('OK', false); $count = getparam('rows', false); $pass = getparam('pass', false); $twofa = getparam('2fa', false); $mfail = false; if ($OK == 'Save' && !nuem($count) && !nuem($pass)) { if ($count > 0 && $count < 1000) { $mfail = true; $addrarr = array(); for ($i = 0; $i < $count; $i++) { $addr = getparam('addr:' . $i, false); $nam = getparam('payname:' . $i, false); if (nuem($nam)) { $nam = ''; } $ratio = getparam('ratio:' . $i, false); if (!nuem($addr) && !nuem($ratio)) { $addrarr[] = array('addr' => $addr, 'payname' => $nam, 'ratio' => $ratio); } } $ans = userSettings($user, null, $addrarr, $pass, $twofa); if ($ans['STATUS'] != 'ok') { $err = $ans['ERROR']; } else { $ans = userSettings($user); if ($ans['STATUS'] != 'ok') { goto meh; } if (isset($ans['email'])) { $email = $ans['email']; } else { goto meh; } $emailinfo = getOpts($user, emailOptList()); if ($emailinfo['STATUS'] != 'ok') { goto meh; } else { payoutAddressChanged($email, zeip(), $emailinfo); } } $mfail = false; } } meh: if ($mfail == true) { if ($err != '') { $err .= '<br>'; } $err .= 'An error occurred, check your details below'; } $pg = addrmgtuser($data, $user, $err); return $pg; }