diff --git a/pool/db.php b/pool/db.php index 908c020b..b2cb3b85 100644 --- a/pool/db.php +++ b/pool/db.php @@ -110,6 +110,18 @@ 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; @@ -134,6 +146,7 @@ function msgEncode($cmd, $id, $fields, $user) $msg .= 'createcode' . $val_sep . 'php' . $fld_sep; $msg .= 'createby' . $val_sep . $user . $fld_sep; $msg .= 'createinet' . $val_sep . zeip(); + adm($user, $msg); return $msg; } # @@ -309,11 +322,13 @@ function getMPayouts($user) return repDecode($rep); } # -function getShifts($user) +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) @@ -321,11 +336,13 @@ function getShifts($user) return repDecode($rep); } # -function getShiftData($user) +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) @@ -333,6 +350,30 @@ function getShiftData($user) 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) diff --git a/pool/page.php b/pool/page.php index 9d377438..7bb2607c 100644 --- a/pool/page.php +++ b/pool/page.php @@ -3,10 +3,12 @@ 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; @@ -40,13 +42,18 @@ function addScript($script) } } # +function addCSS($css) +{ + global $page_css; + + $page_css .= $css; +} +# function addGBase() { $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;i0){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 ccb(c,n){var e=document.getElementById(n);c[n]=(e&&e.checked)} 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)} @@ -69,7 +76,7 @@ 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){ +function ggr(c,xs,ys,yt,xn,x0,x1,y0,y1,ar,nx,vx,vy,av,w,cols){ gtso(c,xs,ys); gss(c,'black');glw(c,1.5); gbe(c,0,1);gln(c,0,0);gln(c,1,0);gst(c); @@ -78,40 +85,63 @@ var hi=c['ctx'].measureText('M').width, wi=c['ctx'].measureText('1').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); -var f=1; for(var i=0;i=x0;i-=hrs){var n=dfmt(c,i);var xo=(i-x0)/(x1-x0);if(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(c['tlines']){gbe(c,xo,0);gln(c,xo,1);gst(c)}l++}} +for(var i=xhr;i>=x0;i-=hrs){var n=dfmt(c,i);var xo=(i-x0)/(x1-x0);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); -gss(c,'#0000c0'); -if(c['smooth']){var xa=0,ya=0,xb=0,yb=0; -for(var i=0;i0){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 col,hrl=c['hrs'].length;for(var i=0;ic['xm']){c['ym']=c['xm']}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){var div=document.getElementById('can0');while(div.firstChild){div.removeChild(div.firstChild)}c['can']=document.createElement('canvas');c['can'].id='can';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']}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 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];c['hln']=[1,2,3,4,6]} -function gopt(c,cbx){for(var i=0;i=0;j--){if(tl 0) - $plb .= ' '.$min.'m'; + $plb .= ' '.$min.'m'; } } } @@ -298,7 +344,7 @@ function pgtop($info, $dotop, $user, $douser) $nlb = $min.'m'; $s = $sec - $min * 60; if ($s > 0) - $nlb .= " ${s}s"; + $nlb .= " ${s}s"; } } @@ -352,9 +398,9 @@ function pgtop($info, $dotop, $user, $douser) } } - $top = "
 Javascript isn't enabled."; + $top = "
"; if ($loginfailed === true) $top .= '
Login Failed
'; @@ -406,18 +452,24 @@ function pgtop($info, $dotop, $user, $douser) $lh = $img1.$lhc.$img2; $lw = $img1.$lwc.$img2; } + + if (!isset($info['users'])) + $info['users'] = '?'; + if (!isset($info['workers'])) + $info['workers'] = '?'; + $top .= '
'; $top .= ''; $top .= ""; $top .= ""; - $top .= "
$lh
$ls
$lw
"; + $top .= "
$lw
"; $top .= ''; $top .= ''; $top .= ''; $top .= ""; $top .= ''; $top .= ""; - $top .= ''; + $top .= ''; $top .= "
CKPool:  $phr
Shares:  $pac
Invalid: 
Invalid:  $per
"; $top .= ''; $top .= ''; @@ -425,9 +477,9 @@ function pgtop($info, $dotop, $user, $douser) $top .= ''; $top .= ''; $top .= ""; - $top .= ''; + $top .= ''; $top .= "
Block
Pool:  $plb
Network: 
Network:  $nlb
"; - $top .= ''; + $top .= ''; $top .= ''; $top .= ''; $top .= ''; @@ -484,7 +536,7 @@ function pgtop($info, $dotop, $user, $douser) # function pgmenu($menus) { - $iCrap = strpos($_SERVER['HTTP_USER_AGENT'],'iP'); + $iCrap = isCrap(); $ret = "\n
Users:  '.$info['users'].'
"; $ret .= '
'; @@ -537,7 +589,7 @@ function pgmenu($menus) # function pgbody($info, $page, $menu, $dotop, $user, $douser) { - $body = ' $pg .= str_replace(' ', ' ', $msg)."
\n"; } - if (strlen($ans['share_status']) > 0) - { - $pg .= '
'; - $msg = $ans['share_status']." - Can't be paid out yet"; - $pg .= str_replace(' ', ' ', $msg)."
\n"; - } - $pg .= "
\n"; $pg .= ''; $pg .= ''; diff --git a/pool/page_psperf.php b/pool/page_psperf.php new file mode 100644 index 00000000..8943d5cf --- /dev/null +++ b/pool/page_psperf.php @@ -0,0 +1,90 @@ +s){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths} +} +for(var j=1;j 'shift key', 'slines' => 'shift lines', + 'tkey' => 'time key', 'tlines' => 'time lines', + 'over' => 'key overlap', 'smooth' => 'smooth', + 'zerob' => 'zero based', 'utc' => 'utc'); + $xon = array('skey' => 1, 'utc' => 1); + if ($vlines === true) + $xon['slines'] = 1; + + $pg .= "
"; + foreach ($cbx as $nam => $txt) + { + $pg .= ' '; + $pg .= ""; + $pg .= "$txt "; + } + + $pg .= '
'; + $pg .= '
'; + $pg .= 'A graph will show here if your browser supports html5/canvas'; + $pg .= "
\n"; + $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); + $data .= $fld_sep . 'cols' . $val_sep . $datacols; + $pg .= "\n"; + } + return $pg; +} +# +function show_psperf($info, $page, $menu, $name, $user) +{ + gopage($info, NULL, 'dopsperf', $page, $menu, $name, $user); +} +# +?> diff --git a/pool/page_shifts.php b/pool/page_shifts.php index b83d3ec6..8902f004 100644 --- a/pool/page_shifts.php +++ b/pool/page_shifts.php @@ -14,10 +14,13 @@ function doshifts($data, $user) $pg .= "
"; $pg .= ""; $pg .= "\n"; - if ($ans['STATUS'] != 'ok') + + if (($ans['STATUS'] != 'ok') || !isset($ans['prefix_all'])) $pg = '

