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 "}"; }
public function actionOrderDialog() { $renter = getrenterparam(getparam('address')); if (!$renter) { return; } $a = 'x11'; $server = ''; $username = ''; $password = '******'; $percent = ''; $price = ''; $speed = ''; $id = 0; $job = getdbo('db_jobs', getiparam('id')); if ($job) { $id = $job->id; $a = $job->algo; $server = "{$job->host}:{$job->port}"; $username = $job->username; $password = $job->password; $percent = $job->percent; $price = mbitcoinvaluetoa($job->price); $speed = $job->speed / 1000000; } echo <<<end <form id='order-edit-form' action='/renting/ordersave' method='post'> <input type="hidden" value='{$id}' name="order_id"> <input type="hidden" value='{$renter->id}' name="order_renterid"> <input type="hidden" value='{$renter->address}' name="order_address"> \t\t <p>Enter your job information below and click Submit when you are ready.</p> \t\t <table cellspacing=10 width=100%> <tr><td>Algo:</td><td><select class="main-text-input" name="order_algo"> end; foreach (yaamp_get_algos() as $algo) { if (!controller()->admin && $algo == 'sha256') { continue; } if (!controller()->admin && $algo == 'scryptn') { continue; } $selected = $algo == $a ? 'selected' : ''; echo "<option {$selected} value='{$algo}'>{$algo}</option>"; } echo <<<end </select></td></tr> <tr><td>Server:</td><td><input type="text" value='{$server}' name="order_host" class="main-text-input" placeholder="stratum.server.com:3333"></td></tr> <tr><td>Username:</td><td><input type="text" value='{$username}' name="order_username" class="main-text-input" placeholder="wallet_address"></td></tr> <tr><td>Password:</td><td><input type="text" value='{$password}' name="order_password" class="main-text-input"></td></tr> <tr><td>Max Price<br><span style='font-size: .8em;'>(mBTC/mh/day)</span>:</td><td><input type="text" value='{$price}' name="order_price" class="main-text-input" placeholder=""></td></tr> <tr><td width=110>Max Hashrate<br><span style='font-size: .8em;'>(Mh/s)</span>:</td><td><input type="text" value='{$speed}' name="order_speed" class="main-text-input" placeholder=""></td></tr> end; if (controller()->admin) { echo "<tr><td>Percent:</td><td><input type=text value='{$percent}' name=order_percent class=main-text-input></td></tr>"; } echo "</table></form>"; }
echo "<td align=right style='font-size: .9em;'>{$res4['a']}</td>"; echo "</tr>"; } /////////////////////////////////////////////////////////////////////// $hashrate1 = controller()->memcache->get_database_scalar("history_hashrate1-{$algo}", "select avg(hashrate) from hashrate where time>{$t1} and algo=:algo", array(':algo' => $algo)); $hashrate2 = controller()->memcache->get_database_scalar("history_hashrate2-{$algo}", "select avg(hashrate) from hashrate where time>{$t2} and algo=:algo", array(':algo' => $algo)); $hashrate3 = controller()->memcache->get_database_scalar("history_hashrate3-{$algo}", "select avg(hashrate) from hashrate where time>{$t3} and algo=:algo", array(':algo' => $algo)); $hashrate4 = controller()->memcache->get_database_scalar("history_hashrate4-{$algo}", "select avg(hashrate) from hashstats where time>{$t4} and algo=:algo", array(':algo' => $algo)); $hashrate1 = max($hashrate1, 1); $hashrate2 = max($hashrate2, 1); $hashrate3 = max($hashrate3, 1); $hashrate4 = max($hashrate4, 1); $btcmhday1 = mbitcoinvaluetoa($total1 / $hashrate1 * 1000000 * 24 * 1000); $btcmhday2 = mbitcoinvaluetoa($total2 / $hashrate2 * 1000000 * 1 * 1000); $btcmhday3 = mbitcoinvaluetoa($total3 / $hashrate3 * 1000000 / 7 * 1000); $btcmhday4 = mbitcoinvaluetoa($total4 / $hashrate4 * 1000000 / 30 * 1000); $hashrate1 = Itoa2($hashrate1); $hashrate2 = Itoa2($hashrate2); $hashrate3 = Itoa2($hashrate3); $hashrate4 = Itoa2($hashrate4); $total1 = bitcoinvaluetoa($total1); $total2 = bitcoinvaluetoa($total2); $total3 = bitcoinvaluetoa($total3); $total4 = bitcoinvaluetoa($total4); echo "<tr class='ssrow' style='border-top: 2px solid #eee;'>"; echo "<td width=18><img width=16 src='/images/btc.png'></td>"; echo "<td><b>BTC Value</b></td>"; echo "<td align=right style='font-size: .9em;'>{$total1}</td>"; echo "<td align=right style='font-size: .9em;'>{$total2}</td>"; echo "<td align=right style='font-size: .9em;'>{$total3}</td>"; echo "<td align=right style='font-size: .9em;'>{$total4}</td>";
echo "<td>{$coin->rpchost}:{$coin->rpcport}"; if ($coin->connections) { echo " ({$coin->connections})"; } echo "<br><span style='font-size: .8em'>{$coin->rpcencoding} <span style='background-color:{$algo_color};'> ({$coin->algo}) </span></span></td>"; $difficulty = Itoa2($coin->difficulty, 3); if (!empty($coin->errors)) { echo "<td align=right style='color: red; font-size: .9em;' title='{$coin->errors}'><b>{$difficulty}</b><br>{$coin->block_height}</td>"; } else { echo "<td align=right style='font-size: .9em'><b>{$difficulty}</b><br>{$coin->block_height}</td>"; } // $network_ttf = $coin->network_ttf? sectoa($coin->network_ttf): ''; // $actual_ttf = $coin->actual_ttf? sectoa($coin->actual_ttf): ''; // $pool_ttf = $coin->pool_ttf? sectoa($coin->pool_ttf): ''; $btcmhd = yaamp_profitability($coin); $btcmhd = mbitcoinvaluetoa($btcmhd); $h = $coin->block_height - 100; $ss1 = dboscalar("select count(*) from blocks where coin_id={$coin->id} and height>={$h} and category!='orphan'"); $ss2 = dboscalar("select count(*) from blocks where coin_id={$coin->id} and height>={$h} and category='orphan'"); $percent_pool1 = $ss1 ? $ss1 . '%' : ''; $percent_pool2 = $ss2 ? $ss2 . '%' : ''; // echo "<td align=right style='font-size: .9em'>$network_ttf<br>$actual_ttf</td>"; // echo "<td align=right style='font-size: .9em'>$pool_ttf<br></td>"; if ($ss1 > 50) { echo "<td align=right style='font-size: .9em'><b>{$btcmhd}</b><br><span style='color: blue;'>{$percent_pool1}</span>"; } else { echo "<td align=right style='font-size: .9em'><b>{$btcmhd}</b><br>{$percent_pool1}"; } echo "<span style='color: red;'> {$percent_pool2}</span></td>"; $owed = dboscalar("select sum(balance) from accounts where coinid={$coin->id}"); $owed_btc = bitcoinvaluetoa($owed * $coin->price);
function show_orders(&$allorders, &$services, $btcmhd = 0) { $algo = user()->getState('yaamp-algo'); $price = controller()->memcache->get_database_scalar("current_price-{$algo}", "select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo)); foreach ($allorders as $i => $order) { if ($order['price'] < $btcmhd) { continue; } if ($order['workers'] <= 0 && !isset($order['me'])) { continue; } if ($order['speed'] <= 0 && !isset($order['me'])) { continue; } $service_btcmhd = mbitcoinvaluetoa($order['price']); $hash = Itoa2($order['speed'] * 1000000000) . 'h/s'; $limit = Itoa2($order['limit'] * 1000000000) . 'h/s'; $btc = round($order['btc'] * 1000, 1); $profit = $price > $service_btcmhd ? round(($price - $service_btcmhd) / $service_btcmhd * 100) . '%' : ''; show_services($services, $service_btcmhd); if (isset($order['me'])) { echo "<tr class='ssrow' style='background-color: #dfd'>"; } else { echo "<tr class='ssrow'>"; } echo "<td></td>"; echo "<td><b>{$hash}</b> ({$order['workers']})</td>"; echo "<td align=right style='font-size: .8em;'>{$limit}</td>"; echo "<td align=right style='font-size: .8em;'>{$btc}</td>"; echo "<td align=right style='font-size: .8em;'><b>{$profit}</b></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right style='font-size: .8em;'><b>{$service_btcmhd}</b></td>"; echo "</tr>"; unset($allorders[$i]); } }
$value = altcoinvaluetoa($earning->amount * 1000); $percent = $block ? mbitcoinvaluetoa($earning->amount * 100 / $block->amount) : ''; $algo = $block ? $block->algo : ''; echo "<tr class='ssrow'>"; echo "<td width=18><img width=16 src='/images/btc.png'></td>"; echo "<td><b>Rental</b><span style='font-size: .8em'> ({$algo})</span></td>"; echo "<td align=right style='font-size: .8em'><b>{$reward} BTC</b></td>"; echo "<td align=right style='font-size: .8em'>{$percent}%</td>"; echo "<td align=right style='font-size: .8em'>{$value}</td>"; echo "<td align=right style='font-size: .8em'>{$d} ago</td>"; echo "<td align=right style='font-size: .8em'>Cleared</td>"; echo "</tr>"; continue; } $reward = altcoinvaluetoa($earning->amount); $percent = mbitcoinvaluetoa($earning->amount * 100 / $block->amount); $value = altcoinvaluetoa($earning->amount * $earning->price * 1000); echo "<tr class='ssrow'>"; echo "<td width=18><img width=16 src='{$coin->image}'></td>"; echo "<td><b>{$coin->name}</b><span style='font-size: .8em'> ({$coin->algo})</span></td>"; echo "<td align=right style='font-size: .8em'><b>{$reward} {$coin->symbol_show}</b></td>"; echo "<td align=right style='font-size: .8em'>{$percent}%</td>"; echo "<td align=right style='font-size: .8em'>{$value}</td>"; echo "<td align=right style='font-size: .8em'>{$d} ago</td>"; echo "<td align=right style='font-size: .8em'>"; if ($earning->status == 0) { echo "Immature ({$block->confirmations})"; } else { if ($earning->status == 1) { echo 'Exchange'; } else {
echo "<th>Nicehash</th>"; echo "<th>Yaamp</th>"; echo "<th>Price</th>"; echo "<th>Speed</th>"; echo "<th>Last Dec</th>"; echo "<th>Workers</th>"; echo "<th>Accepted</th>"; echo "<th>Rejected</th>"; echo "<th></th>"; echo "</tr>"; echo "</thead><tbody>"; $list = getdbolist('db_nicehash'); foreach ($list as $nicehash) { $price2 = mbitcoinvaluetoa(dboscalar("select price from services where algo='{$nicehash->algo}'") * 1000); $d = datetoa2($nicehash->last_decrease); $yaamp = mbitcoinvaluetoa(dboscalar("select price from hashrate where algo='{$nicehash->algo}' order by time desc limit 1")); echo "<tr class='ssrow'>"; echo "<td>{$nicehash->orderid}</td>"; echo "<td>{$nicehash->algo}</td>"; echo "<td>{$nicehash->btc}</td>"; echo "<td>{$price2}</td>"; if ($yaamp > $price2 * 1.1) { echo "<td style='color: #4a4'>{$yaamp}</td>"; } else { echo "<td>{$yaamp}</td>"; } if ($nicehash->price > $yaamp) { echo "<td style='color: #a44'>{$nicehash->price}</td>"; } else { echo "<td>{$nicehash->price}</td>"; }
echo "<td align=right style='font-size: .8em;' title='{$real_ttf} at {$pool_hash}'>{$pool_ttf}</td>"; } else { echo "<td align=right style='font-size: .8em;'>{$pool_ttf}</td>"; } if ($coin->auxpow && $coin->auto_ready) { echo "<td align=right style='font-size: .8em; opacity: 0.6;' title='merge mined\n{$network_hash}'>{$pool_hash_pow}</td>"; } else { echo "<td align=right style='font-size: .8em;' title='{$network_hash}'>{$pool_hash}</td>"; } $btcmhd = mbitcoinvaluetoa($btcmhd); echo "<td align=right style='font-size: .8em;'><b>{$btcmhd}</b></td>"; echo "</tr>"; } if (controller()->admin && $services) { foreach ($services as $i => $service) { $service_btcmhd = mbitcoinvaluetoa($service->price * 1000); echo "<tr class='ssrow'>"; echo "<td width=18><img width=16 src='/images/btc.png'></td>"; echo "<td><b>{$service->name}</b></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right style='font-size: .8em;'><b>{$service_btcmhd}</b></td>"; echo "</tr>"; } } if (isset($price_rent)) { echo "<tr class='ssrow'>"; echo "<td width=18><img width=16 src='/images/btc.png'></td>";
$algo = $item[1]; $count1 = getdbocount('db_jobs', "algo=:algo and ready and active", array(':algo' => $algo)); $count2 = getdbocount('db_jobs', "algo=:algo and ready", array(':algo' => $algo)); $total = yaamp_pool_rate($algo); $hashrate = yaamp_pool_rate_rentable($algo); $hashrate_jobs = yaamp_rented_rate($algo); $hashrate = min($total, $hashrate); $hashrate_jobs = min($hashrate, $hashrate_jobs); $available = $hashrate - $hashrate_jobs; $percent = $hashrate_jobs && $hashrate ? '(' . round($hashrate_jobs / $hashrate * 100, 1) . '%)' : ''; $hashrate_jobs = $hashrate_jobs > 0 ? Itoa2($hashrate_jobs) . 'h/s' : ''; $available = $available > 0 ? Itoa2($available) . 'h/s' : ''; $hashrate = $hashrate > 0 ? Itoa2($hashrate) . 'h/s' : ''; $total = $total > 0 ? Itoa2($total) . 'h/s' : ''; $renting = controller()->memcache->get_database_scalar("current_renting-{$algo}", "select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo)); $renting = mbitcoinvaluetoa($renting); if ($defaultalgo == $algo) { echo "<tr style='cursor: pointer; background-color: #e0d3e8;' onclick='javascript:select_algo(\"{$algo}\")'>"; } else { echo "<tr style='cursor: pointer' class='ssrow' onclick='javascript:select_algo(\"{$algo}\")'>"; } echo "<td><b>{$algo}</b></td>"; echo "<td align=right style='font-size: .9em;'>{$count1} / {$count2}</td>"; // echo "<td align=right style='font-size: .9em;'>$total</td>"; echo "<td align=right style='font-size: .9em;' title='pool hashrate {$total}'>{$hashrate}</td>"; echo "<td align=right style='font-size: .9em;'>{$hashrate_jobs}</td>"; echo "<td align=right style='font-size: .8em;'>{$percent}</td>"; echo "<td align=right style='font-size: .9em;'>{$available}</td>"; // echo "<td align=right style='font-size: .9em;'>$price</td>"; echo "<td align=right style='font-size: .9em;'><b>{$renting}</b></td>"; echo "</tr>";
$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)) : '-'; $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 {
foreach ($list as $job) { $hashrate_bad = yaamp_job_rate_bad($job->id); $hashrate = yaamp_job_rate($job->id) + $hashrate_bad; $title_percent = ''; if ($hashrate_bad) { $percent = round($hashrate_bad / $hashrate * 100, 1) . '%'; $hashrate_bad = Itoa2($hashrate_bad) . 'h/s'; $title_percent = "Rejected {$hashrate_bad} ({$percent})"; } $hashrate = $hashrate ? Itoa2($hashrate) . 'h/s' : ''; $maxhash = $job->speed ? Itoa2($job->speed) . 'h/s' : ''; $title = "-o stratum+tcp://{$job->host}:{$job->port} -u {$job->username} -p {$job->password}"; $servername = substr($job->host, 0, 22); $price = mbitcoinvaluetoa($job->price); $rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $job->algo)); $rent = mbitcoinvaluetoa($rent); $diff = $job->difficulty > 0 ? round($job->difficulty, 3) : ''; if ($job->active) { echo "<tr class='ssrow' style='background-color: #dfd'>"; } else { echo "<tr class='ssrow'>"; } echo "<td title='Show details'><a href='javascript:show_job_graph({$job->id})'>\r\n\t\t<img id='graph_toggle_job-{$job->id}' width=14 src='/images/plus2-78.png'></a></td>"; $p = $job->percent ? "({$job->percent}%)" : ''; echo "<td title='{$title}'>{$servername}</td>"; echo "<td>{$job->algo}</td>"; echo "<td align=right title='Current Price {$rent}'>{$price} {$p}</td>"; // echo "<td>$rent</td>"; echo "<td align=right>{$maxhash}</td>"; echo "<td align=right title='{$title_percent}'>{$hashrate}</td>"; echo "<td align=right>{$diff}</td>";
echo "</thead><tbody>"; $list = getdbolist('db_jobs', "ready and algo=:algo order by price desc, time", array(':algo' => $defaultalgo)); foreach ($list as $job) { $hashrate_bad = yaamp_job_rate_bad($job->id); $hashrate = yaamp_job_rate($job->id) + $hashrate_bad; $title_percent = ''; if ($hashrate_bad) { $percent = round($hashrate_bad / $hashrate * 100, 1) . '%'; $hashrate_bad = Itoa2($hashrate_bad) . 'h/s'; $title_percent = "Rejected {$hashrate_bad} ({$percent})"; } $hashrate = $hashrate ? Itoa2($hashrate) . 'h/s' : ''; $maxhash = $job->speed ? Itoa2($job->speed) . 'h/s' : ''; $title = controller()->admin ? "-o stratum+tcp://{$job->host}:{$job->port} -u {$job->username} -p {$job->password}" : ''; $servername = substr($job->host, 0, 22); $price = mbitcoinvaluetoa($job->price); $diff = $job->difficulty > 0 ? round($job->difficulty, 3) : ''; $d = datetoa2($job->time); if ($job->active) { echo "<tr class='ssrow' style='background-color: #dfd'>"; } else { echo "<tr class='ssrow'>"; } if ($renter && $renter->id == $job->renterid) { echo "<td title='{$title}'>{$job->host}</td>"; } else { echo "<td title='{$title}'></td>"; } // echo "<td>$d</td>"; // echo "<td>$job->algo</td>"; echo "<td align=right>{$price}</td>";