getState('yaamp-algo'); $algo_unit = 'Mh'; $algo_factor = yaamp_algo_mBTC_factor($algo); if ($algo_factor == 1000) $algo_unit = 'Gh'; JavascriptFile("/extensions/jqplot/jquery.jqplot.js"); JavascriptFile("/extensions/jqplot/plugins/jqplot.dateAxisRenderer.js"); JavascriptFile("/extensions/jqplot/plugins/jqplot.barRenderer.js"); JavascriptFile("/extensions/jqplot/plugins/jqplot.highlighter.js"); JavascriptFile('/yaamp/ui/js/auto_refresh.js'); $hour = 60 * 60; $days = 24 * $hour; $dbMax = (int) controller()->memcache->get_database_scalar("stats_maxt-$algo", "SELECT (MAX(time)-30*60) FROM hashstats WHERE time>:t AND algo=:algo", array(':t'=>time()-2*$hour,':algo'=>$algo)); $dtMax = max(time()-$hour, $dbMax); $t1 = $dtMax - 2*$days; $t2 = $dtMax - 7*$days; $t3 = $dtMax - 30*$days; $row1 = controller()->memcache->get_database_row("stats_col1-$algo", "SELECT AVG(hashrate) as a, SUM(earnings) as b FROM hashstats WHERE time>$t1 AND algo=:algo", array(':algo'=>$algo)); $row2 = controller()->memcache->get_database_row("stats_col2-$algo", "SELECT AVG(hashrate) as a, SUM(earnings) as b FROM hashstats WHERE time>$t2 AND algo=:algo", array(':algo'=>$algo)); $row3 = controller()->memcache->get_database_row("stats_col3-$algo", "SELECT AVG(hashrate) as a, SUM(earnings) as b FROM hashstats WHERE time>$t3 AND algo=:algo", array(':algo'=>$algo)); if($row1['a']>0 && $row2['a']>0 && $row3['a']>0) { $a1 = max(1., (double) $row1['a']); $a2 = max(1., (double) $row2['a']); $a3 = max(1., (double) $row3['a']); $btcmhday1 = bitcoinvaluetoa(($row1['b'] / 2) * $algo_factor * (1000000 / $a1)); $btcmhday2 = bitcoinvaluetoa(($row2['b'] / 7) * $algo_factor * (1000000 / $a2)); $btcmhday3 = bitcoinvaluetoa(($row3['b'] / 30) * $algo_factor * (1000000 / $a3)); } else { $btcmhday1 = 0; $btcmhday2 = 0; $btcmhday3 = 0; } $hashrate1 = Itoa2($row1['a']); $hashrate2 = Itoa2($row2['a']); $hashrate3 = Itoa2($row3['a']); $total1 = bitcoinvaluetoa($row1['b']); $total2 = bitcoinvaluetoa($row2['b']); $total3 = bitcoinvaluetoa($row3['b']); $height = '240px'; //$algos = yaamp_get_algos(); $algos = array(); $enabled = dbolist("SELECT algo, count(id) as count FROM coins WHERE enable AND visible GROUP BY algo ORDER BY algo"); foreach ($enabled as $row) { $algos[$row['algo']] = $row['count']; } $string = ''; foreach($algos as $a => $count) { if($a == $algo) $string .= ""; else $string .= ""; } // to fill the graphs on right edges (big tick interval of 4 days) $dtMin1 = $t1 + $hour; $dtMax1 = $dtMax; $dtMin2 = $t2 - 2*$hour; $dtMax2 = $dtMin2 + 7 * $days; $dtMin3 = $dtMax1 - (8*4+1)*$days; $dtMax3 = $dtMin3 + (8*4) * $days; echo <<