本文整理汇总了PHP中getdbo函数的典型用法代码示例。如果您正苦于以下问题:PHP getdbo函数的具体用法?PHP getdbo怎么用?PHP getdbo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getdbo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BackendClearEarnings
function BackendClearEarnings()
{
// debuglog(__FUNCTION__);
$delay = time() - 150 * 60;
$total_cleared = 0;
$list = getdbolist('db_earnings', "status=1 and mature_time<{$delay}");
foreach ($list as $earning) {
$user = getdbo('db_accounts', $earning->userid);
if (!$user) {
$earning->delete();
continue;
}
$coin = getdbo('db_coins', $earning->coinid);
if (!$coin) {
$earning->delete();
continue;
}
$earning->status = 2;
// cleared
$earning->price = $coin->price;
$earning->save();
// $refcoin = getdbo('db_coins', $user->coinid);
// if($refcoin && $refcoin->price<=0) continue;
// $value = $earning->amount * $coin->price / ($refcoin? $refcoin->price: 1);
$value = yaamp_convert_amount_user($coin, $earning->amount, $user);
$user->balance += $value;
$user->save();
if ($user->coinid == 6) {
$total_cleared += $value;
}
}
if ($total_cleared > 0) {
debuglog("total cleared from mining {$total_cleared} BTC");
}
}
示例2: actionIndex
public function actionIndex()
{
if (isset($_COOKIE['mainbtc'])) {
return;
}
if (!LimitRequest('explorer')) {
return;
}
$id = getiparam('id');
$coin = getdbo('db_coins', $id);
$height = getparam('height');
if ($coin && intval($height) > 0) {
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$hash = $remote->getblockhash(intval($height));
} else {
$hash = getparam('hash');
}
$txid = getparam('txid');
if ($coin && !empty($txid) && ctype_alnum($txid)) {
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$tx = $remote->getrawtransaction($txid, 1);
$hash = $tx['blockhash'];
}
if ($coin && !empty($hash) && ctype_alnum($hash)) {
$this->render('block', array('coin' => $coin, 'hash' => substr($hash, 0, 64)));
} else {
if ($coin) {
$this->render('coin', array('coin' => $coin));
} else {
$this->render('index');
}
}
}
示例3: actionUpdate
public function actionUpdate()
{
if (!$this->admin) {
return;
}
$coin = getdbo('db_coins', getiparam('id'));
if (isset($_POST['db_coins'])) {
$coin->attributes = $_POST['db_coins'];
if ($coin->save()) {
$this->redirect(array('index'));
}
}
$this->render('_form', array('coin' => $coin, 'update' => true));
}
示例4: actionStop
public function actionStop()
{
if (!$this->admin) {
return;
}
$id = getiparam('id');
$nicehash = getdbo('db_nicehash', $id);
if (!$nicehash) {
return;
}
$nicehash->active = false;
$nicehash->save();
$this->goback();
}
示例5: showUser
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>";
}
示例6: BackendProcessList
function BackendProcessList()
{
$list = dbolist("show processlist");
foreach ($list as $item) {
$conn = getdbo('db_connections', $item['Id']);
if (!$conn) {
$conn = new db_connections();
$conn->id = $item['Id'];
$conn->user = $item['User'];
$conn->host = $item['Host'];
$conn->db = $item['db'];
$conn->created = time();
}
$conn->idle = $item['Time'];
$conn->last = time();
$conn->save();
}
$delay = time() - 5 * 60;
dborun("delete from connections where last<{$delay}");
}
示例7: actionSellto
public function actionSellto()
{
if (!$this->admin) {
return;
}
$market = getdbo('db_markets', getiparam('id'));
$coin = getdbo('db_coins', $market->coinid);
$amount = getparam('amount');
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$info = $remote->getinfo();
if (!$info || !$info['balance']) {
return false;
}
$deposit_info = $remote->validateaddress($market->deposit_address);
if (!$deposit_info || !isset($deposit_info['isvalid']) || !$deposit_info['isvalid']) {
user()->setFlash('error', "invalid address {$coin->name}, {$market->deposit_address}");
$this->redirect(array('site/coin', 'id' => $coin->id));
}
$amount = min($amount, $info['balance'] - $info['paytxfee']);
// $amount = max($amount, $info['balance'] - $info['paytxfee']);
$amount = round($amount, 8);
debuglog("selling ({$market->deposit_address}, {$amount})");
$tx = $remote->sendtoaddress($market->deposit_address, $amount);
if (!$tx) {
user()->setFlash('error', $remote->error);
$this->redirect(array('site/coin', 'id' => $coin->id));
}
$exchange = new db_exchange();
$exchange->market = $market->name;
$exchange->coinid = $coin->id;
$exchange->send_time = time();
$exchange->quantity = $amount;
$exchange->price_estimate = $coin->price;
$exchange->status = 'waiting';
$exchange->tx = $tx;
$exchange->save();
$this->redirect(array('site/coin', 'id' => $coin->id));
}
示例8: delete_block
function delete_block()
{
global $COLLATE;
global $block_id;
$dbo = getdbo();
$block_ids = array();
$block_ids[] = $block_id;
$sql = "SELECT name FROM blocks WHERE id='{$block_id}'";
$result = $dbo->query($sql);
if ($result->rowCount() != '1') {
header("HTTP/1.1 400 Bad Request");
echo $COLLATE['languages']['selected']['selectblock'];
exit;
}
$name = $result->fetchColumn();
collate_log("4", "Block {$name} has been deleted!");
if (find_child_blocks($block_id) !== false) {
# this is a recursive function
$block_ids = array_merge($block_ids, find_child_blocks($block_id));
}
foreach ($block_ids as $block_id) {
// First delete all static IPs
$sql = "DELETE FROM statics WHERE subnet_id IN (SELECT id FROM subnets WHERE block_id='{$block_id}')";
$dbo->query($sql);
// Next, remove the DHCP ACLs
$sql = "DELETE FROM acl WHERE subnet_id IN (SELECT id FROM subnets WHERE block_id='{$block_id}')";
$dbo->query($sql);
// Next, remove the subnets
$sql = "DELETE FROM subnets WHERE block_id='{$block_id}'";
$dbo->query($sql);
// Lastly, delete the IP block
$sql = "DELETE FROM blocks WHERE id='{$block_id}'";
$dbo->query($sql);
}
# we don't output to the user on success. The row fades on the page to provide feedback.
}
示例9: BackendStatsUpdate
function BackendStatsUpdate()
{
// debuglog(__FUNCTION__);
// $t1xx = microtime(true);
$t = time() - 2 * 60;
$errors = '';
$list = getdbolist('db_stratums', "time<{$t}");
foreach ($list as $stratum) {
debuglog("stratum {$stratum->algo} terminated");
$errors .= "{$stratum->algo}, ";
}
if (!empty($errors)) {
send_email_alert('stratums', "stratums restarted {$errors}", "stratums were restarted: {$errors}");
}
dborun("delete from stratums where time<{$t}");
dborun("delete from workers where pid not in (select pid from stratums)");
//////////////////////////////////////////////////////////////////////////////////////////////////////
// long term stats
$t = floor(time() / 60 / 60) * 60 * 60;
foreach (yaamp_get_algos() as $algo) {
$pool_rate = yaamp_pool_rate($algo);
$stats = getdbosql('db_hashstats', "time={$t} and algo=:algo", array(':algo' => $algo));
if (!$stats) {
$stats = new db_hashstats();
$stats->time = $t;
$stats->hashrate = $pool_rate;
$stats->algo = $algo;
} else {
$percent = 1;
$stats->hashrate = round(($stats->hashrate * (100 - $percent) + $pool_rate * $percent) / 100);
}
$stats->earnings = dboscalar("select sum(amount*price) from blocks where time>{$t} and category!='orphan' and algo=:algo", array(':algo' => $algo));
$stats->save();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// short term stats
$step = 15;
$t = floor(time() / $step / 60) * $step * 60;
foreach (yaamp_get_algos() as $algo) {
$stats = getdbosql('db_hashrate', "time={$t} and algo=:algo", array(':algo' => $algo));
if (!$stats) {
$stats = new db_hashrate();
$stats->time = $t;
$stats->hashrate = dboscalar("select hashrate from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
$stats->hashrate_bad = 0;
//dboscalar("select hashrate_bad from hashrate where algo=:algo order by time desc limit 1", array(':algo'=>$algo));
$stats->price = dboscalar("select price from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
$stats->rent = dboscalar("select rent from hashrate where algo=:algo order by time desc limit 1", array(':algo' => $algo));
$stats->algo = $algo;
}
$pool_rate = yaamp_pool_rate($algo);
$stats->hashrate = $pool_rate;
//round(($stats->hashrate*(100-$percent) + $pool_rate*$percent) / 100);
$pool_rate_bad = yaamp_pool_rate_bad($algo);
$stats->hashrate_bad = $pool_rate_bad;
//round(($stats->hashrate_bad*(100-$percent) + $pool_rate_bad*$percent) / 100);
if ($stats->hashrate < 1000) {
$stats->hashrate = 0;
}
$t1 = time() - 5 * 60;
$total_rentable = dboscalar("select sum(difficulty) from shares where valid and extranonce1 and algo=:algo and time>{$t1}", array(':algo' => $algo));
$total_diff = dboscalar("select sum(difficulty) from shares where valid and algo=:algo and time>{$t1}", array(':algo' => $algo));
$total_rented = 0;
if (!$total_diff) {
$t1 = time() - 15 * 60;
$total_diff = dboscalar("select sum(difficulty) from shares where valid and algo=:algo and time>{$t1}", array(':algo' => $algo));
}
if ($total_diff > 0) {
$price = 0;
$rent = 0;
$list = dbolist("select coinid, sum(difficulty) as d from shares where valid and algo=:algo and time>{$t1} group by coinid", array(':algo' => $algo));
foreach ($list as $item) {
if ($item['coinid'] == 0) {
if (!$total_rentable) {
continue;
}
$total_rented = $item['d'];
$price += $stats->rent * $item['d'] / $total_diff;
$rent += $stats->rent * $item['d'] / $total_rentable;
} else {
$coin = getdbo('db_coins', $item['coinid']);
if (!$coin) {
continue;
}
$btcghd = yaamp_profitability($coin);
$price += $btcghd * $item['d'] / $total_diff;
$rent += $btcghd * $item['d'] / $total_diff;
}
}
$percent = 33;
$rent = max($price, ($stats->rent * (100 - $percent) + $rent * $percent) / 100);
$target = yaamp_hashrate_constant($algo);
$interval = yaamp_hashrate_step();
$aa = $total_rentable * $target / $interval / 1000;
$bb = dboscalar("select sum(speed) from jobs where active and ready and price>{$rent} and algo=:algo", array(':algo' => $algo));
if ($total_rented * 1.3 < $total_rentable || $bb > $aa) {
$rent += $price * YAAMP_FEES_RENTING / 100;
} else {
$rent -= $price * YAAMP_FEES_RENTING / 100;
}
//.........这里部分代码省略.........
示例10: updateJubiMarkets
function updateJubiMarkets()
{
$btc = jubi_api_query('ticker', "?coin=btc");
if (!$btc) {
continue;
}
$list = getdbolist('db_markets', "name='jubi'");
foreach ($list as $market) {
$coin = getdbo('db_coins', $market->coinid);
if (!$coin) {
continue;
}
$lowsymbol = strtolower($coin->symbol);
$ticker = jubi_api_query('ticker', "?coin={$lowsymbol}");
if (!$ticker) {
continue;
}
$ticker->buy /= $btc->sell;
$ticker->sell /= $btc->buy;
$price2 = ($ticker->buy + $ticker->sell) / 2;
$market->price2 = AverageIncrement($market->price2, $price2);
$market->price = AverageIncrement($market->price, $ticker->buy * 0.95);
$market->save();
}
}
示例11: time
echo "<th align=right>Last 7 Days</th>";
echo "<th align=right>Last 30 Days</th>";
echo "</tr>";
echo "</thead>";
$t1 = time() - 60 * 60;
$t2 = time() - 24 * 60 * 60;
$t3 = time() - 7 * 24 * 60 * 60;
$t4 = time() - 30 * 24 * 60 * 60;
$total1 = 0;
$total2 = 0;
$total3 = 0;
$total4 = 0;
$algo = user()->getState('yaamp-algo');
$list = dbolist("SELECT coin_id FROM blocks where category!='orphan' and time>{$t4} and coin_id in (select id from coins where algo=:algo) group by coin_id order by id desc", array(':algo' => $algo));
foreach ($list as $item) {
$coin = getdbo('db_coins', $item['coin_id']);
if ($coin->symbol == 'BTC') {
continue;
}
$res1 = controller()->memcache->get_database_row("history_item1-{$coin->id}-{$algo}", "select count(*) as a, sum(amount*price) as b from blocks where category!='orphan' and time>{$t1} and coin_id={$coin->id} and algo=:algo", array(':algo' => $algo));
$res2 = controller()->memcache->get_database_row("history_item2-{$coin->id}-{$algo}", "select count(*) as a, sum(amount*price) as b from blocks where category!='orphan' and time>{$t2} and coin_id={$coin->id} and algo=:algo", array(':algo' => $algo));
$res3 = controller()->memcache->get_database_row("history_item3-{$coin->id}-{$algo}", "select count(*) as a, sum(amount*price) as b from blocks where category!='orphan' and time>{$t3} and coin_id={$coin->id} and algo=:algo", array(':algo' => $algo));
$res4 = controller()->memcache->get_database_row("history_item4-{$coin->id}-{$algo}", "select count(*) as a, sum(amount*price) as b from blocks where category!='orphan' and time>{$t4} and coin_id={$coin->id} and algo=:algo", array(':algo' => $algo));
$total1 += $res1['b'];
$total2 += $res2['b'];
$total3 += $res3['b'];
$total4 += $res4['b'];
$name = substr($coin->name, 0, 12);
echo "<tr class='ssrow'>";
echo "<td width=18><img width=16 src='{$coin->image}'></td>";
echo "<td><b><a href='/site/block?id={$coin->id}'>{$name}</a></b></td>";
示例12: yaamp_job_rate_bad
function yaamp_job_rate_bad($jobid)
{
$job = getdbo('db_jobs', $jobid);
if (!$job) {
return 0;
}
$target = yaamp_hashrate_constant($job->algo);
$interval = yaamp_hashrate_step();
$delay = time() - $interval;
$rate = controller()->memcache->get_database_scalar("yaamp_job_rate_bad-{$jobid}", "select sum(difficulty) * {$target} / {$interval} / 1000 from jobsubmits where not valid and time>{$delay} and jobid={$jobid}");
return $rate;
}
示例13: doBittrexTrading
function doBittrexTrading($quick = false)
{
$flushall = rand(0, 4) == 0;
if ($quick) {
$flushall = false;
}
// debuglog("-------------- doBittrexTrading() flushall $flushall");
$orders = bittrex_api_query('market/getopenorders');
if (!$orders || !$orders->success) {
return;
}
foreach ($orders->result as $order) {
$symbol = substr($order->Exchange, 4);
$pair = $order->Exchange;
$coin = getdbosql('db_coins', "symbol=:symbol", array(':symbol' => $symbol));
if (!$coin) {
continue;
}
if ($coin->dontsell) {
continue;
}
$ticker = bittrex_api_query('public/getticker', "&market={$order->Exchange}");
if (!$ticker || !$ticker->success || !$ticker->result) {
continue;
}
$ask = bitcoinvaluetoa($ticker->result->Ask);
$sellprice = bitcoinvaluetoa($order->Limit);
// flush orders not on the ask
if ($ask + 5.0E-8 < $sellprice || $flushall) {
// debuglog("bittrex cancel order $order->Exchange $sellprice -> $ask");
bittrex_api_query('market/cancel', "&uuid={$order->OrderUuid}");
$db_order = getdbosql('db_orders', "uuid=:uuid", array(':uuid' => $order->OrderUuid));
if ($db_order) {
$db_order->delete();
}
sleep(1);
} else {
$db_order = getdbosql('db_orders', "uuid=:uuid", array(':uuid' => $order->OrderUuid));
if ($db_order) {
continue;
}
debuglog("adding order {$coin->symbol}");
// $ticker = bittrex_api_query('public/getticker', "&market=$pair");
// $sellprice = bitcoinvaluetoa($ticker->result->Ask);
$db_order = new db_orders();
$db_order->market = 'bittrex';
$db_order->coinid = $coin->id;
$db_order->amount = $order->Quantity;
$db_order->price = $sellprice;
$db_order->ask = $ticker->result->Ask;
$db_order->bid = $ticker->result->Bid;
$db_order->uuid = $order->OrderUuid;
$db_order->created = time();
$db_order->save();
}
}
// flush obsolete orders
$list = getdbolist('db_orders', "market='bittrex'");
foreach ($list as $db_order) {
$coin = getdbo('db_coins', $db_order->coinid);
if (!$coin) {
continue;
}
$found = false;
foreach ($orders->result as $order) {
if ($order->OrderUuid == $db_order->uuid) {
$found = true;
break;
}
}
if (!$found) {
debuglog("bittrex deleting order {$coin->name} {$db_order->amount}");
$db_order->delete();
}
}
// if($flushall)
// {
// debuglog("bittrex flushall");
// return;
// }
sleep(2);
// add orders
$balances = bittrex_api_query('account/getbalances');
if (!$balances || !isset($balances->result) || !$balances->success) {
return;
}
$savebalance = getdbosql('db_balances', "name='bittrex'");
$savebalance->balance = 0;
foreach ($balances->result as $balance) {
if ($balance->Currency == 'BTC') {
$savebalance->balance = $balance->Available;
continue;
}
$amount = floatval($balance->Available);
if (!$amount) {
continue;
}
// debuglog($balance->Currency);
$coin = getdbosql('db_coins', "symbol=:symbol", array(':symbol' => $balance->Currency));
if (!$coin || $coin->dontsell) {
//.........这里部分代码省略.........
示例14: foreach
<div class="main-left-title">Search Wallet:</div>
<div class="main-left-inner">
<form action="/" method="get" style="padding: 10px;">
<input type="text" name="address" class="main-text-input" placeholder="Wallet Address">
<input type="submit" value="Submit" class="main-submit-button" ><br><br>
END;
echo "<table class='dataGrid2'>";
foreach ($recents as $address) {
if (empty($address)) {
continue;
}
$user = getuserparam($address);
if (!$user) {
continue;
}
$coin = getdbo('db_coins', $user->coinid);
if ($user->username == $username) {
echo "<tr style='background-color: #e0d3e8;'><td width=24>";
} else {
echo "<tr class='ssrow'><td width=24>";
}
if ($coin) {
echo "<img width=16 src='{$coin->image}'>";
} else {
echo "<img width=16 src='/images/base/delete.png'>";
}
echo "</td><td><a href='/?address={$address}' style='font-family: monospace; font-size: 1.1em;'>{$address}</a></td>";
$balance = bitcoinvaluetoa($user->balance);
if ($coin) {
$balance = $balance > 0 ? "{$balance} {$coin->symbol}" : '';
} else {
示例15: delete_acl
function delete_acl()
{
global $COLLATE;
$dbo = getdbo();
$acl_id = isset($_GET['acl_id']) && is_numeric($_GET['acl_id']) ? $_GET['acl_id'] : '';
if (empty($acl_id)) {
header("HTTP/1.1 400 Bad Request");
echo $COLLATE['languages']['selected']['invalidrequest'];
exit;
}
$sql = "SELECT name FROM subnets WHERE id=(SELECT subnet_id FROM acl WHERE id='{$acl_id}')";
$result = $dbo->query($sql);
if ($result->rowCount() != '1') {
header("HTTP/1.1 400 Bad Request");
echo $COLLATE['languages']['selected']['invalidrequest'];
exit;
}
$subnet_name = $result->fetchColumn();
collate_log('3', "ACL Statement #{$acl_id} deleted in {$subnet_name} subnet");
$sql = "DELETE FROM acl WHERE id='{$acl_id}'";
$dbo->query($sql);
exit;
}