diff --git a/pool/address.php b/pool/address.php deleted file mode 100644 index 01c840cd..00000000 --- a/pool/address.php +++ /dev/null @@ -1,24 +0,0 @@ - - -CKPool - - diff --git a/pool/base.php b/pool/base.php deleted file mode 100644 index 9afb01e4..00000000 --- a/pool/base.php +++ /dev/null @@ -1,627 +0,0 @@ - 23) - { - $dy = floor($hr / 24); - $hr -= $dy * 24; - if ($dh == true) - { - if ($min >= 30) - { - $hr++; - if ($hr > 23) - { - $dy++; - $hr -= 24; - } - } - $ds = ''; - if ($dy != 1) - $ds = 's'; - if ($hr == 0) - $des = "${dy}day$ds"; - else - { - $hs = ''; - if ($hr != 1) - $hs = 's'; - $des = "${dy}day$ds ${hr}hr$hs"; - } - } - else - $des = $dy.'d '.$hr.'hr '.$min.'m '.$sec.'s'; - } - else - { - if ($dh == true) - { - if ($min >= 30) - $hr++; - $hs = ''; - if ($hr != 1) - $hs = 's'; - $des = "${hr}hr$hs"; - } - else - $des = $hr.'hr '.$min.'m '.$sec.'s'; - } - } - } - return $des; -} -# -function btcfmt($amt) -{ - $amt /= 100000000; - return number_format($amt, 8); -} -# -function utcd($when, $brief = false, $zone = true) -{ - if ($brief) - return gmdate('M‑d H:i:s', round($when)); - else - if ($zone) - return gmdate('Y‑m‑d H:i:s+00', round($when)); - else - return gmdate('Y‑m‑d H:i:s', round($when)); -} -# -global $sipre; -# max of uint64 is ~1.845x10^19, 'Z' is above that (10^21) -# max of uint256 is ~1.158x10^77, which is well above 'Y' (10^24) -$sipre = array('', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'); -# -function siprefmt($amt, $dot = 2) -{ - global $sipre; - - $rnd = pow(10, $dot); - $pref = floor(log10($amt)/3); - if ($pref < 0) - $pref = 0; - if ($pref >= count($sipre)) - $pref = count($sipre)-1; - - $amt = round($rnd * $amt / pow(10, $pref * 3)) / $rnd; - if ($amt > 999.99 && $pref < (count($sipre)-1)) - { - $amt /= 1000; - $pref++; - } - - if ($pref == 0) - $dot = 0; - 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, 3); -} -# -function dspname($name) -{ - if (strlen($name) < 23) - return array(false, htmlspecialchars($name)); - - if (strpbrk($name, '._') === false) - return array(true, htmlspecialchars(substr($name, 0, 20)).'…'); - - $left = htmlspecialchars(substr($name, 0, 17)); - $right = htmlspecialchars(substr($name, -3)); - return array(true, $left.'…'.$right); -} -# -function emailStr($str) -{ - $all = '/[^A-Za-z0-9_+\.@-]/'; // no space = trim - $beg = '/^[\.@+-]+/'; - $fin = '/[\.@+_-]+$/'; - return preg_replace(array($all,$beg,$fin), '', $str); -} -# -function passrequires() -{ - return "Passwords require 6 or more characters, including
" . - "at least one of each uppercase, lowercase and a digit, but not Tab"; -} -# -function safepass($pass) -{ - if (strlen($pass) < 6) - return false; - - # Invalid characters - $p2 = preg_replace('/[\011]/', '', $pass); - if ($p2 != $pass) - return false; - - # At least one lowercase - $p2 = preg_replace('/[a-z]/', '', $pass); - if ($p2 == $pass) - return false; - - # At least one uppercase - $p2 = preg_replace('/[A-Z]/', '', $pass); - if ($p2 == $pass) - return false; - - # At least one digit - $p2 = preg_replace('/[0-9]/', '', $pass); - if ($p2 == $pass) - return false; - - return true; -} -# -# simple test without checksum validation -function btcaddr($addr) -{ - $c0 = substr($addr, 0, 1); - if ($c0 != '1' && $c0 != '3') - return false; - $len = strlen($addr); - if ($len <= 26 || $len >= 37) - return false; - $rem = preg_replace('/[A-HJ-NP-Za-km-z1-9]/', '', $addr); - if (strlen($rem) > 0) - return false; - return true; -} -# -function bademail($email, $isold = false) -{ - if ($email == null || $email == '') - { - if ($isold === false) - return 'Invalid email address'; - else - return 'Invalid email address - you must setup one first'; - } - - $ok = (stripos($email, '@hotmail.') === false && - stripos($email, '@live.') === false && - stripos($email, '@outlook.') === false); - - if ($ok) - return null; - else - { - if ($isold === false) - return "Email from hotmail/live/outlook can't be used"; - else - return 'Email from hotmail/live/outlook no longer works
You must change it first'; - } -} -# -function loginStr($str) -{ - // Anything but . _ / Tab - $all = '/[\._\/\011]/'; - return preg_replace($all, '', $str); -} -# -function deworker($str) -{ - $work = '/[\._].*$/'; - return preg_replace($work, '', $str); -} -# -function trn($str) -{ - $rep = str_replace(array('<', '>'), array('<', '>'), $str); - return $rep; -} -# -function htmler($str) -{ - $srch = array('<','>',"\r\n","\n","\r"); - $rep = array('<','>','
','
','
'); - return str_replace($srch, $rep, $str); -} -# -function cvtdbg() -{ - global $dbg, $dbgstr; - - if ($dbg === false || $dbgstr == '') - $rep = ''; - else - $rep = htmler($dbgstr).'
'; - - return $rep; -} -# -function safeinput($txt, $len = 1024, $lf = true) -{ - $ret = trim($txt); - if ($ret != '') - { - if ($lf === true) - $ret = preg_replace("/[^ -~\r\n]/", '', $ret); - else - $ret = preg_replace('/[^ -~]/', '', $ret); - - if ($len > 0) - $ret = substr($ret, 0, $len); - } - return trim($ret); -} -# -function safetext($txt, $len = 1024) -{ - $tmp = substr($txt, 0, $len); - - $res = ''; - for ($i = 0; $i < strlen($tmp); $i++) - { - $ch = substr($tmp, $i, 1); - if ($ch >= ' ' && $ch <= '~') - $res .= $ch; - else - { - $c = ord($ch); - $res .= sprintf('0x%02x', $c); - } - } - - if (strlen($txt) > $len) - $res .= '...'; - - return $res; -} -# -function isans($ans, $fld) -{ - if (isset($ans[$fld])) - return $ans[$fld]; - else - return ' '; -} -# -function dbd($data, $user) -{ - return "
Database is reloading, mining is all OK
"; -} -# -function dbdown() -{ - gopage(NULL, NULL, 'dbd', 'dbd', def_menu(), '', '', true, false, false); -} -# -function syse($data, $user) -{ - return "
System error
"; -} -# -function syserror() -{ - gopage(NULL, NULL, 'syse', 'syse', def_menu(), '', '', true, false, false); -} -# -function f404($data) -{ - return "
404
"; -} -# -function do404() -{ - gopage(NULL, NULL, 'f404', 'f404', def_menu(), '', '', true, false, false); -} -# -function showPage($info, $page, $menu, $name, $user) -{ -# If you are doing development, use without '@' -# Then switch to '@' when finished -# include_once("page_$page.php"); - @include_once("page_$page.php"); - - $fun = 'show_' . $page; - if (function_exists($fun)) - $fun($info, $page, $menu, $name, $user); - else - do404(); -} -# -function showIndex() -{ - showPage(NULL, 'index', def_menu(), '', false); -} -# -function offline() -{ - if (file_exists('./maintenance.txt')) - { - $ip = $_SERVER['REMOTE_ADDR']; - if ($ip != '192.168.1.666') - gopage(NULL, NULL, file_get_contents('./maintenance.txt'), - 'offline', NULL, '', '', false, false, false); - } -} -# -offline(); -# -session_start(); -# -include_once('db.php'); -# -global $disable_login; -$disable_login = false; -if (file_exists('../pool/disable_login.php')) - include_once('../pool/disable_login.php'); -# -function validUserPass($user, $pass, $twofa) -{ - global $disable_login; - if (function_exists('checklogin')) - checklogin($user); - if ($disable_login == true) - exit(0); - # - $rep = checkPass($user, $pass, $twofa); - if ($rep != null) - $ans = repDecode($rep); - usleep(500000); // Max twice per second - if ($rep != null && $ans['STATUS'] == 'ok') - { - $key = 'ckp'.rand(1000000,9999999); - $_SESSION['ckpkey'] = $key; - $_SESSION[$key] = array('who' => $user, 'id' => $user); - return true; - } - return false; -} -# -function logout() -{ - if (isset($_SESSION['ckpkey'])) - { - $key = $_SESSION['ckpkey']; - - if (isset($_SESSION[$key])) - unset($_SESSION[$key]); - - unset($_SESSION['ckpkey']); - } -} -# -function requestLoginRegReset() -{ - $reg = getparam('Register', true); - $reg2 = getparam('Reset', false); - if ($reg !== NULL || $reg2 !== NULL) - { - logout(); - return true; - } - return false; -} -# -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 validate() -{ - $who = ''; - $whoid = ''; - - if (!isset($_SESSION['ckpkey'])) - return array(false, NULL); - - $key = $_SESSION['ckpkey']; - if (!isset($_SESSION[$key])) - { - logout(); - return array(false, NULL); - } - - if (!isset($_SESSION[$key]['who'])) - { - logout(); - return array(false, NULL); - } - - $who = $_SESSION[$key]['who']; - - if (!isset($_SESSION[$key]['id'])) - { - logout(); - return array(false, NULL); - } - - $whoid = $_SESSION[$key]['id']; - - return array($who, $whoid); -} -# -function loggedIn() -{ - list($who, $whoid) = validate(); - // false if not logged in - return $who; -} -# -function emailcheck($user) -{ - $ans = userSettings($user); - if ($ans['STATUS'] != 'ok') - dbdown(); // Should be no other reason? - if (!isset($ans['email'])) - return 'You need to setup an email address first'; - else - return bademail($ans['email'], true); -} -# -?> diff --git a/pool/db.php b/pool/db.php deleted file mode 100644 index 48280381..00000000 --- a/pool/db.php +++ /dev/null @@ -1,517 +0,0 @@ - 3) - { - $flds = explode($fld_sep, $major[3]); - foreach ($flds as $fld) - { - if (strlen($fld) > 0) - { - $nameval = explode($val_sep, $fld, 2); - if (count($nameval) > 1) - $ans[$nameval[0]] = $nameval[1]; - else - $ans[$nameval[0]] = ''; - } - } - } - - $ans['ID'] = $major[0]; - $ans['STAMP'] = $major[1]; - $ans['STATUS'] = $major[2]; - if ($major[2] == 'ok') - $ans['ERROR'] = null; - else - { - if (isset($major[3])) - $ans['ERROR'] = $major[3]; - else - $ans['ERROR'] = 'system error'; - } - - return $ans; -} -# -function repData($rep) -{ - global $send_sep; - - $fix = preg_replace("/[\n\r]*$/",'',$rep); - $major = explode($send_sep, $fix, 4); - if (count($major) < 3) - return false; - - $ans = array(); - - $ans['ID'] = $major[0]; - $ans['STAMP'] = $major[1]; - $ans['STATUS'] = $major[2]; - $ans['DATA'] = ''; - if ($major[2] == 'ok') - { - $ans['ERROR'] = null; - if (isset($major[3])) - $ans['DATA'] = $major[3]; - } - else - { - if (isset($major[3])) - $ans['ERROR'] = $major[3]; - else - $ans['ERROR'] = 'system error'; - } - - return $ans; -} -# -# Convenience function -function zeip() -{ - return $_SERVER['REMOTE_ADDR']; -} -# -# user administration overrided -function adm($user, &$msg) -{ - global $fld_sep, $val_sep; - if ($user == 'Kano') - { - $admin = getparam('admin', true); - if (!nuem($admin)) - $msg .= $fld_sep . 'admin' . $val_sep . $admin; - } -} -# -function fldEncode($flds, $name, $first) -{ - global $fld_sep, $val_sep; - if ($first) - $rep = ''; - else - $rep = $fld_sep; - $rep .= $name . $val_sep; - if (isset($flds[$name])) - $rep .= $flds[$name]; - return $rep; -} -# -function msgEncode($cmd, $id, $fields, $user) -{ - global $send_sep, $fld_sep, $val_sep; - - $now = time(); - $t = $now % 10000; - $cs = intval(floor(microtime(true) * 100) % 100); - $msg = $cmd . $send_sep . $id.$t.'x'.$cs . $send_sep; - foreach ($fields as $name => $value) - $msg .= $name . $val_sep . $value . $fld_sep; - $msg .= 'createcode' . $val_sep . 'php' . $fld_sep; - $msg .= 'createby' . $val_sep . $user . $fld_sep; - $msg .= 'createinet' . $val_sep . zeip(). $fld_sep; - $msg .= 'webtime' . $val_sep . $now; - adm($user, $msg); - return $msg; -} -# -function getStats($user) -{ - if ($user === null) - $msg = msgEncode('homepage', 'home', array(), $user); - else - $msg = msgEncode('homepage', 'home', array('username'=>$user), $user); - return $msg; -} -# -function homeInfo($user) -{ - $msg = getStats($user); - $rep = sendsockreply('homepage', $msg); - if ($rep === false) - $ans = false; - else - $ans = repDecode($rep); - - return $ans; -} -# -function checkPass($user, $pass, $twofa) -{ - $passhash = myhash($pass); - if (!nuem($twofa)) - $twofa = trim($twofa); - if (nuem($twofa)) - $twofa = 0; - $flds = array('username' => $user, 'passwordhash' => $passhash, - '2fa' => $twofa); - $msg = msgEncode('chkpass', 'chkpass', $flds, $user); - $rep = sendsockreply('checkPass', $msg); - if (!$rep) - dbdown(); - return $rep; -} -# -function setPass($user, $oldpass, $newpass, $twofa) -{ - $oldhash = myhash($oldpass); - $newhash = myhash($newpass); - if (!nuem($twofa)) - $twofa = trim($twofa); - if (nuem($twofa)) - $twofa = 0; - $flds = array('username' => $user, 'oldhash' => $oldhash, - 'newhash' => $newhash, '2fa' => $twofa); - $msg = msgEncode('newpass', 'newpass', $flds, $user); - $rep = sendsockreply('setPass', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function resetPass($user, $newpass, $twofa) -{ - $newhash = myhash($newpass); - if (!nuem($twofa)) - $twofa = trim($twofa); - if (nuem($twofa)) - $twofa = 0; - $flds = array('username' => $user, 'newhash' => $newhash, '2fa' => $twofa); - $msg = msgEncode('newpass', 'newpass', $flds, $user); - $rep = sendsockreply('resetPass', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function get2fa($user, $action, $entropy, $value) -{ - if ($value === null) - $value = ''; - $flds = array('username' => $user, 'action' => $action, - 'entropy' => $entropy, 'value' => $value); - $msg = msgEncode('2fa', '2fa', $flds, $user); - $rep = sendsockreply('get2fa', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function userReg($user, $email, $pass) -{ - $passhash = myhash($pass); - $flds = array('username' => $user, 'emailaddress' => $email, - 'passwordhash' => $passhash); - $msg = msgEncode('adduser', 'reg', $flds, $user); - $rep = sendsockreply('userReg', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -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 workerSet($user, $settings) -{ - $flds = array_merge(array('username' => $user), $settings); - $msg = msgEncode('workerset', 'workerset', $flds, $user); - $rep = sendsockreply('workerSet', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getAllUsers($user) -{ - $flds = array(); - $msg = msgEncode('allusers', 'all', $flds, $user); - $rep = sendsockreply('getAllUsers', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getWorkers($user, $stats = 'Y') -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user, 'stats' => $stats); - $msg = msgEncode('workers', 'work', $flds, $user); - $rep = sendsockreply('getWorkers', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getPercents($user, $stats = 'Y') -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user, 'stats' => $stats, 'percent' => 'Y'); - $msg = msgEncode('workers', 'work', $flds, $user); - $rep = sendsockreply('getPercents', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getPayments($user) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - $msg = msgEncode('payments', 'pay', $flds, $user); - $rep = sendsockreply('getPayments', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getMPayouts($user) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - $msg = msgEncode('mpayouts', 'mp', $flds, $user); - $rep = sendsockreply('getMPayments', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getShifts($user, $workers = null) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - if ($workers !== null) - $flds['select'] = $workers; - $msg = msgEncode('shifts', 'shift', $flds, $user); - $rep = sendsockreply('getShifts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getShiftData($user, $workers = null) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - if ($workers !== null) - $flds['select'] = $workers; - $msg = msgEncode('shifts', 'shift', $flds, $user); - $rep = sendsockreply('getShifts', $msg); - if (!$rep) - dbdown(); - return repData($rep); -} -# -function getPShifts($user) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - $msg = msgEncode('pshift', 'pshift', $flds, $user); - $rep = sendsockreply('getPShifts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getPShiftData($user) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - $msg = msgEncode('pshift', 'pshift', $flds, $user); - $rep = sendsockreply('getPShifts', $msg); - if (!$rep) - dbdown(); - return repData($rep); -} -# -function getBlocks($user) -{ - if ($user == false) - showIndex(); - $flds = array(); - $msg = msgEncode('blocklist', 'blk', $flds, $user); - $rep = sendsockreply('getBlocks', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function getUserInfo($user) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user); - $msg = msgEncode('userinfo', 'usr', $flds, $user); - $rep = sendsockreply('getUserInfo', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -# e.g. $atts = array('ua_Reset.str' => 'FortyTwo', -# 'ua_Reset.date' => 'now+3600') -# 'ua_Tanuki.str' => 'Meme', -# 'ua_Tanuki.date' => 'now'); -function setAtts($user, $atts) -{ - if ($user == false) - showIndex(); - $flds = array_merge(array('username' => $user), $atts); - $msg = msgEncode('setatts', 'setatts', $flds, $user); - $rep = sendsockreply('setAtts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -# e.g. $attlist = 'Reset.str,Reset.dateexp,Tanuki.str,Tanuki.date' -function getAtts($user, $attlist) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user, 'attlist' => $attlist); - $msg = msgEncode('getatts', 'getatts', $flds, $user); - $rep = sendsockreply('getAtts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -# e.g. $attlist = 'Reset,Tanuki' -# effectively makes the useratts disappear (i.e. expired) -function expAtts($user, $attlist) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user, 'attlist' => $attlist); - $msg = msgEncode('expatts', 'expatts', $flds, $user); - $rep = sendsockreply('expAtts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -# e.g. $opts = array('oc_BlockAmountHalf.value' => '25', -# 'oc_BlockAmountHalf.height' => '210000', -# 'oc_BlockAmountHalf.date' => '2012-11-28 15:25:01+00', -# 'oc_BlockAmountQuarter.value' => '12.5', -# 'oc_BlockAmountQuarter.height' => '420000'); -# *.value is always required -function setOpts($user, $opts) -{ - if ($user == false) - showIndex(); - $flds = array_merge(array('username' => $user), $opts); - $msg = msgEncode('setopts', 'setopts', $flds, $user); - $rep = sendsockreply('setOpts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -# e.g. $optlist = 'KWebURL,BlockAmountQuarter' -function getOpts($user, $optlist) -{ - if ($user == false) - showIndex(); - $flds = array('username' => $user, 'optlist' => $optlist); - $msg = msgEncode('getopts', 'getopts', $flds, $user); - $rep = sendsockreply('getOpts', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -function eventCmd($user, $flds) -{ - if ($user == false) - showIndex(); - $msg = msgEncode('events', 'events', $flds, $user); - $rep = sendsockreply('eventCmd', $msg); - if (!$rep) - dbdown(); - return repDecode($rep); -} -# -?> diff --git a/pool/email.php b/pool/email.php deleted file mode 100644 index 1e1d36f2..00000000 --- a/pool/email.php +++ /dev/null @@ -1,261 +0,0 @@ -$eol$eol"; - if ($old != null && $old != '') - { - $message .= "You will no longer receive notifications at the address:$eol <$old>$eol$eol"; - $send = "$to,$old"; - } - else - $send = $to; - $message .= $ret; - - return sendnoheader($send, "EMail Address Change", $message, $emailinfo); -} -# -function passChanged($to, $whoip, $emailinfo) -{ - global $eol; - - if (!isset($emailinfo['KWebURL'])) - return false; - - $web = $emailinfo['KWebURL']; - - $ret = emailEnd('password change', $whoip, $emailinfo); - if ($ret === false) - return false; - - $message = "Your password was changed.$eol$eol"; - $message .= "If you didn't change it, then you need to urgently use$eol"; - $message .= "the password reset at the pool to change it again.$eol$eol"; - $message .= $ret; - - return sendnoheader($to, "Password Change", $message, $emailinfo); -} -# -function twofaSetup($to, $whoip, $emailinfo) -{ - global $eol; - - if (!isset($emailinfo['KWebURL'])) - return false; - - $web = $emailinfo['KWebURL']; - - $ret = emailEnd('2fa change', $whoip, $emailinfo); - if ($ret === false) - return false; - - $message = "2FA is ready to be tested.$eol"; - $message .= "It will be enabled once you test it.$eol$eol"; - $message .= $ret; - - return sendnoheader($to, "2FA is Ready to be Enabled", $message, $emailinfo); -} -# -function twofaEnabled($to, $whoip, $emailinfo) -{ - global $eol; - - if (!isset($emailinfo['KWebURL'])) - return false; - - $web = $emailinfo['KWebURL']; - - $ret = emailEnd('2fa change', $whoip, $emailinfo); - if ($ret === false) - return false; - - $message = "2FA is enabled on your account.$eol$eol"; - $message .= $ret; - - return sendnoheader($to, "2FA is Enabled", $message, $emailinfo); -} -# -function twofaCancel($to, $whoip, $emailinfo) -{ - global $eol; - - if (!isset($emailinfo['KWebURL'])) - return false; - - $web = $emailinfo['KWebURL']; - - $ret = emailEnd('2fa change', $whoip, $emailinfo); - if ($ret === false) - return false; - - $message = "2FA setup was cancelled on your account.$eol"; - $message .= "You can set it up later if you want.$eol$eol"; - $message .= $ret; - - return sendnoheader($to, "2FA was Cancelled", $message, $emailinfo); -} -# -function twofaRemove($to, $whoip, $emailinfo) -{ - global $eol; - - if (!isset($emailinfo['KWebURL'])) - return false; - - $web = $emailinfo['KWebURL']; - - $ret = emailEnd('2fa change', $whoip, $emailinfo); - if ($ret === false) - return false; - - $message = "2FA was removed from your account.$eol"; - $message .= "You can set it up again later if you want.$eol$eol"; - $message .= $ret; - - return sendnoheader($to, "2FA was Removed", $message, $emailinfo); -} -# -# getOpts required for email -# If they aren't all setup in the DB then email functions will return false -function emailOptList() -{ - return 'KWebURL,KNoReply'; -} -# -?> diff --git a/pool/inc.php b/pool/inc.php deleted file mode 100644 index c3fc5ef3..00000000 --- a/pool/inc.php +++ /dev/null @@ -1,163 +0,0 @@ -(zm-0.5)){return(zm-0.5)}return z} -function gchx(c,x){return gch(x*c['xm']+c['xo'],c['ctx'].canvas.width)} -function gchy(c,y){return gch((1-y)*c['ym']+c['yo'],c['ctx'].canvas.height)} -function gx0(c){return -c['xo']/c['xm']} -function gy0(c){return -c['yo']/c['ym']} -function gto(c,xo,yo){c['xo']+=xo;c['yo']+=yo} -function gts(c,xs,ys){c['xm']*=xs;c['ym']*=ys} -function gtso(c,xs,ys){gto(c,c['xm']*(1.0-xs)/2.0,c['ym']*(1.0-ys)/2.0);gts(c,xs,ys)} -function gfs(c,bg){c['ctx'].fillStyle=bg} -function gss(c,fg){c['ctx'].strokeStyle=fg} -function glw(c,w){c['ctx'].lineWidth=w} -function gfz(c,x,y,ox,oy,t,co,a){gfs(c,co);c['ctx'].textAlign=a;c['ctx'].fillText(t,gchx(c,x)+ox,gchy(c,y)-oy)} -function gbe(c,x,y){c['ctx'].beginPath();c['ctx'].moveTo(gchx(c,x),gchy(c,y))} -function gln(c,x,y){c['ctx'].lineTo(gchx(c,x),gchy(c,y))} -function gct(c,x1,y1,x2,y2,x3,y3){c['ctx'].bezierCurveTo(gchx(c,x1),gchy(c,y1),gchx(c,x2),gchy(c,y2),gchx(c,x3),gchy(c,y3))} -function glm(c,x,y){c['ctx'].moveTo(gchx(c,x),gchy(c,y))} -function gle(c){c['ctx'].closePath()} -function gfl(c){c['ctx'].fill()} -function gst(c){c['ctx'].stroke()} -function gfi(c){gle(c);gst(c)} -function gbd(c){gbe(c,0,0);gln(c,1,0);gln(c,1,1);gln(c,0,1);gle(c);gfl(c);gst(c)} -function ggr(c,xs,ys,yt,xn,x0,x1,y0,y1,ar,nx,vx,vy,av,w,cols,ex){if(y0>0){var p=Math.pow(10, Math.floor(Math.log(y0)/Math.LN10)-1);y0=p*Math.floor(y0/p)}var yst=(y1-y0) / 10;var yp=Math.pow(10, Math.floor(Math.log(yst)/Math.LN10)-1);yst=yp * Math.ceil(yst/yp);y1=y0 + (10*yst);gtso(c,xs,ys);if(ex){ex(0,c,xn,x0,x1,y0,y1,ar)}gss(c,'black');glw(c,1.5);gbe(c,0,1);gln(c,0,0);gln(c,1,0);gst(c);glw(c,0.2);var hi=c['ctx'].measureText('M').width, wi=c['ctx'].measureText('0').width;for(var i=0;i<11;i++){var y=i/10.0;gbe(c,-0.01,y);gln(c,1,y);gst(c);var t=''+(((y1-y0)*i/10+y0).toFixed(2));gfz(c,0,y,-wi,0,t,'black','end')}gfz(c,gx0(c),0.55,wi,0,yt,'#0080ff','left');var m=Math.round(0.5+xn/20.0);for(var i=0;i=x0;i-=hrs){var xo=(i-x0)/(x1-x0);if(c['hrs'][c['hr']]<=48){n=dfmt(c,i)}else{n=dfmtm(c,i)}if(xo<=1 && c['tkey'] && ((l%hlv)==0)){gbe(c,xo,0);gln(c,xo,-0.02);gst(c);gfz(c,xo,0,0,-hi*tpos,n,'brown','center')}if(xo<=1 && c['tlines']){gbe(c,xo,0);gln(c,xo,1);gst(c)}l++}}glw(c,1);if(c['smooth']){for(var j=1;j0 && c['lin'+j]){gss(c,'red');var y=(av[j-1]-y0)/(y1-y0);gbe(c,0,y);gln(c,1,y);gst(c);var t=''+av[j-1].toFixed(2)+'av';gfz(c,1,y,1,0,t,cols[j-1],'left')}}if(c['tkey']){var i,dsp;i=c['hrs'][c['hr']];if(i < 24){dsp=''+i+'h'}else{dsp=''+(i/24)+'d'}gfz(c,1,0,c['xo']-c['pxe'],hi,dsp,'red','end');i=c['hln'][c['hl']];gfz(c,1,0,c['xo']-c['pxe'],hi*3,''+i,'red','end')}if(ex){ex(9,c,xn,x0,x1,y0,y1,ar)}} -function sn(i,shi){if(shi.indexOf(' Shift ')<0){return ''+(i%10)}else{return shi.replace(/.* ([a-z])[a-z]*$/,'$1')}} -function gc2(c){var div=document.getElementById('can0');while (div.firstChild){div.removeChild(div.firstChild)}c['can']=document.createElement('canvas');c['can'].id='can';c['xo']=0.0;c['yo']=0.0;c['ctx']=c['can'].getContext('2d');c['ctx'].canvas.width=c['xm']+1;c['ctx'].canvas.height=c['ym']+1;div.appendChild(c['can']);c['pxe']=Math.max(Math.round(c['xm']/250),1)} -function gc(c){c['wx']=window.innerWidth;c['wy']=window.innerHeight;c['xm']=Math.max(Math.round(c['wx']*0.9+0.5),400);c['ym']=Math.max(Math.round(c['wy']*0.8+0.5),400);if(c['ym']>c['xm']){c['ym']=c['xm']}gc2(c)} -function gcxy(c,xm,ym){c['wx']=window.innerWidth;c['wy']=window.innerHeight;c['xm']=Math.min(Math.round(c['wx']*0.95),xm);c['ym']=Math.min(Math.round(c['wy']*0.95),ym);gc2(c)} -function opts(t,i){var e=document.getElementById(i);if(t.checked){e.style.visibility='visible'}else{e.style.visibility='hidden'}} -function ghrs(c){c['hrs']=[1,2,3,4,6,8,12,24,48,168,336,672,1344,2688];c['hln']=[1,2,3,4,6]} -function ghg(c,dx){var tl=dx/(gchx(c,1)/50)/3600;for(var j=c['hrs'].length-1;j>=0;j--){if(tl diff --git a/pool/index.html b/pool/index.html deleted file mode 100644 index 2718071a..00000000 --- a/pool/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - -

