mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-20 18:09:54 +00:00
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
require_once("util.php");
|
|
|
|
class ExplorerController extends CommonController
|
|
{
|
|
public $defaultAction='index';
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
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 = arraySafeVal($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');
|
|
}
|
|
|
|
/**
|
|
* Difficulty Graph
|
|
*/
|
|
public function actionGraph()
|
|
{
|
|
$id = getiparam('id');
|
|
$coin = getdbo('db_coins', $id);
|
|
if ($coin)
|
|
$this->renderPartial('graph', array('coin'=>$coin));
|
|
else
|
|
echo "[]";
|
|
}
|
|
}
|