function BackendStatsUpdate2() { // debuglog('----------------------------------'); // debuglog(__FUNCTION__); //////////////////////////////////////////////////////////////////////////////////////////////////// $step = 15; $t = floor(time() / $step / 60) * $step * 60; $list = dbolist("select userid, algo from shares where time>{$t} group by userid, algo"); foreach ($list as $item) { $stats = getdbosql('db_hashuser', "time={$t} and algo=:algo and userid=:userid", array(':algo' => $item['algo'], ':userid' => $item['userid'])); if (!$stats) { $stats = new db_hashuser(); $stats->userid = $item['userid']; $stats->time = $t; $stats->hashrate = dboscalar("select hashrate from hashuser where algo=:algo and userid=:userid order by time desc limit 1", array(':algo' => $item['algo'], ':userid' => $item['userid'])); $stats->hashrate_bad = 0; $stats->algo = $item['algo']; } $percent = 20; $user_rate = yaamp_user_rate($item['userid'], $item['algo']); $stats->hashrate = round(($stats->hashrate * (100 - $percent) + $user_rate * $percent) / 100); if ($stats->hashrate < 1000) { $stats->hashrate = 0; } $user_rate_bad = yaamp_user_rate_bad($item['userid'], $item['algo']); $stats->hashrate_bad = round(($stats->hashrate_bad * (100 - $percent) + $user_rate_bad * $percent) / 100); if ($stats->hashrate_bad < 1000) { $stats->hashrate_bad = 0; } $stats->save(); } //////////////////////////////////////////////////////////////////////////////////////////////////// $step = 15; $t = floor(time() / $step / 60) * $step * 60; $list = dbolist("select distinct jobid from jobsubmits where time>{$t}"); foreach ($list as $item) { $jobid = $item['jobid']; $stats = getdbosql('db_hashrenter', "time={$t} and jobid={$jobid}"); if (!$stats) { $stats = new db_hashrenter(); // $stats->renterid = ; $stats->jobid = $item['jobid']; $stats->time = $t; $stats->hashrate = dboscalar("select hashrate from hashrenter where jobid=:jobid order by time desc limit 1", array(':jobid' => $jobid)); $stats->hashrate_bad = 0; //dboscalar("select hashrate_bad from hashrenter where jobid=$jobid order by time desc limit 1"); } $percent = 20; $job_rate = yaamp_job_rate($jobid); $stats->hashrate = round(($stats->hashrate * (100 - $percent) + $job_rate * $percent) / 100); if ($stats->hashrate < 1000) { $stats->hashrate = 0; } $job_rate_bad = yaamp_job_rate_bad($jobid); $stats->hashrate_bad = round(($stats->hashrate_bad * (100 - $percent) + $job_rate_bad * $percent) / 100); if ($stats->hashrate_bad < 1000) { $stats->hashrate_bad = 0; } $stats->save(); } //////////////////////////////////////////////////////////////////////////////////////////////////// $t = floor(time() / $step / 60) * $step * 60; $d = time() - 24 * 60 * 60; $list = getdbolist('db_accounts', "balance>0 or last_login>{$d}"); foreach ($list as $user) { $stats = getdbosql('db_balanceuser', "time={$t} and userid={$user->id}"); if (!$stats) { $stats = new db_balanceuser(); $stats->userid = $user->id; $stats->time = $t; } // $refcoin = getdbo('db_coins', $user->coinid); // if(!$refcoin) $refcoin = getdbosql('db_coins', "symbol='BTC'"); // if(!$refcoin->price || !$refcoin->price2) continue; // $pending1 = dboscalar("select sum(amount*price) from earnings where coinid=$refcoin->id and status!=2 and userid=$user->id"); // $pending2 = dboscalar("select sum(amount*price) from earnings where coinid!=$refcoin->id and status!=2 and userid=$user->id"); $stats->pending = yaamp_convert_earnings_user($user, "status!=2"); $stats->pending = bitcoinvaluetoa($stats->pending); $stats->balance = $user->balance; $stats->save(); $id = dboscalar("select id from earnings where userid={$user->id} order by id desc limit 100, 1"); if ($id) { dborun("delete from earnings where status=2 and userid={$user->id} and id<{$id}"); } } }
echo "<td align=right style='font-size: .8em;'>{$confirmed}</td>"; echo "<td align=right style='font-size: .8em;'>{$total}</td>"; echo "<td align=right style='font-size: .8em;'>{$value} {$refcoin->symbol}</td>"; echo "</tr>"; } } $d1 = microtime(true) - $t1; controller()->memcache->add_monitoring_function('wallet_results-1', $d1); } ////////////////////////////////////////////////////////////////////////////// // $confirmed = bitcoinvaluetoa(controller()->memcache->get_database_scalar("wallet_confirmed-$user->id", // "select sum(amount*price) from earnings where status=1 and userid=$user->id"))/$refcoin->price; // $unconfirmed = bitcoinvaluetoa(controller()->memcache->get_database_scalar("wallet_unconfirmed-$user->id", // "select sum(amount*price) from earnings where status=0 and userid=$user->id"))/$refcoin->price; $confirmed = yaamp_convert_earnings_user($user, "status=1"); $unconfirmed = yaamp_convert_earnings_user($user, "status=0"); $total_unsold = bitcoinvaluetoa($confirmed + $unconfirmed); $confirmed = $confirmed ? bitcoinvaluetoa($confirmed) : ''; $unconfirmed = $unconfirmed ? bitcoinvaluetoa($unconfirmed) : ''; //$total_usd = number_format($total_unsold*$mining->usdbtc*$refcoin->price, 3, '.', ' '); $total_pending = bitcoinvaluetoa($total_pending); if (!$show_details && $total_unsold > 0) { echo "<tr><td colspan=6 align=right>\r\n\t\t<label style='font-size: .8em;'>\r\n\t\t\t<input type='checkbox' onclick='javascript:main_wallet_refresh_details()'>\r\n\t\t\tShow Details\r\n\t\t</label>\r\n\t</td></tr>"; } echo "<tr class='ssrow' style='border-top: 3px solid #eee;'>"; echo "<td valign=top><img width=16 src='{$refcoin->image}'></td>"; echo "<td valign=top><b>"; if ($refcoin->symbol == 'BTC') { echo "{$refcoin->name}"; } else { echo "<a href='/site/block?id={$refcoin->id}'>{$refcoin->name}</a>";
public function actionWalletEx() { if (!LimitRequest('api-wallet', 10)) { return; } $wallet = getparam('address'); $user = getuserparam($wallet); if (!$user || $user->is_locked) { return; } $total_unsold = yaamp_convert_earnings_user($user, "status!=2"); $total_paid = bitcoinvaluetoa(controller()->memcache->get_database_scalar("api_wallet_paid-{$user->id}", "select sum(amount) from payouts where account_id={$user->id}")); $balance = bitcoinvaluetoa($user->balance); $total_unpaid = bitcoinvaluetoa($balance + $total_unsold); $total_earned = bitcoinvaluetoa($total_unpaid + $total_paid); $coin = getdbo('db_coins', $user->coinid); if (!$coin) { return; } echo "{"; echo "\"currency\": \"{$coin->symbol}\", "; echo "\"unsold\": {$total_unsold}, "; echo "\"balance\": {$balance}, "; echo "\"unpaid\": {$total_unpaid}, "; echo "\"paid\": {$total_paid}, "; echo "\"total\": {$total_earned}, "; echo "\"miners\": "; echo "["; $workers = getdbolist('db_workers', "userid={$user->id} order by password"); foreach ($workers as $i => $worker) { $user_rate1 = yaamp_worker_rate($worker->id, $worker->algo); $user_rate1_bad = yaamp_worker_rate_bad($worker->id, $worker->algo); if ($i) { echo ", "; } echo "{"; echo "\"version\": \"{$worker->version}\", "; echo "\"password\": \"{$worker->password}\", "; echo "\"ID\": \"{$worker->worker}\", "; echo "\"algo\": \"{$worker->algo}\", "; echo "\"difficulty\": {$worker->difficulty}, "; echo "\"subscribe\": {$worker->subscribe}, "; echo "\"accepted\": {$user_rate1}, "; echo "\"rejected\": {$user_rate1_bad}"; echo "}"; } echo "]"; echo "}"; }