Web configuration needs adjustment

- diff --git a/pool/page.php b/pool/page.php deleted file mode 100644 index bf42ccfa..00000000 --- a/pool/page.php +++ /dev/null @@ -1,638 +0,0 @@ -\n"; - - $page_scripts .= $script; - } -} -# -function addCSS($css) -{ - global $page_css; - - $page_css .= $css; -} -# -global $added_gbase; -$added_gbase = false; -function addGBase() -{ - global $added_gbase; - if ($added_gbase == false) - { - $added_gbase = true; - $g = GBaseJS(); - addScript($g); - } -} -# -global $added_tips; -$added_tips = false; -function addTips() -{ - global $added_tips; - if ($added_tips == false) - { - $added_tips = true; - $t = TipsJS(); - addScript($t); - $tcss = TipsCSS(); - addCSS($tcss); - } -} -# -global $added_sort; -$added_sort = false; -function addSort() -{ - global $added_sort; - if ($added_sort == false) - { - $added_sort = true; - $s = SortJS(); - addScript($s); - } -} -# -global $added_qr; -$added_qr = false; -function addQR() -{ - global $added_qr; - if ($added_qr == false) - { - $added_qr = true; - addGBase(); - $q = QRJS(); - addScript($q); - } -} -# -function makeURL($page) -{ - if ($page == null) - $page = ''; - else if ($page != '') - $page = '?k='.$page; - return "/index.php$page"; -} -# -function makeLink($page, $rest = '') -{ - $href = " 0) - $form .= ""; - return $form; -} -# -function dotrm($html, $dontdoit) -{ - if ($dontdoit === true) - return $html; - else - return preg_replace('/ *\n */', '', $html); -} -# -function trm($html) -{ - global $dont_trm; - - return dotrm($html, $dont_trm); -} -# -function trm_force($html) -{ - return dotrm($html, false); -} -# -function pghead($css_marker, $script_marker, $name) -{ - global $page_title; - - $head = "\n"; - - $head .= "$page_title$name"; - $head .= ""; - $head .= ""; - $head .= ""; - - $head .= "\n"; - $head .= "\n"; - - $head .= ''; - - $head .= $script_marker; // where to put the scripts - - $head .= ''; - - return $head; -} -# -function pgtop($alert_marker, $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 = floor($min / 60); - $min -= ($hr * 60); - $plb = $hr.'h'; - if ($min > 0) - $plb .= ' '.$min.'m'; - } - } - } - } - - if (isset($info['lastblockheight'])) - $plb .= ' ('.$info['lastblockheight'].')'; - - if (isset($info['lastbc'])) - { - $nlb = $info['lastbc']; - if ($nlb != '?') - { - $sec = $now - $nlb; - $min = floor($sec / 60); - if ($min > 0) - { - $nlb = $min.'m'; - $s = $sec - ($min * 60); - if ($s > 0) - $nlb .= " ${s}s"; - } - else - $nlb = "${sec}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 .= ' · '; - - $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 = ""; - - $top .= $alert_marker; - if ($loginfailed === true) - $top .= '
Login Failed
'; - if (isset($info['u_nopayaddr'])) - $top .= '
Please set a payout address on your account!
'; - if (isset($info['u_noemail'])) - $top .= '
Please set an email address on your account!
'; - - $top .= '
'; - 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 = ''; - $top .= 'Workers: '; - $top .= ' '.$info['workers'].''; - $top .= ''; - - if ($douser === true) - { - $top .= ''; - } - $top .= ''; - } - else - $top .= ' '; - - $top .= '
'; - return $top; -} -# -function pgmenu($menus) -{ - $ret = "\n"; - $ret .= ''; - $ans = getAllUsers($user); - if ($ans['STATUS'] == 'ok') - { - $count = $ans['rows']; - $title = NULL; - for ($i = 0; $i < $count; $i++) - { - $pg .= workuser($data, $ans['username:'.$i], - $offset, $totshare, $totdiff, - $totshrate, $totinvalid, $totrate, - $blockacc, $blockreward, - 3600, false, false, - $title, $instances); - } - } - $pg .= ''; - $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, - $totrate, $blockacc, $blockreward, $instances); - - $pg .= "
'; - $ret .= ''; - $ret .= ''; - $side = ''; - foreach ($menus as $menu => $submenus) - { - if ($menu == 'Admin' && $submenus == null) - continue; - - if ($menu == 'gap') - { - $side = 'r'; - continue; - } - $ret .= "
\n"; - return $ret; -} -# -function pgbody($alert_marker, $info, $page, $menu, $dotop, $user, $douser) -{ - $body = ' 5000) - $syc = 'hi'; - else - $syc = 'lo'; - $syncd = number_format($sync); - $foot .= "sync: $syncd "; - } - $foot .= 'Copyright © Kano 2014'; - $now = date('Y'); - if ($now != '2014') - $foot .= "-$now"; - $foot .= ' ' . $elapsed_marker; - $foot .= ' '; - $foot .= "\n"; - - return $foot; -} -# -function gopage($info, $data, $pagefun, $page, $menu, $name, $user, $ispage = true, $dotop = true, $douser = true) -{ - global $dbg, $stt; - global $page_css, $page_scripts; - global $alrts; - - $dbg_marker = '[@dbg@]'; - $css_marker = '[@css@]'; - $script_marker = '[@scripts@]'; - $alert_marker = '[@alert@]'; - $elapsed_marker = '[@elapsed@]'; - - if ($dbg === true) - $pg = $dbg_marker.'
'; - else - $pg = ''; - - if ($info === NULL) - $info = homeInfo($user); - - if ($ispage == true) - { - $both = array('info' => $info, 'data' => $data); - $pg .= $pagefun($both, $user); - } - else - $pg .= $pagefun; - -// if (isset($_SESSION['logkey'])) -// unset($_SESSION['logkey']); - - $head = pghead($css_marker, $script_marker, $name); - $body = pgbody($alert_marker, $info, $page, $menu, $dotop, $user, $douser); - $foot = pgfoot($elapsed_marker, $info); - - if ($dbg === true) - $pg = str_replace($dbg_marker, cvtdbg(), $pg); - - $head = str_replace($css_marker, $page_css, $head); - - if ($page_scripts != '') - $page_scripts .= ""; - - $head = str_replace($script_marker, $page_scripts, $head); - - $alertstr = ''; - foreach ($alrts as $str => $num) - $alertstr .= "
$str
"; - $body = str_replace($alert_marker, $alertstr, $body); - - $all = $head; - $all .= trm_force($body); - $all .= trm($pg); - - if (isset($_SERVER["REQUEST_TIME_FLOAT"])) - $elapsed = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; - else - $elapsed = microtime(true) - $stt; - - $foot = trm_force(str_replace($elapsed_marker, number_format($elapsed, 4).'s', $foot)); - - usleep(100000); - - echo $all.$foot; - - exit(0); -} -?> diff --git a/pool/page_2fa.php b/pool/page_2fa.php deleted file mode 100644 index 736b17f8..00000000 --- a/pool/page_2fa.php +++ /dev/null @@ -1,285 +0,0 @@ -"; - $app .= "Android: Google Play 'FreeOTP Authenticator' by Red Hat
"; - $app .= "Apple: App Store 'OTP Auth' by Roland Moers


