Remove deprecated pool components from source.
This commit is contained in:
parent
c689a1eed2
commit
f4bb210849
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
usleep(100000);
|
||||
include_once('param.php');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html><head><title>CKPool</title><meta content='text/html; charset=iso-8859-1' http-equiv='Content-Type'></head><body>
|
||||
<?php
|
||||
function go()
|
||||
{
|
||||
$a = getparam('a', true);
|
||||
$f = substr($a, 0, 1);
|
||||
if ($f != '1' and $f != '3')
|
||||
return;
|
||||
if (strlen($a) < 24)
|
||||
return;
|
||||
if (preg_match('/^[a-zA-Z0-9]*$/', $a) === false)
|
||||
return;
|
||||
$sta = "../pool/users/$a";
|
||||
if (file_exists($sta))
|
||||
echo file_get_contents($sta);
|
||||
}
|
||||
go();
|
||||
?>
|
||||
</body></html>
|
||||
627
pool/base.php
627
pool/base.php
@ -1,627 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('page.php');
|
||||
#
|
||||
global $dbg, $dbgstr;
|
||||
$dbg = false;
|
||||
$dbgstr = '';
|
||||
#
|
||||
global $alrts;
|
||||
$alrts = array();
|
||||
#
|
||||
function adddbg($str)
|
||||
{
|
||||
global $dbg, $dbgstr;
|
||||
|
||||
if ($dbg === true)
|
||||
{
|
||||
if ($dbgstr != '')
|
||||
$dbgstr .= "\n";
|
||||
$dbgstr .= $str;
|
||||
}
|
||||
}
|
||||
#
|
||||
function sq($str)
|
||||
{
|
||||
return str_replace("'", "\\'", $str);
|
||||
}
|
||||
#
|
||||
function dq($str)
|
||||
{
|
||||
return str_replace('"', "\\\"", $str);
|
||||
}
|
||||
#
|
||||
function daysago($val)
|
||||
{
|
||||
if ($val < -13)
|
||||
return '';
|
||||
|
||||
if ($val < 60)
|
||||
$des = number_format($val,0).'s';
|
||||
else
|
||||
{
|
||||
$val = $val/60;
|
||||
if ($val < 60)
|
||||
$des = number_format($val,1).'min';
|
||||
else
|
||||
{
|
||||
$val = $val/60;
|
||||
if ($val < 24)
|
||||
$des = number_format($val,1).'hrs';
|
||||
else
|
||||
{
|
||||
$val = $val/24;
|
||||
if ($val < 43)
|
||||
$des = number_format($val,1).'days';
|
||||
else
|
||||
{
|
||||
$val = $val/7;
|
||||
if ($val < 10000)
|
||||
$des = number_format($val,1).'wks';
|
||||
else
|
||||
$des = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $des;
|
||||
}
|
||||
#
|
||||
function howlongago($sec)
|
||||
{
|
||||
if ($sec < 60)
|
||||
$des = $sec.'s';
|
||||
else
|
||||
{
|
||||
$sec = round($sec/60);
|
||||
if ($sec < 60)
|
||||
$des = $sec.'min';
|
||||
else
|
||||
{
|
||||
$sec = round($sec/60);
|
||||
if ($sec < 24)
|
||||
{
|
||||
$des = $sec.'hr';
|
||||
if ($sec != 1)
|
||||
$des .= 's';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sec = round($sec/24);
|
||||
if ($sec < 9999)
|
||||
{
|
||||
$des = $sec.'day';
|
||||
if ($sec != 1)
|
||||
$des .= 's';
|
||||
}
|
||||
else
|
||||
$des = 'never';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $des;
|
||||
}
|
||||
#
|
||||
function howmanyhrs($tot, $days = false, $dh = false)
|
||||
{
|
||||
$sec = round($tot);
|
||||
if ($sec < 60)
|
||||
$des = $sec.'s';
|
||||
else
|
||||
{
|
||||
$min = floor($sec / 60);
|
||||
$sec -= $min * 60;
|
||||
if ($min < 60)
|
||||
$des = $min.'m '.$sec.'s';
|
||||
else
|
||||
{
|
||||
$hr = floor($min / 60);
|
||||
$min -= $hr * 60;
|
||||
if ($days && $hr > 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<br>" .
|
||||
"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<br>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('<','>','<br>','<br>','<br>');
|
||||
return str_replace($srch, $rep, $str);
|
||||
}
|
||||
#
|
||||
function cvtdbg()
|
||||
{
|
||||
global $dbg, $dbgstr;
|
||||
|
||||
if ($dbg === false || $dbgstr == '')
|
||||
$rep = '';
|
||||
else
|
||||
$rep = htmler($dbgstr).'<br>';
|
||||
|
||||
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 "<span class=alert><br>Database is reloading, mining is all OK</span>";
|
||||
}
|
||||
#
|
||||
function dbdown()
|
||||
{
|
||||
gopage(NULL, NULL, 'dbd', 'dbd', def_menu(), '', '', true, false, false);
|
||||
}
|
||||
#
|
||||
function syse($data, $user)
|
||||
{
|
||||
return "<span class=err><br>System error</span>";
|
||||
}
|
||||
#
|
||||
function syserror()
|
||||
{
|
||||
gopage(NULL, NULL, 'syse', 'syse', def_menu(), '', '', true, false, false);
|
||||
}
|
||||
#
|
||||
function f404($data)
|
||||
{
|
||||
return "<span class=alert><br>404</span>";
|
||||
}
|
||||
#
|
||||
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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
517
pool/db.php
517
pool/db.php
@ -1,517 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('socket.php');
|
||||
#
|
||||
# List of db functions to call and get the results back from ckdb
|
||||
# From homeInfo() and the rest after that
|
||||
# The repDecode() result is an array of all ckdb result field names and
|
||||
# their values
|
||||
# Also included:
|
||||
# ['ID'] the id sent
|
||||
# ['STAMP'] the ckdb reply timestamp
|
||||
# ['STATUS'] the ckdb reply status (!'ok' = error)
|
||||
# ['ERROR'] if status != 'ok', the error message reply
|
||||
# The reply is false if the ckdb return data was corrupt
|
||||
# The repData() result is:
|
||||
# ['ID'] the id sent
|
||||
# ['STAMP'] the ckdb reply timestamp
|
||||
# ['STATUS'] the ckdb reply status (!'ok' = error)
|
||||
# ['DATA'] the rest of the ckdb reply, or '' on error
|
||||
# ['ERROR'] if status not 'ok', the error message reply
|
||||
#
|
||||
global $send_sep, $fld_sep, $val_sep;
|
||||
$send_sep = '.';
|
||||
$fld_sep = Chr(0x9);
|
||||
$val_sep = '=';
|
||||
#
|
||||
function myhash($str)
|
||||
{
|
||||
return strtolower(hash('sha256', $str));
|
||||
}
|
||||
#
|
||||
function repDecode($rep)
|
||||
{
|
||||
global $send_sep, $fld_sep, $val_sep;
|
||||
|
||||
$fix = preg_replace("/[\n\r]*$/",'',$rep);
|
||||
$major = explode($send_sep, $fix, 4);
|
||||
if (count($major) < 3)
|
||||
return false;
|
||||
|
||||
$ans = array();
|
||||
if (count($major) > 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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
261
pool/email.php
261
pool/email.php
@ -1,261 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
# FYI see PEAR::Mail for functions to add for batch email
|
||||
#
|
||||
global $eol;
|
||||
$eol = "\r\n";
|
||||
#
|
||||
function fullsend($to, $subject, $message, $headers, $extra = null)
|
||||
{
|
||||
if ($extra == null)
|
||||
$ret = mail($to, $subject, $message, $headers);
|
||||
else
|
||||
$ret = mail($to, $subject, $message, $headers, $extra);
|
||||
|
||||
if ($ret == false)
|
||||
error_log("CKPWARN: ".gmdate("Y-m-d H:i:s \\U\\T\\C").
|
||||
" sendmail failed? to: '$to'");
|
||||
|
||||
return $ret;
|
||||
}
|
||||
#
|
||||
function sendnoheader($to, $subject, $message, $emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KNoReply']))
|
||||
return false;
|
||||
|
||||
$noreply = $emailinfo['KNoReply'];
|
||||
|
||||
$headers = "From: $noreply$eol";
|
||||
$headers .= "X-Mailer: .";
|
||||
|
||||
return fullsend($to, $subject, $message, $headers, "-f$noreply");
|
||||
}
|
||||
#
|
||||
function dontReply($emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KWebURL']))
|
||||
return false;
|
||||
|
||||
$web = $emailinfo['KWebURL'];
|
||||
|
||||
$message = "P.S. don't reply to this e-mail, no one will get the reply$eol";
|
||||
$message .= "There is a contact e-mail address (that changes often)$eol";
|
||||
$message .= "at $web/ or visit us on FreeNode IRC #ckpool$eol";
|
||||
|
||||
return $message;
|
||||
}
|
||||
#
|
||||
function emailEnd($the, $whoip, $emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
$ret = dontReply($emailinfo);
|
||||
if ($ret === false)
|
||||
return false;
|
||||
|
||||
$message = "This $the was made '".gmdate("Y-M-d H:i:s \\U\\T\\C");
|
||||
$message .= "' by '$whoip'$eol$eol";
|
||||
$message .= $ret;
|
||||
|
||||
return $message;
|
||||
}
|
||||
#
|
||||
function passWasReset($to, $whoip, $emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KWebURL']))
|
||||
return false;
|
||||
|
||||
$web = $emailinfo['KWebURL'];
|
||||
|
||||
$ret = emailEnd('reset', $whoip, $emailinfo);
|
||||
if ($ret === false)
|
||||
return false;
|
||||
|
||||
$message = "Your password has been reset.$eol$eol";
|
||||
$message .= $ret;
|
||||
|
||||
return sendnoheader($to, "Password Reset", $message, $emailinfo);
|
||||
}
|
||||
#
|
||||
function passReset($to, $code, $whoip, $emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KWebURL']))
|
||||
return false;
|
||||
|
||||
$web = $emailinfo['KWebURL'];
|
||||
|
||||
$ret = emailEnd('password reset', $whoip, $emailinfo);
|
||||
if ($ret === false)
|
||||
return false;
|
||||
|
||||
$message = "Someone requested to reset your password.$eol$eol";
|
||||
$message .= "You can ignore this message since nothing has changed yet,$eol";
|
||||
$message .= "or click on the link below to reset your password.$eol";
|
||||
$message .= "$web/index.php?k=reset&code=$code$eol$eol";
|
||||
$message .= $ret;
|
||||
|
||||
return sendnoheader($to, "Password Reset", $message, $emailinfo);
|
||||
}
|
||||
#
|
||||
function payoutAddressChanged($to, $whoip, $emailinfo)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KWebURL']))
|
||||
return false;
|
||||
|
||||
$web = $emailinfo['KWebURL'];
|
||||
|
||||
$ret = emailEnd('payout address change', $whoip, $emailinfo);
|
||||
if ($ret === false)
|
||||
return false;
|
||||
|
||||
$message = "Your payout address has been changed.$eol$eol";
|
||||
$message .= $ret;
|
||||
|
||||
return sendnoheader($to, "Payout Address Change", $message, $emailinfo);
|
||||
}
|
||||
#
|
||||
function emailAddressChanged($to, $whoip, $emailinfo, $old)
|
||||
{
|
||||
global $eol;
|
||||
|
||||
if (!isset($emailinfo['KWebURL']))
|
||||
return false;
|
||||
|
||||
$web = $emailinfo['KWebURL'];
|
||||
|
||||
$ret = emailEnd('email address change', $whoip, $emailinfo);
|
||||
if ($ret === false)
|
||||
return false;
|
||||
|
||||
$message = "Your email address has been changed to:$eol <$to>$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';
|
||||
}
|
||||
#
|
||||
?>
|
||||
163
pool/inc.php
163
pool/inc.php
@ -1,163 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function GBaseJS()
|
||||
{
|
||||
$g = "function hasCan(){var c0=document.getElementById('can0');c=document.getElementById('can');return !!(c0 && c && c.getContext && c.getContext('2d'))}
|
||||
function sep(d){ans={};var ar=d.split('\\t');var l=ar.length;for(var i=0;i<l;i++){var e=ar[i].indexOf('=');ans[ar[i].substr(0,e)]=ar[i].substr(e+1)}return ans}
|
||||
function dfmt(c,e){var d=new Date(e*1000);var DD,HH,MM;if(c['utc']){DD=d.getUTCDate();HH=d.getUTCHours();MM=d.getUTCMinutes()}else{DD=d.getDate();HH=d.getHours();MM=d.getMinutes()}var ans=''+DD+'/';if(HH<10){ans += '0'}ans += ''+HH+':';if(MM<10){ans += '0'}ans += ''+MM;return ans}
|
||||
function dfmtm(c,e){var d=new Date(e*1000);var M,DD,HH;var MMM=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];if(c['utc']){M=MMM[d.getUTCMonth()];DD=d.getUTCDate();HH=d.getUTCHours()}else{M=MMM[d.getMonth()];DD=d.getDate();HH=d.getHours()}var ans=''+M+'-';if(DD<10){ans += '0'}ans += ''+DD+'/';if(HH<10){ans += '0'}ans += ''+HH;return ans}
|
||||
function ccb(c,n){var e=document.getElementById(n);c[n]=(e&&e.checked)}
|
||||
function ccbd(c,n,d){var e=document.getElementById(n);if(e){c[n]=e.checked}else{c[n]=d}}
|
||||
function gch(z,zm){if(z<0.5){return 0.5}if(z>(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<xn;i++){var n=ar[nx+i];var x=ar[vx+i];var xo=(x-x0)/(x1-x0);if(c['skey'] && (i<(xn-1)) && (i%m) == 0){gbe(c,xo,0);gln(c,xo,-0.01);gst(c);gfz(c,xo,0,0,-hi*1.5,n,'#00a050','center')}if(c['slines']){gbe(c,xo,0);gln(c,xo,1);gst(c)}}var xhr=3600+x1-(x1%3600);gss(c,'brown');if(c['tkey'] || c['tlines']){var hlv=c['hln'][c['hl']];hrs=c['hrs'][c['hr']]*3600/hlv;var n,l=0;tpos=2.7;if(c['over']){tpos=1.5}for(var i=xhr;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;j<w.length;j++){if(c['lin'+j]){var f=1;gss(c,cols[j-1]);var xa=0,ya=0,xb=0,yb=0;for(var i=0;i<xn;i++){var x=ar[vx+i];var y=ar[w[j]+vy+i];var xo=(x-x0)/(x1-x0);var yo=(y-y0)/(y1-y0);if(f==1){gbe(c,xo,yo);f=0;xb=xo;yb=yo}else{gct(c,(xa+xb)/2,(ya+yb)/2,xb,yb,(xb+xo)/2,(yb+yo)/2)}xa=xb;ya=yb;xb=xo;yb=yo}gct(c,(xa+xb)/2,(ya+yb)/2,xo,yo,xo,yo);gst(c)}}}else{for(var j=1;j<w.length;j++){if(c['lin'+j]){var f=1;gss(c,cols[j-1]);for(var i=0;i<xn;i++){var x=ar[vx+i];var y=ar[w[j]+vy+i];var xo=(x-x0)/(x1-x0);var yo=(y-y0)/(y1-y0);if(f==1){gbe(c,xo,yo);f=0}else{gln(c,xo,yo)}}gst(c)}}}glw(c,1);for(var j=1;j<w.length;j++){if(av[j-1]>0 && 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<c['hrs'][j]){c['hr']=j}else{break}}if(tl<0.5){var tb=1/tl;for(var k=0;k<c['hln'].length;k++){if(c['hln'][k]<tb){c['hl']=k}else{break}}}else{c['hl']=1}}
|
||||
function gopt(c,cbx){for(var i=0;i<cbx.length;i++){ccb(c,cbx[i])}}
|
||||
function gsh(c,w){for(var i=1;i<w.length;i++){ccbd(c,'lin'+i,true)}}
|
||||
function doinit(cbx,xon){for(var i=0;i<cbx.length;i++){var e=document.getElementById(cbx[i]);if(e){var n=gcn(cbx[i]);if(n==''){if(xon[cbx[i]]){e.checked=true}else{e.checked=false}}else{if(n=='1'){e.checked=true}else{e.checked=false}}}}}
|
||||
";
|
||||
return $g;
|
||||
}
|
||||
#
|
||||
function TipsJS()
|
||||
{
|
||||
$t = "function untip(e){if(e){if(typeof e.tmo!='undefined'){clearTimeout(e.tmo);delete e.tmo}e.style.opacity=0;e.style.visibility='hidden'}}
|
||||
function tip(i,n){var e=document.getElementById(i);if(e){if(e.style.visibility=='visible'){untip(e)}else{e.style.visibility='visible';e.style.opacity=0.95;e.tmo=setTimeout(function(){untip(e)},n)}}}
|
||||
";
|
||||
return $t;
|
||||
}
|
||||
#
|
||||
function TipsCSS()
|
||||
{
|
||||
$c = "span.tip0 {position:absolute;z-index:42;pointer-events:none;font-size:smaller;text-align:left;}
|
||||
span.notip {position:relative;color:#0077ee;background:#bbffff;border-style:solid;border-color:black;border-width:1px;left:-10px;width:200px;padding:2px;float:left;transition:visibility 0.5s,opacity 0.5s;visibility:hidden;opacity:0;}
|
||||
span.tip {visibility:visibile;}
|
||||
span.q {position:relative;width:16px;height:16px;display:inline-block;background-color:#0077ee;line-height:16px;color:White;font-size:13px;font-weight:bold;border-radius:8px;text-align:center;cursor:pointer;}
|
||||
ul.tip {margin-top:0;margin-bottom:0;list-style:disc inside none;margin-left:0;padding-left:0.5em;display:block;}
|
||||
li {padding-left:0.5em;}
|
||||
";
|
||||
return $c;
|
||||
}
|
||||
#
|
||||
function HeadJS()
|
||||
{
|
||||
$h = "function gcn(n){var ans='',d=document.cookie;if(d){var c0=d.indexOf(n+'='),cs=d.indexOf(' '+n+'=');if(c0==0 || cs>0){if(cs>0){c0=cs+1}var c=d.substr(c0).split(';',1);var e=c[0].indexOf('=');if(e>0){ans=c[0].substr(e+1)}}}return ans}
|
||||
function scnv(n,v){var d=new Date();d.setTime(d.getTime()+(864*Math.pow(10,8)));document.cookie=n+'='+v+';expires='+d.toUTCString()+';path=/'}
|
||||
function ni(e,o){if(e){if(o==0){e.defd=e.style.display;e.style.display='none'}else{e.style.display=e.defd}}}
|
||||
function domin(o){var e=document.getElementById('minicb');if(e){if(o==0){e.checked=true}else{e.checked=false}}for(var i=0;i<10;i++){e=document.getElementById('mini'+i);ni(e,o)}}
|
||||
function mini(){var hm=gcn('mini');if(hm==''){domin(1)}else{domin(0)}}
|
||||
function md(e){var c='';if(e.checked){c='y'}scnv('mini',c);mini()}
|
||||
function tim(){var e=document.getElementById('ftr');if(e){var now=new Date(),t=document.createTextNode(now.toLocaleString());e.appendChild(t)}}
|
||||
function jst(){var e=document.getElementById('jst');if(e){e.style.visibility='hidden'}}
|
||||
";
|
||||
return $h;
|
||||
}
|
||||
#
|
||||
function HeadCSS()
|
||||
{
|
||||
$h = "input[type=checkbox] {vertical-align:-2px;}
|
||||
form {display:inline-block;}
|
||||
html, body {height:100%;font-family:Arial, Verdana, sans-serif;font-size:12pt;background-color:#eeffff;text-align:center;background-repeat:no-repeat;background-position:center;}
|
||||
.page {min-height:100%;height:auto !important;height:100%;margin:0 auto -50px;position:relative;}
|
||||
div.jst {color:red;font-weight:bold;font-size:8;text-align:center;vertical-align:top;}
|
||||
div.accwarn {color:red;font-weight:bold;font-size:8;text-align:center;vertical-align:top;}
|
||||
div.topd {background-color:#cff;border-color:#cff;border-style:solid;border-width:9px;}
|
||||
.topdes {color:blue;text-align:right;}
|
||||
.topdesl {color:blue;text-align:left;}
|
||||
.topwho {color:black;font-weight:bold;margin-right:8px;}
|
||||
.topdat {margin-left:8px;margin-right:24px;color:green;font-weight:bold;}
|
||||
span.nb {white-space:pre;}
|
||||
span.login {float:right;margin-left:8px;margin-right:24px;}
|
||||
span.hil {color:blue;}
|
||||
span.user {color:green;}
|
||||
span.addr {color:brown;}
|
||||
span.hdr {font-weight:bold;text-decoration:underline;}
|
||||
span.nn {font-weight:bold;color:red;}
|
||||
span.warn {color:orange;font-weight:bold;}
|
||||
span.urg {color:red;font-weight:bold;}
|
||||
span.notice {color:blue;font-weight:bold;font-size:120%;}
|
||||
span.err {color:red;font-weight:bold;font-size:120%;}
|
||||
span.alert {color:red;font-weight:bold;font-size:250%;}
|
||||
input.tiny {width:0px;height:0px;margin:0px;padding:0px;outline:none;border:0px;}
|
||||
#n42 {margin:0;position:relative;color:#ffffff;background:#0077ee;}
|
||||
#n42 a {color:#fff;text-decoration:none;padding:6px;display:block;}
|
||||
#n42 td {min-width:100px;float:left;vertical-align:top;padding:0px 2px;}
|
||||
#n42 td.navboxr {float:right;}
|
||||
#n42 td.nav0 {position:relative;}
|
||||
#n42 td.nav {position:relative;}
|
||||
#n42 td.ts {border-width:1px;border-color:#0022ee;border-style:solid none none none;}
|
||||
#n42 div.sub {left:0px;z-index:42;position:absolute;visibility:hidden;}
|
||||
#n42 td.nav0:hover {background:#0099ee;}
|
||||
#n42 td.nav:hover {background:#0099ee;}
|
||||
#n42 td.nav:hover div.sub {background:#0077ee;visibility:visible;}
|
||||
h1 {margin-top:20px;float:middle;font-size:20px;}
|
||||
.foot, .push {height:50px;}
|
||||
.title {background-color:#909090;}
|
||||
.even {background-color:#cccccc;}
|
||||
.evenu td {background-color:#cccccc;border-bottom:2px solid red;}
|
||||
.odd {background-color:#a8a8a8;}
|
||||
.oddu td {background-color:#a8a8a8;border-bottom:2px solid red;}
|
||||
.hid {display:none;}
|
||||
.dl {text-align:left;padding:2px 8px;}
|
||||
.dr {text-align:right;padding:2px 8px;}
|
||||
.dc {text-align:center;padding:2px 8px;}
|
||||
.dls {text-align:left;padding:2px 8px;text-decoration:line-through;font-weight:lighter;}
|
||||
.drs {text-align:right;padding:2px 8px;text-decoration:line-through;font-weight:lighter;}
|
||||
.dcs {text-align:center;padding:2px 8px;text-decoration:line-through;font-weight:lighter;}
|
||||
.st0 {font-weight:bold;}
|
||||
.st1 {color:red;font-weight:bold;}
|
||||
.st2 {color:green;font-weight:bold;}
|
||||
.st3 {color:blue;font-weight:bold;}
|
||||
.fthi {color:red;font-size:7px;}
|
||||
.ftlo {color:green;font-size:7px;}
|
||||
.ft {color:blue;font-size:7px;}
|
||||
.ftl {text-align:left;color:blue;font-size:7px;display:inline-block;width:20%;white-space:nowrap;}
|
||||
.ftm {text-align:middle;font-size:10pt;display:inline-block;width:60%;white-space:nowrap;}
|
||||
.ftr {text-align:right;color:blue;font-size:7px;display:inline-block;width:20%;white-space:nowrap;}
|
||||
";
|
||||
return $h;
|
||||
}
|
||||
#
|
||||
function SortJS()
|
||||
{
|
||||
$s = "function sot(t,s,o){if(t && s>=0){var tb=t.getElementsByTagName('tbody')[0];if(tb){var rs=tb.rows;if(rs && rs.length>0){var all=[], rn, ok=true;for(rn=0;rn<rs.length;rn++){if(rs[rn]){var c=rs[rn].cells[s];if(c){var key=c.getAttribute('data-srt');if(key){all.push([rs[rn],key])}else{all.push([rs[rn],c.innerHTML])}}else{ok=false}}else{ok=false}}if(ok){if(o=='s'){all.sort(function(a,b){return a[1].localeCompare(b[1])})}if(o=='n'){all.sort(function(a,b){return a[1]-b[1]})}if(o=='r'){all.sort(function(a,b){return b[1]-a[1]})}var ch=tb.firstChild;while (ch){tb.removeChild(ch);ch=tb.firstChild}for(rn=0;rn<all.length;rn++){if(rn%2){all[rn][0].className='odd'}else{all[rn][0].className='even'}tb.appendChild(all[rn][0])}}}}}}
|
||||
function sott(cn,t){if(t){var sf=t.getAttribute('data-sf');var o=sf.substring(0,1);var s=Number(sf.substring(1));var id=t.id;scnv(cn,id);t.checked=true;sot(t.parentNode.parentNode.parentNode.parentNode.parentNode,s,o)}}
|
||||
function sotn(cn,n){var e=document.getElementById(n);if(e){sott(cn,e)}}
|
||||
function sotc(cn,d){var ws=gcn(cn);if(ws==''){ws=d}sotn(cn,ws)}
|
||||
";
|
||||
return $s;
|
||||
}
|
||||
#
|
||||
function QRJS()
|
||||
{
|
||||
$q = "function qr(tw,fa,qrx,qry,qrd){if(hasCan()){gcxy(c,qrx*4,qry*4);gfs(c,'white');gss(c,'white');gbd(c);gfs(c,'black');gss(c,'black');for(var y=0;y<qry;y++){var x=0,b=0;for(var j=0;j<qrx;j+=4){var n=qrd[y].substr(b,1).charCodeAt(0)-97;for(k=0;k<4;k++){if(n & (1<<k)){gbe(c,x/qrx,1-(y/qry));gln(c,(x+1)/qrx,1-(y/qry));gln(c,(x+1)/qrx,1-((y+1)/qry));gln(c,x/qrx,1-((y+1)/qry));gle(c);gfl(c)}x++}b++}}}}
|
||||
";
|
||||
return $q;
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,4 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html><body>
|
||||
<h1>Web configuration needs adjustment</h1>
|
||||
</body></html>
|
||||
638
pool/page.php
638
pool/page.php
@ -1,638 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('inc.php');
|
||||
#
|
||||
global $site_title;
|
||||
global $page_title;
|
||||
global $page_scripts;
|
||||
global $page_css;
|
||||
#
|
||||
$site_title = 'CKPool';
|
||||
$page_title = $site_title;
|
||||
$page_scripts = '';
|
||||
$page_css = '';
|
||||
#
|
||||
global $dont_trm;
|
||||
$dont_trm = false;
|
||||
#
|
||||
// work out the page from ?k=page
|
||||
function getPage()
|
||||
{
|
||||
$uri = $_SERVER["REQUEST_URI"];
|
||||
|
||||
$names = explode('k=', trim($uri));
|
||||
if (count($names) < 2)
|
||||
return '';
|
||||
|
||||
$vals = explode('&', trim($names[1]));
|
||||
if (count($vals) < 1)
|
||||
return '';
|
||||
|
||||
return trim($vals[0]);
|
||||
}
|
||||
#
|
||||
function addScript($script)
|
||||
{
|
||||
global $page_scripts;
|
||||
|
||||
if ($script != null and trim($script) != '')
|
||||
{
|
||||
if ($page_scripts == '')
|
||||
$page_scripts = "<script type='text/javascript'>\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 = "<a href='".makeURL($page)."'";
|
||||
if ($rest != '')
|
||||
$href .= " $rest";
|
||||
$href .= '>';
|
||||
|
||||
return $href;
|
||||
}
|
||||
#
|
||||
function makeForm($page)
|
||||
{
|
||||
$form = '<form action=index.php method=POST>';
|
||||
if (strlen($page) > 0)
|
||||
$form .= "<input type=hidden name=k value=$page>";
|
||||
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 = "<!DOCTYPE html>\n";
|
||||
|
||||
$head .= "<html><head><title>$page_title$name</title>";
|
||||
$head .= "<meta content='text/html; charset=iso-8859-1' http-equiv='Content-Type'>";
|
||||
$head .= "<meta content='IE=edge' http-equiv='X-UA-Compatible'>";
|
||||
$head .= "<meta content='width=device-width, initial-scale=1' name='viewport'>";
|
||||
|
||||
$head .= "<script type='text/javascript'>\n";
|
||||
$head .= HeadJS();
|
||||
$head .= "\n</script>\n";
|
||||
$head .= "<style type='text/css'>\n";
|
||||
$head .= HeadCSS();
|
||||
$head .= "\n$css_marker\n</style>\n";
|
||||
|
||||
$head .= '<meta name="robots" content="noindex">';
|
||||
|
||||
$head .= $script_marker; // where to put the scripts
|
||||
|
||||
$head .= '</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 = "<noscript><div class=jst id=jst> Javascript isn't enabled.";
|
||||
$top .= " You need to enable javascript to use";
|
||||
$top .= " the $site_title web site.</div></noscript>";
|
||||
|
||||
$top .= $alert_marker;
|
||||
if ($loginfailed === true)
|
||||
$top .= '<div class=accwarn>Login Failed</div>';
|
||||
if (isset($info['u_nopayaddr']))
|
||||
$top .= '<div class=accwarn>Please set a payout address on your account!</div>';
|
||||
if (isset($info['u_noemail']))
|
||||
$top .= '<div class=accwarn>Please set an email address on your account!</div>';
|
||||
|
||||
$top .= '<div class=topd>';
|
||||
if ($dotop === true)
|
||||
{
|
||||
$lh = ''; $ls = ''; $lw = '';
|
||||
if (isset($info['now']) && isset($info['lastsh'])
|
||||
&& isset($info['lasthb']) && isset($info['lastwi']))
|
||||
{
|
||||
$lsn = $info['now'] - $info['lastsh'];
|
||||
$lhn = $info['now'] - $info['lasthb'];
|
||||
$lwn = $info['now'] - $info['lastwi'];
|
||||
if ($lsn < 8)
|
||||
$lsc = 'green.png';
|
||||
else
|
||||
{
|
||||
if ($lsn < 10)
|
||||
$lsc = 'orange.png';
|
||||
else
|
||||
$lsc = 'red.png';
|
||||
}
|
||||
if ($lhn < 5)
|
||||
$lhc = 'green.png';
|
||||
else
|
||||
{
|
||||
if ($lhn < 10)
|
||||
$lhc = 'orange.png';
|
||||
else
|
||||
$lhc = 'red.png';
|
||||
}
|
||||
if ($lwn < 36)
|
||||
$lwc = 'green.png';
|
||||
else
|
||||
{
|
||||
if ($lwn < 46)
|
||||
$lwc = 'orange.png';
|
||||
else
|
||||
$lwc = 'red.png';
|
||||
}
|
||||
$img1 = '<img border=0 src=/';
|
||||
$img2 = '>';
|
||||
$ls = $img1.$lsc.$img2;
|
||||
$lh = $img1.$lhc.$img2;
|
||||
$lw = $img1.$lwc.$img2;
|
||||
}
|
||||
|
||||
if (!isset($info['users']))
|
||||
$info['users'] = '?';
|
||||
if (!isset($info['workers']))
|
||||
$info['workers'] = '?';
|
||||
|
||||
$top .= '<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td>';
|
||||
$top .= '<table cellpadding=1 cellspacing=0 border=0>';
|
||||
$top .= "<tr><td class=topdes>$lh</td></tr>";
|
||||
$top .= "<tr><td class=topdes>$ls</td></tr>";
|
||||
$top .= "<tr id=mini0><td class=topdes>$lw</td></tr></table>";
|
||||
$top .= '</td><td>';
|
||||
$top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
|
||||
$top .= '<tr><td class=topdes>CKPool: </td>';
|
||||
$top .= "<td class=topdat> $phr</td></tr>";
|
||||
$top .= '<tr><td class=topdes>Shares: </td>';
|
||||
$top .= "<td class=topdat> $pac</td></tr>";
|
||||
$top .= '<tr id=mini1><td class=topdes>Invalids: </td>';
|
||||
$top .= "<td class=topdat> $per</td></tr></table>";
|
||||
$top .= '</td><td>';
|
||||
$top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
|
||||
$top .= '<tr><td class=topdes>Last </td>';
|
||||
$top .= '<td class=topdesl>Block</td></tr>';
|
||||
$top .= '<tr><td class=topdes>Pool: </td>';
|
||||
$top .= "<td class=topdat> $plb</td></tr>";
|
||||
$top .= '<tr id=mini2><td class=topdes>Network: </td>';
|
||||
$top .= "<td class=topdat> $nlb</td></tr></table>";
|
||||
$top .= '</td><td id=mini3>';
|
||||
$top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
|
||||
$top .= '<tr><td class=topdes>Users: </td>';
|
||||
$top .= '<td class=topdat> '.$info['users'].'</td></tr>';
|
||||
$top .= '<tr><td class=topdes>Workers: </td>';
|
||||
$top .= '<td class=topdat> '.$info['workers'].'</td></tr></table>';
|
||||
$top .= '</td><td>';
|
||||
|
||||
if ($douser === true)
|
||||
{
|
||||
$top .= '<span class=login>';
|
||||
list($who, $whoid) = validate();
|
||||
if ($who == false)
|
||||
{
|
||||
$top .= '<table cellpadding=0 cellspacing=0 border=0><tr><td>';
|
||||
$top .= '<a href="https://' . $_SERVER['SERVER_NAME'];
|
||||
$top .= '/index.php?Register=1">Login<br>Register</a>';
|
||||
$top .= '</td></tr></table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra = '';
|
||||
if (strlen($who) > 12)
|
||||
{
|
||||
$who = substr($who, 0, 12);
|
||||
$extra = '…';
|
||||
}
|
||||
$top .= "<span class=topwho>".htmlspecialchars($who)."$extra </span>";
|
||||
$top .= makeForm('');
|
||||
$top .= "<input type=submit name=Logout value=Logout></form>";
|
||||
$top .= "<br><span class=topdes>Hash Rate:</span>";
|
||||
$top .= "<span class=topdat>$uhr$u1hr</span><br>";
|
||||
}
|
||||
|
||||
$top .= '</span>';
|
||||
}
|
||||
$top .= '</td></tr></table>';
|
||||
}
|
||||
else
|
||||
$top .= ' ';
|
||||
|
||||
$top .= '</div>';
|
||||
return $top;
|
||||
}
|
||||
#
|
||||
function pgmenu($menus)
|
||||
{
|
||||
$ret = "\n<table cellpadding=0 cellspacing=0 border=0 width=100% id=n42>";
|
||||
$ret .= '<tr><td width=100%>';
|
||||
$ret .= '<table cellpadding=0 cellspacing=0 border=0 width=100%>';
|
||||
$ret .= '<tr>';
|
||||
$side = '';
|
||||
foreach ($menus as $menu => $submenus)
|
||||
{
|
||||
if ($menu == 'Admin' && $submenus == null)
|
||||
continue;
|
||||
|
||||
if ($menu == 'gap')
|
||||
{
|
||||
$side = 'r';
|
||||
continue;
|
||||
}
|
||||
$ret .= "<td class=navbox$side><table cellpadding=0 cellspacing=0 border=0>";
|
||||
$first = true;
|
||||
foreach ($submenus as $submenu => $item)
|
||||
{
|
||||
if ($first == true)
|
||||
{
|
||||
$first = false;
|
||||
if ($submenu == $menu)
|
||||
{
|
||||
$ret .= "<tr><td class=nav0>".makeLink($item)."$menu</a>";
|
||||
$ret .= '<div class=sub><table cellpadding=0 cellspacing=0 border=0 width=100%>';
|
||||
continue;
|
||||
}
|
||||
$ret .= "<tr><td class=nav onclick=''><a>$menu</a>";
|
||||
$ret .= '<div class=sub><table cellpadding=0 cellspacing=0 border=0 width=100%>';
|
||||
}
|
||||
$ret .= "<tr><td class=ts>".makeLink($item,'class=as')."$submenu</a></td></tr>";
|
||||
}
|
||||
if ($first == false)
|
||||
$ret .= '</table></div></td></tr></table>';
|
||||
$ret .= '</td>';
|
||||
}
|
||||
$ret .= "</tr></table></td></tr></table>\n";
|
||||
return $ret;
|
||||
}
|
||||
#
|
||||
function pgbody($alert_marker, $info, $page, $menu, $dotop, $user, $douser)
|
||||
{
|
||||
$body = '<body';
|
||||
if ($page == 'index')
|
||||
$body .= ' background=/BTC20.png';
|
||||
$body .= '><div class=page>';
|
||||
$body .= '<table border=0 cellpadding=0 cellspacing=0 width=100%>';
|
||||
|
||||
$body .= '<tr><td><center>';
|
||||
$body .= '<table border=0 cellpadding=0 cellspacing=0 width=94%>';
|
||||
|
||||
$body .= '<tr><td>';
|
||||
$body .= pgtop($alert_marker, $info, $dotop, $user, $douser);
|
||||
$body .= '</td></tr>';
|
||||
|
||||
$body .= '<tr><td>';
|
||||
$body .= pgmenu($menu);
|
||||
$body .= '</td></tr>';
|
||||
|
||||
$body .= '<tr><td><div align=center>';
|
||||
|
||||
return $body;
|
||||
}
|
||||
#
|
||||
function pgfoot($elapsed_marker, $info)
|
||||
{
|
||||
global $stt;
|
||||
$foot = '</div></td></tr>';
|
||||
$foot .= '</table>';
|
||||
$foot .= '</center></td></tr>';
|
||||
$foot .= '</table>';
|
||||
$foot .= '<div class=push></div></div>';
|
||||
$std = gmdate('jS M H:i:s \U\T\C', intval($stt));
|
||||
$foot .= "<div class=foot><br><span class=ftl>$std </span><span class=ftm>";
|
||||
if (is_array($info) && isset($info['sync']))
|
||||
{
|
||||
$sync = $info['sync'];
|
||||
if ($sync > 5000)
|
||||
$syc = 'hi';
|
||||
else
|
||||
$syc = 'lo';
|
||||
$syncd = number_format($sync);
|
||||
$foot .= "<span class=ft$syc>sync: $syncd</span> ";
|
||||
}
|
||||
$foot .= 'Copyright © Kano 2014';
|
||||
$now = date('Y');
|
||||
if ($now != '2014')
|
||||
$foot .= "-$now";
|
||||
$foot .= ' <span class=ft>' . $elapsed_marker;
|
||||
$foot .= '</span></span><span class=ftr id=ftr> </span></div>';
|
||||
$foot .= "<script type='text/javascript'>jst();tim();mini();</script></body></html>\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.'<br>';
|
||||
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 .= "</script>";
|
||||
|
||||
$head = str_replace($script_marker, $page_scripts, $head);
|
||||
|
||||
$alertstr = '';
|
||||
foreach ($alrts as $str => $num)
|
||||
$alertstr .= "<div class=accwarn>$str</div>";
|
||||
$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);
|
||||
}
|
||||
?>
|
||||
@ -1,285 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('email.php');
|
||||
#
|
||||
function app_txt($ones)
|
||||
{
|
||||
$app = "The free and recommended $ones that ";
|
||||
$app .= "have been tested here are:<br><span class=hil>";
|
||||
$app .= "Android: Google Play '<b>FreeOTP Authenticator</b>' by Red Hat<br>";
|
||||
$app .= "Apple: App Store '<b>OTP Auth</b>' by Roland Moers</span><br><br>";
|
||||
return $app;
|
||||
}
|
||||
#
|
||||
function app_time()
|
||||
{
|
||||
$app = "Apps to check that your device time is accurate:<br>";
|
||||
$app .= "<span class=hil>";
|
||||
$app .= "Android: Google Play '<b>ClockSync</b>' by Sergey Baranov<br>";
|
||||
$app .= "</span><br>";
|
||||
return $app;
|
||||
}
|
||||
#
|
||||
function set_2fa($data, $user, $tfa, $ans, $err, $msg)
|
||||
{
|
||||
$draw = false;
|
||||
|
||||
$pg = '<h1>Two Factor Authentication Settings</h1>';
|
||||
|
||||
if ($err !== null and $err != '')
|
||||
$pg .= "<span class=err>$err<br><br></span>";
|
||||
|
||||
if ($msg !== null and $msg != '')
|
||||
$pg .= "<span class=notice>$msg<br><br></span>";
|
||||
|
||||
$pg .= '<table cellpadding=20 cellspacing=0 border=1>';
|
||||
$pg .= '<tr class=dc><td><center>';
|
||||
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=0>';
|
||||
$pg .= '<tr class=dc><td>';
|
||||
switch ($tfa)
|
||||
{
|
||||
case '':
|
||||
$pg .= '<tr class=dl><td>';
|
||||
$pg .= "You don't have Two Factor Authentication (2FA) setup yet<br><br>";
|
||||
$pg .= 'To use 2FA you need an App on your phone/tablet<br>';
|
||||
$pg .= app_txt('ones');
|
||||
$pg .= makeForm('2fa');
|
||||
$pg .= 'Click here to begin the setup process for 2FA: ';
|
||||
$pg .= '<input type=submit name=Setup value=Setup>';
|
||||
$pg .= '</form></td></tr>';
|
||||
break;
|
||||
case 'test':
|
||||
$pg .= '<tr class=dc><td>';
|
||||
$pg .= '2FA is not yet enabled.<br>';
|
||||
$pg .= 'Your 2FA key has been created but needs testing.<br><br>';
|
||||
if (isset($ans['2fa_key']))
|
||||
{
|
||||
$key = $ans['2fa_key'];
|
||||
$sfainfo = $ans['2fa_issuer'].': '.$ans['2fa_auth'].' '.
|
||||
$ans['2fa_hash'].' '.$ans['2fa_time'].'s';
|
||||
$who = substr($user, 0, 8);
|
||||
$sfaurl = 'otpauth://'.$ans['2fa_auth'].'/'.$ans['2fa_issuer'].
|
||||
':'.htmlspecialchars($who).'?secret='.$ans['2fa_key'].
|
||||
'&algorithm='.$ans['2fa_hash'].'&issuer='.$ans['2fa_issuer'];
|
||||
$draw = true;
|
||||
addQR();
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = 'unavailable';
|
||||
$sfainfo = 'unavailable';
|
||||
$sfaurl = 'unavailable';
|
||||
}
|
||||
$pg .= "Your <span class=urg>2FA Secret Key</span> is: $key<br>";
|
||||
$pg .= "2FA Settings are $sfainfo<br><br>";
|
||||
$pg .= "To setup 2FA in your App: <a href='$sfaurl'>Click here</a><br>";
|
||||
$pg .= "or scan the qrcode/barcode below with your App:<br><br>";
|
||||
$pg .= '<div id=can0><canvas id=can width=1 height=1>';
|
||||
$pg .= 'A qrcode will show here if your browser supports html5/canvas';
|
||||
$pg .= "</canvas></div><br>";
|
||||
$pg .= makeForm('2fa');
|
||||
$pg .= 'Then enter your App 2FA Value: <input name=Value value="" size=10> ';
|
||||
$pg .= '<input type=submit name=Test value=Test></form><br>';
|
||||
$pg .= 'The 2FA Value is always a 6 digit number</td></tr>';
|
||||
$pg .= '<tr class=dl><td>';
|
||||
$pg .= app_txt('2FA apps');
|
||||
$pg .= '<span class=urg>N.B.</span> if you wish to setup 2FA on more than one device,<br>';
|
||||
$pg .= 'you should setup all devices before testing one of them.<br>';
|
||||
$pg .= 'If you have an old <span class=urg>2FA Secret Key</span> in your device for this web site,<br>';
|
||||
$pg .= 'delete it before scanning in the new <span class=urg>2FA Secret Key</span>.<br><br>';
|
||||
$pg .= '<span class=urg>WARNING:</span> if you lose your 2FA device you will need to know<br>';
|
||||
$pg .= 'the <span class=urg>2FA Secret Key</span> to manually setup a new device,<br>';
|
||||
$pg .= 'so your should copy it and store it somewhere securely.<br>';
|
||||
$pg .= 'For security reasons, the site will not show you an active <span class=urg>2FA Secret Key</span>.<br>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dl><td>';
|
||||
$pg .= makeForm('2fa');
|
||||
$pg .= '<br>If you wish to cancel setting up 2FA, click here: ';
|
||||
$pg .= '<input type=submit name=Cancel value=Cancel></form></td></tr>';
|
||||
break;
|
||||
case 'ok':
|
||||
$pg .= '<tr class=dc><td>';
|
||||
$pg .= '2FA is enabled on your account.<br><br>';
|
||||
$pg .= 'If you wish to replace your Secret Key with a new one:<br><br>';
|
||||
$pg .= makeForm('2fa');
|
||||
$pg .= 'Current 2FA Value: <input name=Value value="" size=10> ';
|
||||
$pg .= '<input type=submit name=New value=New><span class=st1>*</span>';
|
||||
$pg .= '</form><br><br>';
|
||||
$pg .= '<span class=st1>*</span>WARNING: replacing the Secret Key will disable 2FA<br>';
|
||||
$pg .= 'until you successfully test the new key,<br>';
|
||||
$pg .= 'thus getting a new key is effectively the same as disabling 2FA.<br><br>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td>';
|
||||
$pg .= makeForm('2fa');
|
||||
$pg .= 'If you wish to remove 2FA from your account,<br>';
|
||||
$pg .= 'enter your App 2FA Value: <input name=Value value="" size=10><br>';
|
||||
$pg .= 'then click remove: <input type=submit name=Remove value=Remove>';
|
||||
$pg .= '</form></td></tr>';
|
||||
break;
|
||||
}
|
||||
$pg .= '</table>';
|
||||
$pg .= '</center></td></tr>';
|
||||
|
||||
$pg .= '<tr class=dl><td>';
|
||||
$pg .= '2FA means that you need 2 codes to login to your account.<br>';
|
||||
$pg .= 'You will also need the 2FA code to modify any important settings in your account.<br>';
|
||||
$pg .= 'The 1st code is your current password.<br>';
|
||||
$pg .= 'The 2nd code is a number that your 2FA device will generate each time.<br>';
|
||||
$pg .= 'Your 2FA device would be, for example, your phone or tablet.<br><br>';
|
||||
$pg .= 'Each time you need a 2FA code, you use your device to generate a number<br>';
|
||||
$pg .= 'that you type into the "<span class=st1>*</span>2nd Authentication:" field on any page that has it.<br><br>';
|
||||
$pg .= '<b>IMPORTANT:</b> the TOTP algorithm uses the time on your device,<br>';
|
||||
$pg .= "so it is important that your device's clock is accurate within a few seconds.<br><br>";
|
||||
$pg .= app_time();
|
||||
$pg .= '<b>IMPORTANT:</b> you enter the value from your App at the time you submit data.<br>';
|
||||
$pg .= "The value is valid only once for a maximum of 30 seconds.<br>";
|
||||
$pg .= "In both the Apps it has a 'dial' that shows the 30 seconds running out.<br>";
|
||||
$pg .= "If you are close to running out, you can wait for the 30 seconds to run out<br>";
|
||||
$pg .= "and then enter the new value it will come up with.<br>";
|
||||
$pg .= "The pool checks your value using the time at the pool when you submit the data,<br>";
|
||||
$pg .= "it doesn't matter when you loaded the web page,<br>";
|
||||
$pg .= "it only matters when you clicked on the web page button to send the data to the pool.<br><br>";
|
||||
$pg .= '<span class=urg>WARNING:</span> once you have successfully tested and enabled 2FA,<br>';
|
||||
$pg .= 'you will be unable to access or even reset your account without 2FA.<br>';
|
||||
$pg .= 'There is no option to recover your 2FA from the web site,<br>';
|
||||
$pg .= 'and you must know your 2FA code in order to be able to disable 2FA.<br><br>';
|
||||
$pg .= '<span class=urg>WARNING:</span> it is important to <b>not</b> store your login password in your 2FA device.<br>';
|
||||
$pg .= 'These 2 together will give full access to your account.';
|
||||
$pg .= '</td></tr>';
|
||||
|
||||
$pg .= '</table>';
|
||||
|
||||
if ($draw !== false)
|
||||
{
|
||||
$qr = shell_exec("../pool/myqr.sh '$sfaurl'");
|
||||
if ($qr !== null and strlen($qr) > 30)
|
||||
{
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= "${qr}qr(tw,fa,qrx,qry,qrd);</script>\n";
|
||||
|
||||
if (strpos($qr, 'var tw=1,fa=0,qrx=') === false)
|
||||
error_log("QR error for '$user' res='$qr'");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($qr === null)
|
||||
$qr = 'null';
|
||||
error_log("QR failed for '$user' res='$qr'");
|
||||
}
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,207 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('email.php');
|
||||
#
|
||||
function addrmgtuser($data, $user, $err)
|
||||
{
|
||||
$pg = '<h1>Address Management</h1>';
|
||||
|
||||
if ($err != '')
|
||||
$pg .= "<span class=err>$err<br><br></span>";
|
||||
|
||||
$pg .= makeForm('addrmgt');
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dc>#</td>';
|
||||
$pg .= '<td class=dl>Address</td>';
|
||||
$pg .= '<td class=dl>ID</td>';
|
||||
$pg .= '<td class=dr>Ratio</td>';
|
||||
$pg .= '<td class=dr>%</td>';
|
||||
$pg .= '</tr></thead>';
|
||||
|
||||
# new row template for '+'
|
||||
$pg .= '<tr class=hid id=bs>';
|
||||
$pg .= '<td class=dc> </td>';
|
||||
$pg .= '<td class=dl>';
|
||||
$pg .= "<input type=text size=36 name='addr:' value=''>";
|
||||
$pg .= '</td>';
|
||||
$pg .= '<td class=dl>';
|
||||
$pg .= "<input type=text size=16 name='payname:' value=''>";
|
||||
$pg .= '</td>';
|
||||
$pg .= '<td class=dr>';
|
||||
$pg .= "<input type=text size=6 name='ratio:' value='0' id=rat onchange='repc()'>";
|
||||
$pg .= '</td>';
|
||||
$pg .= '<td class=dr>';
|
||||
$pg .= "<span id=per>0.00%</span>";
|
||||
$pg .= '</td>';
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$ans = userSettings($user);
|
||||
|
||||
$offset = 0;
|
||||
$count = 0;
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
if (isset($ans['limit']))
|
||||
$limit = $ans['limit'];
|
||||
else
|
||||
$limit = 1;
|
||||
$count = $ans['rows'];
|
||||
# this will output any DB rows > limit but DB update will ignore extras
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if ((($offset) % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$addr = $ans['addr:'.$i];
|
||||
$pg .= '<td class=dc>'.($i+1).'</td>';
|
||||
$pg .= '<td class=dl>';
|
||||
$pg .= "<input type=text size=36 name='addr:$i' value='$addr'>";
|
||||
$pg .= '</td>';
|
||||
$nam = htmlspecialchars($ans['payname:'.$i]);
|
||||
$pg .= '<td class=dl>';
|
||||
$pg .= "<input type=text size=16 name='payname:$i' value='$nam'>";
|
||||
$pg .= '</td>';
|
||||
$ratio = intval($ans['ratio:'.$i]);
|
||||
$pg .= '<td class=dr>';
|
||||
$pg .= "<input type=text size=6 name='ratio:$i' value='$ratio' id=rat$i onchange='repc()'>";
|
||||
$pg .= '</td>';
|
||||
$pg .= '<td class=dr>';
|
||||
$pg .= "<span id=per$i>%</span>";
|
||||
$pg .= '</td>';
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$offset++;
|
||||
}
|
||||
if ($offset < $limit) {
|
||||
if ((($offset++) % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
$pg .= "<tr class=$row id=plus><td class=dc>";
|
||||
$pg .= "<input type=button value='+' onclick='return adrw($limit);'>";
|
||||
$pg .= "</td><td colspan=4 class=dl><font size=-1>limit $limit</font></td></tr>";
|
||||
}
|
||||
|
||||
$pg .= '</tbody><tfoot>';
|
||||
if ((($offset++) % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= '<td class=dr> </td>';
|
||||
$pg .= '<td class=dr>Password:</td>';
|
||||
$pg .= '<td class=dl><input type=password name=pass size=20></td>';
|
||||
$pg .= '<td colspan=2> </td></tr>';
|
||||
|
||||
if ((($offset++) % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= '<td class=dr> </td>';
|
||||
$pg .= '<td class=dr><span class=st1>*</span>2nd Authentication:</td>';
|
||||
$pg .= '<td class=dl><input name=2fa size=10>';
|
||||
$pg .= ' <input type=submit name=OK value=Save></td>';
|
||||
$pg .= '<td colspan=3 class=dl> </td></tr>';
|
||||
|
||||
$pg .= '<tr><td colspan=5 class=dc><font size=-1>';
|
||||
$pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it<br>";
|
||||
$pg .= 'You must enter your password to save changes<br>';
|
||||
$pg .= 'A ratio of 0, will remove the address from the payouts</td></tr></tfoot>';
|
||||
}
|
||||
$pg .= "</table><input type=hidden name=rows value=$count id=rows></form>\n";
|
||||
|
||||
# TODO - adrw() update the odd/even class for the new row and rows below it
|
||||
# TODO - move the js functions into inc.php
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= "function adrw(l){var p=document.getElementById('plus');";
|
||||
$pg .= "var r=document.getElementById('rows');var c=parseInt(r.value);";
|
||||
$pg .= "var bs=document.getElementById('bs');var n=bs.cloneNode(true);n.id='z';";
|
||||
$pg .= "var ia=n.childNodes[1].firstChild;ia.name='addr:'+c;ia.value='';";
|
||||
$pg .= "var ipn=n.childNodes[2].firstChild;ipn.name='payname:'+c;ipn.value='';";
|
||||
$pg .= "var ir=n.childNodes[3].firstChild;ir.id='rat'+c;ir.name='ratio:'+c;ir.value='0';";
|
||||
$pg .= "var ip=n.childNodes[4].firstChild;ip.id='per'+c;ip.innerHTML='0.00%';";
|
||||
$pg .= "p.parentNode.insertBefore(n, p);";
|
||||
$pg .= "c++;r.value=c;if(c>=l){p.parentNode.removeChild(p)}";
|
||||
$pg .= "n.childNodes[0].innerHTML=''+c;n.className='odd';return true}\n";
|
||||
$pg .= "function repc(){var c=parseInt(document.getElementById('rows').value);";
|
||||
$pg .= "if(!isNaN(c)&&c>0&&c<1000){var v=[],tot=0;for(i=0;i<c;i++){";
|
||||
$pg .= "var o=document.getElementById('rat'+i);var ov=parseInt(o.value);if(!isNaN(ov)&&ov>0)";
|
||||
$pg .= "{tot+=ov;v[i]=ov}else{o.value='0';v[i]=0}";
|
||||
$pg .= "}for(i=0;i<c;i++){var p;var r=document.getElementById('per'+i);if(tot<=0)";
|
||||
$pg .= "{p=0}else{p=v[i]*100/tot};r.innerHTML=p.toFixed(2)+'%';";
|
||||
$pg .= "}}};\nrepc();</script>";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
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 .= '<br>';
|
||||
$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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('page_workers.php');
|
||||
#
|
||||
function doallwork($data, $user)
|
||||
{
|
||||
$pg = '<h1>All Workers</h1>';
|
||||
|
||||
$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 .= '<tbody>';
|
||||
$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 .= '</tbody>';
|
||||
$pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid,
|
||||
$totrate, $blockacc, $blockreward, $instances);
|
||||
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_allwork($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doallwork', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,102 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function no_api($json = "")
|
||||
{
|
||||
if (nuem($json))
|
||||
echo 'nil';
|
||||
else
|
||||
echo '{"nil":"0"}';
|
||||
exit(0);
|
||||
}
|
||||
#
|
||||
function show_api($info, $page, $menu, $name, $user)
|
||||
{
|
||||
global $fld_sep;
|
||||
$u = getparam('username', true);
|
||||
if (nutem($u))
|
||||
no_api();
|
||||
$u = deworker($u);
|
||||
if (nutem($u))
|
||||
no_api();
|
||||
$api = getparam('api', true);
|
||||
if (nutem($api))
|
||||
no_api();
|
||||
$jfu = getparam('json', true);
|
||||
$work = getparam('work', true);
|
||||
$ans = getAtts($u, 'KAPIKey.str');
|
||||
if ($ans['STATUS'] != 'ok')
|
||||
no_api($jfu);
|
||||
# TODO: pass $api to ckdb to produce an invalid Key event
|
||||
if (!isset($ans['KAPIKey.str']))
|
||||
no_api($jfu);
|
||||
if ($ans['KAPIKey.str'] != $api)
|
||||
no_api($jfu);
|
||||
if (nuem($work))
|
||||
{
|
||||
$info = homeInfo($u);
|
||||
if ($info === false)
|
||||
no_api($jfu);
|
||||
$rep = fldEncode($info, 'STAMP', true);
|
||||
$rep .= fldEncode($info, 'lastbc', false);
|
||||
$rep .= fldEncode($info, 'lastheight', false);
|
||||
$rep .= fldEncode($info, 'currndiff', false);
|
||||
$rep .= fldEncode($info, 'lastblock', false);
|
||||
$rep .= fldEncode($info, 'lastblockheight', false);
|
||||
$rep .= fldEncode($info, 'blockacc', false);
|
||||
$rep .= fldEncode($info, 'blockerr', false);
|
||||
$rep .= fldEncode($info, 'p_hashrate5m', false);
|
||||
$rep .= fldEncode($info, 'p_hashrate1hr', false);
|
||||
$rep .= fldEncode($info, 'u_hashrate5m', false);
|
||||
$rep .= fldEncode($info, 'u_hashrate1hr', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$info = homeInfo($u);
|
||||
if ($info === false)
|
||||
no_api($jfu);
|
||||
|
||||
$per = false;
|
||||
if (is_array($info) && isset($info['u_multiaddr']))
|
||||
{
|
||||
$percent = getparam('percent', true);
|
||||
if (!nuem($percent))
|
||||
$per = true;
|
||||
}
|
||||
|
||||
if ($per === true)
|
||||
$ans = getPercents($u);
|
||||
else
|
||||
$ans = getWorkers($u);
|
||||
|
||||
if ($ans === false)
|
||||
no_api($jfu);
|
||||
|
||||
$rep = fldEncode($ans, 'STAMP', true);
|
||||
$rep .= fldEncode($ans, 'rows', false);
|
||||
$rows = $ans['rows'];
|
||||
$flds = explode(',', $ans['flds']);
|
||||
$zeflds = '';
|
||||
for ($i = 0; $i < $rows; $i++)
|
||||
foreach ($flds as $fld)
|
||||
if (substr($fld, 0, 7) != 'idlenot')
|
||||
{
|
||||
$rep .= fldEncode($ans, $fld.':'.$i, false);
|
||||
if ($i == 0)
|
||||
$zeflds .= "$fld,";
|
||||
}
|
||||
$rep .= fldEncode($ans, 'arn', false);
|
||||
$rep .= fldEncode($ans, 'arp', false);
|
||||
$rep .= fldEncode(array(), 'flds', false);
|
||||
$rep .= substr($zeflds, 0, -1);
|
||||
}
|
||||
if (nuem($jfu))
|
||||
echo $rep;
|
||||
else
|
||||
{
|
||||
$j = preg_replace("/([^=]+)=([^$fld_sep]*)$fld_sep/", '"$1":"$2",', $rep.$fld_sep);
|
||||
echo '{'.substr($j, 0, -1).'}';
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,554 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function erlcolour($erl)
|
||||
{
|
||||
if ($erl <= 0.5)
|
||||
{
|
||||
$grn = (-0.3 - log10($erl)) * 383;
|
||||
if ($grn < 0)
|
||||
$grn = 0;
|
||||
if ($grn > 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 = '<h1>Block Statistics</h1>';
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= "<thead><tr class=title>";
|
||||
$pg .= "<td class=dl>Description</td>";
|
||||
$pg .= "<td class=dr>Time</td>";
|
||||
$pg .= "<td class=dr>MeanTx%</td>";
|
||||
$pg .= "<td class=dr>Diff%</td>";
|
||||
$pg .= "<td class=dr>Mean%</td>";
|
||||
$pg .= "<td class=dr>CDF[Erl]</td>";
|
||||
$pg .= "<td class=dr>Luck%</td>";
|
||||
|
||||
$tt = "<span class=q onclick='tip(\"ppst\",6000)'>";
|
||||
$tt .= '?</span><span class=tip0>';
|
||||
$tt .= "<span class=notip id=ppst>";
|
||||
$tt .= "Pool PPS%: MeanTx% * Luck% minus the pool fee</span></span>";
|
||||
|
||||
$pg .= "<td class=dr>${tt}PPS%</td>";
|
||||
$pg .= "</tr></thead><tbody>\n";
|
||||
|
||||
$since = $data['info']['lastblock'];
|
||||
|
||||
$count = $ans['s_rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$desc = $ans['s_desc:'.$i];
|
||||
$age = daysago($since - $ans['s_prevcreatedate:'.$i]);
|
||||
$diff = number_format(100 * $ans['s_diffratio:'.$i], 2);
|
||||
$mean = number_format(100 * $ans['s_diffmean:'.$i], 2);
|
||||
|
||||
$cdferl = $ans['s_cdferl:'.$i];
|
||||
list($fg, $bg) = erlcolour($cdferl);
|
||||
$cdferldsp = "<font color=$fg>".number_format($cdferl, 4).'</font>';
|
||||
$bg = " bgcolor=$bg";
|
||||
|
||||
$luck = number_format(100 * $ans['s_luck:'.$i], 2);
|
||||
$txm = number_format(100 * $ans['s_txmean:'.$i], 1);
|
||||
|
||||
$o = number_format((100 - $poolfee) * $ans['s_txmean:'.$i] / $ans['s_diffmean:'.$i], 2);
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dl>$desc Blocks</td>";
|
||||
$pg .= "<td class=dr>$age</td>";
|
||||
$pg .= "<td class=dr>$txm%</td>";
|
||||
$pg .= "<td class=dr>$diff%</td>";
|
||||
$pg .= "<td class=dr>$mean%</td>";
|
||||
$pg .= "<td class=dr$bg>$cdferldsp</td>";
|
||||
$pg .= "<td class=dr>$luck%</td>";
|
||||
$pg .= "<td class=dr>$o%</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= "</tbody></table>\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 = '<h1>Monthly Statistics</h1>';
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= "<thead><tr class=title>";
|
||||
$pg .= "<td class=dl>UTC Month</td>";
|
||||
$pg .= "<td class=dr>Pool Avg</td>";
|
||||
$pg .= "<td class=dr>Blocks</td>";
|
||||
$pg .= "<td class=dr>Expected</td>";
|
||||
$pg .= "<td class=dr>Mean Diff%</td>";
|
||||
$pg .= "<td class=dr>MeanTx%</td>";
|
||||
$pg .= "<td class=dr>Luck%</td>";
|
||||
$pg .= "<td class=dr>PPS%</td>";
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
$pg .= '<tbody>';
|
||||
$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 .= "<tr class=$row>";
|
||||
$pg .= "<td class=dl>$name$dots</td>";
|
||||
$pg .= "<td class=dr>${phrdsp}Hs</td>";
|
||||
$pg .= "<td class=dr bgcolor=$bg><font color=$fg>$bcount</font></td>";
|
||||
$pg .= "<td class=dr>$exc</td>";
|
||||
$pg .= "<td class=dr>$md%</td>";
|
||||
$pg .= "<td class=dr>$mr%</td>";
|
||||
$pg .= "<td class=dr>$mldsp%</td>";
|
||||
$pg .= "<td class=dr>$odsp%</td>";
|
||||
$pg .= "</tr>\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 .= '</tbody></table>';
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function doblocks($data, $user)
|
||||
{
|
||||
$blink = '<a href=https://www.blocktrail.com/BTC/block/';
|
||||
$poolfee = 0.9; # pool fee as a % out of 100
|
||||
|
||||
$pg = '';
|
||||
|
||||
if ($user === null)
|
||||
$ans = getBlocks('Anon');
|
||||
else
|
||||
$ans = getBlocks($user);
|
||||
|
||||
if (nuem(getparam('csv', true)))
|
||||
$wantcsv = false;
|
||||
else
|
||||
$wantcsv = true;
|
||||
|
||||
if ($wantcsv === false)
|
||||
{
|
||||
$pg .= statstable($poolfee, $ans, $data);
|
||||
|
||||
$pg .= monthtable($poolfee, $ans, 7);
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$count = $ans['rows'];
|
||||
$histsiz = $ans['historysize'] . ' ';
|
||||
if ($count == 1)
|
||||
{
|
||||
$num = '';
|
||||
$s = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$num = " $count";
|
||||
$s = 's';
|
||||
}
|
||||
|
||||
$pg .= "<h1>Last$num Block$s</h1>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$histsiz = '';
|
||||
$pg .= '<h1>Blocks</h1>';
|
||||
}
|
||||
|
||||
list($fg, $bg) = pctcolour(25.0);
|
||||
$pg .= "<span style='background:$bg; color:$fg;'>";
|
||||
$pg .= " Green </span> ";
|
||||
$pg .= 'is good luck. Lower Diff% and brighter green is better luck.<br>';
|
||||
list($fg, $bg) = pctcolour(100.0);
|
||||
$pg .= "<span style='background:$bg; color:$fg;'>";
|
||||
$pg .= " 100% </span> ";
|
||||
$pg .= 'is expected average. ';
|
||||
list($fg, $bg) = pctcolour(400.0);
|
||||
$pg .= "<span style='background:$bg; color:$fg;'>";
|
||||
$pg .= " Red </span> ";
|
||||
$pg .= 'is bad luck. Higher Diff% and brighter red is worse luck.<br><br>';
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= "<thead><tr class=title>";
|
||||
$pg .= "<td class=dr>#</td>";
|
||||
$pg .= "<td class=dl>Height</td>";
|
||||
if ($user !== null)
|
||||
$pg .= "<td class=dl>Who</td>";
|
||||
$pg .= "<td class=dr>Block Reward</td>";
|
||||
$pg .= "<td class=dc>When UTC</td>";
|
||||
$pg .= "<td class=dl>Status</td>";
|
||||
$pg .= "<td class=dr>Diff</td>";
|
||||
$pg .= "<td class=dr>Diff%</td>";
|
||||
$pg .= "<td class=dr>CDF</td>";
|
||||
$pg .= "<td class=dr>${histsiz}Luck%</td>";
|
||||
$pg .= "<td class=dr>B</td>";
|
||||
$pg .= "</tr></thead>\n";
|
||||
}
|
||||
$blktot = 0;
|
||||
$nettot = 0;
|
||||
$i = 0;
|
||||
$cnt = 0;
|
||||
$orph = false;
|
||||
$csv = "Sequence,Height,Status,Timestamp,DiffAcc,NetDiff,Hash\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$count = $ans['rows'];
|
||||
$colpct = 0;
|
||||
for ($i = $count - 1; $i >= 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</a>";
|
||||
|
||||
$ex = '';
|
||||
$conf = $ans['confirmed:'.$i];
|
||||
$stat = $ans['status:'.$i];
|
||||
$inf = $ans['info:'.$i];
|
||||
$tt = '';
|
||||
if ($conf == 'O' or $conf == 'R')
|
||||
{
|
||||
$ex = 's';
|
||||
$orph = true;
|
||||
$seq = '';
|
||||
$nn = $cnt;
|
||||
if ($conf == 'R')
|
||||
{
|
||||
addTips();
|
||||
$in = explode(':', $inf, 2);
|
||||
if (trim($in[0]) != '')
|
||||
$stat = trim($in[0]);
|
||||
if (count($in) < 2 or trim($in[1]) == '')
|
||||
{
|
||||
$tip = 'Share diff was VERY close<br>';
|
||||
$tip .= 'so we tested it,<br>';
|
||||
$tip .= "but it wasn't worthy<br>";
|
||||
}
|
||||
else
|
||||
$tip = str_replace('+', '<br>', trim($in[1]));
|
||||
|
||||
$tt = "<span class=q onclick='tip(\"btip$i\",6000)'>";
|
||||
$tt .= '?</span><span class=tip0>';
|
||||
$tt .= "<span class=notip id=btip$i>";
|
||||
$tt .= "$tip</span></span>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$seq = $ans['seq:'.$i];
|
||||
$nn = ++$cnt;
|
||||
}
|
||||
if ($conf == '1')
|
||||
{
|
||||
if (isset($data['info']['lastheight']))
|
||||
{
|
||||
$confn = 1 + $data['info']['lastheight'] - $hi;
|
||||
$stat = '+'.$confn.' Confirms';
|
||||
}
|
||||
else
|
||||
$stat = 'Conf';
|
||||
}
|
||||
|
||||
$stara = '';
|
||||
if ($conf == 'O' or $conf == 'R')
|
||||
$stara = '<span class=st1>*</span>';
|
||||
|
||||
if (isset($ans['statsconf:'.$i]))
|
||||
{
|
||||
if ($ans['statsconf:'.$i] == 'Y')
|
||||
$approx = '';
|
||||
else
|
||||
$approx = '~';
|
||||
}
|
||||
else
|
||||
$approx = '';
|
||||
|
||||
$diffacc = $ans['diffacc:'.$i];
|
||||
$acc = number_format($diffacc, 0);
|
||||
|
||||
$netdiff = $ans['netdiff:'.$i];
|
||||
$diffratio = $ans['diffratio:'.$i];
|
||||
$cdf = $ans['cdf:'.$i];
|
||||
$luck = $ans['luck:'.$i];
|
||||
$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 = "<font color=$fg>$approx".number_format($pct, 3).'%</font>';
|
||||
$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 .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr$ex>$seq</td>";
|
||||
$pg .= "<td class=dl$ex>$hifld</td>";
|
||||
if ($user !== null)
|
||||
{
|
||||
list($abr, $nam) = dspname($ans['workername:'.$i]);
|
||||
$pg .= "<td class=dl$ex>$nam</td>";
|
||||
}
|
||||
$pg .= "<td class=dr$ex>".btcfmt($ans['reward:'.$i]).'</td>';
|
||||
$pg .= "<td class=dc$ex>".utcd($ans['firstcreatedate:'.$i], false, false).'</td>';
|
||||
$pg .= "<td class=dl$ex>$tt$stat</td>";
|
||||
$pg .= "<td class=dr>$stara$approx$acc</td>";
|
||||
$pg .= "<td class=dr$bg>$bpct</td>";
|
||||
$pg .= "<td class=dr>$cdfdsp</td>";
|
||||
$pg .= "<td class=dr>$histdsp</td>";
|
||||
$pg .= "<td class=dr>$nn</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$csv .= "$seq,";
|
||||
$csv .= "$hi,";
|
||||
$csv .= "\"$stat\",";
|
||||
$csv .= $ans['firstcreatedate:'.$i].',';
|
||||
$csv .= "$diffacc,";
|
||||
$csv .= "$netdiff,";
|
||||
$csv .= $ans['blockhash:'.$i]."\n";
|
||||
}
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
if ($wantcsv === true)
|
||||
{
|
||||
echo $csv;
|
||||
exit(0);
|
||||
}
|
||||
if ($orph === true)
|
||||
{
|
||||
$pg .= '<tfoot><tr><td colspan=';
|
||||
if ($user === null)
|
||||
$pg .= '8';
|
||||
else
|
||||
$pg .= '9';
|
||||
$pg .= ' class=dc><font size=-1><span class=st1>*</span>';
|
||||
$pg .= 'Orphans/Rejects count as shares but not as a block in calculations';
|
||||
$pg .= '</font></td></tr></tfoot>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_blocks($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doblocks', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function stnum($num)
|
||||
{
|
||||
$b4 = '';
|
||||
$af = '';
|
||||
$fmt = number_format($num, 0);
|
||||
if ($num > 99999999)
|
||||
$b4 = '<span class=urg>';
|
||||
else if ($num > 9999999)
|
||||
$b4 = '<span class=warn>';
|
||||
if ($b4 != '')
|
||||
$af = '</span>';
|
||||
return $b4.$fmt.$af;
|
||||
}
|
||||
#
|
||||
function dockp($data, $user)
|
||||
{
|
||||
$pg = '<h1>CKDB</h1>';
|
||||
|
||||
$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']).'<br>';
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= "<td class=dl><span class=nb>Name:<$r id=srtname data-sf=s0></span></td>";
|
||||
$pg .= '<td class=dr>Initial</td>';
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtalloc data-sf=r2>:Alloc</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtstore data-sf=r3>:In Store</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtram data-sf=r4>:RAM</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtram2 data-sf=r5>:RAM2</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtcull data-sf=r6>:Cull</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtlim data-sf=r7>:Limit</span></td>";
|
||||
$pg .= "</tr></thead>\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dl data-srt='".$ans['name:'.$i]."'>".$ans['name:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.stnum($ans['initial:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['allocated:'.$i]."'>".stnum($ans['allocated:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['instore:'.$i]."'>".stnum($ans['instore:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['ram:'.$i]."'>".stnum($ans['ram:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['ram2:'.$i]."'>".stnum($ans['ram2:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['cull:'.$i]."'>".stnum($ans['cull:'.$i]).'</td>';
|
||||
$pg .= "<td class=dr data-srt='".$ans['cull_limit:'.$i]."'>".stnum($ans['cull_limit:'.$i]).'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= "sotc('ckpsrt','srtram');</script>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_ckp($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dockp', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,210 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function doevents($data, $user)
|
||||
{
|
||||
$pg = '<h1>Event Information</h1>';
|
||||
|
||||
$wh = getparam('what', false);
|
||||
if (nuem($wh))
|
||||
$wh = '';
|
||||
|
||||
$pg = '<br>'.makeForm('events')."
|
||||
What: <input type=text name=what size=10 value='$wh'>
|
||||
<input type=submit name=Get value=Get>
|
||||
</form>";
|
||||
|
||||
if ($wh == 'settings')
|
||||
{
|
||||
$ans = eventCmd($user, array('action' => 'settings'));
|
||||
|
||||
$other = array('event_limits_hash_lifetime',
|
||||
'ovent_limits_ipc_factor');
|
||||
|
||||
$pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>#</td>';
|
||||
$pg .= '<td class=dl>Name</td>';
|
||||
$pg .= '<td class=dr>Value</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$i = 0;
|
||||
foreach ($other as $name)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$i++;
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr>$i</td>";
|
||||
$pg .= "<td class=dl>$name</td>";
|
||||
$pg .= '<td class=dr>'.$ans[$name].'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
$flds = array('enabled' => 'Ena',
|
||||
'user_low_time' => 'UserLo',
|
||||
'user_low_time_limit' => 'UserLoLim',
|
||||
'user_hi_time' => 'UserHi',
|
||||
'user_hi_time_limit' => 'UserHiLim',
|
||||
'ip_low_time' => 'IPLo',
|
||||
'ip_low_time_limit' => 'IPLoLim',
|
||||
'ip_hi_time' => 'IPHi',
|
||||
'ip_hi_time_limit' => 'IPHiLim',
|
||||
'lifetime' => 'Life');
|
||||
|
||||
$pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>#</td>';
|
||||
$pg .= '<td class=dl>Name</td>';
|
||||
foreach ($flds as $row => $nam)
|
||||
$pg .= "<td class=dr>$nam</td>";
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$names = array();
|
||||
foreach ($ans as $name => $value)
|
||||
{
|
||||
$ex = explode('_', $name, 2);
|
||||
if (count($ex) == 2 && isset($flds[$ex[1]]))
|
||||
$names[$ex[0]] = 1;
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($names as $name => $one)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$i++;
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr>$i</td>";
|
||||
$pg .= "<td class=dl>$name</td>";
|
||||
foreach ($flds as $fld => $nam)
|
||||
$pg .= '<td class=dr>'.$ans[$name.'_'.$fld].'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
}
|
||||
|
||||
if ($wh == 'all' || $wh == 'user' || $wh == 'ip' || $wh == 'ipc' || $wh == 'hash')
|
||||
{
|
||||
$ans = eventCmd($user, array('action' => 'events', 'list' => $wh));
|
||||
|
||||
$pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>#</td>';
|
||||
$pg .= '<td class=dl>List</td>';
|
||||
$pg .= '<td class=dr>ID</td>';
|
||||
$pg .= '<td class=dl>IDName</td>';
|
||||
$pg .= '<td class=dl>User</td>';
|
||||
$pg .= '<td class=dr>IP</td>';
|
||||
$pg .= '<td class=dr>IPc</td>';
|
||||
$pg .= '<td class=dr>Hash</td>';
|
||||
$pg .= '<td class=dr>UTC</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$j = $i+1;
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr>$j</td>";
|
||||
$pg .= '<td class=dl>'.$ans['list:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['id:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['idname:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['user:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.isans($ans, 'ip:'.$i).'</td>';
|
||||
$pg .= '<td class=dr>'.isans($ans, 'ipc:'.$i).'</td>';
|
||||
$pg .= '<td class=dr>'.isans($ans, 'hash:'.$i).'</td>';
|
||||
$pg .= '<td class=dr>'.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
}
|
||||
|
||||
if ($wh == 'ovents')
|
||||
{
|
||||
$ans = eventCmd($user, array('action' => 'ovents'));
|
||||
|
||||
$pg .= "<br><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>#</td>';
|
||||
$pg .= '<td class=dl>Key</td>';
|
||||
$pg .= '<td class=dr>ID</td>';
|
||||
$pg .= '<td class=dl>IDName</td>';
|
||||
$pg .= '<td class=dr>Hour UTC</td>';
|
||||
$pg .= '<td class=dl>Count</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$j = $i+1;
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr>$j</td>";
|
||||
$pg .= '<td class=dl>'.$ans['key:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['id:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['idname:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.gmdate('j/M H:i:s',$ans['hour:'.$i]*3600).'</td>';
|
||||
$co = '';
|
||||
for ($k = 0; $k < 60; $k++)
|
||||
{
|
||||
if ($k < 10)
|
||||
$min = '0' . $k;
|
||||
else
|
||||
$min = $k;
|
||||
if (isset($ans["min$min:$i"]))
|
||||
{
|
||||
if ($co != '')
|
||||
$co .= ' ';
|
||||
$co .= "$min=".$ans["min$min:$i"];
|
||||
}
|
||||
}
|
||||
$pg .= "<td class=dl>$co</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_events($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doevents', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function dohelp($data, $user)
|
||||
{
|
||||
return '<h1>Helpless</h1>Helpless';
|
||||
}
|
||||
#
|
||||
function show_help($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dohelp', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
@include_once('myindex.php');
|
||||
#
|
||||
function show_index($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doindex', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function doips($data, $user)
|
||||
{
|
||||
$pg = '<h1>Event IP Information</h1>';
|
||||
|
||||
$ans = eventCmd($user, array('action' => 'ips'));
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>#</td>';
|
||||
$pg .= '<td class=dl>Group</td>';
|
||||
$pg .= '<td class=dl>IP</td>';
|
||||
$pg .= '<td class=dl>Name</td>';
|
||||
$pg .= '<td class=dr>Is?</td>';
|
||||
$pg .= '<td class=dr>Lifetime</td>';
|
||||
$pg .= '<td class=dr>Left</td>';
|
||||
$pg .= '<td class=dr>Log</td>';
|
||||
$pg .= '<td class=dl>Desc</td>';
|
||||
$pg .= '<td class=dr>UTC</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$now = $ans['STAMP'];
|
||||
$pg .= '<tbody>';
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$j = $i+1;
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dr>$j</td>";
|
||||
$pg .= '<td class=dl>'.$ans['group:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['ip:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['eventname:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['is_event:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['lifetime:'.$i].'</td>';
|
||||
$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 .= '<td class=dr>'.$dxp.'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['log:'.$i].'</td>';
|
||||
$pg .= '<td class=dl>'.$ans['description:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_ips($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doips', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,197 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function lckg($nc, $av)
|
||||
{
|
||||
$g = "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=0,ymax=0,xmin=-1,xmax=0,tlk=[];
|
||||
var w=d['arp'].split(',');var cols=d['cols'].split(',');
|
||||
gsh(c,w);
|
||||
for(var j=1;j<w.length;j++){tlk[j-1]=$av}
|
||||
for(var i=0;i<rows;i++){var s=parseFloat(d['firstcreatedate:'+i]);d['vx:'+i]=s;if(xmin==-1||xmin>s){xmin=s}if(xmax<s){xmax=s}
|
||||
for(var j=1;j<w.length;j++){var pre=w[j];var lk=0,nam=pre+'luck:'+i;if(d[nam]){lk=parseFloat(d[nam])}if(lk>ymax)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 = '<h1>Pool Avg Block Luck History</h1><br>';
|
||||
|
||||
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 .= '<div>';
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= ' <span class=nb>';
|
||||
$pg .= "<input type=checkbox id=$nam onclick='gact(this)'>";
|
||||
$pg .= "$txt </span>";
|
||||
}
|
||||
$pg .= '</div><div>';
|
||||
|
||||
$i = 1;
|
||||
$datacols = '';
|
||||
foreach ($cols as $col)
|
||||
{
|
||||
if ($i != 1)
|
||||
$pg .= ' ';
|
||||
if ($i == 2 || $i == 4)
|
||||
$chk = ' checked';
|
||||
else
|
||||
$chk = '';
|
||||
$pg .= "<span class=nb><font color=$col>";
|
||||
$pg .= "<input type=checkbox id=lin$i$chk onclick='godrw(0)'>: ";
|
||||
if ($nams[$i-1] == 1)
|
||||
$avs = '';
|
||||
else
|
||||
$avs = ' Avg';
|
||||
$pg .= $nams[$i-1]." Block Luck$avs</font></span>";
|
||||
|
||||
if ($i > 1)
|
||||
$datacols .= ',';
|
||||
$datacols .= $col;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$pg .= '</div>';
|
||||
$pg .= '<div id=can0><canvas id=can width=1 height=1>';
|
||||
$pg .= 'A graph will show here if your browser supports html5/canvas';
|
||||
$pg .= "</canvas></div>\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 .= "<script type='text/javascript'>\n";
|
||||
$pg .= lckg($nc, 100*$count/$avg);
|
||||
$pg .= "\nfunction godrw(f){var cbx=[";
|
||||
$comma = '';
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= "$comma'$nam'";
|
||||
$comma = ',';
|
||||
}
|
||||
$pg .= '];if(f){var xon={};';
|
||||
foreach ($xon as $nam => $val)
|
||||
$pg .= "xon['$nam']=1;";
|
||||
$pg .= "doinit(cbx,xon)}dodrw('$data',cbx)};godrw(1);</script>\n";
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_luck($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doluck', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function dompayouts($data, $user)
|
||||
{
|
||||
$pg = '<h1>Mining Rewards</h1>';
|
||||
|
||||
$ans = getMPayouts($user);
|
||||
|
||||
$pg .= "The rewards you've earned for each block the pool has found.<br>";
|
||||
$pg .= 'See the ';
|
||||
$pg .= makeLink('payments');
|
||||
$pg .= "Payments</a> page for the payments you've been sent.<br><br>";
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dr>Block</td>';
|
||||
$pg .= '<td class=dr>Block UTC</td>';
|
||||
$pg .= '<td class=dr>Miner Reward</td>';
|
||||
$pg .= '<td class=dr>N Diff</td>';
|
||||
$pg .= '<td class=dr>N Range</td>';
|
||||
$pg .= '<td class=dr>Pool N Avg</td>';
|
||||
$pg .= '<td class=dr>Your %</td>';
|
||||
$pg .= '<td class=dr>Your N Diff</td>';
|
||||
$pg .= '<td class=dr>Your N Avg</td>';
|
||||
$pg .= '<td class=dr>Your BTC</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$totamt = 0;
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= '<td class=dr>'.$ans['height:'.$i].'</td>';
|
||||
$pg .= '<td class=dr>'.gmdate('j/M H:i',$ans['blockcreatedate:'.$i]).'</td>';
|
||||
$pg .= '<td class=dr>'.btcfmt($ans['minerreward:'.$i]).'</td>';
|
||||
$diffused = $ans['diffused:'.$i];
|
||||
$pg .= '<td class=dr>'.difffmt($diffused).'</td>';
|
||||
$elapsed = $ans['elapsed:'.$i];
|
||||
$pg .= '<td class=dr>'.howmanyhrs($elapsed).'</td>';
|
||||
$phr = $diffused * pow(2,32) / $elapsed;
|
||||
$pg .= '<td class=dr>'.siprefmt($phr).'Hs</td>';
|
||||
$diffacc = $ans['diffacc:'.$i];
|
||||
$ypct = $diffacc * 100 / $diffused;
|
||||
$pg .= '<td class=dr>'.number_format($ypct, 2).'%</td>';
|
||||
$pg .= '<td class=dr>'.difffmt($diffacc).'</td>';
|
||||
$hr = $diffacc * pow(2,32) / $elapsed;
|
||||
$pg .= '<td class=dr>'.dsprate($hr).'</td>';
|
||||
$amount = $ans['amount:'.$i];
|
||||
$totamt += $amount;
|
||||
$pg .= '<td class=dr>'.btcfmt($amount).'</td>';
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
if ($count > 1)
|
||||
{
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tfoot><tr class=$row>";
|
||||
$pg .= '<td class=dr>Total:</td>';
|
||||
$pg .= '<td class=dl colspan=8></td>';
|
||||
$pg .= '<td class=dr>'.btcfmt($totamt).'</td>';
|
||||
$pg .= "</tr></tfoot>\n";
|
||||
}
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_mpayouts($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dompayouts', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function sortheight($a, $b)
|
||||
{
|
||||
return $b['height'] - $a['height'];
|
||||
}
|
||||
#
|
||||
function dopayments($data, $user)
|
||||
{
|
||||
$btc = 'https://www.blocktrail.com/BTC/address/';
|
||||
$btcn = 'blocktrail';
|
||||
$addr1 = '1KzFJddTvK9TQWsmWFKYJ9fRx9QeSATyrT';
|
||||
$addr2 = '16dRhawxuR3BmdmkzdzUdgEfGAQszgmtbc';
|
||||
$addr3 = '1N6LrEDiHuFwSyJYj2GedZM2FGk7kkLjn';
|
||||
$addr4 = '1CVVn6sC46aZdokEnU1LThmi8WsMV4qzgh';
|
||||
$addr5 = '13pucx6gHP2vyBLc88QfcGivjkhK63PeVg';
|
||||
|
||||
$pg = '<h1>Payments</h1>';
|
||||
$pg .= "The payment transactions on $btcn are here:";
|
||||
$pg .= " <a href='$btc$addr1' target=_blank>BTCa</a>,";
|
||||
$pg .= " <a href='$btc$addr2' target=_blank>BTCb</a>,";
|
||||
$pg .= " <a href='$btc$addr3' target=_blank>BTCc</a>,";
|
||||
$pg .= " <a href='$btc$addr4' target=_blank>BTCd</a> and";
|
||||
$pg .= " <a href='$btc$addr5' target=_blank>BTCe</a><br>";
|
||||
$pg .= "The payments below don't yet show when they have been sent.<br>";
|
||||
$pg .= "Dust payments below 0.00010000 BTC are not sent out yet.<br><br>";
|
||||
|
||||
$ans = getPayments($user);
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dl>Block</td>';
|
||||
$pg .= '<td class=dl>Address</td>';
|
||||
$pg .= '<td class=dl>Status</td>';
|
||||
$pg .= '<td class=dr>BTC</td>';
|
||||
$pg .= '<td class=dl></td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.$all[$i]['height'].'</td>';
|
||||
$pg .= '<td class=dl>'.$all[$i]['payaddress'].'</td>';
|
||||
$pg .= '<td class=dl> </td>';
|
||||
$amount = $all[$i]['amount'];
|
||||
if ($amount < '10000')
|
||||
{
|
||||
$dust = '<span class=st1>*</span>';
|
||||
$hasdust = true;
|
||||
}
|
||||
else
|
||||
$dust = ' ';
|
||||
$pg .= '<td class=dr>'.btcfmt($amount).'</td>';
|
||||
$pg .= "<td class=dl>$dust</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
if ($hasdust === true)
|
||||
{
|
||||
$pg .= '<tfoot><tr><td colspan=5 class=dc>';
|
||||
$pg .= '<font size=-1><span class=st1>*</span> ';
|
||||
$pg .= 'Dust payments are not automatically sent out';
|
||||
$pg .= '</font></td></tr></tfoot>';
|
||||
}
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_payments($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopayments', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function dopayout($data, $user)
|
||||
{
|
||||
$N = 5;
|
||||
$t = "<span class=nn>$N</span>";
|
||||
$ot = "<span class=nn>1/$N</span>";
|
||||
$n = "<span class=nn>${N}Nd</span>";
|
||||
$n1 = '<span class=nn>N</span>';
|
||||
$n1d = '<span class=nn>Nd</span>';
|
||||
$bc = '+101 Confirms';
|
||||
$bm = 'Matured';
|
||||
$nd = 0;
|
||||
if (isset($data['info']['currndiff']))
|
||||
$nd = $data['info']['currndiff'];
|
||||
$nv = number_format($nd, 1);
|
||||
$nvx = '<b>'.number_format($N*$nd, 1).'</b>';
|
||||
$pd = $data['info']['p_hashrate24hr'];
|
||||
$hr = 'is <b>?</b>';
|
||||
$hrt = '<b>?</b>';
|
||||
if ($pd != '?' && $pd != '' && $pd > 0)
|
||||
{
|
||||
$hr = 'for the last day is roughly <b>'.siprefmt($pd,2).'Hs</b>';
|
||||
if ($nd > 0)
|
||||
$hrt = '<b>'.howmanyhrs($nd * $N / ($pd / pow(2,32)), true, true).'</b>';
|
||||
}
|
||||
|
||||
$pg = "<h1>Payouts</h1>
|
||||
<table width=75% cellpadding=0 cellspacing=0 border=0><tr><td>
|
||||
|
||||
<span class=hdr>What payout method does the pool use?</span><br><br>
|
||||
We use <b>PPL${n1}S</b> (<b>P</b>ay <b>P</b>er <b>L</b>ast $n1 <b>S</b>hares)<br><br>
|
||||
<b>PPL${n1}S</b> 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.<br>
|
||||
The $n1 value the pool uses is $t times the network difficulty when the block is found - '$n'.<br><br>
|
||||
|
||||
<span class=hdr>How much of each block does the pool reward?</span><br><br>
|
||||
Transaction fees are included in the miner reward.<br>
|
||||
Pool fee is 0.9% of the total.<br><br>
|
||||
|
||||
<span class=hdr>PPL${n1}S acts like the reward 'ramps up' when you first start mining.<br>What actually happens?</span><br><br>
|
||||
The $n means it takes that long to reward your shares.<br>
|
||||
The ramp isn't missing rewards, it's delaying them to reduce variance.<br>
|
||||
Each share is rewarded in all the blocks found in the $n after the share.<br>
|
||||
That's simply how it reduces variance. Each share's reward is averaged out over the $n after it.<br>
|
||||
The pool hash rate $hr which means the $n 'ramp' is roughly $hrt.<br><br>
|
||||
|
||||
Continue reading below for more detail about how it works:<br><br>
|
||||
|
||||
<span class=hdr>How do the <b>PPL${n1}S</b> payments work?</span><br><br>
|
||||
The $n means the pool rewards $t times the expected number of shares, each time a block is found.<br>
|
||||
So each share will be paid approximately $ot of it's expected value, in each block it gets a reward,<br>
|
||||
but each share is also expected, on average, to be rewarded $t times in blocks found after the share is submitted to the pool.<br>
|
||||
i.e. if pool luck was always 100% then each share is expected to be rewarded $t times.<br><br>
|
||||
If pool luck is better than 100%, then the average share reward will be better than $t times.<br>
|
||||
If pool luck is lower than 100%, then the average share reward will be less than $t times.<br><br>
|
||||
|
||||
<span class=hdr>What's a shift?</span></br><br>
|
||||
When your miner sends shares to the pool, the shares are not stored individually, but rather summarised into shifts.<br>
|
||||
Shifts are ~50min or less in length.<br>
|
||||
Aproximately every 30s, the pool generates new work and sends that to all the miners.<br>
|
||||
The pool also sends new work every time a block is found on the Bitcoin network.<br>
|
||||
A shift summarises all the shares submitted to the pool for 100 work changes.<br>
|
||||
However, when we find pool blocks, the current shift ends at the work in which the block was found<br>
|
||||
and a new shift starts.<br>
|
||||
A ckpool restart will also end the current shift and start a new shift.<br>
|
||||
A network difficulty change will also end the current shift and start a new shift.<br><br>
|
||||
|
||||
<span class=hdr>So, what's the $n value?</span><br><br>
|
||||
The current Bitcoin network value for $n1d is $nv and thus $n is $nvx<br>
|
||||
Bitcoin adjusts the $n1d value every 2016 blocks, which is about every 2 weeks.<br><br>
|
||||
When a block is found, the reward process counts back shifts until the total share difficulty included is $n.<br>
|
||||
Since shares are summarised into shifts, it will include the full shift at the end of the range counting backwards,<br>
|
||||
so it usually will be a bit more than $n.<br><br>
|
||||
|
||||
<span class=hdr>When are payments sent out?</span><br><br>
|
||||
The block 'Status' must first reach '$bc' on the Blocks page, and then is flagged as '$bm', before the reward is distributed.<br>
|
||||
The block reward is sent out manually soon after that.<br><br>
|
||||
|
||||
</td></tr></table>";
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_payout($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopayout', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('page_blocks.php');
|
||||
#
|
||||
function dopblocks($data, $user)
|
||||
{
|
||||
return doblocks($data, null);
|
||||
}
|
||||
#
|
||||
function show_pblocks($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopblocks', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,172 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function pertitle($data, $user)
|
||||
{
|
||||
$pg = '<thead><tr class=title>';
|
||||
$pg .= '<td class=dl>Address</td>';
|
||||
$pg .= '<td class=dl>ID</td>';
|
||||
$pg .= '<td class=dr>Shares</td>';
|
||||
$pg .= '<td class=dr>Diff</td>';
|
||||
$pg .= '<td class=dr>Invalid</td>';
|
||||
$pg .= '<td class=dr>Block %</td>';
|
||||
$pg .= '<td class=dr>Hash Rate</td>';
|
||||
$pg .= '<td class=dr>Ratio</td>';
|
||||
$pg .= '<td class=dr>Addr %</td>';
|
||||
$pg .= "</tr></thead>\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 .= '<tbody>';
|
||||
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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.$all[$i]['payaddress'].'</td>';
|
||||
$pg .= '<td class=dl>'.$all[$i]['payname'].'</td>';
|
||||
|
||||
$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 .= "<td class=dr>$shareacc</td>";
|
||||
$pg .= "<td class=dr>$diffacc</td>";
|
||||
|
||||
$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 .= "<td class=dr>$rej%</td>";
|
||||
|
||||
if ($blockacc <= 0)
|
||||
$blkpct = ' ';
|
||||
else
|
||||
$blkpct = number_format(100.0 * $all[$i]['p_diffacc'] / $blockacc, 3) . '%';
|
||||
|
||||
$pg .= "<td class=dr>$blkpct</td>";
|
||||
|
||||
$uhr = $all[$i]['p_uhr'];
|
||||
if ($uhr == '?')
|
||||
$uhr = '?GHs';
|
||||
else
|
||||
{
|
||||
$totrate += $uhr;
|
||||
$uhr = dsprate($uhr);
|
||||
}
|
||||
$pg .= "<td class=dr>$uhr</td>";
|
||||
|
||||
$pg .= '<td class=dr>'.$all[$i]['payratio'].'</td>';
|
||||
$paypct = number_format($all[$i]['paypercent'], 3);
|
||||
$pg .= "<td class=dr>$paypct%</td>";
|
||||
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$offset++;
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
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 .= "<tfoot><tr class=$row><td class=dl>Total:</td>";
|
||||
$pg .= "<td class=dl> </td>";
|
||||
$shareacc = number_format($totshare, 0);
|
||||
$pg .= "<td class=dr>$shareacc</td>";
|
||||
$diffacc = number_format($totdiff, 0);
|
||||
$pg .= "<td class=dr>$diffacc</td>";
|
||||
$dtot = $totdiff + $totinvalid;
|
||||
if ($dtot > 0)
|
||||
$rej = number_format(100.0 * $totinvalid / $dtot, 3);
|
||||
else
|
||||
$rej = '0';
|
||||
$pg .= "<td class=dr>$rej%</td>";
|
||||
if ($blockacc <= 0)
|
||||
$blkpct = ' ';
|
||||
else
|
||||
$blkpct = number_format(100.0 * $totdiff / $blockacc, 3) . '%';
|
||||
$pg .= "<td class=dr>$blkpct</td>";
|
||||
$pg .= "<td class=dr>$totrate</td>";
|
||||
$pg .= "</td><td colspan=2 class=dl></td></tr></tfoot>\n";
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function dopercent($data, $user)
|
||||
{
|
||||
$pg = '<h1>Address Percents</h1>';
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\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 .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_percent($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopercent', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,329 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function stnum($num)
|
||||
{
|
||||
$b4 = '';
|
||||
$af = '';
|
||||
$fmt = number_format($num, 0);
|
||||
if ($num > 99999999)
|
||||
$b4 = '<span class=urg>';
|
||||
else if ($num > 9999999)
|
||||
$b4 = '<span class=warn>';
|
||||
if ($b4 != '')
|
||||
$af = '</span>';
|
||||
return $b4.$fmt.$af;
|
||||
}
|
||||
#
|
||||
# ... Of course ... check the output and add the txin ... etc.
|
||||
function calctx($ans, $count, $miner_sat, $diffacc_total)
|
||||
{
|
||||
$pg = '<br><table cellpadding=0 cellspacing=0 border=0>';
|
||||
$pg .= '<tr><td>';
|
||||
|
||||
$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<br>";
|
||||
}
|
||||
$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 .= "<span class=err>Dust limit = $dust = ".btcfmt($dust);
|
||||
$pg .= ", Dust amount = $dust_amt = ".btcfmt($dust_amt);
|
||||
$pg .= ",<br>Upaid = $unpaid = ".btcfmt($unpaid);
|
||||
$pg .= ", Change = $change = ".btcfmt($change);
|
||||
$pg .= ",<br>Fee = $fee = ".btcfmt($fee)."</span><br>";
|
||||
|
||||
if ($change < $fee)
|
||||
$ers .= "Change ($change) is less than Fee ($fee)<br>";
|
||||
|
||||
if (($dust_amt + $change - $fee) > 0)
|
||||
{
|
||||
$txout .= "$comma\"<changeaddress>\":";
|
||||
$txout .= btcfmt($dust_amt + $change - $fee);
|
||||
$comma = ', ';
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($ers) > 0)
|
||||
$pg .= "<span class=err>$ers</span><br>";
|
||||
|
||||
$txn = '[{"txid":"<txid1>","vout":<n>},';
|
||||
$txn .= '{"txid":"<txid2>","vout":<n>}] ';
|
||||
$txn .= '{'.$txout.'}<br>';
|
||||
|
||||
$pg .= $txn.'</td></tr></table>';
|
||||
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 = '<h1>CKPool</h1>';
|
||||
|
||||
$blk = getparam('blk', true);
|
||||
if (nuem($blk))
|
||||
{
|
||||
$tx = '';
|
||||
# so can make a link
|
||||
$blkuse = getparam('blkuse', true);
|
||||
if (nuem($blkuse))
|
||||
$blkuse = '';
|
||||
else
|
||||
$tx = 'y';
|
||||
$pg = '<br>'.makeForm('pplns')."
|
||||
Block: <input type=text name=blk size=10 value='$blkuse'>
|
||||
Tx: <input type=text name=tx size=1 value='$tx'>
|
||||
Dust (Satoshi): <input type=text name=dust size=5 value='10000'>
|
||||
Fee (BTC): <input type=text name=fee size=5 value='0.0'>
|
||||
<input type=submit name=Calc value=Calc>
|
||||
</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tx = getparam('tx', true);
|
||||
if (nuem($tx) || substr($tx, 0, 1) != 'y')
|
||||
$dotx = false;
|
||||
else
|
||||
$dotx = true;
|
||||
|
||||
$flds = array('height' => $blk, 'allow_aged' => 'Y');
|
||||
if ($blk > 334106)
|
||||
$flds['diff_times'] = '5';
|
||||
$msg = msgEncode('pplns', 'pplns', $flds, $user);
|
||||
$rep = sendsockreply('pplns', $msg, 4);
|
||||
if ($rep == false)
|
||||
$ans = array();
|
||||
else
|
||||
$ans = repDecode($rep);
|
||||
|
||||
|
||||
if ($ans['ERROR'] != null)
|
||||
return '<font color=red size=+1><br>'.$ans['STATUS'].': '.$ans['ERROR'].'</font>';
|
||||
|
||||
if (!isset($ans['pplns_last']))
|
||||
return '<font color=red size=+1><br>Partial data returned</font>';
|
||||
|
||||
$reward_sat = $ans['block_reward'];
|
||||
$miner_sat = round($reward_sat * 0.991);
|
||||
$ans['miner_sat'] = $miner_sat;
|
||||
|
||||
$data = array( 'Block' => 'block',
|
||||
'Block Status' => 'block_status',
|
||||
'Block Hash' => 'block_hash',
|
||||
'Block Reward (Satoshis)' => 'block_reward',
|
||||
'Miner Reward (Satoshis)' => 'miner_sat',
|
||||
'PPLNS Wanted' => '.diff_want',
|
||||
'PPLNS Used' => '.diffacc_total',
|
||||
'Elapsed Seconds' => ',pplns_elapsed',
|
||||
'Users' => 'rows',
|
||||
'Oldest Workinfoid' => 'begin_workinfoid',
|
||||
'Oldest Time' => 'begin_stamp',
|
||||
'Oldest Epoch' => 'begin_epoch',
|
||||
'Block Workinfoid' => 'block_workinfoid',
|
||||
'Block Time' => 'block_stamp',
|
||||
'Block Epoch' => 'block_epoch',
|
||||
'Newest Workinfoid' => 'end_workinfoid',
|
||||
'Newest Share Time' => 'end_stamp',
|
||||
'Newest Share Epoch' => 'end_epoch',
|
||||
'Network Difficulty' => 'block_ndiff',
|
||||
'PPLNS Factor' => 'diff_times',
|
||||
'PPLNS Added' => 'diff_add',
|
||||
'Accepted Share Count' => ',acc_share_count',
|
||||
'Total Share Count' => ',total_share_count',
|
||||
'ShareSummary Count' => ',ss_count',
|
||||
'WorkMarkers Count' => ',wm_count',
|
||||
'MarkerSummary Count' => ',ms_count');
|
||||
|
||||
$pg = '<br><a href=https://blockchain.info/block-height/';
|
||||
$pg .= $ans['block'].'>Blockchain '.$ans['block']."</a><br>\n";
|
||||
|
||||
if (strlen($ans['marks_status']) > 0)
|
||||
{
|
||||
$pg .= '<br><span class=err>';
|
||||
$msg = $ans['marks_status'];
|
||||
$pg .= str_replace(' ', ' ', $msg)."</span><br>\n";
|
||||
}
|
||||
|
||||
if (strlen($ans['block_extra']) > 0)
|
||||
{
|
||||
$pg .= '<br><span class=err>';
|
||||
$msg = $ans['block_status'].' - '.$ans['block_extra'];
|
||||
$pg .= str_replace(' ', ' ', $msg)."</span><br>\n";
|
||||
}
|
||||
|
||||
if (strlen($ans['share_status']) > 0)
|
||||
{
|
||||
$pg .= '<br><span class=err>';
|
||||
$msg = $ans['share_status']." - Can't be paid out yet";
|
||||
$pg .= str_replace(' ', ' ', $msg)."</span><br>\n";
|
||||
}
|
||||
|
||||
$pg .= "<br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<tr class=title>';
|
||||
$pg .= '<td class=dl>Name</td>';
|
||||
$pg .= '<td class=dr>Value</td>';
|
||||
$pg .= "</tr>\n";
|
||||
$i = 0;
|
||||
foreach ($data as $dsp => $name)
|
||||
{
|
||||
if (($i++ % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dl>$dsp</td>";
|
||||
switch ($name[0])
|
||||
{
|
||||
case ',':
|
||||
case '.':
|
||||
$nm = substr($name, 1);
|
||||
$fmt = fmtdata($name[0], $ans[$nm]);
|
||||
break;
|
||||
default:
|
||||
$fmt = $ans[$name];
|
||||
break;
|
||||
}
|
||||
$pg .= "<td class=dr>$fmt</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
|
||||
$pg .= "</table><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<tr class=title>';
|
||||
$pg .= '<td class=dl>User</td>';
|
||||
$pg .= '<td class=dr>Diff Accepted</td>';
|
||||
$pg .= '<td class=dr>%</td>';
|
||||
$pg .= '<td class=dr>Avg Hashrate</td>';
|
||||
$pg .= '<td class=dr>BTC -0.9%</td>';
|
||||
$pg .= '<td class=dr>Address</td>';
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$diffacc_total = $ans['diffacc_total'];
|
||||
if ($diffacc_total == 0)
|
||||
$diffacc_total = pow(10,15);
|
||||
$elapsed = $ans['pplns_elapsed'];
|
||||
$count = $ans['rows'];
|
||||
$tot_pay = 0;
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$diffacc_user = $ans['diffacc_user:'.$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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.$ans['user:'.$i].'</td>';
|
||||
$pg .= "<td class=dr>$diffacc_user</td>";
|
||||
$pg .= "<td class=dr>$diffacc_percent</td>";
|
||||
$pg .= "<td class=dr>$avg_hash</td>";
|
||||
$pg .= '<td class=dr>'.btcfmt($pay_sat).'</td>';
|
||||
$pg .= "<td class=dr>$payaddress</td>";
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$tot_pay += $pay_sat;
|
||||
}
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl colspan=3></td>';
|
||||
$pg .= '<td class=dr></td>';
|
||||
$pg .= '<td class=dr>'.btcfmt($tot_pay).'</td>';
|
||||
$pg .= '<td class=dr></td>';
|
||||
$pg .= "</tr>\n";
|
||||
$pg .= "</table>\n";
|
||||
|
||||
if ($dotx === true)
|
||||
$pg .= calctx($ans, $count, $miner_sat, $diffacc_total);
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_pplns($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopplns', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,337 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function stnum($num)
|
||||
{
|
||||
$b4 = '';
|
||||
$af = '';
|
||||
$fmt = number_format($num, 0);
|
||||
if ($num > 99999999)
|
||||
$b4 = '<span class=urg>';
|
||||
else if ($num > 9999999)
|
||||
$b4 = '<span class=warn>';
|
||||
if ($b4 != '')
|
||||
$af = '</span>';
|
||||
return $b4.$fmt.$af;
|
||||
}
|
||||
#
|
||||
# ... Of course ... check the output and add the txin ... etc.
|
||||
function calctx($ans, $count, $miner_sat, $diffacc_total)
|
||||
{
|
||||
$pg = '<br><table cellpadding=0 cellspacing=0 border=0>';
|
||||
$pg .= '<tr><td>';
|
||||
|
||||
$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)<br>";
|
||||
$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)<br>";
|
||||
}
|
||||
$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 .= "<span class=err>Dust limit = $dust = ".btcfmt($dust);
|
||||
$pg .= ", Dust amount = $dust_amt = ".btcfmt($dust_amt);
|
||||
$pg .= ",<br>Upaid = $unpaid = ".btcfmt($unpaid);
|
||||
$pg .= ", Change = $change = ".btcfmt($change);
|
||||
$pg .= ",<br>Fee = $fee = ".btcfmt($fee)."</span><br>";
|
||||
|
||||
if ($change < $fee)
|
||||
$ers .= "Change ($change) is less than Fee ($fee)<br>";
|
||||
|
||||
if (($dust_amt + $change - $fee) > 0)
|
||||
{
|
||||
$txout .= "$comma\"<changeaddress>\":";
|
||||
$txout .= btcfmt($dust_amt + $change - $fee);
|
||||
$comma = ', ';
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($ers) > 0)
|
||||
$pg .= "<span class=err>$ers</span><br>";
|
||||
|
||||
$txn = '[{"txid":"<txid1>","vout":<n>},';
|
||||
$txn .= '{"txid":"<txid2>","vout":<n>}] ';
|
||||
$txn .= '{'.$txout.'}<br>';
|
||||
|
||||
$pg .= $txn.'</td></tr></table>';
|
||||
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 = '<h1>CKPool</h1>';
|
||||
|
||||
$blk = getparam('blk', true);
|
||||
if (nuem($blk))
|
||||
{
|
||||
$tx = '';
|
||||
# so can make a link
|
||||
$blkuse = getparam('blkuse', true);
|
||||
if (nuem($blkuse))
|
||||
$blkuse = '';
|
||||
else
|
||||
$tx = 'y';
|
||||
$pg = '<br>'.makeForm('pplns2')."
|
||||
Block: <input type=text name=blk size=10 value='$blkuse'>
|
||||
Tx: <input type=text name=tx size=1 value='$tx'>
|
||||
Dust (Satoshi): <input type=text name=dust size=5 value='10000'>
|
||||
Fee (BTC): <input type=text name=fee size=5 value='0.0'>
|
||||
<input type=submit name=Calc value=Calc>
|
||||
</form>";
|
||||
}
|
||||
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 '<font color=red size=+1><br>'.$ans['STATUS'].': '.$ans['ERROR'].'</font>';
|
||||
|
||||
if (!isset($ans['pplns_last']))
|
||||
return '<font color=red size=+1><br>Partial data returned</font>';
|
||||
|
||||
$reward_sat = $ans['block_reward'];
|
||||
$miner_sat = $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 = '<br><a href=https://blockchain.info/block-height/';
|
||||
$pg .= $ans['block'].'>Blockchain '.$ans['block']."</a><br>\n";
|
||||
|
||||
if (strlen($ans['marks_status']) > 0)
|
||||
{
|
||||
$pg .= '<br><span class=err>';
|
||||
$msg = $ans['marks_status'];
|
||||
$pg .= str_replace(' ', ' ', $msg)."</span><br>\n";
|
||||
}
|
||||
|
||||
if (strlen($ans['block_extra']) > 0)
|
||||
{
|
||||
$pg .= '<br><span class=err>';
|
||||
$msg = $ans['block_status'].' - '.$ans['block_extra'];
|
||||
$pg .= str_replace(' ', ' ', $msg)."</span><br>\n";
|
||||
}
|
||||
|
||||
$pg .= "<br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<tr class=title>';
|
||||
$pg .= '<td class=dl>Name</td>';
|
||||
$pg .= '<td class=dr>Value</td>';
|
||||
$pg .= "</tr>\n";
|
||||
$i = 0;
|
||||
foreach ($data as $dsp => $name)
|
||||
{
|
||||
if (($i++ % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= "<td class=dl>$dsp</td>";
|
||||
switch ($name[0])
|
||||
{
|
||||
case ',':
|
||||
case '.':
|
||||
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 .= "<td class=dr>$fmt</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
|
||||
$pg .= "</table><br><table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<tr class=title>';
|
||||
$pg .= '<td class=dl>User</td>';
|
||||
$pg .= '<td class=dr>Diff Accepted</td>';
|
||||
$pg .= '<td class=dr>%</td>';
|
||||
$pg .= '<td class=dr>Avg Hashrate</td>';
|
||||
$pg .= '<td class=dr>BTC -0.9%</td>';
|
||||
$pg .= '<td class=dr>Address</td>';
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$diffacc_total = $ans['diffacc_total'];
|
||||
if ($diffacc_total == 0)
|
||||
$diffacc_total = pow(10,15);
|
||||
$elapsed = $ans['pplns_elapsed'];
|
||||
$count = $ans['rows'];
|
||||
$tot_pay = 0;
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$diffacc_user = $ans['diffacc:'.$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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.$ans['user:'.$i].'</td>';
|
||||
$pg .= "<td class=dr>$diffacc_user</td>";
|
||||
$pg .= "<td class=dr>$diffacc_percent</td>";
|
||||
$pg .= "<td class=dr>$avg_hash</td>";
|
||||
$pg .= '<td class=dr>'.btcfmt($pay_sat).'</td>';
|
||||
$pg .= "<td class=dr>$payaddress</td>";
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$tot_pay += $pay_sat;
|
||||
}
|
||||
if (($i % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl colspan=3></td>';
|
||||
$pg .= '<td class=dr></td>';
|
||||
$pg .= '<td class=dr>'.btcfmt($tot_pay).'</td>';
|
||||
$pg .= '<td class=dr></td>';
|
||||
$pg .= "</tr>\n";
|
||||
$pg .= "</table>\n";
|
||||
|
||||
if ($dotx === true)
|
||||
$pg .= calctx($ans, $count, $miner_sat, $diffacc_total);
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_pplns2($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopplns2', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function pspg($nc)
|
||||
{
|
||||
$g = "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;j<w.length;j++){tda[j-1]=0}
|
||||
for(var i=0;i<rows;i++){var s=parseFloat(d['start:'+i]);var e=parseFloat(d['end:'+i]);d['nx:'+i]=sn(i,d['shift:'+i]);if(xmin==-1||xmin>s){xmin=s}if(xmax<e){xmax=e}d['vx:'+i]=(s+e)/2.0;
|
||||
for(var j=1;j<w.length;j++){var pre=w[j];var ths=0,nam=pre+'diffacc:'+i;if(d[nam]){var da=parseFloat(d[nam]);ths=(da/(e-s))*Math.pow(2,32)/Math.pow(10,12);tda[j-1]+=da}d[pre+'ths:'+i]=ths;if(ymin==-1||ymin>ths){ymin=ths}if(ths>ymax)ymax=ths}
|
||||
}
|
||||
for(var j=1;j<w.length;j++){tda[j-1]*=(Math.pow(2,32)/Math.pow(10,12)/(xmax-xmin))}
|
||||
var p5=(ymax-ymin)*0.05;ymax+=p5;ymin-=p5;if(ymin<0){ymin=0}
|
||||
if(c['zerob']){ymin=0}
|
||||
var tl='TH/s';
|
||||
if(ymax>=2000){ymin/=1000;ymax/=1000;tl='PH/s';for(var j=1;j<w.length;j++){tda[j-1]/=1000}
|
||||
for(var i=0;i<rows;i++){ for(var j=1;j<w.length;j++){var pre=w[j];d[pre+'ths:'+i]/=1000} } }
|
||||
ghg(c,xmax-xmin);
|
||||
ggr(c,0.9,0.9,tl,rows,xmin,xmax,ymin,ymax,d,'nx:','vx:','ths:',tda,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 dopsperf($data, $user)
|
||||
{
|
||||
global $fld_sep, $val_sep;
|
||||
|
||||
$cols = array('#0000c0');
|
||||
$nc = count($cols);
|
||||
$datacols = $cols[0];
|
||||
|
||||
$ans = getPShiftData($user);
|
||||
|
||||
$iCrap = strpos($_SERVER['HTTP_USER_AGENT'],'iP');
|
||||
if ($iCrap)
|
||||
$vlines = false;
|
||||
else
|
||||
$vlines = true;
|
||||
|
||||
$pg = '<h1>Pool Shift Reward Performance</h1><br>';
|
||||
|
||||
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 .= "<div>";
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= ' <span class=nb>';
|
||||
$pg .= "<input type=checkbox id=$nam onclick='gact(this)'>";
|
||||
$pg .= "$txt </span>";
|
||||
}
|
||||
|
||||
$pg .= '</div>';
|
||||
$pg .= '<div id=can0><canvas id=can width=1 height=1>';
|
||||
$pg .= 'A graph will show here if your browser supports html5/canvas';
|
||||
$pg .= "</canvas></div>\n";
|
||||
$data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']);
|
||||
$data .= $fld_sep . 'cols' . $val_sep . $datacols;
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= pspg($nc);
|
||||
$pg .= "\nfunction godrw(f){var cbx=[";
|
||||
$comma = '';
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= "$comma'$nam'";
|
||||
$comma = ',';
|
||||
}
|
||||
$pg .= '];if(f){var xon={};';
|
||||
foreach ($xon as $nam => $val)
|
||||
$pg .= "xon['$nam']=1;";
|
||||
$pg .= "doinit(cbx,xon)}dodrw('$data',cbx)};godrw(1);</script>\n";
|
||||
}
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_psperf($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dopsperf', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,274 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('email.php');
|
||||
#
|
||||
function doregres($data, $u)
|
||||
{
|
||||
if (isset($data['data']['user']))
|
||||
$user = htmlspecialchars($data['data']['user']);
|
||||
else
|
||||
$user = '';
|
||||
|
||||
if (isset($data['data']['mail']))
|
||||
$mail = htmlspecialchars($data['data']['mail']);
|
||||
else
|
||||
$mail = '';
|
||||
|
||||
$pg = "<br><span class=urg>WARNING:</span>
|
||||
<b>Do not</b> give your username+password to anyone else.<br>
|
||||
<b>Do not</b> give your username+password to apps or web sites.<br>
|
||||
A monitoring app or web site will <b>ONLY</b> need your username+API key.<br>
|
||||
You can setup an API key from the 'Account'->'User Settings' menu page after you login.<br>
|
||||
Your miner password should be '<b>x</b>' and <b>must not</b> use your login password.<br>";
|
||||
|
||||
$pg .= makeForm('')."<br>
|
||||
<table cellpadding=0 cellspacing=0 border=0><tr>
|
||||
<td>User:</td><td><input type=text name=User size=10 value=''></td>
|
||||
<td> Pass:</td><td><input type=password name=Pass size=10 value=''></td>
|
||||
<td> <input type=submit name=Login value=Login></td>
|
||||
</tr></table></form>";
|
||||
|
||||
$pg .= '<br><h1>or choose one:</h1>';
|
||||
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=1><tr><td class=dc>';
|
||||
|
||||
$pg .= '<h1>Login</h1>';
|
||||
if (isset($data['data']['error']) && !isset($_POST['pass2']))
|
||||
$pg .= "<br><span class=err>".$data['data']['error']." - please try again</span><br><br>";
|
||||
$pg .= makeForm('');
|
||||
$pg .= "
|
||||
<table>
|
||||
<tr><td class=dr>Username:</td>
|
||||
<td class=dl><input name=User value=''></td></tr>
|
||||
<tr><td class=dr>Password:</td>
|
||||
<td class=dl><input type=password name=Pass value=''></td></tr>
|
||||
<tr><td class=dr><span class=st1>*</span>2nd Authentication:</td>
|
||||
<td class=dl><input name=2fa size=10></td></tr>
|
||||
<tr><td colspan=2 class=dc><font size=-1><span class=st1>*</span>
|
||||
Leave blank if you haven't enabled it</font></td></tr>
|
||||
<tr><td> </td>
|
||||
<td class=dl><input type=submit name=Login value=Login></td></tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
$pg.= '</td></tr><tr><td class=dc>';
|
||||
|
||||
$pg .= '<h1>Register</h1>';
|
||||
if (isset($data['data']['error']) && isset($_POST['pass2']))
|
||||
$pg .= "<br><span class=err>".$data['data']['error']." - please try again</span><br><br>";
|
||||
$pg .= makeForm('');
|
||||
$pg .= "
|
||||
<table>
|
||||
<tr><td class=dr>Username:</td>
|
||||
<td class=dl><input name=user value=\"$user\"></td></tr>
|
||||
<tr><td class=dr>Email:</td>
|
||||
<td class=dl><input name=mail value=\"$mail\"></td></tr>
|
||||
<tr><td class=dr>Password:</td>
|
||||
<td class=dl><input type=password name=pass value=''></td></tr>
|
||||
<tr><td class=dr>Retype Password:</td>
|
||||
<td class=dl><input type=password name=pass2 value=''></td></tr>
|
||||
<tr><td> </td>
|
||||
<td class=dl><input type=submit name=Register value=Register></td></tr>
|
||||
<tr><td colspan=2 class=dc><br><font size=-1><span class=st1>*</span>
|
||||
All fields are required<br>Your Username can't be a BTC address</font></td></tr>
|
||||
<tr><td colspan=2 class=dc><font size=-1><br>Note: your username is upper/lowercase sensitive,<br>
|
||||
and you must also have upper/lowercase correct on all your miners<br><br>" . passrequires() . "</font></td></tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
$pg.= '</td></tr><tr><td class=dc>';
|
||||
|
||||
$pg .= '<h1>Password Reset</h1>';
|
||||
$pg .= makeForm('');
|
||||
$pg .= "
|
||||
<table>
|
||||
<tr><td class=dr>Username:</td>
|
||||
<td class=dl><input name=user value=\"$user\"></td></tr>
|
||||
<tr><td class=dr>Email:</td>
|
||||
<td class=dl><input name=mail value=''></td></tr>
|
||||
<tr><td> </td>
|
||||
<td class=dl><input type=submit name=Reset value=Reset></td></tr>
|
||||
<tr><td colspan=2 class=dc><br><font size=-1>
|
||||
If you enter the details correctly,<br>
|
||||
an Email will be sent to you to let you reset your password</font></td></tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
$pg .= '</td></tr></table>';
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function doreg2($data)
|
||||
{
|
||||
if (isset($data['data']['user']))
|
||||
$user = htmlspecialchars($data['data']['user']);
|
||||
else
|
||||
$user = '';
|
||||
|
||||
$pg = '<h1>Registered</h1>';
|
||||
// $pg .= '<br>You will receive an email shortly to verify your account';
|
||||
$pg .= '<br>Your account is registered and ready to mine.';
|
||||
$pg .= '<br>Choose your own worker names in cgminer.';
|
||||
$pg .= '<br>Worker names must start with your username and a dot or an underscore';
|
||||
$pg .= "<br>e.g. <span class=hil>${user}_worker1</span> or <span class=hil>${user}.worker7</span>";
|
||||
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 = '<h1>Reset Sent</h1>';
|
||||
$pg .= '<br>An Email has been sent that will allow you to';
|
||||
$pg .= '<br>reset your password.';
|
||||
$pg .= '<br>If you got your username or email address wrong,';
|
||||
$pg .= '<br>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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,168 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('email.php');
|
||||
#
|
||||
function allow_reset($error)
|
||||
{
|
||||
$pg = '<br><br><table cellpadding=5 cellspacing=0 border=1><tr><td class=dc>';
|
||||
|
||||
$pg .= '<h1>Password Reset</h1>';
|
||||
if ($error !== null)
|
||||
$pg .= "<br><b>$error - please try again</b><br><br>";
|
||||
$pg .= makeForm('reset');
|
||||
$pg .= "
|
||||
<table>
|
||||
<tr><td class=dc colspan=2>Enter a new password twice.<br>
|
||||
" . passrequires() . "
|
||||
<input type=hidden name=k value=reset></td></tr>
|
||||
<tr><td class=dr>Password:</td>
|
||||
<td class=dl><input type=password name=pass></td></tr>
|
||||
<tr><td class=dr>Retype Password:</td>
|
||||
<td class=dl><input type=password name=pass2></td></tr>
|
||||
<tr><td class=dr><span class=st1>*</span>2nd Authentication:</td>
|
||||
<td class=dl><input name=2fa size=10></td></tr>
|
||||
<tr><td colspan=2 class=dc><br><font size=-1><span class=st1>*</span>
|
||||
Leave blank if you haven't enabled it</font></td></tr>
|
||||
<tr><td> </td>
|
||||
<td class=dl><input type=submit name=Update value=Update></td></tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
$pg .= '</td></tr></table>';
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function yok()
|
||||
{
|
||||
$pg = '<h1>Password Reset</h1>';
|
||||
$pg .= '<br>Your password has been reset,';
|
||||
$pg .= '<br>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 = '<h1>Reset Failed</h1>';
|
||||
$pg .= '<br>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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,257 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
include_once('email.php');
|
||||
#
|
||||
function settings($data, $user, $email, $addr, $err)
|
||||
{
|
||||
$pg = '<h1>Account Settings</h1>';
|
||||
|
||||
if ($err != '')
|
||||
$pg .= "<span class=err>$err<br><br></span>";
|
||||
|
||||
$pg .= '<table cellpadding=20 cellspacing=0 border=1>';
|
||||
$pg .= '<tr class=dc><td><center>';
|
||||
|
||||
$_SESSION['old_set_email'] = $email;
|
||||
|
||||
$pg .= makeForm('settings');
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=0>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'To change your email, enter a new email address and your password';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr>';
|
||||
$pg .= 'EMail:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= "<input type=text name=email value='$email' size=20>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr>';
|
||||
$pg .= 'Password:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input type=password name=pass size=20>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= '<span class=st1>*</span>2nd Authentication:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input name=2fa size=10>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
|
||||
$pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'Change: <input type=submit name=Change value=EMail>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '</table></form>';
|
||||
|
||||
$pg .= '</center></td></tr>';
|
||||
$pg .= '<tr class=dc><td><center>';
|
||||
|
||||
if (!isset($data['info']['u_multiaddr']))
|
||||
{
|
||||
$pg .= makeForm('settings');
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=0>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'To change your payout address, enter a new address and your password.<br>';
|
||||
$pg .= 'A payout address can only ever be set to one account';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr>';
|
||||
$pg .= 'BTC Address:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= "<input type=text name=baddr value='$addr' size=42>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr>';
|
||||
$pg .= 'Password:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input type=password name=pass size=20>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= '<span class=st1>*</span>2nd Authentication:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input name=2fa size=10>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
|
||||
$pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'Change: <input type=submit name=Change value=Address>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '</table></form>';
|
||||
|
||||
$pg .= '</center></td></tr>';
|
||||
$pg .= '<tr class=dc><td><center>';
|
||||
}
|
||||
|
||||
$pg .= makeForm('settings');
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=0>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'To change your password, enter your old password and new password twice';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= 'Old Password:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= "<input type=password name=oldpass size=20>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= 'New Password:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input type=password name=pass1 size=20>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= 'New Password again:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input type=password name=pass2 size=20>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr nowrap>';
|
||||
$pg .= '<span class=st1>*</span>2nd Authentication:';
|
||||
$pg .= '</td><td class=dl>';
|
||||
$pg .= '<input name=2fa size=10>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td colspan=2 class=dc><font size=-1>';
|
||||
$pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it</font>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td class=dr colspan=2>';
|
||||
$pg .= 'Change: <input type=submit name=Change value=Password>';
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '</table></form>';
|
||||
|
||||
$pg .= '</center></td></tr>';
|
||||
$pg .= '</table>';
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
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 .= '<br>';
|
||||
$err .= 'An error occurred, check your details below';
|
||||
goto iroiroattanoyo;
|
||||
}
|
||||
|
||||
$emailinfo = getOpts($user, emailOptList());
|
||||
if ($emailinfo['STATUS'] != 'ok')
|
||||
{
|
||||
if ($err != '')
|
||||
$err .= '<br>';
|
||||
$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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function doshifts($data, $user)
|
||||
{
|
||||
$ans = getShifts($user);
|
||||
|
||||
$pg = "Click <a href='#payoutmark'>here</a> to jump to the start of the last payout<br><br>";
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dl>Shift</td>';
|
||||
$pg .= '<td class=dl>Start UTC</td>';
|
||||
$pg .= '<td class=dr>Length</td>';
|
||||
$pg .= '<td class=dr>Your Diff</td>';
|
||||
$pg .= '<td class=dr>Inv Diff</td>';
|
||||
$pg .= '<td class=dr>Avg Hs</td>';
|
||||
$pg .= '<td class=dr>Shares</td>';
|
||||
$pg .= '<td class=dr>Avg Share</td>';
|
||||
$pg .= '<td class=dr>Rewards</td>';
|
||||
$pg .= '<td class=dr>Rewarded<span class=st1>*</span></td>';
|
||||
$pg .= '<td class=dr>PPS%</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
|
||||
if (($ans['STATUS'] != 'ok') || !isset($ans['prefix_all']))
|
||||
$pg = '<h1>Shifts</h1>'.$pg;
|
||||
else
|
||||
{
|
||||
$pre = $ans['prefix_all'];
|
||||
|
||||
$count = $ans['rows'];
|
||||
$pg = '<h1>Last '.($count+1).' Shifts</h1>'.$pg.'<tbody>';
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$u = '';
|
||||
$mark = '';
|
||||
if (isset($ans['lastpayoutstart:'.$i])
|
||||
&& $ans['lastpayoutstart:'.$i] != '')
|
||||
{
|
||||
$u = 'u';
|
||||
$mark = '<a name=payoutmark></a>';
|
||||
}
|
||||
if (($i % 2) == 0)
|
||||
$row = "even$u";
|
||||
else
|
||||
$row = "odd$u";
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
$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 = ' <img src=/BTCSym.png border=0>';
|
||||
else
|
||||
$btc = '';
|
||||
$pg .= "<td class=dl>$shif$btc$mark</td>";
|
||||
$start = $ans['start:'.$i];
|
||||
$pg .= '<td class=dl>'.utcd($start, true).'</td>';
|
||||
$nd = $ans['end:'.$i];
|
||||
$elapsed = $nd - $start;
|
||||
$pg .= '<td class=dr>'.howmanyhrs($elapsed).'</td>';
|
||||
$diffacc = $ans[$pre.'diffacc:'.$i];
|
||||
$pg .= '<td class=dr>'.difffmt($diffacc).'</td>';
|
||||
$diffinv = $ans[$pre.'diffinv:'.$i];
|
||||
$pg .= '<td class=dr>'.difffmt($diffinv).'</td>';
|
||||
$hr = $diffacc * pow(2,32) / $elapsed;
|
||||
$pg .= '<td class=dr>'.dsprate($hr).'</td>';
|
||||
$shareacc = $ans[$pre.'shareacc:'.$i];
|
||||
$pg .= '<td class=dr>'.difffmt($shareacc).'</td>';
|
||||
if ($shareacc > 0)
|
||||
$avgsh = $diffacc / $shareacc;
|
||||
else
|
||||
$avgsh = 0;
|
||||
$pg .= '<td class=dr>'.number_format($avgsh, 2).'</td>';
|
||||
$pg .= '<td class=dr>'.$ans['rewards:'.$i].'</td>';
|
||||
$ppsr = (float)$ans['ppsrewarded:'.$i];
|
||||
if ($ppsr > 0)
|
||||
$ppsd = sprintf('%.5f', $ppsr*1000.0);
|
||||
else
|
||||
$ppsd = '0';
|
||||
$pg .= "<td class=dr>$ppsd</td>";
|
||||
$ppsv = (float)$ans['ppsvalue:'.$i];
|
||||
if ($ppsv > 0)
|
||||
$pgot = number_format(100.0 * $ppsr / $ppsv, 2).'%';
|
||||
else
|
||||
$pgot = '?';
|
||||
$pg .= "<td class=dr>$pgot</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
$pg .= "<span class=st1>*</span> The Rewarded value unit is satoshis per 1000diff share<br>";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_shifts($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'doshifts', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function allusersort($a, $b)
|
||||
{
|
||||
$cmp = $b['u_hashrate5m'] - $a['u_hashrate5m'];
|
||||
if ($cmp != 0)
|
||||
return $cmp;
|
||||
return $a['userid'] - $b['userid'];
|
||||
}
|
||||
#
|
||||
function dostats($data, $user)
|
||||
{
|
||||
$pg = '<h1>Pool Stats</h1>';
|
||||
|
||||
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 .= '<table cellpadding=8 cellspacing=0 border=0><tr>';
|
||||
$pg .= "<td>Pool Hashrate: $dsp</td>";
|
||||
$pg .= "<td>5m: $dsp5m</td>";
|
||||
$pg .= "<td>1hr: $dsp1hr</td>";
|
||||
$pg .= "<td>24hr: $dsp24hr</td>";
|
||||
$pg .= '</tr></table><br>';
|
||||
}
|
||||
|
||||
$ans = getAllUsers($user);
|
||||
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dl>Username</td>';
|
||||
$pg .= '<td class=dr>Hash Rate 5m</td>';
|
||||
$pg .= "</tr></thead>\n";
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.htmlspecialchars($all[$i]['username']).'</td>';
|
||||
$uhr = $all[$i]['u_hashrate5m'];
|
||||
if ($uhr == '?')
|
||||
$dsp = '?GHs';
|
||||
else
|
||||
$dsp = dsprate($uhr);
|
||||
$pg .= "<td class=dr>$dsp</td>";
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_stats($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dostats', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function blocksorder($a, $b)
|
||||
{
|
||||
if ($b['blocks'] != $a['blocks'])
|
||||
return $b['blocks'] - $a['blocks'];
|
||||
else
|
||||
{
|
||||
if ($b['diffacc'] != $a['diffacc'])
|
||||
return $a['diffacc'] - $b['diffacc'];
|
||||
else
|
||||
return strcasecmp($a['username'], $b['username']);
|
||||
}
|
||||
}
|
||||
#
|
||||
function douserinfo($data, $user)
|
||||
{
|
||||
$sall = ($user == 'Kano');
|
||||
|
||||
$ans = getUserInfo($user);
|
||||
|
||||
$pg = '<h1>Block Acclaim</h1>';
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<thead><tr class=title>';
|
||||
$pg .= '<td class=dl>User</td>';
|
||||
$pg .= '<td class=dr>Blocks</td>';
|
||||
if ($sall)
|
||||
{
|
||||
$pg .= '<td class=dr>Diff</td>';
|
||||
$pg .= '<td class=dr>Avg</td>';
|
||||
}
|
||||
$pg .= "</thead></tr>\n";
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$pg .= '<tbody>';
|
||||
$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 .= "<tr class=$row>";
|
||||
$un = htmlspecialchars($all[$i]['username']);
|
||||
$pg .= "<td class=dl>$un</td>";
|
||||
$pg .= "<td class=dr>$bl</td>";
|
||||
if ($sall)
|
||||
{
|
||||
$diffacc = $all[$i]['diffacc'];
|
||||
$pg .= '<td class=dr>'.difffmt($diffacc).'</td>';
|
||||
if ($bl == 0)
|
||||
$bl = 1;
|
||||
$pg .= '<td class=dr>'.difffmt($diffacc/$bl).'</td>';
|
||||
}
|
||||
$pg .= "</tr>\n";
|
||||
}
|
||||
$pg .= '</tbody>';
|
||||
}
|
||||
$pg .= "</table>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_userinfo($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'douserinfo', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,130 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function uset($data, $user, $api, $err)
|
||||
{
|
||||
$pg = '<h1>User Settings</h1>';
|
||||
|
||||
if ($err != '')
|
||||
$pg .= "<span class=err>$err<br><br></span>";
|
||||
|
||||
$pg .= '<table cellpadding=20 cellspacing=0 border=1>';
|
||||
$pg .= '<tr class=dc><td><span class=nb>';
|
||||
$pg .= "<input type=checkbox id=minicb onclick='md(this)'>";
|
||||
$pg .= 'mini header</span></td></tr>';
|
||||
$pg .= '<tr class=dc><td><center>';
|
||||
|
||||
$pg .= makeForm('userset');
|
||||
$pg .= '<table cellpadding=5 cellspacing=0 border=0>';
|
||||
$pg .= '<tr class=dc><td>';
|
||||
if ($api === false)
|
||||
{
|
||||
$pg .= "You don't have an API Key setup yet";
|
||||
$draw = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
addQR();
|
||||
$pg .= 'Your current API Key is:';
|
||||
$pg .= '</td></tr><tr class=dc><td>';
|
||||
$pg .= "<span class=hil>$api</span></td></tr>";
|
||||
$pg .= '<tr class=dc><td><div id=can0><canvas id=can width=1 height=1>';
|
||||
$pg .= 'A qrcode will show here if your browser supports html5/canvas';
|
||||
$pg .= "</canvas></div>";
|
||||
$draw = true;
|
||||
}
|
||||
$pg .= '</td></tr><tr class=dc><td>';
|
||||
$pg .= 'Click to generate a new API key';
|
||||
$pg .= ": <input type=submit name=Change value='API Key'>";
|
||||
$pg .= '</td></tr>';
|
||||
if ($api !== false)
|
||||
{
|
||||
$pg .= '<tr class=dc><td> </td></tr>';
|
||||
$pg .= '<tr class=dc><td>You can access the API via:';
|
||||
$pg .= '</td></tr><tr class=dc><td>';
|
||||
$pg .= "<span class=hil>/index.php?k=api&username=";
|
||||
$pg .= htmlspecialchars(urlencode($user));
|
||||
$pg .= "&api=$api&json=y</span><br>";
|
||||
$pg .= '</td></tr>';
|
||||
$pg .= '<tr class=dc><td>You can get your workers via:';
|
||||
$pg .= '</td></tr><tr class=dc><td>';
|
||||
$pg .= "<span class=hil>/index.php?k=api&username=";
|
||||
$pg .= htmlspecialchars(urlencode($user));
|
||||
$pg .= "&api=$api&json=y&work=y</span><br>";
|
||||
$pg .= '</td></tr>';
|
||||
}
|
||||
$pg .= '</table></form>';
|
||||
|
||||
$pg .= '</center></td></tr>';
|
||||
$pg .= '</table>';
|
||||
|
||||
if ($draw !== false)
|
||||
{
|
||||
$qr = shell_exec("../pool/myqr.sh '$api'");
|
||||
if ($qr !== null and strlen($qr) > 30)
|
||||
{
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= "${qr}qr(tw,fa,qrx,qry,qrd);</script>\n";
|
||||
|
||||
if (strpos($qr, 'var tw=1,fa=0,qrx=') === false)
|
||||
error_log("QR error for '$user' res='$qr'");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($qr === null)
|
||||
$qr = 'null';
|
||||
error_log("QR failed for '$user' res='$qr'");
|
||||
}
|
||||
}
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,151 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function uspg($nc,$ff,$fs)
|
||||
{
|
||||
$g = "function exf(n,c,xn,x0,x1,y0,y1,ar){if(n==0){var i,st=-1,fi=-1;for(i=0;i<xn;i++){if(st==-1&&ar['lastpayoutstart:'+i]!=''){st=ar['start:'+i]}if(fi==-1&&ar['endmarkextra:'+i].indexOf('Block')==0){fi=ar['end:'+i]}}if(st>=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;j<w.length;j++){tda[j-1]=0}
|
||||
for(var i=0;i<rows;i++){var s=parseFloat(d['start:'+i]);var e=parseFloat(d['end:'+i]);d['nx:'+i]=sn(i,d['shift:'+i]);if(xmin==-1||xmin>s){xmin=s}if(xmax<e){xmax=e}d['vx:'+i]=(s+e)/2.0;
|
||||
for(var j=1;j<w.length;j++){var pre=w[j];var ths=0,nam=pre+'diffacc:'+i;if(d[nam]){var da=parseFloat(d[nam]);ths=(da/(e-s))*Math.pow(2,32)/Math.pow(10,12);tda[j-1]+=da}d[pre+'ths:'+i]=ths;if(ymin==-1||ymin>ths){ymin=ths}if(ths>ymax)ymax=ths;document.getElementById('worker'+j).value=d[pre+'worker']}
|
||||
}
|
||||
for(var j=1;j<w.length;j++){tda[j-1]*=(Math.pow(2,32)/Math.pow(10,12)/(xmax-xmin))}
|
||||
var p5=(ymax-ymin)*0.05;ymax+=p5;ymin-=p5;if(ymin<0){ymin=0}
|
||||
if(c['zerob']){ymin=0}
|
||||
ghg(c,xmax-xmin);
|
||||
ggr(c,0.9,0.9,'TH/s',rows,xmin,xmax,ymin,ymax,d,'nx:','vx:','ths:',tda,w,cols,exf)}
|
||||
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)}
|
||||
function wch(){var w='';for(var i=1;i<=$nc;i++){var e=document.getElementById('worker'+i);if(e&&e.value&&e.value.trim()){if(i>1){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 = '<h1>User Shift Reward Performance</h1><br>';
|
||||
|
||||
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 .= '<form>';
|
||||
|
||||
$tt = "<ul class=tip><li>all = all workers</li><li>noname = worker with no workername</li>";
|
||||
$tt .= "<li>or full workername without the username i.e. .worker or _worker</li>";
|
||||
$tt .= "<li>add a '*' on the end to match multiple workers e.g. .S3*</li></ul>";
|
||||
$pg .= "<span class=q onclick='tip(\"wtip\",6000)'>?</span>";
|
||||
$pg .= "<span class=tip0><span class=notip id=wtip>$tt</span></span>";
|
||||
|
||||
$i = 0;
|
||||
$datacols = '';
|
||||
$onch = " onchange='wch()'";
|
||||
foreach ($cols as $col)
|
||||
{
|
||||
$i++;
|
||||
$pg .= " <span class=nb><font color=$col>Worker$i";
|
||||
$pg .= "<input type=checkbox id=lin$i checked onclick='godrw(0)'>:</font>";
|
||||
$pg .= "<input type=text size=10 id=worker$i$onch> </span>";
|
||||
|
||||
if ($i > 1)
|
||||
$datacols .= ',';
|
||||
$datacols .= $col;
|
||||
}
|
||||
$oncl = "wch();location.href=\"".makeURL('usperf')."\"";
|
||||
$pg .= "<button type=button onclick='$oncl'>Update</button></form><div>";
|
||||
|
||||
# the rest of the workers/colours go below the graph
|
||||
$pg2 = '<form>';
|
||||
foreach ($cols2 as $col)
|
||||
{
|
||||
$i++;
|
||||
$pg2 .= " <span class=nb><font color=$col>Worker$i";
|
||||
$pg2 .= "<input type=checkbox id=lin$i checked onclick='godrw(0)'>:</font>";
|
||||
$pg2 .= "<input type=text size=10 id=worker$i$onch> </span>";
|
||||
|
||||
if ($i > 1)
|
||||
$datacols .= ',';
|
||||
$datacols .= $col;
|
||||
}
|
||||
$pg2 .= "<button type=button onclick='$oncl'>Update</button></form>\n";
|
||||
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= ' <span class=nb>';
|
||||
$pg .= "<input type=checkbox id=$nam onclick='gact(this)'>";
|
||||
$pg .= "$txt </span>";
|
||||
}
|
||||
|
||||
$pg .= '</div>';
|
||||
$pg .= '<div id=can0><canvas id=can width=1 height=1>';
|
||||
$pg .= 'A graph will show here if your browser supports html5/canvas';
|
||||
$pg .= "</canvas></div>\n";
|
||||
$pg .= $pg2;
|
||||
$data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']);
|
||||
$data .= $fld_sep . 'cols' . $val_sep . $datacols;
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= uspg($nc,'#ff0000','#fff0f0');
|
||||
$pg .= "\nfunction godrw(f){var cbx=[";
|
||||
$comma = '';
|
||||
foreach ($cbx as $nam => $txt)
|
||||
{
|
||||
$pg .= "$comma'$nam'";
|
||||
$comma = ',';
|
||||
}
|
||||
$pg .= '];if(f){var xon={};';
|
||||
foreach ($xon as $nam => $val)
|
||||
$pg .= "xon['$nam']=1;";
|
||||
$pg .= "doinit(cbx,xon)}dodrw('$data',cbx)};godrw(1);</script>\n";
|
||||
}
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function show_usperf($info, $page, $menu, $name, $user)
|
||||
{
|
||||
gopage($info, NULL, 'dousperf', $page, $menu, $name, $user);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,289 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function worktable()
|
||||
{
|
||||
$pg = "<script type='text/javascript'>\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 .= "</script>\n";
|
||||
$pg .= "Show Details for Invalids: <input type=checkbox onclick='wkdet(\"wkt\",this)'><br>";
|
||||
$pg .= "<table id=wkt cellpadding=0 cellspacing=0 border=0>\n";
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
function worktitle($data, $user)
|
||||
{
|
||||
addSort();
|
||||
$r = "input type=radio name=srt onclick=\"sott('worksrt',this);\"";
|
||||
$pg = '<thead><tr class=title>';
|
||||
$pg .= "<td class=dl>Worker <span class=nb>Name:<$r id=srtwrk data-sf=s0></span></td>";
|
||||
$pg .= '<td class=dr>Work Diff</td>';
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtlst data-sf=n2>:Last</span> Share</td>";
|
||||
$pg .= '<td class=dr>Shares</td>';
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtdiff data-sf=r4>:Diff</span></td>";
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtshrate data-sf=r5>:Share Rate</span></td>";
|
||||
$pg .= '<td class=dr>«Elapsed</td>';
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtinv data-sf=r7>:Invalid</span></td>";
|
||||
$pg .= "<td class=hid data-hid=dr><span class=nb><$r id=srtstale data-sf=r8>:Stale</span></td>";
|
||||
$pg .= "<td class=hid data-hid=dr><span class=nb><$r id=srtdup data-sf=r9>:Dup</span></td>";
|
||||
$pg .= "<td class=hid data-hid=dr><span class=nb><$r id=srthi data-sf=r10>:Hi</span></td>";
|
||||
$pg .= "<td class=hid data-hid=dr><span class=nb><$r id=srtreject data-sf=r11>:Rej</span></td>";
|
||||
$pg .= '<td class=dr>Block %</td>';
|
||||
$pg .= "<td class=dr><span class=nb><$r id=srtrate data-sf=r13>:Hash</span> Rate</td>";
|
||||
$pg .= "</tr></thead>\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 .= "<tr class=$row>";
|
||||
$pg .= '<td class=dl>'.htmlspecialchars($arow['workername']).'</td>';
|
||||
if ($arow['w_lastdiff'] > 0)
|
||||
$ld = difffmt($arow['w_lastdiff']);
|
||||
else
|
||||
$ld = ' ';
|
||||
$pg .= "<td class=dr>$ld</td>";
|
||||
|
||||
$pg .= "<td class=dr data-srt=$lstacc>".howlongago($lstacc).'</td>';
|
||||
|
||||
$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 .= "<td class=dr>$shareacc</td>";
|
||||
$pg .= "<td class=dr data-srt=$ds>$diffacc</td>";
|
||||
|
||||
$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 .= "<td class=dr data-srt=$acthrv>$acthr</td>";
|
||||
$pg .= "<td class=dr>$actsin</td>";
|
||||
|
||||
$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 .= "<td class=dr data-srt=$rejf>$rej%</td>";
|
||||
|
||||
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 .= "<td class=hid data-srt=$sdif data-hid=dr>$ddif/$shr</td>";
|
||||
}
|
||||
|
||||
if ($blockacc <= 0)
|
||||
$blkpct = ' ';
|
||||
else
|
||||
$blkpct = number_format(100.0 * $dacc / $blockacc, 3) . '%';
|
||||
|
||||
$pg .= "<td class=dr>$blkpct</td>";
|
||||
|
||||
$uhr = $arow['w_uhr'];
|
||||
if ($uhr == '?')
|
||||
{
|
||||
$uhr = '?GHs';
|
||||
$su = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$su = round($uhr);
|
||||
$totrate += $uhr;
|
||||
$uhr = dsprate($uhr);
|
||||
}
|
||||
$pg .= "<td class=dr data-srt=$su>$uhr</td>";
|
||||
|
||||
$pg .= "</tr>\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 .= "<tfoot><tr class=$row><td class=dl colspan=3>Total: $offset$dspinst</td>";
|
||||
$shareacc = number_format($totshare, 0);
|
||||
$pg .= "<td class=dr>$shareacc</td>";
|
||||
$diffacc = number_format($totdiff, 0);
|
||||
$pg .= "<td class=dr>$diffacc</td>";
|
||||
$pg .= "<td class=dr>$totshrate</td><td> </td>";
|
||||
$dtot = $totdiff + $totinvalid;
|
||||
if ($dtot > 0)
|
||||
$rej = number_format(100.0 * $totinvalid / $dtot, 3);
|
||||
else
|
||||
$rej = '0';
|
||||
$pg .= "<td class=dr>$rej%</td>";
|
||||
if ($blockacc <= 0)
|
||||
$blkpct = ' ';
|
||||
else
|
||||
$blkpct = number_format(100.0 * $totdiff / $blockacc, 3) . '%';
|
||||
$pg .= "<td class=hid colspan=4 data-hid=dr> </td>";
|
||||
$pg .= "<td class=dr>$blkpct</td>";
|
||||
$pg .= "<td class=dr>$totrate</td></tr></tfoot>\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 .= '<tbody>';
|
||||
$pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totshrate,
|
||||
$totinvalid, $totrate, $blockacc, $blockreward,
|
||||
false, true, true, $title, $instances);
|
||||
$pg .= '</tbody>';
|
||||
$pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid,
|
||||
$totrate, $blockacc, $blockreward, $instances);
|
||||
|
||||
$pg .= "</table>\n";
|
||||
$pg .= "<script type='text/javascript'>\n";
|
||||
$pg .= "sotc('worksrt','srtrate');</script>\n";
|
||||
|
||||
return "<h1>Workers$title</h1>".$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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,123 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function workmgtuser($data, $user, $err)
|
||||
{
|
||||
$pg = '<h1>Worker Management</h1>';
|
||||
|
||||
if ($err != '')
|
||||
$pg .= "<span class=err>$err<br><br></span>";
|
||||
|
||||
$ans = getWorkers($user, 'N');
|
||||
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
if (isset($ans['oldworkers']) && $ans['oldworkers'] == '0')
|
||||
$chk = '';
|
||||
else
|
||||
$chk = ' checked';
|
||||
$pg .= makeForm('workmgt');
|
||||
$pg .= '<span>Active workers (7 days)';
|
||||
$pg .= "<input type=checkbox name=seven$chk>";
|
||||
$pg .= '<input type=submit name=S value=Update>';
|
||||
$pg .= '</span></form><br><br>';
|
||||
}
|
||||
|
||||
$pg .= makeForm('workmgt');
|
||||
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
|
||||
$pg .= '<tr class=title>';
|
||||
$pg .= '<td class=dl>Worker Name</td>';
|
||||
$pg .= '<td class=dr>Minimum Diff</td>';
|
||||
$pg .= '</tr>';
|
||||
|
||||
$offset = 0;
|
||||
if ($ans['STATUS'] == 'ok')
|
||||
{
|
||||
$count = $ans['rows'];
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
if ((($offset) % 2) == 0)
|
||||
$row = 'even';
|
||||
else
|
||||
$row = 'odd';
|
||||
|
||||
$pg .= "<tr class=$row>";
|
||||
|
||||
$wn = htmlspecialchars($ans['workername:'.$i]);
|
||||
$wnv = urlencode($ans['workername:'.$i]);
|
||||
$pg .= '<td class=dl>';
|
||||
$pg .= "<input type=hidden name='workername:$i' value='$wnv'>";
|
||||
$pg .= $wn.'</td>';
|
||||
|
||||
$md = intval($ans['difficultydefault:'.$i]);
|
||||
$pg .= '<td class=dr>';
|
||||
$pg .= "<input type=text size=6 name='difficultydefault:$i' value='$md'>";
|
||||
$pg .= "<input type=submit name=OK value=OK>";
|
||||
$pg .= "</td>";
|
||||
|
||||
$pg .= "</tr>\n";
|
||||
|
||||
$offset++;
|
||||
}
|
||||
}
|
||||
$pg .= '<tr><td colspan=2 class=dc><font size=-1><span class=st1>*</span>';
|
||||
$pg .= ' A value of 0, less than the pool minimum,<br>';
|
||||
$pg .= 'or less than the pool calculated value for you,<br>';
|
||||
$pg .= 'will use the pool calculated value</font></td></tr>';
|
||||
$pg .= "</table><input type=hidden name=rows value=$count></form>\n";
|
||||
|
||||
return $pg;
|
||||
}
|
||||
#
|
||||
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);
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
function nutem($str)
|
||||
{
|
||||
if (($str === null) or trim($str) == '')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#
|
||||
function nuem($str)
|
||||
{
|
||||
if (($str === null) or $str == '')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#
|
||||
function getparam($name, $both)
|
||||
{
|
||||
$a = null;
|
||||
if (isset($_POST[$name]))
|
||||
$a = $_POST[$name];
|
||||
|
||||
if (($both === true) and ($a === null))
|
||||
{
|
||||
if (isset($_GET[$name]))
|
||||
$a = $_GET[$name];
|
||||
}
|
||||
|
||||
if ($a == '' || $a == null)
|
||||
return null;
|
||||
|
||||
// limit to 1K just to be sure
|
||||
return substr($a, 0, 1024);
|
||||
}
|
||||
#
|
||||
?>
|
||||
130
pool/prime.php
130
pool/prime.php
@ -1,130 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
global $stt;
|
||||
$stt = microtime(true);
|
||||
#
|
||||
global $loginfailed;
|
||||
$loginfailed = false;
|
||||
#
|
||||
include_once('param.php');
|
||||
include_once('base.php');
|
||||
#
|
||||
function process($p, $user, $menu)
|
||||
{
|
||||
$info = homeInfo($user);
|
||||
if (is_array($info) && isset($info['u_multiaddr']))
|
||||
{
|
||||
if (isset($menu['Account']))
|
||||
$menu['Account']['Addresses'] = 'addrmgt';
|
||||
if (isset($menu['Workers']))
|
||||
$menu['Workers']['Percents'] = 'percent';
|
||||
}
|
||||
if ($user == 'Kano' || $user == 'ckolivas')
|
||||
{
|
||||
$menu['Admin']['ckp'] = 'ckp';
|
||||
$menu['Admin']['PPLNS2'] = 'pplns2';
|
||||
$menu['Admin']['PPLNS'] = 'pplns';
|
||||
$menu['Admin']['AllWork'] = 'allwork';
|
||||
$menu['Admin']['IPS'] = 'ips';
|
||||
$menu['Admin']['Events'] = 'events';
|
||||
}
|
||||
bp:
|
||||
$page = '';
|
||||
$n = '';
|
||||
foreach ($menu as $item => $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();
|
||||
#
|
||||
?>
|
||||
231
pool/socket.php
231
pool/socket.php
@ -1,231 +0,0 @@
|
||||
<?php
|
||||
#
|
||||
# See function sendsockreply($fun, $msg, $tmo) at the end
|
||||
#
|
||||
function socktmo($socket, $factor)
|
||||
{
|
||||
# default timeout factor
|
||||
if ($factor === false)
|
||||
$factor = 1;
|
||||
|
||||
# on a slower server increase this base value
|
||||
$tmo = 8;
|
||||
|
||||
$usetmo = $tmo * $factor;
|
||||
$sec = floor($usetmo);
|
||||
$usec = floor(($usetmo - $sec) * 1000000);
|
||||
$tmoval = array('sec' => $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;
|
||||
}
|
||||
#
|
||||
?>
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
usleep(100000);
|
||||
include_once('param.php');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html><head><title>CKPool</title><meta content='text/html; charset=iso-8859-1' http-equiv='Content-Type'></head><body>
|
||||
<?php
|
||||
function go()
|
||||
{
|
||||
$a = getparam('a', true);
|
||||
$f = substr($a, 0, 1);
|
||||
if ($f != '1' and $f != '3')
|
||||
return;
|
||||
if (preg_match('/^[a-zA-Z0-9]{24,}[\._]?[a-zA-Z0-9\._]*$/', $a) === false)
|
||||
return;
|
||||
$sta = "../pool/workers/$a";
|
||||
if (file_exists($sta))
|
||||
echo file_get_contents($sta);
|
||||
}
|
||||
go();
|
||||
?>
|
||||
</body></html>
|
||||
Loading…
Reference in New Issue
Block a user