\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 = " 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 pghead($css_marker, $script_marker, $name) { global $page_title; $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($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 = ""; $top .= $alert_marker; 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) { $ret = "\n"; $ret .= '
'; $ret .= ''; $ret .= ''; $side = ''; foreach ($menus as $menu => $submenus) { if ($menu == 'Admin' && $submenus == null) continue; if ($menu == 'gap') { $side = 'r'; continue; } $ret .= "
\n"; return $ret; } # function pgbody($alert_marker, $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 .= ' ' . $elapsed_marker; $foot .= ' '; $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; global $alrts; $dbg_marker = '[@dbg@]'; $css_marker = '[@css@]'; $script_marker = '[@scripts@]'; $alert_marker = '[@alert@]'; $elapsed_marker = '[@elapsed@]'; 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($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 .= ""; $head = str_replace($script_marker, $page_scripts, $head); $alertstr = ''; foreach ($alrts as $str => $num) $alertstr .= "
$str
"; $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); } ?>