Shifts

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

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

'.$pg; for ($i = 0; $i < $count; $i++) @@ -49,11 +52,11 @@ function doshifts($data, $user) $nd = $ans['end:'.$i]; $elapsed = $nd - $start; $pg .= ''; - $diffacc = $ans['diffacc:'.$i]; + $diffacc = $ans[$pre.'diffacc:'.$i]; $pg .= ''; $hr = $diffacc * pow(2,32) / $elapsed; $pg .= ''; - $shareacc = $ans['shareacc:'.$i]; + $shareacc = $ans[$pre.'shareacc:'.$i]; $pg .= ''; if ($shareacc > 0) $avgsh = $diffacc / $shareacc; diff --git a/pool/page_userset.php b/pool/page_userset.php index ae4b382c..bfed9cdf 100644 --- a/pool/page_userset.php +++ b/pool/page_userset.php @@ -8,6 +8,9 @@ function uset($data, $user, $api, $err) $pg .= "$err

"; $pg .= '
NameSharesAvg Share
'.howmanyhrs($elapsed).''.difffmt($diffacc).''.dsprate($hr).''.difffmt($shareacc).'
'; + $pg .= ''; $pg .= '
'; + $pg .= ""; + $pg .= 'mini header
'; $pg .= makeForm('userset'); diff --git a/pool/page_usperf.php b/pool/page_usperf.php index 2d9d5fb5..f16030a6 100644 --- a/pool/page_usperf.php +++ b/pool/page_usperf.php @@ -1,24 +1,53 @@ ths){ymin=ths}if(ths>ymax)ymax=ths;d['nx:'+i]=sn(i,d['shift:'+i]);if(xmin==-1||xmin>s){xmin=s}if(xmaxs){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths;document.getElementById('worker'+j).value=d[pre+'worker']} +} +for(var j=1;j1){w+=','}w+=e.value.trim()}}if(w){scnv('workers',w)}}"; return $g; } # function dousperf($data, $user) { - $ans = getShiftData($user); + global $fld_sep, $val_sep; + + // This also defines how many worker fields there are + $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); + $nc = count($cols); + + $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) @@ -27,9 +56,11 @@ function dousperf($data, $user) $vlines = true; $pg = '

User Shift Reward Performance


'; + if ($ans['STATUS'] == 'ok' and $ans['DATA'] != '') { addGBase(); + addTips(); $cbx = array('skey' => 'shift key', 'slines' => 'shift lines', 'tkey' => 'time key', 'tlines' => 'time lines', 'over' => 'key overlap', 'smooth' => 'smooth', @@ -38,17 +69,44 @@ function dousperf($data, $user) if ($vlines === true) $xon['slines'] = 1; - $pg .= '
'; + $pg .= '
'; + + $tt = "
  • all = all workers
  • noname = worker with no workername
  • "; + $tt .= "
  • or full workername without the username i.e. .worker or _worker
"; + $pg .= "?"; + $pg .= "$tt"; + + $i = 0; + $datacols = ''; + $onch = " onchange='wch()'"; + foreach ($cols as $col) + { + $i++; + $pg .= " Worker$i:"; + $pg .= " "; + + if ($i > 1) + $datacols .= ','; + $datacols .= $col; + } + + $oncl = "wch();location.href=\"".makeURL('usperf')."\""; + $pg .= "
"; foreach ($cbx as $nam => $txt) - $pg .= " $txt "; + { + $pg .= ' '; + $pg .= ""; + $pg .= "$txt "; + } $pg .= '
'; $pg .= '
'; $pg .= 'A graph will show here if your browser supports html5/canvas'; $pg .= "
\n"; $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); + $data .= $fld_sep . 'cols' . $val_sep . $datacols; $pg .= "