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');
         }
     }
 }
Exemple #2
0
<?php

$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
echo "<table class='dataGrid2'>";
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>";
$tx = $remote->getrawtransaction($txhash, 1);
if (!$tx) {
    continue;
}
$valuetx = 0;
foreach ($tx['vout'] as $vout) {
    $valuetx += $vout['value'];
}
echo "<tr class='ssrow'>";
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 "<td>";
foreach ($tx['vin'] as $vin) {
    if (isset($vin['coinbase'])) {
        echo "Generation";
    }
}
echo "</td>";
echo "<td>";
Exemple #3
0
    $hashRate = $rpc->getnetworkhashps() / 1000000;
}
$hashRate = sprintf('%.2f', $hashRate);
echo "<div class=\"mid\"><table><tr><td class=\"urgh\"><b><a href=\"{$coinHome}\">{$coinName}</a></b> block explorer</td><td>Blocks:</td><td><a href=\"?{$info['blocks']}\">{$info['blocks']}</a></td></tr>";
echo "<tr><td /><td>{$diffNom}:</td><td>{$diff}</td></tr>";
echo "<tr><td>Powered by <a href=\"https://github.com/stolendata/rpc-ace/\">RPC Ace</a> v{$aceVersion} (RPC AnyCoin Explorer)</td><td>Network hashrate: </td><td>{$hashRate} MH/s</td></tr><tr><td> </td><td /><td /></tr></table>";
if (preg_match("/^([[:xdigit:]]{64})\$/", $query) === 1) {
    if (($block = $rpc->getblock($query)) === false) {
        echo 'No matching block hash.<br />';
    } else {
        echo '<table>';
        foreach ($block as $id => $val) {
            if ($id === 'tx') {
                foreach ($val as $txid) {
                    echo "<tr><td class=\"key\">{$id}</td><td class=\"value\">{$txid}</td></tr>";
                    if (($tx = $rpc->getrawtransaction($txid, 1)) === false) {
                        continue;
                    }
                    foreach ($tx['vout'] as $entry) {
                        if ($entry['value'] > 0.0) {
                            // nasty number formatting trick that hurts my soul, but it had to be done...
                            echo '<tr><td /><td class="value">     ' . rtrim(rtrim(sprintf('%.8f', $entry['value']), '0'), '.') . " -> {$entry['scriptPubKey']['addresses'][0]}</td></tr>";
                        }
                    }
                }
            } else {
                if ($id === 'previousblockhash' || $id === 'nextblockhash') {
                    echo "<tr><td class=\"key\">{$id}</td><td class=\"value\"><a href=\"?{$val}\">{$val}</a></td></tr>";
                } elseif (in_array($id, $blockFields) === true) {
                    echo "<tr><td class=\"key\">{$id}</td><td class=\"value\">{$val}</td></tr>";
                }