コード例 #1
0
ファイル: ApiController.php プロジェクト: zarethernet/yaamp
 public function actionStatus()
 {
     if (!LimitRequest('api-status', 10)) {
         return;
     }
     echo "{";
     foreach (yaamp_get_algos() as $i => $algo) {
         if ($i) {
             echo ", ";
         }
         $coins = controller()->memcache->get_database_count_ex("api_status_coins-{$algo}", 'db_coins', "enable and visible and auto_ready and algo=:algo", array(':algo' => $algo));
         $hashrate = controller()->memcache->get_database_scalar("api_status_hashrate-{$algo}", "select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $price = controller()->memcache->get_database_scalar("api_status_price-{$algo}", "select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $price = bitcoinvaluetoa(take_yaamp_fee($price / 1000, $algo));
         $rental = controller()->memcache->get_database_scalar("api_status_price-{$algo}", "select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
         $rental = bitcoinvaluetoa($rental);
         $t = time() - 24 * 60 * 60;
         $avgprice = controller()->memcache->get_database_scalar("api_status_avgprice-{$algo}", "select avg(price) from hashrate where algo=:algo and time>{$t}", array(':algo' => $algo));
         $avgprice = bitcoinvaluetoa(take_yaamp_fee($avgprice / 1000, $algo));
         $total1 = controller()->memcache->get_database_scalar("api_status_total-{$algo}", "select sum(amount*price) from blocks where category!='orphan' and time>{$t} and algo=:algo", array(':algo' => $algo));
         $hashrate1 = controller()->memcache->get_database_scalar("api_status_avghashrate-{$algo}", "select avg(hashrate) from hashrate where time>{$t} and algo=:algo", array(':algo' => $algo));
         //			$btcmhday1 = $hashrate1 != 0? bitcoinvaluetoa($total1 / $hashrate1 * 1000000): '0.00000000';
         if ($algo == 'sha256') {
             $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000) : '0';
         } else {
             $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000) : '0';
         }
         $fees = yaamp_fee($algo);
         $port = getAlgoPort($algo);
         if ($port == '-') {
             $port = 0;
         }
         echo "\"{$algo}\": ";
         echo "{";
         echo "\"name\": \"{$algo}\", ";
         echo "\"port\": {$port}, ";
         echo "\"coins\": {$coins}, ";
         echo "\"fees\": {$fees}, ";
         echo "\"hashrate\": {$hashrate}, ";
         echo "\"estimate_current\": {$price}, ";
         echo "\"estimate_last24h\": {$avgprice}, ";
         echo "\"actual_last24h\": {$btcmhday1}, ";
         echo "\"rental_current\": {$rental}";
         echo "}";
     }
     echo "}";
 }
コード例 #2
0
ファイル: yaamp.php プロジェクト: zarethernet/yaamp
function take_yaamp_fee($v, $algo)
{
    return $v - $v * yaamp_fee($algo) / 100;
}
コード例 #3
0
 $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)) : '-';
 $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));
 $hashrate1 = dboscalar("select avg(hashrate) from hashrate where time>{$t1} and algo=:algo", array(':algo' => $algo));
 if ($algo == 'sha256') {
     $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000000) : '';
 } else {
     $btcmhday1 = $hashrate1 != 0 ? mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 1000) : '';
 }
 $fees = yaamp_fee($algo);
 $stratum = getdbosql('db_stratums', "algo=:algo", array(':algo' => $algo));
 $isup = Booltoa($stratum);
 echo "<tr class='ssrow'>";
 echo "<td style='background-color: {$algo_color}'><b><a href='/site/gomining?algo={$algo}'>{$algo}</a></b></td>";
 echo "<td align=right'>{$isup}</td>";
 echo "<td align=right style='font-size: .8em;'>{$coins}</td>";
 echo "<td align=right style='font-size: .8em;'>{$count}</td>";
 echo "<td align=right style='font-size: .8em;'>{$fees}%</td>";
 echo "<td align=right style='font-size: .8em;'>{$hashrate}</td>";
 echo "<td align=right style='font-size: .8em;'>{$hashrate_jobs}</td>";
 if ($bad > 10) {
     echo "<td align=right style='font-size: .8em; color: white; background-color: #d9534f'>{$bad}%</td>";
 } else {
     if ($bad > 5) {
         echo "<td align=right style='font-size: .8em; color: white; background-color: #f0ad4e'>{$bad}%</td>";