diff --git a/pool/base.php b/pool/base.php index 8f26c8b1..afa6e4cc 100644 --- a/pool/base.php +++ b/pool/base.php @@ -87,6 +87,22 @@ function siprefmt($amt) return number_format($amt, $dot).$sipre[$pref]; } # +function dsprate($hr) +{ + $hr /= 10000000; + if ($hr < 100000) + { + if ($hr < 0.01) + $hr = '0GHs'; + else + $hr = number_format(round($hr)/100, 2).'GHs'; + } + else + $hr = number_format(round($hr/1000)/100, 2).'THs'; + + return $hr; +} +# function difffmt($amt) { return siprefmt($amt); diff --git a/pool/page.php b/pool/page.php index b9fca6ed..d3e060ac 100644 --- a/pool/page.php +++ b/pool/page.php @@ -145,11 +145,10 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;} return $head; } # -function pgtop($dotop, $user, $douser) +function pgtop($info, $dotop, $user, $douser) { global $site_title; - $info = homeInfo($user); $phr = '?THs'; $plb = '?'; $nlb = '?'; @@ -164,21 +163,15 @@ function pgtop($dotop, $user, $douser) 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 (isset($info['p_elapsed']) +// and isset($info['p_hashrate1hr']) +// and $info['p_elapsed'] > 3600) +// $phr = $info['p_hashrate1hr']; if ($phr == '?') $phr = '?THs'; else - { - $phr /= 10000000; - if ($phr < 100000) - $phr = (round($phr)/100).'GHs'; - else - $phr = (round($phr/1000)/100).'THs'; - } + $phr = dsprate($phr); if (isset($info['lastblock'])) { @@ -254,13 +247,7 @@ function pgtop($dotop, $user, $douser) if ($uhr == '?') $uhr = '?GHs'; else - { - $uhr /= 10000000; - if ($uhr < 100000) - $uhr = (round($uhr)/100).'GHs'; - else - $uhr = (round($uhr/1000)/100).'THs'; - } + $uhr = dsprate($uhr); } if (isset($info['u_hashrate1hr']) @@ -272,11 +259,7 @@ function pgtop($dotop, $user, $douser) $u1hr = ''; else { - $u1hr /= 10000000; - if ($u1hr < 100000) - $u1hr = '/'.(round($u1hr)/100).'GHs'; - else - $u1hr = '/'.(round($u1hr/1000)/100).'THs'; + $u1hr = dsprate($u1hr); if (substr($u1hr, -3) == substr($uhr, -3)) $uhr = substr($uhr, 0, -3); @@ -395,7 +378,7 @@ function pgmenu($menus) return $ret; } # -function pgbody($page, $menu, $dotop, $user, $douser) +function pgbody($info, $page, $menu, $dotop, $user, $douser) { $body = ' $info, 'data' => $data); + $pg .= $pagefun($both, $user); + } else $pg .= $pagefun; @@ -458,7 +446,7 @@ function gopage($data, $pagefun, $page, $menu, $name, $user, $ispage = true, $do // unset($_SESSION['logkey']); $head = pghead($script_marker, $name); - $body = pgbody($page, $menu, $dotop, $user, $douser); + $body = pgbody($info, $page, $menu, $dotop, $user, $douser); $foot = pgfoot(); if ($dbg === true) diff --git a/pool/page_reg.php b/pool/page_reg.php index 43326c7a..d1411742 100644 --- a/pool/page_reg.php +++ b/pool/page_reg.php @@ -5,21 +5,21 @@ include_once('email.php'); # function doregres($data, $u) { - if (isset($data['user'])) - $user = htmlspecialchars($data['user']); + if (isset($data['data']['user'])) + $user = htmlspecialchars($data['data']['user']); else $user = ''; - if (isset($data['mail'])) - $mail = htmlspecialchars($data['mail']); + if (isset($data['data']['mail'])) + $mail = htmlspecialchars($data['data']['mail']); else $mail = ''; $pg = '

'; $pg .= '

Register