"; - return $app; -} -# -function app_time() -{ - $app = "Apps to check that your device time is accurate:
"; - $app .= ""; - $app .= "Android: Google Play 'ClockSync' by Sergey Baranov
"; - $app .= "

"; - return $app; -} -# -function set_2fa($data, $user, $tfa, $ans, $err, $msg) -{ - $draw = false; - - $pg = '

Two Factor Authentication Settings

'; - - if ($err !== null and $err != '') - $pg .= "$err

"; - - if ($msg !== null and $msg != '') - $pg .= "$msg

"; - - $pg .= ''; - $pg .= ''; - - $pg .= ''; - - $pg .= '
'; - - $pg .= ''; - $pg .= ''; - break; - case 'test': - $pg .= ''; - $pg .= ''; - $pg .= ''; - break; - case 'ok': - $pg .= ''; - $pg .= ''; - break; - } - $pg .= '
'; - switch ($tfa) - { - case '': - $pg .= '
'; - $pg .= "You don't have Two Factor Authentication (2FA) setup yet

"; - $pg .= 'To use 2FA you need an App on your phone/tablet
'; - $pg .= app_txt('ones'); - $pg .= makeForm('2fa'); - $pg .= 'Click here to begin the setup process for 2FA: '; - $pg .= ''; - $pg .= '
'; - $pg .= '2FA is not yet enabled.
'; - $pg .= 'Your 2FA key has been created but needs testing.

'; - 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 2FA Secret Key is: $key
"; - $pg .= "2FA Settings are $sfainfo

"; - $pg .= "To setup 2FA in your App: Click here
"; - $pg .= "or scan the qrcode/barcode below with your App:

"; - $pg .= '
'; - $pg .= 'A qrcode will show here if your browser supports html5/canvas'; - $pg .= "

"; - $pg .= makeForm('2fa'); - $pg .= 'Then enter your App 2FA Value: '; - $pg .= '
'; - $pg .= 'The 2FA Value is always a 6 digit number
'; - $pg .= app_txt('2FA apps'); - $pg .= 'N.B. if you wish to setup 2FA on more than one device,
'; - $pg .= 'you should setup all devices before testing one of them.
'; - $pg .= 'If you have an old 2FA Secret Key in your device for this web site,
'; - $pg .= 'delete it before scanning in the new 2FA Secret Key.

'; - $pg .= 'WARNING: if you lose your 2FA device you will need to know
'; - $pg .= 'the 2FA Secret Key to manually setup a new device,
'; - $pg .= 'so your should copy it and store it somewhere securely.
'; - $pg .= 'For security reasons, the site will not show you an active 2FA Secret Key.
'; - $pg .= '
'; - $pg .= makeForm('2fa'); - $pg .= '
If you wish to cancel setting up 2FA, click here: '; - $pg .= '
'; - $pg .= '2FA is enabled on your account.

'; - $pg .= 'If you wish to replace your Secret Key with a new one:

'; - $pg .= makeForm('2fa'); - $pg .= 'Current 2FA Value: '; - $pg .= '*'; - $pg .= '

'; - $pg .= '*WARNING: replacing the Secret Key will disable 2FA
'; - $pg .= 'until you successfully test the new key,
'; - $pg .= 'thus getting a new key is effectively the same as disabling 2FA.

'; - $pg .= '
'; - $pg .= makeForm('2fa'); - $pg .= 'If you wish to remove 2FA from your account,
'; - $pg .= 'enter your App 2FA Value:
'; - $pg .= 'then click remove: '; - $pg .= '
'; - $pg .= '
'; - $pg .= '2FA means that you need 2 codes to login to your account.
'; - $pg .= 'You will also need the 2FA code to modify any important settings in your account.
'; - $pg .= 'The 1st code is your current password.
'; - $pg .= 'The 2nd code is a number that your 2FA device will generate each time.
'; - $pg .= 'Your 2FA device would be, for example, your phone or tablet.

'; - $pg .= 'Each time you need a 2FA code, you use your device to generate a number
'; - $pg .= 'that you type into the "*2nd Authentication:" field on any page that has it.

'; - $pg .= 'IMPORTANT: the TOTP algorithm uses the time on your device,
'; - $pg .= "so it is important that your device's clock is accurate within a few seconds.

"; - $pg .= app_time(); - $pg .= 'IMPORTANT: you enter the value from your App at the time you submit data.
'; - $pg .= "The value is valid only once for a maximum of 30 seconds.
"; - $pg .= "In both the Apps it has a 'dial' that shows the 30 seconds running out.
"; - $pg .= "If you are close to running out, you can wait for the 30 seconds to run out
"; - $pg .= "and then enter the new value it will come up with.
"; - $pg .= "The pool checks your value using the time at the pool when you submit the data,
"; - $pg .= "it doesn't matter when you loaded the web page,
"; - $pg .= "it only matters when you clicked on the web page button to send the data to the pool.

"; - $pg .= 'WARNING: once you have successfully tested and enabled 2FA,
'; - $pg .= 'you will be unable to access or even reset your account without 2FA.
'; - $pg .= 'There is no option to recover your 2FA from the web site,
'; - $pg .= 'and you must know your 2FA code in order to be able to disable 2FA.

'; - $pg .= 'WARNING: it is important to not store your login password in your 2FA device.
'; - $pg .= 'These 2 together will give full access to your account.'; - $pg .= '
'; - - if ($draw !== false) - { - $qr = shell_exec("../pool/myqr.sh '$sfaurl'"); - if ($qr !== null and strlen($qr) > 30) - { - $pg .= "\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; -} -# -function do2fa($data, $user) -{ - $mailmode = ''; - $tfa = null; - $err = ''; - $msg = ''; - $res = emailcheck($user); - if ($res != null) - { - $msg = $res; - $ans = get2fa($user, '', 0, 0); - goto skipo; - } - $setup = getparam('Setup', false); - if ($setup === 'Setup') - { - // rand() included as part of the entropy - $ans = get2fa($user, 'setup', rand(1073741824,2147483647), 0); - $mailmode = 'Setup'; - } - else - { - $can = getparam('Cancel', false); - if ($can === 'Cancel') - { - $ans = get2fa($user, 'untest', 0, 0); - $mailmode = 'Cancel'; - } - else - { - $value = getparam('Value', false); - $test = getparam('Test', false); - if ($test === 'Test' and $value !== null) - { - $ans = get2fa($user, 'test', 0, $value); - $mailmode = 'Test'; - } - else - { - $nw = getparam('New', false); - if ($nw === 'New' and $value !== null) - { - $ans = get2fa($user, 'new', rand(1073741824,2147483647), $value); - $mailmode = 'New'; - } - else - { - $rem = getparam('Remove', false); - if ($rem === 'Remove' and $value !== null) - { - $ans = get2fa($user, 'remove', 0, $value); - $mailmode = 'Remove'; - } - else - $ans = get2fa($user, '', 0, 0); - } - } - } - } -skipo: - if ($ans['STATUS'] != 'ok') - $err = 'DBERR'; - else - { - if (isset($ans['2fa_error'])) - $err = $ans['2fa_error']; - - if ($mailmode != '' and $err == '') - { - $ans2 = userSettings($user); - if ($ans2['STATUS'] != 'ok') - dbdown(); // Should be no other reason? - if (!isset($ans2['email'])) - $err = 'An error occurred, check your details below'; - else - { - $email = $ans2['email']; - $emailinfo = getOpts($user, emailOptList()); - if ($emailinfo['STATUS'] != 'ok') - $err = 'An error occurred, check your details below'; - else - { - if ($mailmode === 'Setup') - twofaSetup($email, zeip(), $emailinfo); - else if ($mailmode === 'Test') - twofaEnabled($email, zeip(), $emailinfo); - else if ($mailmode === 'New') - twofaSetup($email, zeip(), $emailinfo); - else if ($mailmode === 'Cancel') - twofaCancel($email, zeip(), $emailinfo); - else if ($mailmode === 'Remove') - twofaRemove($email, zeip(), $emailinfo); - } - } - } - } - if (isset($ans['2fa_status'])) - $tfa = $ans['2fa_status']; - if ($msg == '' && isset($ans['2fa_msg'])) - $msg = $ans['2fa_msg']; - - $pg = set_2fa($data, $user, $tfa, $ans, $err, $msg); - return $pg; -} -# -function show_2fa($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'do2fa', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_addrmgt.php b/pool/page_addrmgt.php deleted file mode 100644 index 28222660..00000000 --- a/pool/page_addrmgt.php +++ /dev/null @@ -1,207 +0,0 @@ -Address Management'; - - if ($err != '') - $pg .= "$err

"; - - $pg .= makeForm('addrmgt'); - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - - # new row template for '+' - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - $ans = userSettings($user); - - $offset = 0; - $count = 0; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - 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 .= ""; - $addr = $ans['addr:'.$i]; - $pg .= ''; - $pg .= ''; - $nam = htmlspecialchars($ans['payname:'.$i]); - $pg .= ''; - $ratio = intval($ans['ratio:'.$i]); - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - $offset++; - } - if ($offset < $limit) { - if ((($offset++) % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - $pg .= ""; - } - - $pg .= ''; - if ((($offset++) % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - - if ((($offset++) % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - - $pg .= ''; - } - $pg .= "
#AddressIDRatio%
'; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= "0.00%"; - $pg .= '
'.($i+1).''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= "%"; - $pg .= '
"; - $pg .= ""; - $pg .= "limit $limit
 Password: 
 *2nd Authentication:'; - $pg .= '  
'; - $pg .= "*Leave blank if you haven't enabled it
"; - $pg .= 'You must enter your password to save changes
'; - $pg .= 'A ratio of 0, will remove the address from the payouts
\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 .= ""; - - return $pg; -} -# -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' => trim($addr), 'payname' => trim($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 .= '
'; - $err .= 'An error occurred, check your details below'; - } - - $pg = addrmgtuser($data, $user, $err); - - return $pg; -} -# -function show_addrmgt($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doaddrmgt', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_allwork.php b/pool/page_allwork.php deleted file mode 100644 index 4f62f706..00000000 --- a/pool/page_allwork.php +++ /dev/null @@ -1,52 +0,0 @@ -All Workers'; - - $pg .= worktable(); - - $totshare = 0; - $totdiff = 0; - $totshrate = 0; - $totinvalid = 0; - $totrate = 0; - $offset = 0; - $blockacc = 0; - $blockreward = 0; - $instances = 0; - - $pg .= worktitle($data, $user); - $pg .= '
\n"; - - return $pg; -} -# -function show_allwork($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doallwork', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_api.php b/pool/page_api.php deleted file mode 100644 index bd92055b..00000000 --- a/pool/page_api.php +++ /dev/null @@ -1,102 +0,0 @@ - diff --git a/pool/page_blocks.php b/pool/page_blocks.php deleted file mode 100644 index f6b59547..00000000 --- a/pool/page_blocks.php +++ /dev/null @@ -1,554 +0,0 @@ - 255) - $grn = 255; - - if ($grn > 190) - $fg = 'blue'; - else - $fg = 'white'; - $bg = sprintf("#00%02x00", $grn); - } - else # ($erl > 0.5) - { - $red = (-0.3 - log10(1.0 - $erl)) * 255; - if ($red < 0) - $red = 0; - if ($red > 255) - $red = 255; - - $fg = 'white'; - $bg = sprintf("#%02x0000", $red); - } - - return array($fg, $bg); -} -# -function pctcolour($pct) -{ - if ($pct == 100) - { - $fg = 'white'; - $bg = 'black'; - } - - if ($pct < 100) - { - $grn = (2.0 - log10($pct)) * 255; - if ($grn < 0) - $grn = 0; - if ($grn > 255) - $grn = 255; - - if ($grn > 190) - $fg = 'blue'; - else - $fg = 'white'; - $bg = sprintf("#00%02x00", $grn); - } - - if ($pct > 100) - { - $red = (log10(pow($pct,4.0)) - 8.0) / 3.0 * 255; - if ($red < 0) - $red = 0; - if ($red > 255) - $red = 255; - - $fg = 'white'; - $bg = sprintf("#%02x0000", $red); - } - - return array($fg, $bg); -} -# -function mthcolour($luck) -{ - if ($luck == 1.0) - { - $fg = 'white'; - $bg = 'black'; - } - else if ($luck > 1.0) - { - // 1.0 .. 1.1 (> 1.1 = max) - $grn = ($luck - 1.0) * 2550.0; - if ($grn > 255) - $grn = 255; - if ($grn < 0) - $grn = 0; - if ($grn > 190) - $fg = 'blue'; - else - $fg = 'white'; - $bg = sprintf("#00%02x00", $grn); - } - else - { - // 0.9 .. 1.0 (< 0.9 = max) - $red = (1.0 - $luck) * 2550.0; - if ($red > 255) - $red = 255; - if ($red < 0) - $red = 0; - $fg = 'white'; - $bg = sprintf("#%02x0000", $red); - } - return array($fg, $bg); -} -# -function statstable($poolfee, $ans, $data) -{ - if ($ans['STATUS'] != 'ok' or !isset($ans['s_rows']) or $ans['s_rows'] < 1) - return ''; - - $pg = '

Block Statistics

'; - $pg .= "\n"; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - - $tt = ""; - $tt .= '?'; - $tt .= ""; - $tt .= "Pool PPS%: MeanTx% * Luck% minus the pool fee"; - - $pg .= ""; - $pg .= "\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 = "".number_format($cdferl, 4).''; - $bg = " bgcolor=$bg"; - - $luck = number_format(100 * $ans['s_luck:'.$i], 2); - $txm = number_format(100 * $ans['s_txmean:'.$i], 1); - - $o = number_format((100 - $poolfee) * $ans['s_txmean:'.$i] / $ans['s_diffmean:'.$i], 2); - - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= "\n"; - } - $pg .= "
DescriptionTimeMeanTx%Diff%Mean%CDF[Erl]Luck%${tt}PPS%
$desc Blocks$age$txm%$diff%$mean%$cdferldsp$luck%$o%
\n"; - return $pg; -} -# -function monthtable($poolfee, $ans, $limit) -{ - if ($ans['STATUS'] != 'ok' or !isset($ans['rows']) or $ans['rows'] < 1) - return ''; - - $nowmon = intval(gmdate('n', $ans['STAMP'])); - $nowyyyy = intval(gmdate('Y', $ans['STAMP'])); - - $pg = '

