Exemplo n.º 1
0
 public function get_database_count_ex($key, $table, $query, $params = array())
 {
     $value = $this->get($key);
     if ($value === false) {
         $value = getdbocount($table, $query, $params);
         $this->set($key, $value);
     }
     return $value;
 }
Exemplo n.º 2
0
function showUser($userid, $what)
{
    $user = getdbo('db_accounts', $userid);
    if (!$user) {
        return;
    }
    $d = datetoa2($user->last_login);
    $balance = bitcoinvaluetoa($user->balance);
    $paid = dboscalar("select sum(amount) from payouts where account_id={$user->id}");
    $paid = bitcoinvaluetoa($paid);
    $t = time() - 24 * 60 * 60;
    $miner_count = getdbocount('db_workers', "userid={$user->id}");
    $share_count = getdbocount('db_shares', "userid={$user->id}");
    $block_count = getdbocount('db_blocks', "userid={$user->id} and time>{$t}");
    $coin = getdbo('db_coins', $user->coinid);
    echo "<tr class='ssrow'>";
    if ($coin) {
        echo "<td><img src='{$coin->image}' width=16> {$coin->symbol}</td>";
    } else {
        echo "<td></td>";
    }
    echo "<td>{$user->id}</td>";
    echo "<td><a href='/site?address={$user->username}'>{$user->username}</a></td>";
    echo "<td>{$what}</td>";
    echo "<td>{$d}</td>";
    echo "<td>{$block_count}</td>";
    echo "<td>{$balance}</td>";
    if (intval($paid) > 0.01) {
        echo "<td><b>{$paid}</b></td>";
    } else {
        echo "<td>{$paid}</td>";
    }
    echo "<td>{$miner_count}</td>";
    echo "<td>{$share_count}</td>";
    if ($user->is_locked) {
        echo "<td>locked</td>";
        echo "<td><a href='/site/unblockuser?wallet={$user->username}'>unblock</a></td>";
    } else {
        echo "<td></td>";
        echo "<td><a href='/site/blockuser?wallet={$user->username}'>block</a></td>";
    }
    echo "</tr>";
}
Exemplo n.º 3
0
echo "</thead><tbody>";
$total_balance = 0;
$total_paid = 0;
$total_unsold = 0;
foreach ($users as $user) {
    $target = yaamp_hashrate_constant();
    $interval = yaamp_hashrate_step();
    $delay = time() - $interval;
    $user_rate = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where valid and time>{$delay} and userid={$user->id}");
    $user_bad = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where not valid and time>{$delay} and userid={$user->id}");
    $percent = $user_rate ? round($user_bad * 100 / $user_rate, 3) : 0;
    $balance = bitcoinvaluetoa($user->balance);
    $paid = dboscalar("select sum(amount) from payouts where account_id={$user->id}");
    $d = datetoa2($user->last_login);
    $miner_count = getdbocount('db_workers', "userid={$user->id}");
    $block_count = getdbocount('db_blocks', "userid={$user->id}");
    $block_diff = $paid ? round(dboscalar("select sum(difficulty) from blocks where userid={$user->id}") / $paid, 3) : '?';
    $paid = bitcoinvaluetoa($paid);
    $user_rate = Itoa2($user_rate);
    $user_bad = Itoa2($user_bad);
    echo "<tr class='ssrow'>";
    echo "<td>{$user->id}</td>";
    echo "<td><a href='/?address={$user->username}'><b>{$user->username}</b></a></td>";
    echo "<td>{$d}</td>";
    echo "<td align=right>{$miner_count}</td>";
    echo "<td align=right>{$user_rate}</td>";
    echo "<td align=right>{$user_bad}</td>";
    if ($percent > 50) {
        echo "<td align=right><b>{$percent}%</b></td>";
    } else {
        echo "<td align=right>{$percent}%</td>";
Exemplo n.º 4
0
<?php

function WriteBoxHeader($title)
{
    echo "<div class='main-left-box'>";
    echo "<div class='main-left-title'>{$title}</div>";
    echo "<div class='main-left-inner'>";
}
$algo = user()->getState('yaamp-algo');
$target = yaamp_hashrate_constant($algo);
$interval = yaamp_hashrate_step();
$delay = time() - $interval;
$total_workers = getdbocount('db_workers', "algo=:algo", array(':algo' => $algo));
$total_extranonce = getdbocount('db_workers', "algo=:algo and subscribe", array(':algo' => $algo));
$total_hashrate = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where valid and time>{$delay} and algo=:algo", array(':algo' => $algo));
$total_invalid = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where not valid and time>{$delay} and algo=:algo", array(':algo' => $algo));
WriteBoxHeader("Miners Version ({$algo})");
//echo "<br><table class='dataGrid2'>";
showTableSorter('maintable2');
echo "<thead>";
echo "<tr>";
echo "<th>Version</th>";
echo "<th align=right>Count</th>";
echo "<th align=right>Extranonce</th>";
echo "<th align=right>Percent</th>";
echo "<th align=right>Hashrate*</th>";
echo "<th align=right>Reject</th>";
echo "</tr>";
echo "</thead><tbody>";
$error_tab = array(20 => 'Invalid nonce size', 21 => 'Invalid job id', 22 => 'Duplicate share', 23 => 'Invalid time rolling', 24 => 'Invalid extranonce2 size', 25 => 'Invalid share', 26 => 'Low difficulty share');
$versions = dbolist("select version, count(*) as c, sum(subscribe) as s from workers where algo=:algo group by version order by c desc", array(':algo' => $algo));
Exemplo n.º 5
0
    echo "<td align=right style='font-size: .8em;'>{$pool_ttf}</td>";
    echo "<td align=right style='font-size: .8em;'>{$pool_hash}</td>";
    echo "<td align=right style='font-size: .8em;'><b>{$btcmhd}</b></td>";
    echo "</tr>";
}
show_orders($allorders, $services);
show_services($services);
echo "</table><br>";
/////////////////////////////////////////////////////////////////////////////////////////////
$target = yaamp_hashrate_constant($algo);
$interval = yaamp_hashrate_step();
$delay = time() - $interval;
$version = 'NiceHash/1.0.0';
$hashrate = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where valid and time>{$delay} and\n\tworkerid in (select id from workers where algo=:algo and version='{$version}')", array(':algo' => $algo));
$invalid = dboscalar("select sum(difficulty) * {$target} / {$interval} / 1000 from shares where not valid and time>{$delay} and\n\tworkerid in (select id from workers where algo=:algo and version='{$version}')", array(':algo' => $algo));
$count = getdbocount('db_workers', "algo=:algo and version='{$version}'", array(':algo' => $algo));
$percent = $total_nicehash && $hashrate ? round($hashrate * 100 / $total_nicehash / 1000000000, 2) . '%' : '';
$hashrate = $hashrate ? Itoa2($hashrate) . 'h/s' : '';
$version = substr($version, 0, 30);
$total_nicehash = round($total_nicehash, 3);
echo "Total Nicehash: <b>{$total_nicehash} Gh/s</b> *** yaamp: ";
echo "<b>{$hashrate}</b> ";
echo "{$count} workers ";
echo "{$percent} ";
echo "</div></div><br>";
//////////////////////////////////////////////////////////////////////////////////////////////////
function show_services(&$services, $btcmhd = 0)
{
    if (!controller()->admin || !$services) {
        return;
    }
Exemplo n.º 6
0
    echo "<div class='main-left-title'>{$title}</div>";
    echo "<div class='main-left-inner'>";
}
$algo = user()->getState('yaamp-algo');
$total_rate = yaamp_pool_rate();
$total_rate_d = $total_rate ? Itoa2($total_rate) . 'h/s' : '';
if ($algo == 'all') {
    $list = getdbolist('db_coins', "enable and visible order by index_avg desc");
} else {
    $list = getdbolist('db_coins', "enable and visible and algo=:algo order by index_avg desc", array(':algo' => $algo));
}
$count = count($list);
if ($algo == 'all') {
    $worker = getdbocount('db_workers');
} else {
    $worker = getdbocount('db_workers', "algo=:algo", array(':algo' => $algo));
}
$services = getdbolist('db_services', "algo=:algo order by price desc", array(':algo' => $algo));
////////////////////////////////////////////////////////////////////////////////////
WriteBoxHeader("Mining {$count} coins at {$total_rate_d} * with {$worker} miners ({$algo})");
//echo "<table  class='dataGrid2'>";
showTableSorter('maintable3');
echo "<thead>";
echo "<tr>";
echo "<th></th>";
echo "<th>Name</th>";
echo "<th align=right>Amount</th>";
echo "<th align=right>Diff</th>";
echo "<th align=right>Block</th>";
echo "<th align=right>TTF*</th>";
echo "<th align=right>Hash**</th>";
Exemplo n.º 7
0
    $algo_norm = yaamp_get_algo_norm($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));
    $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];
    $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}\")'>";