'; - if (isset($data['error'])) - $pg .= "
".$data['error']." - please try again

"; + if (isset($data['data']['error'])) + $pg .= "
".$data['data']['error']." - please try again

"; $pg .= makeForm(''); $pg .= " @@ -65,8 +65,8 @@ An Email will be sent to you, to let you reset your password # function doreg2($data) { - if (isset($data['user'])) - $user = htmlspecialchars($data['user']); + if (isset($data['data']['user'])) + $user = htmlspecialchars($data['data']['user']); else $user = ''; @@ -74,8 +74,8 @@ function doreg2($data) // $pg .= '
You will receive an email shortly to verify your account'; $pg .= '
Your account is registered and ready to mine.'; $pg .= '
Choose your own worker names in cgminer.'; - $pg .= '
Worker names must start with your username like'; - $pg .= ": ${user}_ or ${user}."; + $pg .= '
Worker names must start with your username and a dot or an underscore'; + $pg .= "
e.g. ${user}_worker1 or ${user}.worker7"; return $pg; } # @@ -138,8 +138,8 @@ function try_reg($page, $menu, $name, $u) # function doreset2($data) { - $user = $data['user']; - $email = $data['email']; + $user = $data['data']['user']; + $email = $data['data']['email']; $emailinfo = getOpts($user, emailOptList()); if ($emailinfo['STATUS'] != 'ok') @@ -154,7 +154,7 @@ function doreset2($data) { // This line $code = isn't an attempt at security - // it's simply to ensure the username is readable when we get it back - $code = bin2hex($data['user']). '_'; + $code = bin2hex($data['data']['user']). '_'; // A code that's large enough to not be worth guessing $ran = $ans['STAMP'].$user.$email.rand(100000000,999999999); diff --git a/pool/page_stats.php b/pool/page_stats.php index 7b27d35c..ede9f6d5 100644 --- a/pool/page_stats.php +++ b/pool/page_stats.php @@ -12,6 +12,50 @@ function dostats($data, $user) { $pg = '

Pool Stats

'; + if (isset($data['info']) && $data['info'] !== false) + { + $info = $data['info']; + $dsp = '?THs'; + $dsp5m = '?THs'; + $dsp1hr = '?THs'; + $dsp24hr = '?THs'; + + if (isset($info['p_hashrate'])) + { + $hr = $info['p_hashrate']; + if ($hr != '?') + $dsp = dsprate($hr); + } + + if (isset($info['p_hashrate5m'])) + { + $hr = $info['p_hashrate5m']; + if ($hr != '?') + $dsp5m = dsprate($hr); + } + + if (isset($info['p_hashrate1hr'])) + { + $hr = $info['p_hashrate1hr']; + if ($hr != '?') + $dsp1hr = dsprate($hr); + } + + if (isset($info['p_hashrate24hr'])) + { + $hr = $info['p_hashrate24hr']; + if ($hr != '?') + $dsp24hr = dsprate($hr); + } + + $pg .= '
'; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= '
Pool Hashrate: $dsp5m: $dsp5m1hr: $dsp1hr24hr: $dsp24hr

