diff --git a/pool/page.php b/pool/page.php index 1ac1a8bb..a8750b86 100644 --- a/pool/page.php +++ b/pool/page.php @@ -91,6 +91,8 @@ span.topwho {color:black; font-weight: bold; margin-right: 8px;} span.topdat {margin-left: 8px; margin-right: 24px; color:green; font-weight: bold;} span.login {float: right; margin-left: 8px; margin-right: 24px;} span.hil {color:blue;} +span.warn {color:orange; font-weight:bold;} +span.urg {color:red; font-weight:bold;} #n42 {margin:0; position: relative; color:#fff; background:#07e;} #n42 a {color:#fff; text-decoration:none; margin: 4px;} #n42 td {min-width: 100px; float: left; vertical-align: top; padding: 2px;} diff --git a/pool/page_ckp.php b/pool/page_ckp.php new file mode 100644 index 00000000..ae03d288 --- /dev/null +++ b/pool/page_ckp.php @@ -0,0 +1,71 @@ + 99999999) + $b4 = ''; + else if ($num > 9999999) + $b4 = ''; + if ($b4 != '') + $af = ''; + return $b4.$fmt.$af; +} +# +function dockp($data, $user) +{ + $pg = '

CKPool

'; + + $msg = msgEncode('stats', 'stats', array()); + $rep = sendsockreply('stats', $msg); + if ($rep == false) + $ans = array(); + else + $ans = repDecode($rep); + + $pg .= 'TotalRAM: '.stnum($ans['totalram']).'
'; + $pg .= "\n"; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + if ($ans['STATUS'] == 'ok') + { + for ($i = 0; $i < 999; $i++) + { + if ($i == 0) + $name = 'stats.name'; + else + $name = 'name'; + + if (!isset($ans[$name.$i])) + break; + + if (($i % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $pg .= ""; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + } + } + $pg .= "
NameAllocatedStoreRAM
'.$ans[$name.$i].''.stnum($ans['allocated'.$i]).''.stnum($ans['store'.$i]).''.stnum($ans['ram'.$i]).'
\n"; + + return $pg; +} +# +function show_ckp($menu, $name, $user) +{ + gopage(NULL, 'dockp', $menu, $name, $user); +} +# +?> diff --git a/pool/page_payout.php b/pool/page_payout.php new file mode 100644 index 00000000..ae40f73e --- /dev/null +++ b/pool/page_payout.php @@ -0,0 +1,13 @@ +PayoutsDescription'; +} +# +function show_payout($menu, $name, $user) +{ + gopage(NULL, 'dopayout', $menu, $name, $user); +} +# +?> diff --git a/pool/page_stats.php b/pool/page_stats.php index 363813c0..fad0f4db 100644 --- a/pool/page_stats.php +++ b/pool/page_stats.php @@ -2,7 +2,7 @@ # function allusersort($a, $b) { - $cmp = $a['u_hashrate1hr'] != $b['u_hashrate1hr']; + $cmp = $b['u_hashrate5m'] - $a['u_hashrate5m']; if ($cmp != 0) return $cmp; return $a['userid'] - $b['userid']; @@ -18,7 +18,7 @@ function dostats($data, $user) $pg .= "\n"; $pg .= ""; $pg .= ""; - $pg .= ""; + $pg .= ""; $pg .= "\n"; if ($ans['STATUS'] == 'ok') { @@ -28,7 +28,7 @@ function dostats($data, $user) { $all[] = array('username' => $ans['username'.$i], 'userid' => $ans['userid'.$i], - 'u_hashrate1hr' => $ans['u_hashrate1hr'.$i]); + 'u_hashrate5m' => $ans['u_hashrate5m'.$i]); } usort($all, 'allusersort'); @@ -42,18 +42,22 @@ function dostats($data, $user) $pg .= ""; $pg .= ''; - $uhr = $all[$i]['u_hashrate1hr']; + $uhr = $all[$i]['u_hashrate5m']; if ($uhr == '?') - $uhr = '?GHs'; + $dsp = '?GHs'; else { $uhr /= 10000000; if ($uhr < 100000) - $uhr = (round($uhr)/100).'GHs'; + $rate = 'G'; else - $uhr = (round($uhr/1000)/100).'THs'; + { + $rate = 'T'; + $uhr /= 1000; + } + $dsp = number_format($uhr/100, 2).$rate.'Hs'; } - $pg .= ""; + $pg .= ""; $pg .= "\n"; } } diff --git a/pool/prime.php b/pool/prime.php index 7066cc99..ae6e5069 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -19,9 +19,12 @@ function process($p, $user) ), 'gap' => NULL, 'Help' => array( - 'Help' => 'help' + 'Help' => 'help', + 'Payouts' => 'payout' ) ); + if ($user == 'Kano' || $user == 'ckolivas') + $menu['Help']['ckp'] = 'ckp'; $page = ''; $n = ''; foreach ($menu as $item => $options) diff --git a/src/ckdb.c b/src/ckdb.c index 3c183a21..9d8a4952 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -253,6 +253,7 @@ static POOLSTATUS pool; // TAB #define FLDSEP 0x09 +#define FLDSEPSTR "\011" // Ensure long long and int64_t are both 8 bytes (and thus also the same) #define ASSERT1(condition) __maybe_unused static char sizeof_longlong_must_be_8[(condition)?1:-1] @@ -652,7 +653,7 @@ static cklock_t fpm_lock; static char *first_pool_message; static sem_t socketer_sem; -static const char *userpatt = "^[^/\\._ ]*$"; // disallow: '/' '.' '_' +static const char *userpatt = "^[^/\\._"FLDSEPSTR"]*$"; // disallow: '/' '.' '_' and FLDSEP static const char *mailpatt = "^[A-Za-z0-9_-][A-Za-z0-9_\\.-]*@[A-Za-z0-9][A-Za-z0-9\\.-]*[A-Za-z0-9]$"; static const char *idpatt = "^[_A-Za-z][_A-Za-z0-9]*$"; static const char *intpatt = "^[0-9][0-9]*$"; @@ -6796,6 +6797,7 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id, size_t len, off; int rows; int64_t userid = -1; + double u_hashrate5m = 0.0; double u_hashrate1hr = 0.0; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -6811,6 +6813,7 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id, DATA_USERSTATS(usw_item)->userid = DATA_USERSTATS(us_item)->userid; strcpy(DATA_USERSTATS(usw_item)->workername, DATA_USERSTATS(us_item)->workername); + DATA_USERSTATS(usw_item)->hashrate5m = DATA_USERSTATS(us_item)->hashrate5m; DATA_USERSTATS(usw_item)->hashrate1hr = DATA_USERSTATS(us_item)->hashrate1hr; userstats_workername_root = add_to_ktree(userstats_workername_root, usw_item, cmp_userstats_workername); @@ -6841,6 +6844,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(u_hashrate5m, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "u_hashrate5m%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(u_hashrate1hr, reply, sizeof(reply)); snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -6849,8 +6856,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id, } } userid = DATA_USERSTATS(usw_item)->userid; + u_hashrate5m = 0; u_hashrate1hr = 0; } + u_hashrate5m += DATA_USERSTATS(usw_item)->hashrate5m; u_hashrate1hr += DATA_USERSTATS(usw_item)->hashrate1hr; tmp_item = usw_item; @@ -6874,6 +6883,10 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "userid%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(u_hashrate5m, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "u_hashrate5m%d=%s%c", rows, reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(u_hashrate1hr, reply, sizeof(reply)); snprintf(tmp, sizeof(tmp), "u_hashrate1hr%d=%s%c", rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -7583,14 +7596,14 @@ static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id, /* The socket command format is as follows: * Basic structure: - * cmd.id.fld1=value1 FLD_SEP fld2=value2 FLD_SEP fld3=... + * cmd.id.fld1=value1 FLDSEP fld2=value2 FLDSEP fld3=... * cmd is the cmd_str from the table below * id is a string of anything but '.' - preferably just digits and/or letters - * FLD_SEP is a single character macro - defined in the code near the top - * no spaces around FLD_SEP - they are added above for readability - * i.e. it's really: cmd.id.fld1=value1FLD_SEPfld2... - * fldN names cannot contain '=' or FLD_SEP - * valueN values cannot contain FLD_SEP except for the json field (see below) + * FLDSEP is a single character macro - defined in the code near the top + * no spaces around FLDSEP - they are added above for readability + * i.e. it's really: cmd.id.fld1=value1FLDSEPfld2... + * fldN names cannot contain '=' or FLDSEP + * valueN values cannot contain FLDSEP except for the json field (see below) * * The reply will be id.timestamp.status.information... * Status 'ok' means it succeeded
UsernameHash RateHash Rate 5m
'.$all[$i]['username'].'$uhr$dsp