Monthly Statistics

'; - $pg .= "\n"; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= "\n"; - - $pg .= ''; - $count = $ans['rows']; - $rout = $bcount = $bcd = $bmon = $byyyy = $bdiffacc = $bdiffratio = $btxn = 0; - $skipped = false; - for ($i = 0; $i < $count; $i++) - { - $conf = $ans['confirmed:'.$i]; - // Skip leading orphans - if (!$skipped && ($conf == 'O' || $conf == 'R')) - continue; - - $skipped = true; - - // If anything is missing, skip this table - $diffratio = $ans['diffratio:'.$i]; - if ($diffratio == '?') - break; - - $cd = $ans['firstcreatedate:'.$i]; - $mon = intval(gmdate('n', $cd)); - $yyyy = intval(gmdate('Y', $cd)); - // all orphans after a block must be included with that block - if (($conf != 'O' && $conf != 'R') - && ($mon != $bmon || $yyyy != $byyyy)) - { - if ($bcount != 0) - { - if (($rout % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - if ($bmon == $nowmon && $byyyy == $nowyyyy) - $dots = '…'; - else - $dots = ''; - - $elap = $bcd - $cd; - $phr = ($bdiffacc / $elap) * pow(2, 32); - $phrdsp = siprefmt($phr); - - $name = gmdate('Y M', $bcd); - $exc = number_format($bdiffratio, 2); - if ($bdiffratio > $bcount) - $bcol = 'darkred'; - else - $bcol = 'darkgreen'; - $md = number_format(100 * $bdiffratio / $bcount, 2); - $mr = number_format(100 * $btxn / $bcount, 2); - $ml = $bcount / $bdiffratio; - $mldsp = number_format(100 * $ml, 2); - $oa = (100 - $poolfee) * ($bcount / $bdiffratio) * ($btxn / $bcount); - $odsp = number_format($oa, 2); - list($fg, $bg) = mthcolour($ml); - - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= "\n"; - - $rout++; - } - if ($rout > $limit) - break; - - $bcd = $cd; - $bmon = $mon; - $byyyy = $yyyy; - $bcount = $bdiffacc = $bdiffratio = $btxn = 0; - } - $bdiffratio += floatval($ans['diffratio:'.$i]); - $bdiffacc += floatval($ans['diffacc:'.$i]); - - if ($conf != 'O' and $conf != 'R') - { - $height = $ans['height:'.$i]; - $reward = floatval($ans['reward:'.$i]); - $re = 5000000000.0 * pow(0.5, floor($height / 210000.0)); - $btxn += $reward / $re; - $bcount++; - } - } - $pg .= '
UTC MonthPool AvgBlocksExpectedMean Diff%MeanTx%Luck%PPS%
$name$dots${phrdsp}Hs$bcount$exc$md%$mr%$mldsp%$odsp%
'; - - return $pg; -} -# -function doblocks($data, $user) -{ - $blink = '
= 0; $i--) - { - $conf = $ans['confirmed:'.$i]; - $diffratio = $ans['diffratio:'.$i]; - if ($diffratio > 0) - { - $colpct += 100.0 * $diffratio; - $ans['colpct:'.$i] = $colpct; - if ($conf != 'O' and $conf != 'R') - $colpct = 0; - } - } - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $hi = $ans['height:'.$i]; - $hifld = "$blink$hi>$hi"; - - $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
'; - $tip .= 'so we tested it,
'; - $tip .= "but it wasn't worthy
"; - } - else - $tip = str_replace('+', '
', trim($in[1])); - - $tt = ""; - $tt .= '?'; - $tt .= ""; - $tt .= "$tip"; - } - } - 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 = '*'; - - 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]; - $hist = $ans['luckhistory:'.$i]; - - if ($diffratio > 0) - { - $pct = 100.0 * $diffratio; - $colpct = $ans['colpct:'.$i]; - if ($conf != 'O' and $conf != 'R') - { - list($fg, $bg) = pctcolour($colpct); - $bpct = "$approx".number_format($pct, 3).'%'; - $bg = " bgcolor=$bg"; - $histdsp = "$approx".number_format(100.0 * $hist, 2).'%'; - } - else - { - $bpct = "$approx".number_format($pct, 3).'%'; - $bg = ''; - $histdsp = ' '; - } - $blktot += $diffacc; - if ($conf != 'O' and $conf != 'R') - $nettot += $netdiff; - - $cdfdsp = number_format($cdf, 3); - } - else - { - $bg = ''; - $bpct = '?'; - $cdfdsp = '?'; - $histdsp = '?'; - } - - if ($wantcsv === false) - { - $pg .= ""; - $pg .= "$seq"; - $pg .= "$hifld"; - if ($user !== null) - { - list($abr, $nam) = dspname($ans['workername:'.$i]); - $pg .= "$nam"; - } - $pg .= "".btcfmt($ans['reward:'.$i]).''; - $pg .= "".utcd($ans['firstcreatedate:'.$i], false, false).''; - $pg .= "$tt$stat"; - $pg .= "$stara$approx$acc"; - $pg .= "$bpct"; - $pg .= "$cdfdsp"; - $pg .= "$histdsp"; - $pg .= "$nn"; - $pg .= "\n"; - } - else - { - $csv .= "$seq,"; - $csv .= "$hi,"; - $csv .= "\"$stat\","; - $csv .= $ans['firstcreatedate:'.$i].','; - $csv .= "$diffacc,"; - $csv .= "$netdiff,"; - $csv .= $ans['blockhash:'.$i]."\n"; - } - } - $pg .= ''; - } - if ($wantcsv === true) - { - echo $csv; - exit(0); - } - if ($orph === true) - { - $pg .= ' diff --git a/pool/page_ckp.php b/pool/page_ckp.php deleted file mode 100644 index 769d0d60..00000000 --- a/pool/page_ckp.php +++ /dev/null @@ -1,78 +0,0 @@ - 99999999) - $b4 = ''; - else if ($num > 9999999) - $b4 = ''; - if ($b4 != '') - $af = ''; - return $b4.$fmt.$af; -} -# -function dockp($data, $user) -{ - $pg = '

CKDB

'; - - $msg = msgEncode('stats', 'stats', array(), $user); - $rep = sendsockreply('stats', $msg); - if ($rep == false) - $ans = array(); - else - $ans = repDecode($rep); - - addSort(); - $r = "input type=radio name=srt onclick=\"sott('ckpsrt',this);\""; - $pg .= 'TotalRAM: '.stnum($ans['totalram']).'
'; - $pg .= "\n"; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= "\n"; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= "'; - $pg .= ''; - $pg .= "'; - $pg .= "'; - $pg .= "'; - $pg .= "'; - $pg .= "'; - $pg .= "'; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
Name:<$r id=srtname data-sf=s0>Initial<$r id=srtalloc data-sf=r2>:Alloc<$r id=srtstore data-sf=r3>:In Store<$r id=srtram data-sf=r4>:RAM<$r id=srtram2 data-sf=r5>:RAM2<$r id=srtcull data-sf=r6>:Cull<$r id=srtlim data-sf=r7>:Limit
".$ans['name:'.$i].''.stnum($ans['initial:'.$i]).'".stnum($ans['allocated:'.$i]).'".stnum($ans['instore:'.$i]).'".stnum($ans['ram:'.$i]).'".stnum($ans['ram2:'.$i]).'".stnum($ans['cull:'.$i]).'".stnum($ans['cull_limit:'.$i]).'
\n"; - $pg .= "\n"; - - return $pg; -} -# -function show_ckp($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dockp', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_events.php b/pool/page_events.php deleted file mode 100644 index 97f109e8..00000000 --- a/pool/page_events.php +++ /dev/null @@ -1,210 +0,0 @@ -Event Information'; - - $wh = getparam('what', false); - if (nuem($wh)) - $wh = ''; - - $pg = '
'.makeForm('events')." -What: -"; - - if ($wh == 'settings') - { - $ans = eventCmd($user, array('action' => 'settings')); - - $other = array('event_limits_hash_lifetime', - 'ovent_limits_ipc_factor'); - - $pg .= "

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $i = 0; - foreach ($other as $name) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $i++; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
#NameValue
$i$name'.$ans[$name].'
\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 .= "

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - foreach ($flds as $row => $nam) - $pg .= ""; - $pg .= "\n"; - - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $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 .= ""; - $pg .= ""; - $pg .= ""; - foreach ($flds as $fld => $nam) - $pg .= ''; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
#Name$nam
$i$name'.$ans[$name.'_'.$fld].'
\n"; - } - - if ($wh == 'all' || $wh == 'user' || $wh == 'ip' || $wh == 'ipc' || $wh == 'hash') - { - $ans = eventCmd($user, array('action' => 'events', 'list' => $wh)); - - $pg .= "

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $j = $i+1; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
#ListIDIDNameUserIPIPcHashUTC
$j'.$ans['list:'.$i].''.$ans['id:'.$i].''.$ans['idname:'.$i].''.$ans['user:'.$i].''.isans($ans, 'ip:'.$i).''.isans($ans, 'ipc:'.$i).''.isans($ans, 'hash:'.$i).''.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'
\n"; - } - - if ($wh == 'ovents') - { - $ans = eventCmd($user, array('action' => 'ovents')); - - $pg .= "

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $j = $i+1; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $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 .= ""; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
#KeyIDIDNameHour UTCCount
$j'.$ans['key:'.$i].''.$ans['id:'.$i].''.$ans['idname:'.$i].''.gmdate('j/M H:i:s',$ans['hour:'.$i]*3600).'$co
\n"; - } - - return $pg; -} -# -function show_events($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doevents', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_help.php b/pool/page_help.php deleted file mode 100644 index 2ed74e87..00000000 --- a/pool/page_help.php +++ /dev/null @@ -1,13 +0,0 @@ -HelplessHelpless'; -} -# -function show_help($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dohelp', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_index.php b/pool/page_index.php deleted file mode 100644 index 106d0402..00000000 --- a/pool/page_index.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/pool/page_ips.php b/pool/page_ips.php deleted file mode 100644 index 00b42c98..00000000 --- a/pool/page_ips.php +++ /dev/null @@ -1,74 +0,0 @@ -Event IP Information'; - - $ans = eventCmd($user, array('action' => 'ips')); - - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - if ($ans['STATUS'] == 'ok') - { - $now = $ans['STAMP']; - $pg .= ''; - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $j = $i+1; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $exp = $ans['lifetime:'.$i]; - if ($exp == 0) - $dxp = '∞'; - else - { - $exp += $ans['createdate:'.$i]; - if ($exp <= $now) - $dxp = 'Exp'; - else - { - $exp -= $now; - $dxp = $exp . 's'; - } - } - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
#GroupIPNameIs?LifetimeLeftLogDescUTC
$j'.$ans['group:'.$i].''.$ans['ip:'.$i].''.$ans['eventname:'.$i].''.$ans['is_event:'.$i].''.$ans['lifetime:'.$i].''.$dxp.''.$ans['log:'.$i].''.$ans['description:'.$i].''.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'
\n"; - - return $pg; -} -# -function show_ips($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doips', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_luck.php b/pool/page_luck.php deleted file mode 100644 index 19a932fd..00000000 --- a/pool/page_luck.php +++ /dev/null @@ -1,197 +0,0 @@ -s){xmin=s}if(xmaxymax)ymax=lk} -} -if(ymax>500){ymax=500} -ghg(c,xmax-xmin); -ggr(c,0.90,0.90,'Luck%',rows,xmin,xmax,ymin,ymax,d,'seq:','vx:','luck:',tlk,w,cols,null)} -c={}; -function dodrw(data,cbx){if(hasCan()){gdrw(c,sep(data),cbx)}} -function gact(t){if(t.checked){scnv(t.id,1)}else{scnv(t.id,0)}godrw(0)}"; -return $g; -} -# -function doluck($data, $user) -{ - global $fld_sep, $val_sep; - - if ($user === null) - $ans = getBlocks('Anon'); - else - $ans = getBlocks($user); - - $pg = '

Pool Avg Block Luck History


'; - - if ($ans['STATUS'] == 'ok' and isset($ans['rows']) and $ans['rows'] > 0) - { - $count = $ans['s_rows'] - 1; - $av = number_format(100 * $ans['s_luck:'.$count], 3); - - for ($i = 0; $i < $count; $i++) - // This also defines how many lines there are - $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); - $nams = array(1, 5, 15, 25); - $nc = count($cols); - - addGBase(); - $cbx = array('skey' => 'block key', 'slines' => 'block lines', - 'tkey' => 'time key', 'tlines' => 'time lines', - 'over' => 'key overlap', 'smooth' => 'smooth', - 'utc' => 'utc'); - $xon = array('skey' => 1, 'tkey' => 1, 'tlines' => 1, 'utc' => 1); - - $pg .= '
'; - foreach ($cbx as $nam => $txt) - { - $pg .= ' '; - $pg .= ""; - $pg .= "$txt "; - } - $pg .= '
'; - - $i = 1; - $datacols = ''; - foreach ($cols as $col) - { - if ($i != 1) - $pg .= '  '; - if ($i == 2 || $i == 4) - $chk = ' checked'; - else - $chk = ''; - $pg .= ""; - $pg .= ": "; - if ($nams[$i-1] == 1) - $avs = ''; - else - $avs = ' Avg'; - $pg .= $nams[$i-1]." Block Luck$avs"; - - if ($i > 1) - $datacols .= ','; - $datacols .= $col; - $i++; - } - - $pg .= '
'; - $pg .= '
'; - $pg .= 'A graph will show here if your browser supports html5/canvas'; - $pg .= "
\n"; - - $count = $ans['rows']; - # add the orphan/reject ratios to the subsequent blocks - $dr = 0; - for ($i = $count-1; $i >= 0; $i--) - { - $conf = $ans["confirmed:$i"]; - if ($conf == '1' or $conf == 'F') - { - $ans["diffratio:$i"] += $dr; - $dr = 0; - } - else - $dr += $ans["diffratio:$i"]; - } - - # $ans blocks are 0->rows-1 highest->lowest - # build an array of valid block offsets (reversed lowest->highest) - $off = array(); - for ($i = $count-1; $i >= 0; $i--) - { - $conf = $ans["confirmed:$i"]; - if ($conf == '1' or $conf == 'F') - $off[] = $i; - } - - $data = ''; - $count = count($off); - $avg = 0; - # each valid block offset number (lowest->highest) - for ($j = 0; $j < $count; $j++) - { - $i = $off[$j]; - - $data .= $fld_sep . "height:$j$val_sep"; - $data .= $ans["height:$i"]; - $data .= $fld_sep . "seq:$j$val_sep"; - $data .= $ans["seq:$i"]; - $data .= $fld_sep . "firstcreatedate:$j$val_sep"; - $data .= $ans["firstcreatedate:$i"]; - $data .= $fld_sep . "0_luck:$j$val_sep"; - $data .= number_format(100 * $ans['luck:'.$i], 3); - - $avg += $ans["diffratio:$i"]; - - $l5c = $l15c = $l25c = 1; - $l5 = $l15 = $l25 = $ans['diffratio:'.$i]; - - # +/- offset from j (12 is the max for 25) - for ($k = 1; $k <= 12; $k++) - { - # we want the (n-1)/2 on each side of the offset number - foreach (array(-1, 1) as $s) - { - $o = $j + ($s * $k); - if (0 <= $o && $o < $count) - { - $dr = $ans['diffratio:'.$off[$o]]; - if ($k <= 2) # (5-1)/2 - { - $l5 += $dr; - $l5c++; - } - if ($k < 7) # (15-1)/2 - { - $l15 += $dr; - $l15c++; - } - $l25 += $dr; - $l25c++; - } - } - } - # luck is 1/(mean diffratio) - $data .= $fld_sep . "1_luck:$j$val_sep"; - $data .= number_format(100 * $l5c / $l5, 3); - $data .= $fld_sep . "2_luck:$j$val_sep"; - $data .= number_format(100 * $l15c / $l15, 3); - $data .= $fld_sep . "3_luck:$j$val_sep"; - $data .= number_format(100 * $l25c / $l25, 3); - } - $data .= $fld_sep . 'rows' . $val_sep . $count; - $data .= $fld_sep . 'arp' . $val_sep . ',0_,1_,2_,3_'; - $data .= $fld_sep . 'cols' . $val_sep . $datacols; - - $pg .= "\n"; - } - - return $pg; -} -# -function show_luck($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doluck', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_mpayouts.php b/pool/page_mpayouts.php deleted file mode 100644 index 9bd335c2..00000000 --- a/pool/page_mpayouts.php +++ /dev/null @@ -1,85 +0,0 @@ -Mining Rewards'; - - $ans = getMPayouts($user); - - $pg .= "The rewards you've earned for each block the pool has found.
"; - $pg .= 'See the '; - $pg .= makeLink('payments'); - $pg .= "Payments page for the payments you've been sent.

"; - - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $totamt = 0; - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $diffused = $ans['diffused:'.$i]; - $pg .= ''; - $elapsed = $ans['elapsed:'.$i]; - $pg .= ''; - $phr = $diffused * pow(2,32) / $elapsed; - $pg .= ''; - $diffacc = $ans['diffacc:'.$i]; - $ypct = $diffacc * 100 / $diffused; - $pg .= ''; - $pg .= ''; - $hr = $diffacc * pow(2,32) / $elapsed; - $pg .= ''; - $amount = $ans['amount:'.$i]; - $totamt += $amount; - $pg .= ''; - $pg .= "\n"; - } - $pg .= ''; - if ($count > 1) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - } - } - $pg .= "
BlockBlock UTCMiner RewardN DiffN RangePool N AvgYour %Your N DiffYour N AvgYour BTC
'.$ans['height:'.$i].''.gmdate('j/M H:i',$ans['blockcreatedate:'.$i]).''.btcfmt($ans['minerreward:'.$i]).''.difffmt($diffused).''.howmanyhrs($elapsed).''.siprefmt($phr).'Hs'.number_format($ypct, 2).'%'.difffmt($diffacc).''.dsprate($hr).''.btcfmt($amount).'
Total:'.btcfmt($totamt).'
\n"; - - return $pg; -} -# -function show_mpayouts($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dompayouts', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_payments.php b/pool/page_payments.php deleted file mode 100644 index 3a8adb53..00000000 --- a/pool/page_payments.php +++ /dev/null @@ -1,95 +0,0 @@ -Payments'; - $pg .= "The payment transactions on $btcn are here:"; - $pg .= " BTCa,"; - $pg .= " BTCb,"; - $pg .= " BTCc,"; - $pg .= " BTCd and"; - $pg .= " BTCe
"; - $pg .= "The payments below don't yet show when they have been sent.
"; - $pg .= "Dust payments below 0.00010000 BTC are not sent out yet.

"; - - $ans = getPayments($user); - - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $all = array(); - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - $all[] = array('payoutid' => $ans['payoutid:'.$i], - 'height' => $ans['height:'.$i], - 'payaddress' => $ans['payaddress:'.$i], - 'amount' => $ans['amount:'.$i], - 'paydate' => $ans['paydate:'.$i]); - } - usort($all, 'sortheight'); - $hasdust = false; - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $amount = $all[$i]['amount']; - if ($amount < '10000') - { - $dust = '*'; - $hasdust = true; - } - else - $dust = ' '; - $pg .= ''; - $pg .= ""; - $pg .= "\n"; - } - $pg .= ''; - if ($hasdust === true) - { - $pg .= ''; - } - } - $pg .= "
BlockAddressStatusBTC
'.$all[$i]['height'].''.$all[$i]['payaddress'].' '.btcfmt($amount).'$dust
'; - $pg .= '* '; - $pg .= 'Dust payments are not automatically sent out'; - $pg .= '
\n"; - - return $pg; -} -# -function show_payments($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopayments', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_payout.php b/pool/page_payout.php deleted file mode 100644 index 5990b6fd..00000000 --- a/pool/page_payout.php +++ /dev/null @@ -1,88 +0,0 @@ -$N
"; - $ot = "1/$N"; - $n = "${N}Nd"; - $n1 = 'N'; - $n1d = 'Nd'; - $bc = '+101 Confirms'; - $bm = 'Matured'; - $nd = 0; - if (isset($data['info']['currndiff'])) - $nd = $data['info']['currndiff']; - $nv = number_format($nd, 1); - $nvx = ''.number_format($N*$nd, 1).''; - $pd = $data['info']['p_hashrate24hr']; - $hr = 'is ?'; - $hrt = '?'; - if ($pd != '?' && $pd != '' && $pd > 0) - { - $hr = 'for the last day is roughly '.siprefmt($pd,2).'Hs'; - if ($nd > 0) - $hrt = ''.howmanyhrs($nd * $N / ($pd / pow(2,32)), true, true).''; - } - - $pg = "

Payouts

-
- -What payout method does the pool use?

-We use PPL${n1}S (Pay Per Last $n1 Shares)

-PPL${n1}S means that when a block is found, the block reward is shared among the last $n1 shares that miners sent to the pool, up to when the block was found.
-The $n1 value the pool uses is $t times the network difficulty when the block is found - '$n'.

- -How much of each block does the pool reward?

-Transaction fees are included in the miner reward.
-Pool fee is 0.9% of the total.

- -PPL${n1}S acts like the reward 'ramps up' when you first start mining.
What actually happens?


-The $n means it takes that long to reward your shares.
-The ramp isn't missing rewards, it's delaying them to reduce variance.
-Each share is rewarded in all the blocks found in the $n after the share.
-That's simply how it reduces variance. Each share's reward is averaged out over the $n after it.
-The pool hash rate $hr which means the $n 'ramp' is roughly $hrt.

- -Continue reading below for more detail about how it works:

- -How do the PPL${n1}S payments work?

-The $n means the pool rewards $t times the expected number of shares, each time a block is found.
-So each share will be paid approximately $ot of it's expected value, in each block it gets a reward,
-but each share is also expected, on average, to be rewarded $t times in blocks found after the share is submitted to the pool.
-i.e. if pool luck was always 100% then each share is expected to be rewarded $t times.

-If pool luck is better than 100%, then the average share reward will be better than $t times.
-If pool luck is lower than 100%, then the average share reward will be less than $t times.

- -What's a shift?

-When your miner sends shares to the pool, the shares are not stored individually, but rather summarised into shifts.
-Shifts are ~50min or less in length.
-Aproximately every 30s, the pool generates new work and sends that to all the miners.
-The pool also sends new work every time a block is found on the Bitcoin network.
-A shift summarises all the shares submitted to the pool for 100 work changes.
-However, when we find pool blocks, the current shift ends at the work in which the block was found
-and a new shift starts.
-A ckpool restart will also end the current shift and start a new shift.
-A network difficulty change will also end the current shift and start a new shift.

- -So, what's the $n value?

-The current Bitcoin network value for $n1d is $nv and thus $n is $nvx
-Bitcoin adjusts the $n1d value every 2016 blocks, which is about every 2 weeks.

-When a block is found, the reward process counts back shifts until the total share difficulty included is $n.
-Since shares are summarised into shifts, it will include the full shift at the end of the range counting backwards,
-so it usually will be a bit more than $n.

- -When are payments sent out?

-The block 'Status' must first reach '$bc' on the Blocks page, and then is flagged as '$bm', before the reward is distributed.
-The block reward is sent out manually soon after that.

- -
"; - return $pg; -} -# -function show_payout($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopayout', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_pblocks.php b/pool/page_pblocks.php deleted file mode 100644 index 7bedd01d..00000000 --- a/pool/page_pblocks.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/pool/page_percent.php b/pool/page_percent.php deleted file mode 100644 index c1668446..00000000 --- a/pool/page_percent.php +++ /dev/null @@ -1,172 +0,0 @@ -'; - $pg .= 'Address'; - $pg .= 'ID'; - $pg .= 'Shares'; - $pg .= 'Diff'; - $pg .= 'Invalid'; - $pg .= 'Block %'; - $pg .= 'Hash Rate'; - $pg .= 'Ratio'; - $pg .= 'Addr %'; - $pg .= "\n"; - return $pg; -} -# -function perhashorder($a, $b) -{ - return $b['payratio'] - $a['payratio']; -} -# -function peruser($data, $user, &$offset, &$totshare, &$totdiff, - &$totinvalid, &$totrate, &$blockacc, - &$blockreward, $srt = false) -{ - $ans = getPercents($user); - - $pg = ''; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - if (isset($ans['blockacc'])) - $blockacc = $ans['blockacc']; - if (isset($ans['blockreward'])) - $blockreward = $ans['blockreward']; - $all = array(); - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - $all[] = array('payaddress' => $ans['payaddress:'.$i], - 'payratio' => $ans['payratio:'.$i], - 'paypercent' => $ans['paypercent:'.$i], - 'payname' => $ans['payname:'.$i], - 'p_shareacc' => $ans['p_shareacc:'.$i], - 'p_diffacc' => $ans['p_diffacc:'.$i], - 'p_diffinv' => $ans['p_diffinv:'.$i], - 'p_uhr' => $ans['p_hashrate5m:'.$i]); - } - - if ($srt) - usort($all, 'perhashorder'); - - for ($i = 0; $i < $count; $i++) - { - if ((($offset) % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''.$all[$i]['payaddress'].''; - $pg .= ''.$all[$i]['payname'].''; - - $shareacc = number_format($all[$i]['p_shareacc'], 0); - $totshare += $all[$i]['p_shareacc']; - $diffacc = number_format($all[$i]['p_diffacc'], 0); - $totdiff += $all[$i]['p_diffacc']; - $pg .= "$shareacc"; - $pg .= "$diffacc"; - - $dtot = $all[$i]['p_diffacc'] + $all[$i]['p_diffinv']; - if ($dtot > 0) - $rej = number_format(100.0 * $all[$i]['p_diffinv'] / $dtot, 3); - else - $rej = '0'; - $totinvalid += $all[$i]['p_diffinv']; - - $pg .= "$rej%"; - - if ($blockacc <= 0) - $blkpct = ' '; - else - $blkpct = number_format(100.0 * $all[$i]['p_diffacc'] / $blockacc, 3) . '%'; - - $pg .= "$blkpct"; - - $uhr = $all[$i]['p_uhr']; - if ($uhr == '?') - $uhr = '?GHs'; - else - { - $totrate += $uhr; - $uhr = dsprate($uhr); - } - $pg .= "$uhr"; - - $pg .= ''.$all[$i]['payratio'].''; - $paypct = number_format($all[$i]['paypercent'], 3); - $pg .= "$paypct%"; - - $pg .= "\n"; - - $offset++; - } - $pg .= ''; - } - return $pg; -} -# -function pertotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockacc, $blockreward) -{ - $pg = ''; - $totrate = dsprate($totrate); - if (($offset % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - $pg .= "Total:"; - $pg .= " "; - $shareacc = number_format($totshare, 0); - $pg .= "$shareacc"; - $diffacc = number_format($totdiff, 0); - $pg .= "$diffacc"; - $dtot = $totdiff + $totinvalid; - if ($dtot > 0) - $rej = number_format(100.0 * $totinvalid / $dtot, 3); - else - $rej = '0'; - $pg .= "$rej%"; - if ($blockacc <= 0) - $blkpct = ' '; - else - $blkpct = number_format(100.0 * $totdiff / $blockacc, 3) . '%'; - $pg .= "$blkpct"; - $pg .= "$totrate"; - $pg .= "\n"; - return $pg; -} -# -function dopercent($data, $user) -{ - $pg = '

Address Percents

'; - - $pg .= "\n"; - - $totshare = 0; - $totdiff = 0; - $totinvalid = 0; - $totrate = 0; - $offset = 0; - $blockacc = 0; - $blockreward = 0; - - $pg .= pertitle($data, $user); - $pg .= peruser($data, $user, $offset, $totshare, $totdiff, $totinvalid, - $totrate, $blockacc, $blockreward, true); - $pg .= pertotal($offset, $totshare, $totdiff, $totinvalid, $totrate, - $blockacc, $blockreward); - - $pg .= "
\n"; - - return $pg; -} -# -function show_percent($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopercent', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_pplns.php b/pool/page_pplns.php deleted file mode 100644 index 0e85aabe..00000000 --- a/pool/page_pplns.php +++ /dev/null @@ -1,329 +0,0 @@ - 99999999) - $b4 = ''; - else if ($num > 9999999) - $b4 = ''; - if ($b4 != '') - $af = ''; - return $b4.$fmt.$af; -} -# -# ... Of course ... check the output and add the txin ... etc. -function calctx($ans, $count, $miner_sat, $diffacc_total) -{ - $pg = '
'; - $pg .= '
'; - - $dust = getparam('dust', true); - if (nuem($dust) || $dust <= 0) - $dust = 10000; - - $fee = getparam('fee', true); - if (nuem($fee) || $fee < 0) - $fee = 0; - $fee *= 100000000; - - $adr = array(); - $ers = ''; - $unpaid = 0; - $change = $miner_sat; - $dust_amt = 0; # not included in $change - for ($i = 0; $i < $count; $i++) - { - $username = $ans['user:'.$i]; - $diffacc_user = $ans['diffacc_user:'.$i]; - $pay_sat = floor($miner_sat * $diffacc_user / $diffacc_total); - $payaddress = $ans['payaddress:'.$i]; - if ($payaddress == 'none') - { - $c0 = substr($username, 0, 1); - $parts = explode('.', $username); - $len = strlen($parts[0]); - if (($c0 == '1' || $c0 == '3') && $len > 26 && $len < 37) - $payaddress = $parts[0]; - else - { - if ($pay_sat > 0) - { - $dd = ''; - if ($pay_sat < $dust) - $dd = ' (dust)'; - $ers .= "No address for '$username'$dd
"; - } - $unpaid += $pay_sat; - continue; - } - } - if (isset($adr[$payaddress])) - $adr[$payaddress] += $pay_sat; - else - $adr[$payaddress] = $pay_sat; - - $change -= $pay_sat; - } - - $txout = ''; - $comma = ''; - foreach ($adr as $payaddress => $pay_sat) - { - if ($pay_sat < $dust) - $dust_amt += $pay_sat; - else - { - $txout .= "$comma\"$payaddress\":".btcfmt($pay_sat); - $comma = ', '; - } - } - - if ($change > 0 || $dust_amt > 0 || $change < $fee) - { - $pg .= "Dust limit = $dust = ".btcfmt($dust); - $pg .= ", Dust amount = $dust_amt = ".btcfmt($dust_amt); - $pg .= ",
Upaid = $unpaid = ".btcfmt($unpaid); - $pg .= ", Change = $change = ".btcfmt($change); - $pg .= ",
Fee = $fee = ".btcfmt($fee)."

"; - - if ($change < $fee) - $ers .= "Change ($change) is less than Fee ($fee)
"; - - if (($dust_amt + $change - $fee) > 0) - { - $txout .= "$comma\"<changeaddress>\":"; - $txout .= btcfmt($dust_amt + $change - $fee); - $comma = ', '; - } - } - - if (strlen($ers) > 0) - $pg .= "$ers
"; - - $txn = '[{"txid":"<txid1>","vout":<n>},'; - $txn .= '{"txid":"<txid2>","vout":<n>}] '; - $txn .= '{'.$txout.'}
'; - - $pg .= $txn.'
'; - return $pg; -} -# -function fmtdata($code, $val) -{ - switch ($code) - { - case ',': - $ret = number_format($val); - break; - case '.': - $ret = number_format($val, 1); - break; - default: - $ret = $val; - } - return $ret; -} -# -function dopplns($data, $user) -{ - global $send_sep; - - $pg = '

CKPool

