s){xmin=s}if(xmaxymax)ymax=lk} } if(ymax>500){ymax=500} ghg(c,xmax-xmin); ggr(c,0.90,0.90,'Luck%',rows,xmin,xmax,ymin,ymax,d,'seq:','vx:','luck:',tlk,w,cols)} c={}; function dodrw(data,cbx){if(hasCan()){gdrw(c,sep(data),cbx)}} function gact(t){if(t.checked){scnv(t.id,1)}else{scnv(t.id,0)}godrw(0)}"; return $g; } # function doluck($data, $user) { global $fld_sep, $val_sep; if ($user === null) $ans = getBlocks('Anon'); else $ans = getBlocks($user); $pg = '

Pool Avg Block Luck History


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