explorer: dynamic generation of all explorer links

will use a more friendly format if the coin is visible

bitcoins txs will be linked to an external site, and if the site explorer
is disabled, hyperlinks should be disabled (text only)

+ some other changes related to the explorer...
This commit is contained in:
Tanguy Pruvot 2016-05-03 21:19:13 +02:00
parent b97682e225
commit f3c65e270c
16 changed files with 264 additions and 176 deletions

View file

@ -16,11 +16,16 @@ return array(
'components'=>array(
// url() rules...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'appendParams'=>true,
'caseSensitive'=>false,
'rules'=>array(
// prevent /explorer/id/<num>/p1/v1/... -> /explorer/<num>?params...
'/explorer/<id:\d+>' => array('/explorer', 'urlFormat'=>'get'),
),
),
'assetManager'=>array(

View file

@ -507,12 +507,12 @@ end;
return $links;
}
// shared by wallet "tabs"
// shared by wallet "tabs", to move in another php file...
function getAdminWalletLinks($coin, $info=NULL, $src='wallet')
{
$html = CHtml::link("<b>COIN PROPERTIES</b>", '/site/update?id='.$coin->id);
if($info) {
$html .= ' || '.CHtml::link("<b>EXPLORER</b>", '/explorer?id='.$coin->id);
$html .= ' || '.$coin->createExplorerLink("<b>EXPLORER</b>");
$html .= ' || '.CHtml::link("<b>PEERS</b>", '/site/peers?id='.$coin->id);
$html .= ' || '.CHtml::link("<b>CONSOLE</b>", '/site/console?id='.$coin->id);
if ($src != 'wallet')

View file

@ -61,6 +61,28 @@ class db_coins extends CActiveRecord
return $this->symbol;
}
/**
* Link for txs
* @param string $label link content
* @param array $params 'height'=>123 or 'hash'=>'xxx' or 'txid'=>'xxx'
* @param array $htmlOptions target/title ...
*/
public function createExplorerLink($label, $params=array(), $htmlOptions=array(), $force=false)
{
if($this->id == 6 && isset($params['txid'])) {
// BTC txid
$url = 'https://blockchain.info/tx/'.$params['txid'];
$htmlOpts = array_merge(array('target'=>'_blank'), $htmlOptions);
return CHtml::link($label, $url, $htmlOpts);
}
else if (YIIMP_PUBLIC_EXPLORER || $force || user()->getState('yaamp_admin')) {
$urlParams = array_merge(array('id'=>$this->id), $params);
Yii::import('application.modules.explorer.ExplorerController');
$url = ExplorerController::createUrl('/explorer', $urlParams);
return CHtml::link($label, trim($url,'?'), $htmlOptions);
}
return $label;
}
}

View file

@ -5,16 +5,28 @@ require_once("util.php");
class ExplorerController extends CommonController
{
public $defaultAction='index';
public $admin = false;
/////////////////////////////////////////////////
public function run($actionID)
{
$this->admin = user()->getState('yaamp_admin');
// Forward the url /explorer/BTC to the BTC block explorer
if (!empty($actionID) && !isset($_REQUEST['id'])) {
if (strlen($actionID) <= 5) {
$coin = getdbosql('db_coins', "enable AND visible AND symbol=:symbol", array(
if (!empty($actionID)) {
if (is_numeric($actionID) && isset($_REQUEST['id'])) {
$this->forward('id');
}
elseif (strlen($actionID) <= 6 && !isset($_REQUEST['id'])) {
$coin = getdbosql('db_coins', "symbol=:symbol", array(
':symbol'=>strtoupper($actionID)
));
if ($coin) {
if ($coin && ($coin->visible || $this->admin)) {
if (!empty($_POST)) {
$_GET['SYM'] = $coin->symbol;
$this->forward('search');
}
$_REQUEST['id'] = $coin->id;
$this->forward('id');
}
@ -25,6 +37,22 @@ class ExplorerController extends CommonController
/////////////////////////////////////////////////
// Hide coin id from explorer links... created by createUrl()
public function createUrl($route,$params=array(),$ampersand='&')
{
if ($route == '/explorer' && isset($params['id'])) {
$coin = getdbo('db_coins', intval($params['id']));
if ($coin && $coin->visible) {
unset($params['id']);
$route = '/explorer/'.$coin->symbol.'?'.http_build_query($params,'',$ampersand);
$params = array();
}
}
return parent::createUrl($route, $params, $ampersand);
}
/////////////////////////////////////////////////
public function actionIndex()
{
if(isset($_COOKIE['mainbtc'])) return;
@ -33,7 +61,7 @@ class ExplorerController extends CommonController
$id = getiparam('id');
$coin = getdbo('db_coins', $id);
$height = getparam('height');
$height = getiparam('height');
if($coin && intval($height)>0)
{
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
@ -44,15 +72,16 @@ class ExplorerController extends CommonController
$hash = getparam('hash');
$txid = getparam('txid');
if($coin && !empty($txid) && ctype_alnum($txid))
if($coin && !empty($txid) && ctype_xdigit($txid))
{
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$tx = $remote->getrawtransaction($txid, 1);
if (!$tx) $tx = $remote->gettransaction($txid);
$hash = arraySafeVal($tx,'blockhash');
}
if($coin && !empty($hash) && ctype_alnum($hash))
if($coin && !empty($hash) && ctype_xdigit($hash))
$this->render('block', array('coin'=>$coin, 'hash'=>substr($hash, 0, 64)));
else if($coin)
@ -62,11 +91,32 @@ class ExplorerController extends CommonController
$this->render('index');
}
// alias...
public function actionId()
{
return $this->actionIndex();
}
// redirect POST request with url cleanup...
public function actionSearch()
{
$height = getiparam('height');
$txid = arraySafeVal($_REQUEST,'txid');
$hash = arraySafeVal($_REQUEST,'hash');
if (isset($_GET['SYM'])) {
// only for visible coins
$url = "/explorer/".$_GET['SYM']."?";
} else if (isset($_GET['id'])) {
// only for hidden coins
$url = "/explorer/".$_GET['id']."?";
}
if (!empty($height)) $url .= "&height=$height";
if (!empty($txid)) $url .= "&txid=$txid";
if (!empty($hash)) $url .= "&hash=$hash";
return $this->redirect(str_replace('?&', '?', $url));
}
/**
* Difficulty Graph
*/

View file

@ -5,8 +5,9 @@ if (!$coin) return;
$this->pageTitle = $coin->name." block explorer";
$txid = getparam('txid', 'tssssssss');
if (empty($txid)) $txid = 'tssssssss'; // rmmm
echo <<<ENDJS
echo <<<END
<script type="text/javascript">
function toggleRaw(el) {
$(el).parents('tr').next('tr.raw').toggle();
@ -18,7 +19,15 @@ $(function() {
$('span.txid:contains("{$txid}")').css('color','darkred');
});
</script>
ENDJS;
<style type="text/css">
span.monospace { font-family: monospace; }
span.txid { cursor: pointer; }
tr.raw td { overflow-x: scroll; max-width: 1880px; }
pre.json { font-size: 10px; }
.main-text-input { margin-top: 4px; margin-bottom: 4px; }
</style>
END;
function simplifyscript($script)
{
@ -45,8 +54,8 @@ $nonce = dechex($block['nonce']);
echo '<table class="dataGrid1">';
echo '<tr><td width=100></td><td></td></tr>';
echo '<tr><td>Coin:</td><td><b><a href="/explorer?id='.$coin->id.'">'.$coin->name.'</a></b></td></tr>';
echo '<tr><td>Blockhash:</td><td><span class="txid" style="font-family: monospace;">'.$hash.'</span></td></tr>';
echo '<tr><td>Coin:</td><td><b>'.$coin->createExplorerLink($coin->name).'</b></td></tr>';
echo '<tr><td>Blockhash:</td><td><span class="txid monospace">'.$hash.'</span></td></tr>';
echo '</tr><tr class="raw" style="display:none;"><td colspan="2"><pre class="json">';
echo json_encode($block, 128);
@ -56,23 +65,25 @@ echo '<tr><td>Confirmations:</td><td>'.$confirms.'</td></tr>';
echo '<tr><td>Height:</td><td>'.$block['height'].'</td></tr>';
echo '<tr><td>Time:</td><td>'.$d.'</td></tr>';
echo '<tr><td>Difficulty:</td><td>'.$block['difficulty'].'</td></tr>';
echo '<tr><td>Bits:</td><td><span style="font-family: monospace;">'.$block['bits'].'</span></td></tr>';
echo '<tr><td>Nonce:</td><td><span style="font-family: monospace;">'.$nonce.'</span></td></tr>';
echo '<tr><td>Version:</td><td><span style="font-family: monospace;">'.$version.'</span></td></tr>';
echo '<tr><td>Bits:</td><td><span class="monospace">'.$block['bits'].'</span></td></tr>';
echo '<tr><td>Nonce:</td><td><span class="monospace">'.$nonce.'</span></td></tr>';
echo '<tr><td>Version:</td><td><span class="monospace">'.$version.'</span></td></tr>';
echo '<tr><td>Size:</td><td>'.$block['size'].' bytes</td></tr>';
if(isset($block['flags']))
echo '<tr><td>Flags:</td><td><span style="font-family: monospace;">'.$block['flags'].'</span></td></tr>';
echo '<tr><td>Flags:</td><td><span class="monospace">'.$block['flags'].'</span></td></tr>';
if(isset($block['previousblockhash']))
echo '<tr><td>Previous Hash:</td><td><span style="font-family: monospace;">
<a href="/explorer?id='.$coin->id.'&hash='.$block['previousblockhash'].'">'.$block['previousblockhash'].'</a></span></td></tr>';
echo '<tr><td>Previous Hash:</td><td><span class="monospace">'.
$coin->createExplorerLink($block['previousblockhash'], array('hash'=>$block['previousblockhash'])).
'</span></td></tr>';
if(isset($block['nextblockhash']))
echo '<tr><td>Next Hash:</td><td><span style="font-family: monospace;">
<a href="/explorer?id='.$coin->id.'&hash='.$block['nextblockhash'].'">'.$block['nextblockhash'].'</a></span></td></tr>';
echo '<tr><td>Next Hash:</td><td><span class="monospace">'.
$coin->createExplorerLink($block['nextblockhash'], array('hash'=>$block['nextblockhash'])).
'</span></td></tr>';
echo '<tr><td>Merkle Root:</td><td><span style="font-family: monospace;">'.$block['merkleroot'].'</span></td></tr>';
echo '<tr><td>Merkle Root:</td><td><span class="monospace">'.$block['merkleroot'].'</span></td></tr>';
echo '<tr><td>Transactions:</td><td>'.$txcount.'</td></tr>';
@ -81,11 +92,6 @@ echo "</table><br>";
////////////////////////////////////////////////////////////////////////////////
echo <<<end
<style type="text/css">
span.txid { font-family: monospace; cursor: pointer; }
tr.raw td { overflow-x: scroll; max-width: 1880px; }
pre.json { font-size: 10px; }
</style>
<table class="dataGrid">
<thead>
@ -107,9 +113,8 @@ foreach($block['tx'] as $txhash)
foreach($tx['vout'] as $vout)
$valuetx += $vout['value'];
echo "<tr class='ssrow'>";
echo '<td><span class="txid">'.$tx['txid'].'</span></td>';
echo '<tr class="ssrow">';
echo '<td><span class="txid monospace">'.$tx['txid'].'</span></td>';
echo "<td>$valuetx</td>";
echo "<td>";
@ -126,7 +131,7 @@ foreach($block['tx'] as $txhash)
if ($value == 0) continue;
if(isset($vout['scriptPubKey']['addresses'][0]))
echo '<span style="font-family: monospace;">'.$vout['scriptPubKey']['addresses'][0]."</span> ($value)";
echo '<span class="monospace">'.$vout['scriptPubKey']['addresses'][0]."</span> ($value)";
else
echo "($value)";
@ -158,7 +163,7 @@ if ($coin->rpcencoding == 'DCR' && isset($block['stx'])) {
$valuetx += $vout['value'];
echo '<tr class="ssrow">';
echo '<td><span class="txid">'.$stx['txid'].'</span></td>';
echo '<td><span class="txid monospace">'.$stx['txid'].'</span></td>';
echo "<td>$valuetx</td>";
echo "<td>";
@ -166,7 +171,7 @@ if ($coin->rpcencoding == 'DCR' && isset($block['stx'])) {
echo "Ticket";
else foreach($stx['vin'] as $vin) {
if (arraySafeVal($vin,'blockheight') > 0) {
echo '<a href="/explorer?id='.$coin->id.'&height='.$vin['blockheight'].'">'.$vin['blockheight'].'</a>';
echo $coin->createExplorerLink($vin['blockheight'], array('height'=>$vin['blockheight']));
echo '<br/>';
}
}
@ -179,7 +184,7 @@ if ($coin->rpcencoding == 'DCR' && isset($block['stx'])) {
if ($value == 0) continue;
if(isset($vout['scriptPubKey']['addresses'][0]))
echo '<span style="font-family: monospace;">'.$vout['scriptPubKey']['addresses'][0]."</span> ($value)";
echo '<span class="monospace">'.$vout['scriptPubKey']['addresses'][0]."</span> ($value)";
else
echo "($value)";
@ -198,12 +203,13 @@ if ($coin->rpcencoding == 'DCR' && isset($block['stx'])) {
echo '</table>';
$actionUrl = $coin->visible ? '/explorer/'.$coin->symbol : '/explorer/search?id='.$coin->id;
echo <<<end
<form action="/explorer" method="get" style="padding: 10px;">
<input type="hidden" name="id" value="$coin->id">
<form action="{$actionUrl}" method="POST" style="padding: 8px; padding-left: 0px;">
<input type="text" name="height" class="main-text-input" placeholder="block height" style="width: 80px;">
<input type="text" name="txid" class="main-text-input" placeholder="tx hash" style="width: 450px;">
<input type="submit" value="Search" class="main-submit-button" >
<input type="text" name="txid" class="main-text-input" placeholder="tx hash" style="width: 450px; margin: 4px;">
<input type="submit" value="Search" class="main-submit-button">
</form>
end;

View file

@ -1,42 +1,50 @@
<?php
if (!$coin) $this->goback();
JavascriptFile("/extensions/jqplot/jquery.jqplot.js");
JavascriptFile("/extensions/jqplot/plugins/jqplot.dateAxisRenderer.js");
JavascriptFile("/extensions/jqplot/plugins/jqplot.highlighter.js");
$this->pageTitle = $coin->name." bloc explorer";
$start = (int) getparam('start');
$start = (int) getiparam('start');
if ($coin) echo <<<ENDJS
<script>
$(function() {
$('#favicon').remove();
$('head').append('<link href="{$coin->image}" id="favicon" rel="shortcut icon">');
});
</script>
ENDJS;
echo <<<END
<script type="text/javascript">
$(function() {
$('#favicon').remove();
$('head').append('<link href="{$coin->image}" id="favicon" rel="shortcut icon">');
});
</script>
<style type="text/css">
table.dataGrid2 { margin-top: 0; }
span.monospace { font-family: monospace; }
.main-text-input { }
.page .footer { width: auto; }
</style>
END;
// version is used for multi algo coins
// but each coin use different values...
$multiAlgos = versionToAlgo($coin, 0) !== false;
echo "<br>";
echo "<div class='main-left-box'>";
echo "<div class='main-left-title'>$coin->name Explorer</div>";
echo "<div class='main-left-inner'>";
echo '<br/>';
echo '<div class="main-left-box">';
echo '<div class="main-left-title">'.$coin->name.' Explorer</div>';
echo '<div class="main-left-inner" style="padding-left: 8px; padding-right: 8px;">';
echo "<table class='dataGrid2'>";
echo '<table class="dataGrid2">';
echo "<thead>";
echo "<tr>";
echo "<th>Time</th>";
echo "<th>Age</th>";
echo "<th>Height</th>";
echo "<th>Diff</th>";
echo "<th>Difficulty</th>";
echo "<th>Type</th>";
if ($multiAlgos) echo "<th>Algo</th>";
echo "<th>Transactions</th>";
echo "<th>Confirmations</th>";
echo "<th>Tx</th>";
echo "<th>Conf</th>";
echo "<th>Blockhash</th>";
echo "</tr>";
echo "</thead>";
@ -63,15 +71,18 @@ for($i = $start; $i > max(1, $start-21); $i--)
else if (isset($block['mint']) || arraySafeVal($block,'flags') == 'proof-of-stake') $type = 'PoS';
// debuglog($block);
echo "<tr class='ssrow'>";
echo "<td>$d</td>";
echo "<td><a href='/explorer?id=$coin->id&height=$i'>$i</a></td>";
echo "<td>$diff</td>";
echo "<td>$type</td>";
echo '<tr class="ssrow">';
echo '<td>'.$d.'</td>';
echo '<td>'.$coin->createExplorerLink($i, array('height'=>$i)).'</td>';
echo '<td>'.$diff.'</td>';
echo '<td>'.$type.'</td>';
if ($multiAlgos) echo "<td>$algo</td>";
echo "<td>$tx</td>";
echo "<td>$confirms</td>";
echo "<td><span style='font-family: monospace;'><a href='/explorer?id=$coin->id&hash=$hash'>$hash</a></span></td>";
echo '<td>'.$tx.'</td>';
echo '<td>'.$confirms.'</td>';
echo '<td><span class="monospace">'.$coin->createExplorerLink($hash, array('hash'=>$hash)).'</span></td>';
echo "</tr>";
}
@ -80,19 +91,20 @@ echo "</table>";
$pager = '';
if ($start <= $coin->block_height - 20)
$pager = '<a href="?id='.$coin->id.'&start='.min($coin->block_height,$start+20).'"><< Prev</a>';
$pager = $coin->createExplorerLink('<< Prev', array('start'=>min($coin->block_height,$start+20)));
if ($start != $coin->block_height)
$pager .= '&nbsp; <a href="?id='.$coin->id.'">Now</a>';
$pager .= '&nbsp; '.$coin->createExplorerLink('Now');
if ($start > 20)
$pager .= '&nbsp; <a href="?id='.$coin->id.'&start='.max(1,$start-20).'">Next >></a>';
$pager .= '&nbsp; '.$coin->createExplorerLink('Next >>', array('start'=>max(1,$start-20)));
$actionUrl = $coin->visible ? '/explorer/'.$coin->symbol : '/explorer/search?id='.$coin->id;
echo <<<end
<div id="pager" style="float: right; width: 200px; text-align: right; margin-right: 20px; margin-top: 4px;">$pager</div>
<div id="form" style="width: 650px; height: 50px;">
<form action="/explorer" method="get" style="padding-top: 4px; width: 650px;">
<input type="hidden" name="id" value="{$coin->id}">
<div id="pager" style="float: right; width: 200px; text-align: right; margin-right: 16px; margin-top: 8px;">$pager</div>
<div id="form" style="width: 660px; height: 50px; overflow: hidden;">
<form action="{$actionUrl}" method="POST" style="padding-top: 4px; width: 650px;">
<input type="text" name="height" class="main-text-input" placeholder="Height" style="width: 80px;">
<input type="text" name="txid" class="main-text-input" placeholder="Transaction hash" style="width: 450px;">
<input type="text" name="txid" class="main-text-input" placeholder="Transaction hash" style="width: 450px; margin: 4px;">
<input type="submit" value="Search" class="main-submit-button" >
</form>
</div>
@ -102,7 +114,7 @@ if ($start != $coin->block_height)
return;
echo <<<end
<div id="diff_graph" style="margin-right: 8px;">
<div id="diff_graph" style="margin-right: 8px; margin-top: -16px;">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>

View file

@ -3,11 +3,16 @@
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
echo "<br/>";
echo <<<end
<style type="text/css">
td.low { color: red; font-weight: bold; }
</style>
echo "<div class='main-left-box'>";
echo "<div class='main-left-title'>Block Explorer</div>";
echo "<div class='main-left-inner'>";
<br/>
<div class="main-left-box">
<div class="main-left-title">Block Explorer</div>
<div class="main-left-inner">
end;
showTableSorter('maintable', "{
tableClass: 'dataGrid2',
@ -64,13 +69,13 @@ foreach($list as $coin)
echo '<tr class="ssrow">';
echo '<td><img src="'.$coin->image.'" width="18"></td>';
echo "<td><b><a href='/explorer?id=$coin->id'>$coin->name</a></b></td>";
echo "<td><b>$coin->symbol</b></td>";
echo '<td><b>'.$coin->createExplorerLink($coin->name).'</a></b></td>';
echo '<td><b>'.$coin->symbol.'</b></td>';
echo "<td>$coin->algo</td>";
echo "<td>$coin->version</td>";
echo '<td>'.$coin->algo.'</td>';
echo '<td>'.$coin->version.'</td>';
echo "<td>$coin->block_height</td>";
echo '<td>'.$coin->block_height.'</td>';
echo '<td data="'.$coin->difficulty.'">'.$difficulty.'</td>';
$cnx_class = (intval($coin->connections) > 3) ? '' : 'low';
echo '<td class="'.$cnx_class.'">'.$coin->connections.'</td>';
@ -92,10 +97,6 @@ echo <<<end
</tbody>
</table>
<style type="text/css">
td.low { color: red; font-weight: bold; }
</style>
<br></div></div>
<br><br><br><br><br><br><br><br><br><br>

View file

@ -1,28 +1,35 @@
<?php
$this->pageTitle = $coin->name." bloc explorer";
if (!$coin) $this->goback();
if ($coin) echo <<<ENDJS
<script>
$(function() {
$('#favicon').remove();
$('head').append('<link href="{$coin->image}" id="favicon" rel="shortcut icon">');
});
</script>
ENDJS;
$this->pageTitle = $coin->name." block explorer";
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
echo "<table class='dataGrid2'>";
echo <<<END
<script type="text/javascript">
$(function() {
$('#favicon').remove();
$('head').append('<link href="{$coin->image}" id="favicon" rel="shortcut icon">');
});
</script>
echo "<thead>";
echo "<tr>";
echo "<th>Transaction Hash</th>";
echo "<th>Value</th>";
echo "<th>From (amount)</th>";
echo "<th>To (amount)</th>";
echo "</tr>";
echo "</thead>";
<style type="text/css">
span.monospace { font-family: monospace; }
.main-text-input { margin-top: 4px; margin-bottom: 4px; }
</style>
<table class="dataGrid2">
<thead>
<tr>
<th>Transaction Hash</th>
<th>Value</th>
<th>From</th>
<th>To (amount)</th>
</tr>
</thead>
<tbody>
END;
$tx = $remote->getrawtransaction($txhash, 1);
if(!$tx) continue;
@ -31,10 +38,13 @@ $valuetx = 0;
foreach($tx['vout'] as $vout)
$valuetx += $vout['value'];
echo "<tr class='ssrow'>";
$coinUrl = $this->createUrl('/explorer', array('id'=>$coin->id));
echo "<td><span style='font-family: monospace;'><a href='/explorer?id=$coin->id&txid={$tx['txid']}'>{$tx['txid']}</a></span></td>";
echo "<td>$valuetx</td>";
echo '<tr class="ssrow">';
$url = ;
echo '<td><span class="monospace">'.CHtml::link($tx['txid'], $coinUrl.'txid='.$tx['txid']).'</a></span></td>';
echo '<td>'.$valuetx.'</td>';
echo "<td>";
foreach($tx['vin'] as $vin)
@ -51,7 +61,7 @@ foreach($tx['vout'] as $vout)
$value = $vout['value'];
if(isset($vout['scriptPubKey']['addresses'][0]))
echo "<span style='font-family: monospace;'>{$vout['scriptPubKey']['addresses'][0]}</span> ($value)";
echo '<span class="monospace">'.$vout['scriptPubKey']['addresses'][0]."</span> ($value)";
else
echo "($value)";
@ -59,15 +69,15 @@ foreach($tx['vout'] as $vout)
}
echo "</td>";
echo "</tr>";
echo "</tr></tbody>";
echo "</table>";
$actionUrl = $coin->visible ? '/explorer/'.$coin->symbol : '/explorer/search?id='.$coin->id;
echo <<<end
<form action="/explorer" method="get" style="padding: 10px;">
<input type="hidden" name="id" value="$coin->id">
<form action="{$actionUrl}" method="POST" style="padding: 10px;">
<input type="text" name="height" class="main-text-input" placeholder="block height" style="width: 80px;">
<input type="text" name="txid" class="main-text-input" placeholder="tx hash" style="width: 450px;">
<input type="text" name="txid" class="main-text-input" placeholder="tx hash" style="width: 450px; margin: 4px;">
<input type="submit" value="Search" class="main-submit-button" >
</form>
end;

View file

@ -86,14 +86,8 @@ foreach($db_blocks as $db_block)
$d = datetoa2($db_block->time);
echo '<td data="'.$db_block->time.'"><b>'.$d.' ago</b></td>';
if (YIIMP_PUBLIC_EXPLORER)
echo '<td><a href="/explorer?id='.$coin->id.'&height='.$db_block->height.'">'.$db_block->height.'</a></td>';
else
echo "<td>$db_block->height</td>";
echo "<td>$db_block->amount</td>";
echo '<td>'.$coin->createExplorerLink($db_block->height, array('height'=>$db_block->height)).'</td>';
echo '<td>'.$db_block->amount.'</td>';
echo '<td class="'.strtolower($db_block->category).'">';
if($db_block->category == 'orphan')
@ -126,10 +120,7 @@ foreach($db_blocks as $db_block)
}
echo '<td>'.$finder.'</td>';
echo '<td style="font-size: .8em; font-family: monospace;">';
if (YIIMP_PUBLIC_EXPLORER)
echo '<a href="/explorer?id='.$coin->id.'&hash='.$db_block->blockhash.'">'.$db_block->blockhash.'</a>';
else
echo $db_block->blockhash;
echo $coin->createExplorerLink($db_block->blockhash, array('hash'=>$db_block->blockhash));
echo "</td>";
echo "</tr>";
}

View file

@ -356,10 +356,9 @@ foreach($txs_array as $tx)
echo '<td>';
if(!empty($block)) {
$txid = arraySafeVal($tx, 'txid');
$label = substr($txid, 0, 7);
echo CHtml::link($label, '/explorer?id='.$coin->id.'&txid='.$txid, array('target'=>'_blank'));
echo $coin->createExplorerLink($label, array('txid'=>$txid), array('target'=>'_blank'));
}
echo '</td>';

View file

@ -230,7 +230,7 @@ foreach($txs_array as $tx)
if(!empty($block)) {
$txid = arraySafeVal($tx, 'txid');
$label = substr($txid, 0, 7);
echo CHtml::link($label, '/explorer?id='.$coin->id.'&txid='.$txid, array('target'=>'_blank'));
echo $coin->createExplorerLink($label, array('txid'=>$txid), array('target'=>'_blank'));
}
echo '</td>';

View file

@ -69,11 +69,12 @@ foreach($db_blocks as $db_block)
$coin = $db_block->coin ? $db_block->coin : getdbo('db_coins', $db_block->coin_id);
$difficulty = Itoa2($db_block->difficulty, 3);
$height = number_format($db_block->height, 0, '.', ' ');
$url = "/explorer?id=$coin->id&hash=$db_block->blockhash";
echo "<tr class='ssrow'>";
echo "<td width=18><img width=16 src='$coin->image'></td>";
echo "<td><b><a href='$url'>$coin->name</a></b><span style='font-size: .8em'> ($coin->algo)</span></td>";
$link = $coin->createExplorerLink($coin->name, array('hash'=>$db_block->blockhash));
echo '<tr class="ssrow">';
echo '<td width="18"><img width="16" src="'.$coin->image.'"></td>';
echo "<td><b>$link</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' title='found $db_block->difficulty_user'>$difficulty</td>";
echo "<td align=right style='font-size: .8em'>$height</td>";

View file

@ -6,49 +6,47 @@ $algo = user()->getState('yaamp-algo');
$step = 15*60;
$t = time() - 24*60*60;
$stats = getdbolist('db_hashrate', "time>$t and algo=:algo order by time", array(':algo'=>$algo));
$stats = getdbolist('db_hashrate', "time > $t AND algo=:algo ORDER BY time", array(':algo'=>$algo));
$averages = array();
echo '[[';
$json = '';
for($i = 0; $i < 95-count($stats); $i++)
{
$d = date('Y-m-d H:i:s', $t);
echo "[\"$d\",0],";
$json .= "[\"$d\",0],";
$averages[] = array($d, 0);
$t += $step;
}
foreach($stats as $i=>$n)
foreach($stats as $n)
{
$m = round($n->hashrate/1000000, 3);
if($i) echo ',';
$d = date('Y-m-d H:i:s', $n->time);
echo "[\"$d\",$m]";
$json .= "[\"$d\",$m],";
$averages[] = array($d, $m);
}
echo '],[';
echo '[['.rtrim($json,',').'],';
echo '[';
$json = '';
$average = $averages[0][1];
foreach($averages as $i=>$n)
foreach($averages as $n)
{
if($i) echo ',';
$average = ($average*(100-$percent) + $n[1]*$percent) / 100;
$m = round($average, 3);
echo "[\"{$n[0]}\",$m]";
$json .= "[\"{$n[0]}\",$m],";
}
// $a = 10;
// foreach($averages as $i=>$n)
// {
// if($i < $a) continue;
// if($i > $a) echo ',';
// $average = 0;
// for($j = $i-$a+1; $j<=$i; $j++)
@ -56,9 +54,10 @@ foreach($averages as $i=>$n)
// $m = round($average, 3);
// echo "[\"{$n[0]}\",$m]";
// $json .= "[\"{$n[0]}\",$m]";
// }
echo rtrim($json,',');
echo ']]';

View file

@ -70,9 +70,10 @@ foreach($earnings as $earning)
$percent = mbitcoinvaluetoa($earning->amount*100/$block->amount);
$value = altcoinvaluetoa($earning->amount*$earning->price*1000);
$blockUrl = $coin->createExplorerLink($coin->name, array('height'=>$block->height));
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><b>$blockUrl</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>";

View file

@ -241,20 +241,15 @@ foreach($list as $payout)
$amount = bitcoinvaluetoa($payout->amount);
$firstid = min($firstid, (int) $payout->id);
echo '<tr class="ssrow">';
echo '<td align="right"><b>'.$d.' ago</b></td>';
echo '<td align="right"><b>'.$amount.'</b></td>';
$payout_tx = substr($payout->tx, 0, 36).'...';
$link = $refcoin->createExplorerLink($payout_tx, array('txid'=>$payout->tx), array(), true);
echo "<tr class='ssrow'>";
echo "<td align=right><b>$d ago</b></td>";
echo "<td align=right><b>$amount</b></td>";
if($user->coinid == 6)
$txurl = "https://blockchain.info/tx/$payout->tx";
else
$txurl = "/explorer?id=$user->coinid&txid=$payout->tx";
echo "<td style='font-family: monospace;'><a href='$txurl' target=_blank>$payout_tx</a></td>";
echo "</tr>";
echo '<td style="font-family: monospace;">'.$link.'</td>';
echo '</tr>';
$total += $payout->amount;
}
@ -296,19 +291,15 @@ end;
$d = datetoa2($payout->time);
$amount = bitcoinvaluetoa($payout->amount);
echo '<tr class="ssrow">';
echo '<td align="right"><b>'.$d.' ago</b></td>';
echo '<td align="right"><b>'.$amount.'</b></td>';
$payout_tx = substr($payout->tx, 0, 36).'...';
$link = $refcoin->createExplorerLink($payout_tx, array('txid'=>$payout->tx), array(), true);
echo "<tr class='ssrow'>";
echo "<td align=right><b>$d ago</b></td>";
echo "<td align=right><b>$amount</b></td>";
if($user->coinid == 6)
$txurl = "https://blockchain.info/tx/$payout->tx";
else
$txurl = "/explorer?id=$user->coinid&txid=$payout->tx";
echo "<td style='font-family: monospace;'><a href='$txurl' target=_blank>$payout_tx</a></td>";
echo "</tr>";
echo '<td style="font-family: monospace;">'.$link.'</td>';
echo '</tr>';
$total += $payout->amount;
}

View file

@ -5,7 +5,7 @@ require dirname(__FILE__).'/../../ui/lib/pageheader.php';
$user = getuserparam(getparam('address'));
if(!$user) return;
$this->pageTitle = "$user->username | yiimp";
$this->pageTitle = $user->username.' | '.YAAMP_SITE_NAME;
$bitcoin = getdbosql('db_coins', "symbol='BTC'");
@ -13,9 +13,9 @@ echo "<div class='main-left-box'>";
echo "<div class='main-left-title'>Transactions to $user->username</div>";
echo "<div class='main-left-inner'>";
$list = getdbolist('db_payouts', "account_id=$user->id order by time desc");
$list = getdbolist('db_payouts', "account_id={$user->id} ORDER BY time DESC");
echo "<table class='dataGrid2'>";
echo '<table class="dataGrid2">';
echo "<thead>";
echo "<tr>";
@ -26,6 +26,8 @@ echo "<th>Tx</th>";
echo "</tr>";
echo "</thead>";
$coin = ($user->coinid == $bitcoin->id) ? $bitcoin : getdbo('db_coins', $user->coinid);
$total = 0;
foreach($list as $payout)
{
@ -38,10 +40,8 @@ foreach($list as $payout)
echo "<td align=right><b>$amount</b></td>";
if($user->coinid == $bitcoin->id)
echo "<td style='font-family: monospace;'><a href='https://blockchain.info/tx/$payout->tx' target=_blank>$payout->tx</a></td>";
else
echo "<td style='font-family: monospace;'><a href='/explorer?id=$user->coinid&txid=$payout->tx' target=_blank>$payout->tx</a></td>";
$url = $coin->createExplorerLink($payout->tx, array('txid'=>$payout->tx), array('target'=>'_blank'));
echo '<td style="font-family: monospace;">'.$url.'</td>';
echo "</tr>";
$total += $payout->amount;