Exemplo n.º 8
0
echo "<tr>";
echo "<th align=left>Summary</th>";
echo "<th align=right>Miners</th>";
echo "<th align=right>Shares</th>";
echo "<th align=right width=80>Hashrate*</th>";
echo "<th align=right width=60>Reject*</th>";
echo "</tr>";
echo "</thead>";
foreach (yaamp_get_algos() as $algo) {
    //	debuglog($algo);
    $user_rate1 = yaamp_user_rate($user->id, $algo);
    $user_rate1_bad = yaamp_user_rate_bad($user->id, $algo);
    $percent_bad = $user_rate1 + $user_rate1_bad ? $user_rate1_bad * 100 / ($user_rate1 + $user_rate1_bad) : 0;
    $percent_bad = $percent_bad ? round($percent_bad, 1) . '%' : '';
    $user_rate1 = $user_rate1 ? Itoa2($user_rate1) . 'h/s' : '-';
    $minercount = getdbocount('db_workers', "userid={$user->id} and algo=:algo", array(':algo' => $algo));
    $user_shares = controller()->memcache->get_database_scalar("wallet_user_shares-{$user->id}-{$algo}", "select sum(difficulty) from shares where valid and algo=:algo and userid={$user->id}", array(':algo' => $algo));
    if (!$user_shares && !$minercount) {
        continue;
    }
    $total_shares = controller()->memcache->get_database_scalar("wallet_total_shares-{$algo}", "select sum(difficulty) from shares where valid and algo=:algo", array(':algo' => $algo));
    if (!$total_shares) {
        continue;
    }
    $percent_shares = round($user_shares * 100 / $total_shares, 4);
    echo "<tr class='ssrow'>";
    echo "<td><b>{$algo}</b></td>";
    echo "<td align=right>{$minercount}</td>";
    echo "<td align=right width=100>{$percent_shares}%</td>";
    echo "<td align=right width=100><b>{$user_rate1}</b></td>";
    echo "<td align=right>{$percent_bad}</td>";