public function get_database_row($key, $query, $params = array()) { $value = $this->get($key); if ($value === false) { $value = dborow($query, $params); $this->set($key, $value); } return $value; }
<?php $algo = user()->getState('yaamp-algo'); 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'); $t1 = time() - 2 * 24 * 60 * 60; $t2 = time() - 7 * 24 * 60 * 60; $t3 = time() - 30 * 24 * 60 * 60; $row1 = dborow("select avg(hashrate) as a, sum(earnings) as b from hashstats where time>{$t1} and algo=:algo", array(':algo' => $algo)); $row2 = dborow("select avg(hashrate) as a, sum(earnings) as b from hashstats where time>{$t2} and algo=:algo", array(':algo' => $algo)); $row3 = dborow("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) { $btcmhday1 = bitcoinvaluetoa($row1['b'] / $row1['a'] * 1000000 / 2); $btcmhday2 = bitcoinvaluetoa($row2['b'] / $row2['a'] * 1000000 / 7); $btcmhday3 = bitcoinvaluetoa($row3['b'] / $row3['a'] * 1000000 / 30); } 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();