\n"; $page_scripts .= $script; } } # function addCSS($css) { global $page_css; $page_css .= $css; } # function addGBase() { $g = GBaseJS(); addScript($g); } # function addTips() { $t = TipsJS(); addScript($t); $tcss = TipsCSS(); addCSS($tcss); } # function addSort() { $s = SortJS(); addScript($s); } # function makeURL($page) { if ($page == null) $page = ''; else if ($page != '') $page = '?k='.$page; return "/index.php$page"; } # function makeLink($page, $rest = '') { $href = " 0) $form .= ""; return $form; } # function dotrm($html, $dontdoit) { if ($dontdoit === true) return $html; else return preg_replace('/ *\n */', '', $html); } # function trm($html) { global $dont_trm; return dotrm($html, $dont_trm); } # function trm_force($html) { return dotrm($html, false); } # function isCrap() { if (isset($_SERVER['HTTP_USER_AGENT'])) return strpos($_SERVER['HTTP_USER_AGENT'],'iP'); else return false; } # function pghead($css_marker, $script_marker, $name) { global $page_title; $iCrap = isCrap(); $head = "\n"; $head .= "$page_title$name"; $head .= ""; $head .= ""; $head .= ""; $head .= "\n"; $head .= "\n"; $head .= ''; $head .= $script_marker; // where to put the scripts $head .= ''; return $head; } # function pgtop($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 = round($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 = round($sec / 60); $nlb = $min.'m'; $s = $sec - $min * 60; if ($s > 0) $nlb .= " ${s}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 = ""; if ($loginfailed === true) $top .= '
Login Failed
'; if (isset($info['u_nopayaddr'])) $top .= '
Please set a payout address on your account!
'; if (isset($info['u_noemail'])) $top .= '
Please set an email address on your account!
'; $top .= '
'; if ($dotop === true) { $lh = ''; $ls = ''; $lw = ''; if (isset($info['now']) && isset($info['lastsh']) && isset($info['lasthb']) && isset($info['lastwi'])) { $lsn = $info['now'] - $info['lastsh']; $lhn = $info['now'] - $info['lasthb']; $lwn = $info['now'] - $info['lastwi']; if ($lsn < 8) $lsc = 'green.png'; else { if ($lsn < 10) $lsc = 'orange.png'; else $lsc = 'red.png'; } if ($lhn < 5) $lhc = 'green.png'; else { if ($lhn < 10) $lhc = 'orange.png'; else $lhc = 'red.png'; } if ($lwn < 36) $lwc = 'green.png'; else { if ($lwn < 46) $lwc = 'orange.png'; else $lwc = 'red.png'; } $img1 = ''; $top .= 'Workers: '; $top .= ' '.$info['workers'].''; $top .= ''; if ($douser === true) { $top .= ''; } $top .= ''; } else $top .= ' '; $top .= '
'; return $top; } # function pgmenu($menus) { $iCrap = isCrap(); $ret = "\n"; $ret .= '
'; $ret .= ''; $ret .= ''; $side = ''; foreach ($menus as $menu => $submenus) { if ($menu == 'Admin' && $submenus == null) continue; if ($menu == 'gap') { $side = 'r'; continue; } if ($iCrap) { foreach ($submenus as $submenu => $item) $ret .= ""; } else { $ret .= "
\n"; return $ret; } # function pgbody($info, $page, $menu, $dotop, $user, $douser) { $body = ' 5000) $syc = 'hi'; else $syc = 'lo'; $syncd = number_format($sync); $foot .= "sync: $syncd "; } $foot .= 'Copyright © Kano 2014'; $now = date('Y'); if ($now != '2014') $foot .= "-$now"; $foot .= ' Z/s '; $foot .= "\n"; return $foot; } # function gopage($info, $data, $pagefun, $page, $menu, $name, $user, $ispage = true, $dotop = true, $douser = true) { global $dbg, $stt; global $page_css, $page_scripts; $dbg_marker = '[@dbg@]'; $css_marker = '[@css@]'; $script_marker = '[@scripts@]'; if ($dbg === true) $pg = $dbg_marker.'
'; else $pg = ''; if ($info === NULL) $info = homeInfo($user); if ($ispage == true) { $both = array('info' => $info, 'data' => $data); $pg .= $pagefun($both, $user); } else $pg .= $pagefun; // if (isset($_SESSION['logkey'])) // unset($_SESSION['logkey']); $head = pghead($css_marker, $script_marker, $name); $body = pgbody($info, $page, $menu, $dotop, $user, $douser); $foot = pgfoot($info); if ($dbg === true) $pg = str_replace($dbg_marker, cvtdbg(), $pg); $head = str_replace($css_marker, $page_css, $head); if ($page_scripts != '') $page_scripts .= ""; $head = str_replace($script_marker, $page_scripts, $head); $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('Z/', number_format($elapsed, 4), $foot)); usleep(100000); echo $all.$foot; exit(0); } ?>