'; - - $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 = '
'.makeForm('pplns')." -Block: -  Tx: -  Dust (Satoshi): -  Fee (BTC): -"; - } - 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 '
'.$ans['STATUS'].': '.$ans['ERROR'].'
'; - - if (!isset($ans['pplns_last'])) - return '
Partial data returned
'; - - $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 = '
Blockchain '.$ans['block']."
\n"; - - if (strlen($ans['marks_status']) > 0) - { - $pg .= '
'; - $msg = $ans['marks_status']; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - - if (strlen($ans['block_extra']) > 0) - { - $pg .= '
'; - $msg = $ans['block_status'].' - '.$ans['block_extra']; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - - if (strlen($ans['share_status']) > 0) - { - $pg .= '
'; - $msg = $ans['share_status']." - Can't be paid out yet"; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - - $pg .= "
\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - $i = 0; - foreach ($data as $dsp => $name) - { - if (($i++ % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ""; - switch ($name[0]) - { - case ',': - case '.': - $nm = substr($name, 1); - $fmt = fmtdata($name[0], $ans[$nm]); - break; - default: - $fmt = $ans[$name]; - break; - } - $pg .= ""; - $pg .= "\n"; - } - - $pg .= "
NameValue
$dsp$fmt

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\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:'.$i]; - $diffacc_percent = number_format(100.0 * $diffacc_user / $diffacc_total, 3).'%'; - $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 .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= "\n"; - - $tot_pay += $pay_sat; - } - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - $pg .= "
UserDiff Accepted%Avg HashrateBTC -0.9%Address
'.$ans['user:'.$i].'$diffacc_user$diffacc_percent$avg_hash'.btcfmt($pay_sat).'$payaddress
'.btcfmt($tot_pay).'
\n"; - - if ($dotx === true) - $pg .= calctx($ans, $count, $miner_sat, $diffacc_total); - } - - return $pg; -} -# -function show_pplns($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopplns', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_pplns2.php b/pool/page_pplns2.php deleted file mode 100644 index e8cbc9af..00000000 --- a/pool/page_pplns2.php +++ /dev/null @@ -1,337 +0,0 @@ - 99999999) - $b4 = ''; - else if ($num > 9999999) - $b4 = ''; - if ($b4 != '') - $af = ''; - return $b4.$fmt.$af; -} -# -# ... Of course ... check the output and add the txin ... etc. -function calctx($ans, $count, $miner_sat, $diffacc_total) -{ - $pg = '
'; - $pg .= '
'; - - $dust = getparam('dust', true); - if (nuem($dust) || $dust <= 0) - $dust = 10000; - - $fee = getparam('fee', true); - if (nuem($fee) || $fee < 0) - $fee = 0; - $fee *= 100000000; - - $adr = array(); - $ers = ''; - $unpaid = 0; - $change = $miner_sat; - $dust_amt = 0; # not included in $change - for ($i = 0; $i < $count; $i++) - { - $username = $ans['user:'.$i]; - $diffacc_user = $ans['diffacc:'.$i]; - $pay_sat = $ans['amount:'.$i]; - $payaddress = $ans['payaddress:'.$i]; - if ($payaddress == 'hold') - { - $dd = ''; - if ($pay_sat > 0 && $pay_sat < $dust) - $dd = ' (dust)'; - $ers .= "Hold for '$username'$dd ($pay_sat)
"; - $unpaid += $pay_sat; - continue; - } - if ($payaddress == 'none') - { - $parts = explode('.', $username); - if (btcaddr($parts[0]) === true) - $payaddress = $parts[0]; - else - { - if ($pay_sat > 0) - { - $dd = ''; - if ($pay_sat < $dust) - $dd = ' (dust)'; - $ers .= "No address for '$username'$dd ($pay_sat)
"; - } - $unpaid += $pay_sat; - continue; - } - } - if (isset($adr[$payaddress])) - $adr[$payaddress] += $pay_sat; - else - $adr[$payaddress] = $pay_sat; - - $change -= $pay_sat; - } - - $txout = ''; - $comma = ''; - foreach ($adr as $payaddress => $pay_sat) - { - if ($pay_sat < $dust) - $dust_amt += $pay_sat; - else - { - $txout .= "$comma\"$payaddress\":".btcfmt($pay_sat); - $comma = ', '; - } - } - - if ($change > 0 || $dust_amt > 0 || $change < $fee) - { - $pg .= "Dust limit = $dust = ".btcfmt($dust); - $pg .= ", Dust amount = $dust_amt = ".btcfmt($dust_amt); - $pg .= ",
Upaid = $unpaid = ".btcfmt($unpaid); - $pg .= ", Change = $change = ".btcfmt($change); - $pg .= ",
Fee = $fee = ".btcfmt($fee)."

"; - - if ($change < $fee) - $ers .= "Change ($change) is less than Fee ($fee)
"; - - if (($dust_amt + $change - $fee) > 0) - { - $txout .= "$comma\"<changeaddress>\":"; - $txout .= btcfmt($dust_amt + $change - $fee); - $comma = ', '; - } - } - - if (strlen($ers) > 0) - $pg .= "$ers
"; - - $txn = '[{"txid":"<txid1>","vout":<n>},'; - $txn .= '{"txid":"<txid2>","vout":<n>}] '; - $txn .= '{'.$txout.'}
'; - - $pg .= $txn.'
'; - return $pg; -} -# -function fmtdata($code, $val) -{ - switch ($code) - { - case ',': - $ret = number_format($val); - break; - case '.': - $ret = number_format($val, 1); - break; - case '@': - $ret = howmanyhrs($val, true); - break; - default: - $ret = $val; - } - return $ret; -} -# -function dopplns2($data, $user) -{ - global $send_sep; - - $pg = '

CKPool

