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 dousperf($data, $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) { $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>"; 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 .= 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 addQR() { global $added_qr; if ($added_qr == false) { $added_qr = true; addGBase(); $q = QRJS(); addScript($q); } }
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) { $l5 += $dr; $l5c++; } if ($k < 7) { $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; }