'; + } + $ans = getAllUsers($user); $pg .= "\n"; @@ -45,17 +89,7 @@ function dostats($data, $user) if ($uhr == '?') $dsp = '?GHs'; else - { - $uhr /= 10000000; - if ($uhr < 100000) - $rate = 'G'; - else - { - $rate = 'T'; - $uhr /= 1000; - } - $dsp = number_format($uhr/100, 2).$rate.'Hs'; - } + $dsp = dsprate($uhr); $pg .= ""; $pg .= "\n"; } diff --git a/pool/page_workers.php b/pool/page_workers.php index fe007999..3157703d 100644 --- a/pool/page_workers.php +++ b/pool/page_workers.php @@ -82,16 +82,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, else { $totrate += $uhr; - $uhr /= 10000000; - if ($uhr < 0.01) - $uhr = '0GHs'; - else - { - if ($uhr < 100000) - $uhr = number_format(round($uhr)/100,2).'GHs'; - else - $uhr = number_format(round($uhr/1000)/100,2).'THs'; - } + $uhr = dsprate($uhr); } $pg .= ""; @@ -106,16 +97,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff, function worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockacc, $blockreward) { $pg = ''; - $totrate /= 10000000; - if ($totrate < 0.01) - $totrate = '0GHs'; - else - { - if ($totrate < 100000) - $totrate = number_format(round($totrate)/100,2).'GHs'; - else - $totrate = number_format(round($totrate/1000)/100,2).'THs'; - } + $totrate = dsprate($totrate); if (($offset % 2) == 0) $row = 'even'; else diff --git a/src/ckdb.h b/src/ckdb.h index f27fafdc..37fadec1 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.2" -#define CKDB_VERSION DB_VERSION"-0.402" +#define CKDB_VERSION DB_VERSION"-0.405" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index cfc4b8d1..b5abc749 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -9,7 +9,6 @@ #include "ckdb.h" - static char *cmd_adduser(PGconn *conn, char *cmd, char *id, tv_t *now, char *by, char *code, char *inet, __maybe_unused tv_t *notcd, K_TREE *trf_root) @@ -53,7 +52,7 @@ static char *cmd_newpass(__maybe_unused PGconn *conn, char *cmd, char *id, K_ITEM *i_username, *i_oldhash, *i_newhash, *u_item; char reply[1024] = ""; size_t siz = sizeof(reply); - bool ok = false; + bool ok = true; char *oldhash; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -2007,6 +2006,10 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "workers=%s%c", reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(poolstats->hashrate, reply, siz); + snprintf(tmp, sizeof(tmp), "p_hashrate=%s%c", reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(poolstats->hashrate5m, reply, siz); snprintf(tmp, sizeof(tmp), "p_hashrate5m=%s%c", reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -2015,13 +2018,24 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "p_hashrate1hr=%s%c", reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + double_to_buf(poolstats->hashrate24hr, reply, siz); + snprintf(tmp, sizeof(tmp), "p_hashrate24hr=%s%c", reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + bigint_to_buf(poolstats->elapsed, reply, siz); snprintf(tmp, sizeof(tmp), "p_elapsed=%s%c", reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); + + tvs_to_buf(&(poolstats->createdate), reply, siz); + snprintf(tmp, sizeof(tmp), "p_statsdate=%s%c", reply, FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); } else { - snprintf(tmp, sizeof(tmp), "users=?%cworkers=?%cp_hashrate5m=?%c" - "p_hashrate1hr=?%cp_elapsed=?%c", - FLDSEP, FLDSEP, FLDSEP, FLDSEP, FLDSEP); + snprintf(tmp, sizeof(tmp), "users=?%cworkers=?%cp_hashrate=?%c" + "p_hashrate5m=?%cp_hashrate1hr=?%c" + "p_hashrate24hr=?%cp_elapsed=?%c" + "p_statsdate=?%c", + FLDSEP, FLDSEP, FLDSEP, FLDSEP, + FLDSEP, FLDSEP, FLDSEP, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); } @@ -3292,7 +3306,12 @@ static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id, * loglevel.ID * sets the loglevel to atoi(ID) * Without an ID, it just reports the current value + * + * createdate = true + * means that the data sent must contain a fld or json fld called createdate */ + +// cmd_val cmd_str noid createdate func access struct CMDS ckdb_cmds[] = { { CMD_SHUTDOWN, "shutdown", true, false, NULL, ACCESS_SYSTEM }, { CMD_PING, "ping", true, false, NULL, ACCESS_SYSTEM ACCESS_POOL ACCESS_WEB }, diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index b4ad1773..a7f4a2e2 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -4456,6 +4456,7 @@ unparam: return ok; } +// This is to RAM. The summariser calls the DB I/O functions for userstats bool userstats_add(char *poolinstance, char *elapsed, char *username, char *workername, char *hashrate, char *hashrate5m, char *hashrate1hr, char *hashrate24hr, bool idle,
$dsp
$uhr