'; - - $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 = '
'.makeForm('pplns2')." -Block: -  Tx: -  Dust (Satoshi): -  Fee (BTC): -"; - } - else - { - $tx = getparam('tx', true); - if (nuem($tx) || substr($tx, 0, 1) != 'y') - $dotx = false; - else - $dotx = true; - - $flds = array('height' => $blk); - $msg = msgEncode('pplns2', 'pplns2', $flds, $user); - $rep = sendsockreply('pplns2', $msg, 4); - if ($rep == false) - $ans = array(); - else - $ans = repDecode($rep); - - - if ($ans['ERROR'] != null) - return '
'.$ans['STATUS'].': '.$ans['ERROR'].'
'; - - if (!isset($ans['pplns_last'])) - return '
Partial data returned
'; - - $reward_sat = $ans['block_reward']; - $miner_sat = $ans['miner_reward']; - $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', - 'Elapsed Time' => '@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 = '
Blockchain '.$ans['block']."
\n"; - - if (strlen($ans['marks_status']) > 0) - { - $pg .= '
'; - $msg = $ans['marks_status']; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - - if (strlen($ans['block_extra']) > 0) - { - $pg .= '
'; - $msg = $ans['block_status'].' - '.$ans['block_extra']; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - - $pg .= "
\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - $i = 0; - foreach ($data as $dsp => $name) - { - if (($i++ % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ""; - switch ($name[0]) - { - case ',': - case '.': - case '@': - $nm = substr($name, 1); - $fmt = fmtdata($name[0], $ans[$nm]); - break; - default: - $fmt = $ans[$name]; - break; - } - if ($dsp == 'Elapsed Seconds') - { - $pl = $ans['diffacc_total'] * pow(2,32) / $ans['pplns_elapsed']; - $fmt .= ' ' . dsprate($pl); - } - $pg .= ""; - $pg .= "\n"; - } - - $pg .= "
NameValue
$dsp$fmt

\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\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:'.$i]; - $diffacc_percent = number_format(100.0 * $diffacc_user / $diffacc_total, 3).'%'; - $avg_hash = number_format($diffacc_user / $elapsed * pow(2,32), 0); - $pay_sat = $ans['amount:'.$i]; - $payaddress = $ans['payaddress:'.$i]; - - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= "\n"; - - $tot_pay += $pay_sat; - } - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - $pg .= "
UserDiff Accepted%Avg HashrateBTC -0.9%Address
'.$ans['user:'.$i].'$diffacc_user$diffacc_percent$avg_hash'.btcfmt($pay_sat).'$payaddress
'.btcfmt($tot_pay).'
\n"; - - if ($dotx === true) - $pg .= calctx($ans, $count, $miner_sat, $diffacc_total); - } - - return $pg; -} -# -function show_pplns2($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopplns2', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_psperf.php b/pool/page_psperf.php deleted file mode 100644 index 9e8ae968..00000000 --- a/pool/page_psperf.php +++ /dev/null @@ -1,94 +0,0 @@ -s){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths} -} -for(var j=1;j=2000){ymin/=1000;ymax/=1000;tl='PH/s';for(var j=1;j 'shift key', 'slines' => 'shift lines', - 'tkey' => 'time key', 'tlines' => 'time lines', - 'over' => 'key overlap', 'smooth' => 'smooth', - 'zerob' => 'zero based', 'utc' => 'utc'); - $xon = array('skey' => 1, 'utc' => 1); - if ($vlines === true) - $xon['slines'] = 1; - - $pg .= "
"; - foreach ($cbx as $nam => $txt) - { - $pg .= ' '; - $pg .= ""; - $pg .= "$txt "; - } - - $pg .= '
'; - $pg .= '
'; - $pg .= 'A graph will show here if your browser supports html5/canvas'; - $pg .= "
\n"; - $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); - $data .= $fld_sep . 'cols' . $val_sep . $datacols; - $pg .= "\n"; - } - return $pg; -} -# -function show_psperf($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dopsperf', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_reg.php b/pool/page_reg.php deleted file mode 100644 index 1214c3da..00000000 --- a/pool/page_reg.php +++ /dev/null @@ -1,274 +0,0 @@ -WARNING:  -Do not give your username+password to anyone else.
-Do not give your username+password to apps or web sites.
-A monitoring app or web site will ONLY need your username+API key.
-You can setup an API key from the 'Account'->'User Settings' menu page after you login.
-Your miner password should be 'x' and must not use your login password.
"; - - $pg .= makeForm('')."
- - - - -
User: Pass: 
"; - - $pg .= '

or choose one:

'; - - $pg .= '
'; - - $pg .= '

Login

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

"; - $pg .= makeForm(''); - $pg .= " - - - - - - - - - - -
Username:
Password:
*2nd Authentication:
* - Leave blank if you haven't enabled it
 
-"; - - $pg.= '
'; - - $pg .= '

Register

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

"; - $pg .= makeForm(''); - $pg .= " - - - - - - - - - - - - - -
Username:
Email:
Password:
Retype Password:
 

* - All fields are required
Your Username can't be a BTC address

Note: your username is upper/lowercase sensitive,
-and you must also have upper/lowercase correct on all your miners

" . passrequires() . "
-"; - - $pg.= '
'; - - $pg .= '

Password Reset

'; - $pg .= makeForm(''); - $pg .= " - - - - - - - - -
Username:
Email:
 

-If you enter the details correctly,
-an Email will be sent to you to let you reset your password
-"; - - $pg .= '
'; - - return $pg; -} -# -function doreg2($data) -{ - if (isset($data['data']['user'])) - $user = htmlspecialchars($data['data']['user']); - else - $user = ''; - - $pg = '

Registered

'; -// $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 and a dot or an underscore'; - $pg .= "
e.g. ${user}_worker1 or ${user}.worker7"; - return $pg; -} -# -function try_reg($info, $page, $menu, $name, $u) -{ - $disallow = array('/kano/i', '/pool/i', '/kolivas/i'); - - $user = getparam('user', false); - $mail = trim(getparam('mail', false)); - $pass = getparam('pass', false); - $pass2 = getparam('pass2', false); - - $data = array(); - - if (nuem($user)) - $data['user'] = ''; - else - $data['user'] = $user; - - if (nuem($mail)) - $data['mail'] = ''; - else - $data['mail'] = $mail; - - $ok = true; - if (nuem($user) || nuem($mail) || nuem($pass) || nuem($pass2)) - $ok = false; - else - { - $res = bademail($mail); - if ($res != null) - { - $ok = false; - $data['error'] = $res; - } - - if (safepass($pass) !== true) - { - $ok = false; - $data['error'] = "Password is unsafe"; - } - elseif ($pass2 != $pass) - { - $ok = false; - $data['error'] = "Passwords don't match"; - } - - $orig = $user; - $user = loginStr($orig); - if ($user != $orig) - { - $ok = false; - $data['error'] = "Username cannot include '.', '_', '/' or Tab"; - $data['user'] = $user; - } - } - - if ($ok === true) - { - foreach ($disallow as $patt) - if (preg_match($patt, $user) === 1) - { - $ok = false; - $data['error'] = 'Disallowed username'; - break; - } - } - - if ($ok === true) - { - $ans = userReg($user, $mail, $pass); - if ($ans['STATUS'] == 'ok') - gopage($info, $data, 'doreg2', $page, $menu, $name, $u, true, true, false); - else - $data['error'] = "Invalid username, password or email address"; - } - - gopage($info, $data, 'doregres', $page, $menu, $name, $u, true, true, false); -} -# -function doreset2($data) -{ - $user = $data['data']['user']; - $email = $data['data']['email']; - - $emailinfo = getOpts($user, emailOptList()); - if ($emailinfo['STATUS'] != 'ok') - syserror(); - - $ans = getAtts($user, 'KLastReset.dateexp'); - if ($ans['STATUS'] != 'ok') - syserror(); - - // If the last attempt hasn't expired don't do anything but show a fake msg - if (!isset($ans['KLastReset.dateexp']) || $ans['KLastReset.dateexp'] == 'Y') - { - // 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['data']['user']). '_'; - - // A code that's large enough to not be worth guessing - $ran = $ans['STAMP'].$user.$email.rand(100000000,999999999); - $hash = hash('md4', $ran); - - $ans = setAtts($user, array('ua_KReset.str' => $hash, - 'ua_KReset.date' => 'now+3600', - 'ua_LastReset.date' => 'now+3600')); - if ($ans['STATUS'] != 'ok') - syserror(); - - $ok = passReset($email, $code.$hash, zeip(), $emailinfo); - if ($ok === false) - syserror(); - } - - $pg = '

Reset Sent

'; - $pg .= '
An Email has been sent that will allow you to'; - $pg .= '
reset your password.'; - $pg .= '
If you got your username or email address wrong,'; - $pg .= '
you wont get the email.'; - 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 show_reg($info, $page, $menu, $name, $u) -{ - // Slow this right down - usleep(1000000); - - $reg = getparam('Register', false); - if ($reg !== NULL) - try_reg($info, $page, $menu, $name, $u); - else - try_reset($info, $page, $menu, $name, $u); -} -# -?> diff --git a/pool/page_reset.php b/pool/page_reset.php deleted file mode 100644 index 83b46c90..00000000 --- a/pool/page_reset.php +++ /dev/null @@ -1,168 +0,0 @@ -
'; - - $pg .= '

Password Reset

'; - if ($error !== null) - $pg .= "
$error - please try again

"; - $pg .= makeForm('reset'); - $pg .= " - - - - - - - - - - - -
Enter a new password twice.
-" . passrequires() . " -
Password:
Retype Password:
*2nd Authentication:

* - Leave blank if you haven't enabled it
 
-"; - - $pg .= '
'; - - return $pg; -} -# -function yok() -{ - $pg = '

Password Reset

'; - $pg .= '
Your password has been reset,'; - $pg .= '
login with it on the Home page.'; - return $pg; -} -# -function resetfail() -{ - if (isset($_SESSION['reset_user'])) - unset($_SESSION['reset_user']); - if (isset($_SESSION['reset_hash'])) - unset($_SESSION['reset_hash']); - if (isset($_SESSION['reset_email'])) - unset($_SESSION['reset_email']); - $pg = '

Reset Failed

'; - $pg .= '
Try again from the Home page Register/Reset button later'; - return $pg; -} -# -function dbreset() -{ - $user = $_SESSION['reset_user']; - $hash = $_SESSION['reset_hash']; - $email = $_SESSION['reset_email']; - - $pass = getparam('pass', true); - $pass2 = getparam('pass2', true); - $twofa = getparam('2fa', true); - - if (nuem($pass) || nuem($pass2)) - return allow_reset('Enter both passwords'); - - if ($pass2 != $pass) - return allow_reset("Passwords don't match"); - - if (safepass($pass) !== true) - return allow_reset('Password is unsafe'); - - $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(); - - $emailinfo = getOpts($user, emailOptList()); - if ($emailinfo['STATUS'] != 'ok') - syserror(); - - $ans = resetPass($user, $pass, $twofa); - if ($ans['STATUS'] != 'ok') - return resetfail(); - - unset($_SESSION['reset_user']); - unset($_SESSION['reset_hash']); - unset($_SESSION['reset_email']); - - $ans = expAtts($user, 'KReset'); - - $ok = passWasReset($email, zeip(), $emailinfo); - - return yok(); -} -# -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 show_reset($info, $page, $menu, $name, $u) -{ - gopage($info, array(), 'doreset', $page, $menu, $name, $u, true, true, false); -} -# -?> diff --git a/pool/page_settings.php b/pool/page_settings.php deleted file mode 100644 index 862ddbb1..00000000 --- a/pool/page_settings.php +++ /dev/null @@ -1,257 +0,0 @@ -Account Settings'; - - if ($err != '') - $pg .= "$err

"; - - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - - $_SESSION['old_set_email'] = $email; - - $pg .= makeForm('settings'); - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'To change your email, enter a new email address and your password'; - $pg .= '
'; - $pg .= 'EMail:'; - $pg .= ''; - $pg .= ""; - $pg .= '
'; - $pg .= 'Password:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= '*2nd Authentication:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= "*Leave blank if you haven't enabled it"; - $pg .= '
'; - $pg .= 'Change: '; - $pg .= '
'; - - $pg .= '
'; - - if (!isset($data['info']['u_multiaddr'])) - { - $pg .= makeForm('settings'); - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'To change your payout address, enter a new address and your password.
'; - $pg .= 'A payout address can only ever be set to one account'; - $pg .= '
'; - $pg .= 'BTC Address:'; - $pg .= ''; - $pg .= ""; - $pg .= '
'; - $pg .= 'Password:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= '*2nd Authentication:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= "*Leave blank if you haven't enabled it"; - $pg .= '
'; - $pg .= 'Change: '; - $pg .= '
'; - - $pg .= '
'; - } - - $pg .= makeForm('settings'); - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'To change your password, enter your old password and new password twice'; - $pg .= '
'; - $pg .= 'Old Password:'; - $pg .= ''; - $pg .= ""; - $pg .= '
'; - $pg .= 'New Password:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'New Password again:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= '*2nd Authentication:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= "*Leave blank if you haven't enabled it"; - $pg .= '
'; - $pg .= 'Change: '; - $pg .= '
'; - - $pg .= '
'; - - return $pg; -} -# -function dosettings($data, $user) -{ - $err = ''; - $chg = getparam('Change', false); - $check = false; - switch ($chg) - { - case 'EMail': - $email = getparam('email', false); - $res = bademail($email); - if ($res != null) - $err = $res; - else - { - $pass = getparam('pass', false); - $twofa = getparam('2fa', false); - $ans = userSettings($user, $email, null, $pass, $twofa); - $err = 'EMail changed'; - $check = true; - } - break; - case 'Address': - if (!isset($data['info']['u_multiaddr'])) - { - $res = emailcheck($user); - if ($res != null) - $err = $res; - else - { - $addr = getparam('baddr', false); - if (nuem($addr)) - $addr = ''; - $addrarr = array(array('addr' => trim($addr))); - $pass = getparam('pass', false); - $twofa = getparam('2fa', false); - $ans = userSettings($user, null, $addrarr, $pass, $twofa); - $err = 'Payout address changed'; - $check = true; - } - } - break; - case 'Password': - $res = emailcheck($user); - if ($res != null) - $err = $res; - else - { - $oldpass = getparam('oldpass', false); - $pass1 = getparam('pass1', false); - $pass2 = getparam('pass2', false); - $twofa = getparam('2fa', false); - if (!safepass($pass1)) - $err = 'Unsafe password. ' . passrequires(); - elseif ($pass1 != $pass2) - $err = "Passwords don't match"; - else - { - $ans = setPass($user, $oldpass, $pass1, $twofa); - $err = 'Password changed'; - $check = true; - } - } - break; - } - $doemail = false; - if ($check === true) - { - if ($ans['STATUS'] != 'ok') - { - $err = $ans['STATUS']; - if ($ans['ERROR'] != '') - $err .= ': '.$ans['ERROR']; - } - else - $doemail = true; - } - $ans = userSettings($user); - if ($ans['STATUS'] != 'ok') - dbdown(); // Should be no other reason? - if (isset($ans['email'])) - $email = $ans['email']; - else - $email = ''; - // Use the first one - updating will expire all others - if (isset($ans['rows']) and $ans['rows'] > 0) - $addr = $ans['addr:0']; - else - $addr = ''; - - if ($doemail) - { - if ($email == '') - { - if ($err != '') - $err .= '
'; - $err .= 'An error occurred, check your details below'; - goto iroiroattanoyo; - } - - $emailinfo = getOpts($user, emailOptList()); - if ($emailinfo['STATUS'] != 'ok') - { - if ($err != '') - $err .= '
'; - $err .= 'An error occurred, check your details below'; - goto iroiroattanoyo; - } - - switch ($chg) - { - case 'EMail': - if (isset($_SESSION['old_set_email'])) - $old = $_SESSION['old_set_email']; - else - $old = null; - emailAddressChanged($email, zeip(), $emailinfo, $old); - break; - case 'Address': - payoutAddressChanged($email, zeip(), $emailinfo); - break; - case 'Password': - passChanged($email, zeip(), $emailinfo); - break; - } - } -iroiroattanoyo: - $pg = settings($data, $user, $email, $addr, $err); - return $pg; -} -# -function show_settings($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dosettings', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_shifts.php b/pool/page_shifts.php deleted file mode 100644 index 1c0ffbe6..00000000 --- a/pool/page_shifts.php +++ /dev/null @@ -1,109 +0,0 @@ -here to jump to the start of the last payout

"; - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - - if (($ans['STATUS'] != 'ok') || !isset($ans['prefix_all'])) - $pg = '

Shifts

'.$pg; - else - { - $pre = $ans['prefix_all']; - - $count = $ans['rows']; - $pg = '

Last '.($count+1).' Shifts

'.$pg.''; - for ($i = 0; $i < $count; $i++) - { - $u = ''; - $mark = ''; - if (isset($ans['lastpayoutstart:'.$i]) - && $ans['lastpayoutstart:'.$i] != '') - { - $u = 'u'; - $mark = ''; - } - if (($i % 2) == 0) - $row = "even$u"; - else - $row = "odd$u"; - - $pg .= ""; - $shifname = $ans['shift:'.$i]; - $shif = preg_replace(array('/^.* to /','/^.*fin: /'), '', $shifname); - $ablock = false; - if (preg_match('/to.*Block.* fin/', $shifname) == 1) - $ablock = true; - else - { - $shifex = $ans['endmarkextra:'.$i]; - if (preg_match('/Block .* fin/', $shifex) == 1) - $ablock = true; - } - if ($ablock === true) - $btc = ' '; - else - $btc = ''; - $pg .= ""; - $start = $ans['start:'.$i]; - $pg .= ''; - $nd = $ans['end:'.$i]; - $elapsed = $nd - $start; - $pg .= ''; - $diffacc = $ans[$pre.'diffacc:'.$i]; - $pg .= ''; - $diffinv = $ans[$pre.'diffinv:'.$i]; - $pg .= ''; - $hr = $diffacc * pow(2,32) / $elapsed; - $pg .= ''; - $shareacc = $ans[$pre.'shareacc:'.$i]; - $pg .= ''; - if ($shareacc > 0) - $avgsh = $diffacc / $shareacc; - else - $avgsh = 0; - $pg .= ''; - $pg .= ''; - $ppsr = (float)$ans['ppsrewarded:'.$i]; - if ($ppsr > 0) - $ppsd = sprintf('%.5f', $ppsr*1000.0); - else - $ppsd = '0'; - $pg .= ""; - $ppsv = (float)$ans['ppsvalue:'.$i]; - if ($ppsv > 0) - $pgot = number_format(100.0 * $ppsr / $ppsv, 2).'%'; - else - $pgot = '?'; - $pg .= ""; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
ShiftStart UTCLengthYour DiffInv DiffAvg HsSharesAvg ShareRewardsRewarded*PPS%
$shif$btc$mark'.utcd($start, true).''.howmanyhrs($elapsed).''.difffmt($diffacc).''.difffmt($diffinv).''.dsprate($hr).''.difffmt($shareacc).''.number_format($avgsh, 2).''.$ans['rewards:'.$i].'$ppsd$pgot
\n"; - $pg .= "* The Rewarded value unit is satoshis per 1000diff share
"; - - return $pg; -} -# -function show_shifts($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doshifts', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_stats.php b/pool/page_stats.php deleted file mode 100644 index 94fe02ce..00000000 --- a/pool/page_stats.php +++ /dev/null @@ -1,126 +0,0 @@ -Pool Stats'; - - if (isset($data['info']) && $data['info'] !== false) - { - $info = $data['info']; - - $pe = false; - if (isset($info['p_elapsed'])) - { - $dspel = howlongago($info['p_elapsed']); - $pg .= "Pool Uptime: $dspel"; - $pe = true; - } - - if (isset($info['ckdb_elapsed'])) - { - if ($pe) - $pg .= ' '; - $dspel = howlongago($info['ckdb_elapsed']); - $pg .= "CKDB Uptime: $dspel"; - } - - $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"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= "\n"; - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $all = array(); - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - $all[] = array('username' => $ans['username:'.$i], - 'userid' => $ans['userid:'.$i], - 'u_hashrate5m' => $ans['u_hashrate5m:'.$i]); - } - - usort($all, 'allusersort'); - - for ($i = 0; $i < $count; $i++) - { - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - $uhr = $all[$i]['u_hashrate5m']; - if ($uhr == '?') - $dsp = '?GHs'; - else - $dsp = dsprate($uhr); - $pg .= ""; - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
UsernameHash Rate 5m
'.htmlspecialchars($all[$i]['username']).'$dsp
\n"; - - return $pg; -} -# -function show_stats($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dostats', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_userinfo.php b/pool/page_userinfo.php deleted file mode 100644 index 436cbad3..00000000 --- a/pool/page_userinfo.php +++ /dev/null @@ -1,89 +0,0 @@ -Block Acclaim'; - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - if ($sall) - { - $pg .= ''; - $pg .= ''; - } - $pg .= "\n"; - - if ($ans['STATUS'] == 'ok') - { - $pg .= ''; - $all = array(); - $count = $ans['rows']; - for ($i = 0; $i < $count; $i++) - { - if ($sall) - $diffacc = $ans['diffacc:'.$i]; - else - $diffacc = 0; - - $all[] = array('blocks' => $ans['blocks:'.$i], - 'username' => $ans['username:'.$i], - 'diffacc' => $diffacc); - } - usort($all, 'blocksorder'); - - for ($i = 0; $i < $count; $i++) - { - $bl = $all[$i]['blocks']; - if ($sall == false && $bl < 1) - break; - - if (($i % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $un = htmlspecialchars($all[$i]['username']); - $pg .= ""; - $pg .= ""; - if ($sall) - { - $diffacc = $all[$i]['diffacc']; - $pg .= ''; - if ($bl == 0) - $bl = 1; - $pg .= ''; - } - $pg .= "\n"; - } - $pg .= ''; - } - $pg .= "
UserBlocksDiffAvg
$un$bl'.difffmt($diffacc).''.difffmt($diffacc/$bl).'
\n"; - - return $pg; -} -# -function show_userinfo($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'douserinfo', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_userset.php b/pool/page_userset.php deleted file mode 100644 index 6b02bc04..00000000 --- a/pool/page_userset.php +++ /dev/null @@ -1,130 +0,0 @@ -User Settings'; - - if ($err != '') - $pg .= "$err

"; - - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= ""; - $pg .= 'mini header
'; - - $pg .= makeForm('userset'); - $pg .= ''; - $pg .= '"; - $pg .= ''; - if ($api !== false) - { - $pg .= ''; - $pg .= ''; - $pg .= ''; - } - $pg .= '
'; - if ($api === false) - { - $pg .= "You don't have an API Key setup yet"; - $draw = false; - } - else - { - addQR(); - $pg .= 'Your current API Key is:'; - $pg .= '
'; - $pg .= "$api
'; - $pg .= 'A qrcode will show here if your browser supports html5/canvas'; - $pg .= "
"; - $draw = true; - } - $pg .= '
'; - $pg .= 'Click to generate a new API key'; - $pg .= ": "; - $pg .= '
 
You can access the API via:'; - $pg .= '
'; - $pg .= "/index.php?k=api&username="; - $pg .= htmlspecialchars(urlencode($user)); - $pg .= "&api=$api&json=y
"; - $pg .= '
You can get your workers via:'; - $pg .= '
'; - $pg .= "/index.php?k=api&username="; - $pg .= htmlspecialchars(urlencode($user)); - $pg .= "&api=$api&json=y&work=y
"; - $pg .= '
'; - - $pg .= '
'; - - if ($draw !== false) - { - $qr = shell_exec("../pool/myqr.sh '$api'"); - if ($qr !== null and strlen($qr) > 30) - { - $pg .= "\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; -} -# -function douserset($data, $user) -{ - $err = ''; - $chg = getparam('Change', false); - $api = false; - switch ($chg) - { - case 'API Key': - $ans = getAtts($user, 'KAPIKey.str,KAPIKey.dateexp'); - if ($ans['STATUS'] != 'ok') - dbdown(); // Should be no other reason? - if (isset($ans['KAPIKey.dateexp']) && $ans['KAPIKey.dateexp'] == 'N') - { - $err = 'You can only change it once a day'; - if (isset($ans['KAPIKey.str'])) - $api = $ans['KAPIKey.str']; - } - else - { - $ran = $ans['STAMP'].$user.rand(100000000,999999999); - $api = hash('md4', $ran); - - $day = 60 * 60 * 24; - $ans = setAtts($user, array('ua_KAPIKey.str' => $api, - 'ua_KAPIKey.date' => "now+$day")); - if ($ans['STATUS'] != 'ok') - syserror(); - - } - break; - } - if ($api === false) - { - $ans = getAtts($user, 'KAPIKey.str'); - if ($ans['STATUS'] != 'ok') - dbdown(); // Should be no other reason? - if (isset($ans['KAPIKey.str'])) - $api = $ans['KAPIKey.str']; - } - $pg = uset($data, $user, $api, $err); - return $pg; -} -# -function show_userset($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'douserset', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_usperf.php b/pool/page_usperf.php deleted file mode 100644 index 813808c7..00000000 --- a/pool/page_usperf.php +++ /dev/null @@ -1,151 +0,0 @@ -=0&&fi>=0){var xs,xf;xs=(st-x0)/(x1-x0);xf=(fi-x0)/(x1-x0);gfs(c,'$fs');gbe(c,xs,0);gln(c,xs,1);gln(c,xf,1);gln(c,xf,0);gle(c);gfl(c);gfz(c,xs,1,0,2,'Last 5Nd Reward \u279c','$ff','left')}}} -function gdrw(c,d,cbx){gc(c);ghrs(c);gopt(c,cbx); -gfs(c,'white');gss(c,'#0000c0');glw(c,2);gbd(c); -var rows=d['rows'],ymin=-1,ymax=0,xmin=-1,xmax=0,tda=[]; -var w=d['arp'].split(',');var cols=d['cols'].split(','); -gsh(c,w); -for(var j=1;js){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths;document.getElementById('worker'+j).value=d[pre+'worker']} -} -for(var j=1;j1){w+=','}w+=e.value.trim()}}if(w){scnv('workers',w)}}"; -return $g; -} -# -function dousperf($data, $user) -{ - global $fld_sep, $val_sep; - - // This also defines how many worker fields there are - $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); - $cols2 = array('#2090e0', '#e0c040', '#ff6090', '#90e040'); - $nc = count($cols)+count($cols2); - - $workers = 'all'; - if (isset($_COOKIE['workers'])) - { - $w = substr(trim($_COOKIE['workers']), 0, 1024); - if ($w !== false) - { - $wa = explode(',', $w, $nc+1); - if (count($wa) > $nc) - { - $w = ''; - for ($i = 0; $i < $nc; $i++) - $w .= (($i == 0) ? '' : ',').$wa[$i]; - } - $workers = $w; - } - } - - $ans = getShiftData($user, $workers); - - $iCrap = strpos($_SERVER['HTTP_USER_AGENT'],'iP'); - if ($iCrap) - $vlines = false; - else - $vlines = true; - - $pg = '

User Shift Reward Performance


'; - - if ($ans['STATUS'] == 'ok' and $ans['DATA'] != '') - { - addGBase(); - addTips(); - $cbx = array('skey' => 'shift key', 'slines' => 'shift lines', - 'tkey' => 'time key', 'tlines' => 'time lines', - 'over' => 'key overlap', 'smooth' => 'smooth', - 'zerob' => 'zero based', 'utc' => 'utc'); - $xon = array('skey' => 1, 'utc' => 1); - if ($vlines === true) - $xon['slines'] = 1; - - $pg .= '
'; - - $tt = "
  • all = all workers
  • noname = worker with no workername
  • "; - $tt .= "
  • or full workername without the username i.e. .worker or _worker
  • "; - $tt .= "
  • add a '*' on the end to match multiple workers e.g. .S3*
"; - $pg .= "?"; - $pg .= "$tt"; - - $i = 0; - $datacols = ''; - $onch = " onchange='wch()'"; - foreach ($cols as $col) - { - $i++; - $pg .= " Worker$i"; - $pg .= ":"; - $pg .= " "; - - if ($i > 1) - $datacols .= ','; - $datacols .= $col; - } - $oncl = "wch();location.href=\"".makeURL('usperf')."\""; - $pg .= "
"; - - # the rest of the workers/colours go below the graph - $pg2 = '
'; - foreach ($cols2 as $col) - { - $i++; - $pg2 .= " Worker$i"; - $pg2 .= ":"; - $pg2 .= " "; - - if ($i > 1) - $datacols .= ','; - $datacols .= $col; - } - $pg2 .= "
\n"; - - foreach ($cbx as $nam => $txt) - { - $pg .= ' '; - $pg .= ""; - $pg .= "$txt "; - } - - $pg .= '
'; - $pg .= '
'; - $pg .= 'A graph will show here if your browser supports html5/canvas'; - $pg .= "
\n"; - $pg .= $pg2; - $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); - $data .= $fld_sep . 'cols' . $val_sep . $datacols; - $pg .= "\n"; - } - return $pg; -} -# -function show_usperf($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'dousperf', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_workers.php b/pool/page_workers.php deleted file mode 100644 index ed7c7ab1..00000000 --- a/pool/page_workers.php +++ /dev/null @@ -1,289 +0,0 @@ -\n"; - $pg .= "function wkdet(n,i){var t=document.getElementById(n);if(i&&t){var b,cs,j,c,a;b=i.checked;cs=t.getElementsByTagName('td');for(j=0;c=cs[j];j++) -{a=c.getAttribute('data-hid');if(a){if(b){c.className=a}else{c.className='hid'}}}}}"; - $pg .= "\n"; - $pg .= "Show Details for Invalids:
"; - $pg .= "\n"; - return $pg; -} -# -function worktitle($data, $user) -{ - addSort(); - $r = "input type=radio name=srt onclick=\"sott('worksrt',this);\""; - $pg = ''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ""; - $pg .= ''; - $pg .= ""; - $pg .= "\n"; - return $pg; -} -# -function workhashorder($a, $b) -{ - return $b['w_uhr'] - $a['w_uhr']; -} -# -function workuser($data, $user, &$offset, &$totshare, &$totdiff, - &$totshrate, &$totinvalid, &$totrate, &$blockacc, - &$blockreward, $old = false, $srt = false, - $one = false, &$title, &$instances) -{ - $ans = getWorkers($user); - - $pg = ''; - if ($ans['STATUS'] == 'ok') - { - if (isset($ans['blockacc'])) - $blockacc = $ans['blockacc']; - if (isset($ans['blockreward'])) - $blockreward = $ans['blockreward']; - if ($one === true && isset($ans['oldworkers'])) - { - $days = intval($ans['oldworkers']); - if ($days != 0) - $title = ' (active during the last '.$days.' day'. - (($days==1)?'':'s').')'; - } - $all = array(); - $count = $ans['rows']; - $now = $ans['STAMP']; - for ($i = 0; $i < $count; $i++) - { - $lst = $now - $ans['w_lastshare:'.$i]; - if ($old !== false && $lst > $old) - continue; - - if ($ans['w_elapsed:'.$i] > 3600) - $uhr = $ans['w_hashrate1hr:'.$i]; - else - $uhr = $ans['w_hashrate5m:'.$i]; - - $all[] = array('workername' => $ans['workername:'.$i], - 'w_lastshare' => $ans['w_lastshare:'.$i], - 'w_lastshareacc' => $ans['w_lastshareacc:'.$i], - 'w_lastdiff' => $ans['w_lastdiff:'.$i], - 'w_shareacc' => $ans['w_shareacc:'.$i], - 'w_diffacc' => $ans['w_diffacc:'.$i], - 'w_diffinv' => $ans['w_diffinv:'.$i], - 'w_diffsta' => $ans['w_diffsta:'.$i], - 'w_diffdup' => $ans['w_diffdup:'.$i], - 'w_diffhi' => $ans['w_diffhi:'.$i], - 'w_diffrej' => $ans['w_diffrej:'.$i], - 'w_sharesta' => $ans['w_sharesta:'.$i], - 'w_sharedup' => $ans['w_sharedup:'.$i], - 'w_sharehi' => $ans['w_sharehi:'.$i], - 'w_sharerej' => $ans['w_sharerej:'.$i], - 'w_lastdiff' => $ans['w_lastdiff:'.$i], - 'w_active_diffacc' => $ans['w_active_diffacc:'.$i], - 'w_active_start' => $ans['w_active_start:'.$i], - 'w_uhr' => $uhr); - - $instances += $ans['w_instances:'.$i]; - } - - if ($srt) - usort($all, 'workhashorder'); - - foreach ($all as $arow) - { - $lst = $now - $arow['w_lastshare']; - if ($old !== false && $lst > $old) - continue; - - $lstacc = $now - $arow['w_lastshareacc']; - - if ((($offset) % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - - $pg .= ""; - $pg .= ''; - if ($arow['w_lastdiff'] > 0) - $ld = difffmt($arow['w_lastdiff']); - else - $ld = ' '; - $pg .= ""; - - $pg .= "'; - - $shareacc = number_format($arow['w_shareacc'], 0); - $totshare += $arow['w_shareacc']; - $dacc = $arow['w_diffacc']; - $diffacc = number_format($dacc, 0); - $ds = round($dacc); - $totdiff += $dacc; - $pg .= ""; - $pg .= ""; - - $acthr = '0'; - $acthrv = 0; - $actstt = $arow['w_active_start']; - if ($actstt <= 0 || ($now - $actstt) < 0) - $actsin = ' '; - else - { - $actsin = howmanyhrs($now - $actstt); - $elapsed = $now - $actstt; - if ($elapsed > 0) - { - $acthrv = $arow['w_active_diffacc'] * - pow(2,32) / $elapsed; - $acthr = dsprate($acthrv); - $totshrate += $acthrv; - } - } - $pg .= ""; - $pg .= ""; - - $dinv = $arow['w_diffinv']; - $dtot = $dacc + $dinv; - if ($dtot > 0) - { - $rejf = $dinv / $dtot; - $rej = number_format(100.0 * $rejf, 3); - } - else - { - $rejf = 0; - $rej = '0'; - } - $totinvalid += $dinv; - - $pg .= ""; - - foreach(array('sta','dup','hi','rej') as $fld) - { - $shr = number_format($arow['w_share'.$fld]); - $dif = $arow['w_diff'.$fld]; - $ddif = number_format($dif); - $sdif = number_format($dif,0,'',''); - $pg .= ""; - } - - if ($blockacc <= 0) - $blkpct = ' '; - else - $blkpct = number_format(100.0 * $dacc / $blockacc, 3) . '%'; - - $pg .= ""; - - $uhr = $arow['w_uhr']; - if ($uhr == '?') - { - $uhr = '?GHs'; - $su = 0; - } - else - { - $su = round($uhr); - $totrate += $uhr; - $uhr = dsprate($uhr); - } - $pg .= ""; - - $pg .= "\n"; - - $offset++; - } - } - return $pg; -} -# -function worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, - $totrate, $blockacc, $blockreward, $instances) -{ - $pg = ''; - $totshrate = dsprate($totshrate); - $totrate = dsprate($totrate); - if ($instances >= 0) - $dspinst = " ($instances miners)"; - else - $dspinst = ''; - - if (($offset % 2) == 0) - $row = 'even'; - else - $row = 'odd'; - $pg .= ""; - $shareacc = number_format($totshare, 0); - $pg .= ""; - $diffacc = number_format($totdiff, 0); - $pg .= ""; - $pg .= ""; - $dtot = $totdiff + $totinvalid; - if ($dtot > 0) - $rej = number_format(100.0 * $totinvalid / $dtot, 3); - else - $rej = '0'; - $pg .= ""; - if ($blockacc <= 0) - $blkpct = ' '; - else - $blkpct = number_format(100.0 * $totdiff / $blockacc, 3) . '%'; - $pg .= ""; - $pg .= ""; - $pg .= "\n"; - return $pg; -} -# -function doworker($data, $user) -{ - $title = ''; - - $pg = worktable(); - - $totshare = 0; - $totdiff = 0; - $totshrate = 0; - $totinvalid = 0; - $totrate = 0; - $offset = 0; - $blockacc = 0; - $blockreward = 0; - $instances = 0; - - $pg .= worktitle($data, $user); - $pg .= ''; - $pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totshrate, - $totinvalid, $totrate, $blockacc, $blockreward, - false, true, true, $title, $instances); - $pg .= ''; - $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, - $totrate, $blockacc, $blockreward, $instances); - - $pg .= "
Worker Name:<$r id=srtwrk data-sf=s0>Work Diff<$r id=srtlst data-sf=n2>:Last ShareShares<$r id=srtdiff data-sf=r4>:Diff<$r id=srtshrate data-sf=r5>:Share Rate«Elapsed<$r id=srtinv data-sf=r7>:Invalid<$r id=srtstale data-sf=r8>:Stale<$r id=srtdup data-sf=r9>:Dup<$r id=srthi data-sf=r10>:Hi<$r id=srtreject data-sf=r11>:RejBlock %<$r id=srtrate data-sf=r13>:Hash Rate
'.htmlspecialchars($arow['workername']).'$ld".howlongago($lstacc).'$shareacc$diffacc$acthr$actsin$rej%$ddif/$shr$blkpct$uhr
Total: $offset$dspinst$shareacc$diffacc$totshrate $rej% $blkpct$totrate
\n"; - $pg .= "\n"; - - return "

