END;
///////////////////////////////////////////////////////////////////////////////////////////////////////
showTableSorter('maintable', '{
tableClass: "dataGrid",
widgets: ["Storage","saveSort"],
textExtraction: {
5: function(node, table, cellIndex) { return $(node).attr("data"); }
},
widgetOptions: {
saveSort: true
}}');
echo <<
Algo |
|
C |
M |
Fee |
Rate |
Rent |
Bad |
Now |
Rent |
Norm |
24E |
24A |
end;
$total_coins = 0;
$total_workers = 0;
$total_hashrate = 0;
$total_hashrate_bad = 0;
$algos = array();
foreach(yaamp_get_algos() as $algo)
{
$algo_norm = yaamp_get_algo_norm($algo);
$t = time() - 48*60*60;
$price = controller()->memcache->get_database_scalar("current_price-$algo",
"SELECT price FROM hashrate WHERE algo=:algo AND time>$t ORDER BY time DESC LIMIT 1", array(':algo'=>$algo));
$norm = $price*$algo_norm;
$norm = take_yaamp_fee($norm, $algo);
$algos[] = array($norm, $algo);
}
function cmp($a, $b)
{
return $a[0] < $b[0];
}
usort($algos, 'cmp');
foreach($algos as $item)
{
$norm = $item[0];
$algo = $item[1];
$algo_color = getAlgoColors($algo);
$algo_norm = yaamp_get_algo_norm($algo);
$coins = getdbocount('db_coins', "enable AND auto_ready AND algo=:algo", array(':algo'=>$algo));
$count = getdbocount('db_workers', "algo=:algo", array(':algo'=>$algo));
$total_coins += $coins;
$total_workers += $count;
$t1 = time() - 24*60*60;
$total1 = dboscalar("SELECT sum(amount*price) FROM blocks WHERE category!='orphan' AND time>$t1 AND algo=:algo", array(':algo'=>$algo));
if (!$coins && !$total1) continue;
$hashrate1 = dboscalar("SELECT avg(hashrate) FROM hashrate WHERE time>$t1 AND algo=:algo", array(':algo'=>$algo));
$hashrate = dboscalar("SELECT hashrate FROM hashrate WHERE algo=:algo ORDER BY time DESC LIMIT 1", array(':algo'=>$algo));
$hashrate_bad = dboscalar("SELECT hashrate_bad FROM hashrate WHERE algo=:algo ORDER BY time DESC LIMIT 1", array(':algo'=>$algo));
$bad = ($hashrate+$hashrate_bad)? round($hashrate_bad * 100 / ($hashrate+$hashrate_bad), 1): '';
$total_hashrate += $hashrate;
$total_hashrate_bad += $hashrate_bad;
$hashrate_sfx = $hashrate? Itoa2($hashrate).'h/s': '-';
$hashrate_bad = $hashrate_bad? Itoa2($hashrate_bad).'h/s': '-';
$hashrate_jobs = yaamp_rented_rate($algo);
$hashrate_jobs = $hashrate_jobs>0? Itoa2($hashrate_jobs).'h/s': '';
$price = dboscalar("SELECT price FROM hashrate WHERE algo=:algo ORDER BY time DESC LIMIT 1", array(':algo'=>$algo));
$price = $price? mbitcoinvaluetoa($price): '-';
$rent = dboscalar("SELECT rent FROM hashrate WHERE algo=:algo ORDER BY time DESC LIMIT 1", array(':algo'=>$algo));
$rent = $rent? mbitcoinvaluetoa($rent): '-';
$norm = mbitcoinvaluetoa($norm);
$t = time() - 24*60*60;
$avgprice = dboscalar("SELECT avg(price) FROM hashrate WHERE algo=:algo AND time>$t", array(':algo'=>$algo));
$avgprice = $avgprice? mbitcoinvaluetoa(take_yaamp_fee($avgprice, $algo)): '-';
$algo_unit_factor = yaamp_algo_mBTC_factor($algo);
$btcmhday1 = $hashrate1 != 0? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000 * $algo_unit_factor): '';
$fees = yaamp_fee($algo);
$stratum = getdbosql('db_stratums', "algo=:algo", array(':algo'=>$algo));
$isup = Booltoa($stratum);
echo '';
echo '';
echo CHtml::link($algo, '/site/gomining?algo='.$algo);
echo ' | ';
echo ''.$isup.' | ';
echo ''.(empty($coins) ? '-' : $coins).' | ';
echo ''.(empty($count) ? '-' : $count).' | ';
echo ''.(empty($fees) ? '-' : "$fees %").' | ';
echo ''.$hashrate_sfx.' | ';
echo ''.$hashrate_jobs.' | ';
if ($bad > 10)
echo ''.$bad.'% | ';
else if($bad > 5)
echo ''.$bad.'% | ';
else
echo ''.(empty($bad) ? '-' : "$bad %").' | ';
if ($norm>0)
echo ''.($price == 0.0 ? '-' : $price).' | ';
else
echo ''.($price == 0.0 ? '-' : $price).' | ';
echo ''.$rent.' | ';
// Norm
echo ''.($norm == 0.0 ? '-' : $norm).' | ';
// 24E
echo ''.($avgprice == 0.0 ? '-' : $avgprice).' | ';
// 24A
if($btcmhday1 != '-' && $btcmhday1 > $avgprice*1.1)
echo ''.$btcmhday1.' | ';
else if($btcmhday1 != '-' && $btcmhday1*1.3 < $avgprice)
echo ''.$btcmhday1.' | ';
else if($btcmhday1 != '-' && $btcmhday1*1.2 < $avgprice)
echo ''.$btcmhday1.' | ';
else if($btcmhday1 != '-' && $btcmhday1*1.1 < $avgprice)
echo ''.$btcmhday1.' | ';
else
echo ''.($btcmhday1 == 0.0 ? '-' : $btcmhday1).' | ';
echo ' ';
}
echo '';
$bad = ($total_hashrate+$total_hashrate_bad)? round($total_hashrate_bad * 100 / ($total_hashrate+$total_hashrate_bad), 1): '';
$total_hashrate = Itoa2($total_hashrate).'h/s';
echo '';
echo ' |