Workers$title

".$pg; -} -# -function doworkers($data, $user) -{ - $pg = doworker($data, $user); - return $pg; -} -# -function show_workers($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doworkers', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/page_workmgt.php b/pool/page_workmgt.php deleted file mode 100644 index 87f60c63..00000000 --- a/pool/page_workmgt.php +++ /dev/null @@ -1,123 +0,0 @@ -Worker Management'; - - if ($err != '') - $pg .= "$err

"; - - $ans = getWorkers($user, 'N'); - - if ($ans['STATUS'] == 'ok') - { - if (isset($ans['oldworkers']) && $ans['oldworkers'] == '0') - $chk = ''; - else - $chk = ' checked'; - $pg .= makeForm('workmgt'); - $pg .= 'Active workers (7 days)'; - $pg .= ""; - $pg .= ''; - $pg .= '

'; - } - - $pg .= makeForm('workmgt'); - $pg .= "\n"; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - - $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 .= ""; - - $wn = htmlspecialchars($ans['workername:'.$i]); - $wnv = urlencode($ans['workername:'.$i]); - $pg .= ''; - - $md = intval($ans['difficultydefault:'.$i]); - $pg .= '"; - - $pg .= "\n"; - - $offset++; - } - } - $pg .= ''; - $pg .= "
Worker NameMinimum Diff
'; - $pg .= ""; - $pg .= $wn.''; - $pg .= ""; - $pg .= ""; - $pg .= "
*'; - $pg .= ' A value of 0, less than the pool minimum,
'; - $pg .= 'or less than the pool calculated value for you,
'; - $pg .= 'will use the pool calculated value
\n"; - - return $pg; -} -# -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 show_workmgt($info, $page, $menu, $name, $user) -{ - gopage($info, NULL, 'doworkmgt', $page, $menu, $name, $user); -} -# -?> diff --git a/pool/param.php b/pool/param.php deleted file mode 100644 index 594be090..00000000 --- a/pool/param.php +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/pool/prime.php b/pool/prime.php deleted file mode 100644 index dd0c5973..00000000 --- a/pool/prime.php +++ /dev/null @@ -1,130 +0,0 @@ - $options) - if ($options !== NULL) - foreach ($options as $name => $pagename) - if ($pagename === $p) - { - $page = $p; - $n = " - $name"; - } - - if ($page === '' and $p == 'blocks') - { - $p = 'pblocks'; - goto bp; - } - if ($page === '') - showPage($info, 'index', $menu, '', $user); - else - showPage($info, $page, $menu, $n, $user); -} -# -function def_menu() -{ - $dmenu = array('Home' => array('Home' => ''), - 'Pool' => array( - 'Blocks' => 'pblocks' - ), - 'gap' => array( # options not shown - 'API' => 'api'), - 'Help' => array( - 'Payouts' => 'payout')); - return $dmenu; -} -# -function check() -{ - $dmenu = def_menu(); - $menu = array( - 'Home' => array( - 'Home' => '' - ), - 'Account' => array( - 'Rewards' => 'mpayouts', - 'Payments' => 'payments', - 'Settings' => 'settings', - 'User Settings' => 'userset', - '2FA Settings' => '2fa' - ), - 'Workers' => array( - 'Shifts' => 'shifts', - 'Shift Graph' => 'usperf', - 'Workers' => 'workers', - 'Management' => 'workmgt' - ), - 'Pool' => array( - 'Stats' => 'stats', - 'Blocks' => 'blocks', - 'Graph' => 'psperf', - 'Acclaim' => 'userinfo', - 'Luck' => 'luck' - ), - 'Admin' => NULL, - 'gap' => array( # options not shown - 'API' => 'api', - 'PBlocks' => 'pblocks' - ), - 'Help' => array( - 'Payouts' => 'payout' - ) - ); - tryLogInOut(); - $who = loggedIn(); - if ($who === false) - { - $p = getparam('k', true); - if ($p == 'reset') - showPage(NULL, 'reset', $dmenu, '', $who); - else - { - if (requestLoginRegReset() == true) - showPage(NULL, 'reg', $dmenu, '', $who); - else - { - $p = getparam('k', true); - process($p, $who, $dmenu); - } - } - } - else - { - $p = getparam('k', true); - process($p, $who, $menu); - } -} -# -check(); -# -?> diff --git a/pool/socket.php b/pool/socket.php deleted file mode 100644 index 01c2c122..00000000 --- a/pool/socket.php +++ /dev/null @@ -1,231 +0,0 @@ - $sec, 'usec' => $usec); - socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $tmoval); - socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $tmoval); -} -# -# Note that $port in AF_UNIX should be the socket filename -function _getsock($fun, $port, $tmo, $unix=true) -{ - $socket = null; - if ($unix === true) - $socket = socket_create(AF_UNIX, SOCK_STREAM, 0); - else - $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - if ($socket === false || $socket === null) - { - $sle = socket_last_error(); - $sockerr = socket_strerror($sle); - $msg = "$fun() _getsock() create($port) failed"; - error_log("CKPERR: $msg ($sle) '$sockerr'"); - return false; - } - - if ($unix === true) - $res = socket_connect($socket, $port, NULL); - else - $res = socket_connect($socket, '127.0.0.1', $port); - if ($res === false) - { - // try 3x - if ($unix === true) - $res = socket_connect($socket, $port); - else - { - sleep(2); - $res = socket_connect($socket, '127.0.0.1', $port); - } - if ($res === false) - { - if ($unix === true) - $res = socket_connect($socket, $port); - else - { - sleep(5); - $res = socket_connect($socket, '127.0.0.1', $port); - } - if ($res === false) - { - $sle = socket_last_error(); - $sockerr = socket_strerror($sle); - if ($unix === true) - $msg = "$fun() _getsock() connect($port) failed 3x"; - else - $msg = "$fun() _getsock() connect($port) failed 3x (+2+5s sleep)"; - error_log("CKPERR: $msg ($sle) '$sockerr'"); - socket_close($socket); - return false; - } - } - } - # Avoid getting locked up for long - socktmo($socket, $tmo); - # Enable timeout - socket_set_block($socket); - return $socket; -} -# -function getsock($fun, $tmo) -{ - return _getsock($fun, '/opt/ckdb/listenerweb', $tmo); -} -# -function readsockline($fun, $socket) -{ - $siz = socket_read($socket, 4, PHP_BINARY_READ); - if ($siz === false) - { - $sle = socket_last_error(); - $sockerr = socket_strerror($sle); - $msg = "$fun() readsockline() failed"; - error_log("CKPERR: $msg ($sle) '$sockerr'"); - return false; - } - if (strlen($siz) != 4) - { - $msg = "$fun() readsockline() short 4 read got ".strlen($siz); - error_log("CKPERR: $msg"); - return false; - } - $len = ord($siz[0]) + ord($siz[1])*256 + - ord($siz[2])*65536 + ord($siz[3])*16777216; - $ans = ''; - $left = $len; - while ($left > 0) - { - $line = socket_read($socket, $left, PHP_BINARY_READ); - if ($line === false) - { - $sle = socket_last_error(); - $sockerr = socket_strerror($sle); - $msg = "$fun() readsockline() $left failed (len=$len)"; - error_log("CKPERR: $msg ($sle) '$sockerr'"); - return false; - } - $red = strlen($line); - if ($red == 0) - { - $msg = "$fun() readsockline() incomplete (".($len-$left)." vs $len)"; - $sub = "'".substr($line, 0, 30)."'"; - if (strlen($line) > 30) - $sub .= '...'; - error_log("CKPERR: $msg $sub"); - return false; - } - $left -= $red; - $ans .= $line; - } - return $ans; -} -# -function dosend($fun, $socket, $msg) -{ - $msg .= "\n"; - $len = strlen($msg); - - $sen = $len; - $siz = chr($sen % 256); - $sen = $sen >> 8; - $siz .= chr($sen % 256); - $sen = $sen >> 8; - $siz .= chr($sen % 256); - $sen = $sen >> 8; - $siz .= chr($sen % 256); - - $msg = $siz . $msg; - - $len += 4; - $left = $len; - $ret = false; - while ($left > 0) - { - $res = socket_write($socket, substr($msg, 0 - $left), $left); - if ($res === false) - { - $sockerr = socket_strerror(socket_last_error()); - $msg = "$fun() sendsock() failed"; - error_log("CKPERR: $msg '$sockerr'"); - break; - } - if ($res == 0) - { - $msg = "$fun() sendsock() incomplete (".($len-$left)." vs $len)"; - error_log("CKPERR: $msg"); - break; - } - $left -= $res; - } - if ($left == 0) - $ret = true; - - return $ret; -} -# -function sendsock($fun, $msg, $tmo = false) -{ - $ret = false; - $socket = getsock($fun, $tmo); - if ($socket !== false) - { - $ret = dosend($fun, $socket, $msg); - socket_close($socket); - } - return $ret; -} -# -# This is the only function in here you call -# You pass it a string $fun for debugging -# and the data $msg to send to ckdb -# and it returns $ret = false on error or $ret = the string reply -# -# Alerts are always tagged on the end as: $fld_sep alert $val_sep text -# There's allowed to be more than one. They are removed -# -function sendsockreply($fun, $msg, $tmo = false) -{ - global $fld_sep, $val_sep, $alrts; - - $ret = false; - $socket = getsock($fun, $tmo); - if ($socket !== false) - { - $ret = dosend($fun, $socket, $msg); - if ($ret !== false) - $ret = readsockline($fun, $socket); - - socket_close($socket); - } - $al = $fld_sep . 'alert' . $val_sep; - if ($ret !== false and strpos($ret, $al) !== false) - { - $all = explode($al, $ret); - $ret = $all[0]; - $skip = true; - foreach ($all as $lrt) - { - if ($skip) - $skip = false; - else - // Discard duplicates - $alrts[preg_replace("/[\n\r]*$/",'',$lrt)] = 1; - } - } - return $ret; -} -# -?> diff --git a/pool/worker.php b/pool/worker.php deleted file mode 100644 index 5cc393cf..00000000 --- a/pool/worker.php +++ /dev/null @@ -1,22 +0,0 @@ - - -CKPool - -