Chainquery integration #49
6 changed files with 250 additions and 228 deletions
|
@ -106,7 +106,7 @@ class MainController extends AppController {
|
||||||
$hashRate = $this->_formatHashRate($this->_gethashrate());
|
$hashRate = $this->_formatHashRate($this->_gethashrate());
|
||||||
|
|
||||||
// recent claims
|
// recent claims
|
||||||
$claims = $this->Claims->find()->select(['transaction_hash_id', 'name', 'vout', 'claim_id', 'claim_type', 'author', 'title', 'description', 'content_type', 'is_nsfw', 'language', 'thumbnail_url', 'created_at'])->
|
$claims = $this->Claims->find()->select(['transaction_hash_id', 'name', 'vout', 'claim_id', 'claim_type', 'author', 'title', 'description', 'content_type', 'is_nsfw', 'language', 'thumbnail_url', 'created_at', 'publisher_id'])->
|
||||||
distinct(['Claims.claim_id'])->order(['Claims.created_at' => 'DESC'])->limit(5)->toArray();
|
distinct(['Claims.claim_id'])->order(['Claims.created_at' => 'DESC'])->limit(5)->toArray();
|
||||||
|
|
||||||
foreach($claims as $claim) {
|
foreach($claims as $claim) {
|
||||||
|
@ -124,7 +124,9 @@ class MainController extends AppController {
|
||||||
$this->loadModel('Transactions');
|
$this->loadModel('Transactions');
|
||||||
|
|
||||||
$canConvert = false;
|
$canConvert = false;
|
||||||
$priceInfo = json_decode($this->redis->get(self::lbcPriceKey));
|
if(isset($this->redis)) {
|
||||||
|
$priceInfo = json_decode($this->redis->get(self::lbcPriceKey));
|
||||||
|
}
|
||||||
if (isset($priceInfo->price)) {
|
if (isset($priceInfo->price)) {
|
||||||
$canConvert = true;
|
$canConvert = true;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +138,7 @@ class MainController extends AppController {
|
||||||
$page = intval($this->request->query('page'));
|
$page = intval($this->request->query('page'));
|
||||||
|
|
||||||
$conn = ConnectionManager::get('default');
|
$conn = ConnectionManager::get('default');
|
||||||
$stmt = $conn->execute('SELECT COUNT(Id) AS Total FROM Claims');
|
$stmt = $conn->execute('SELECT COUNT(Id) AS Total FROM claim');
|
||||||
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||||
$numClaims = $count->Total;
|
$numClaims = $count->Total;
|
||||||
|
|
||||||
|
@ -149,10 +151,17 @@ class MainController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$offset = ($page - 1) * $pageLimit;
|
$offset = ($page - 1) * $pageLimit;
|
||||||
$claims = $this->Claims->find()->distinct(['Claims.ClaimId'])->contain(['Stream', 'Publisher' => ['fields' => ['Name']]])->order(['Claims.Created' => 'DESC'])->offset($offset)->limit($pageLimit)->toArray();
|
$claims = $this->Claims->find()->distinct(['claim_id'])->order(['created_at' => 'DESC'])->offset($offset)->limit($pageLimit)->toArray();
|
||||||
|
foreach($claims as $claim) {
|
||||||
|
if(isset($claim->publisher_id)) {
|
||||||
|
$publisher = $this->Claims->find()->select(['name'])->where(['claim_id' => $claim->publisher_id])->first();
|
||||||
|
$claim->publisher = $publisher;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < count($claims); $i++) {
|
for ($i = 0; $i < count($claims); $i++) {
|
||||||
if ($canConvert && $claims[$i]->Fee > 0 && $claims[$i]->FeeCurrency == 'USD') {
|
if ($canConvert && $claims[$i]->Fee > 0 && $claims[$i]->fee_currency == 'USD') {
|
||||||
$claims[$i]->Price = $claims[$i]->Fee / $priceInfo->price;
|
$claims[$i]->price = $claims[$i]->fee / $priceInfo->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($claims[$i]->Stream)) {
|
if (isset($claims[$i]->Stream)) {
|
||||||
|
@ -172,13 +181,16 @@ class MainController extends AppController {
|
||||||
$this->set('currentPage', $page);
|
$this->set('currentPage', $page);
|
||||||
$this->set('claims', $claims);
|
$this->set('claims', $claims);
|
||||||
} else {
|
} else {
|
||||||
$claim = $this->Claims->find()->contain(['Stream', 'Publisher' => ['fields' => ['ClaimId', 'Name']]])->where(['Claims.ClaimId' => $id])->order(['Claims.Created' => 'DESC'])->first();
|
$claim = $this->Claims->find()->where(['claim_id' => $id])->order(['created_at' => 'DESC'])->first();
|
||||||
|
$publisher = $this->Claims->find()->select(['name'])->where(['claim_id' => $claim->publisher_id])->first();
|
||||||
|
$claim->publisher = $publisher;
|
||||||
|
|
||||||
if (!$claim) {
|
if (!$claim) {
|
||||||
return $this->redirect('/');
|
return $this->redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($canConvert && $claim->Fee > 0 && $claim->FeeCurrency == 'USD') {
|
if ($canConvert && $claim->fee > 0 && $claim->fee_currency == 'USD') {
|
||||||
$claim->Price = $claim->Fee / $priceInfo->price;
|
$claim->price = $claim->fee / $priceInfo->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($claim->Stream)) {
|
if (isset($claim->Stream)) {
|
||||||
|
@ -192,14 +204,13 @@ class MainController extends AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$moreClaims = [];
|
$moreClaims = [];
|
||||||
if (isset($claim->Publisher) || $claim->ClaimType == 1) {
|
if (isset($claim->publisher) || $claim->claim_type == 1) {
|
||||||
// find more claims for the publisher
|
// find more claims for the publisher
|
||||||
$moreClaims = $this->Claims->find()->contain(['Stream', 'Publisher' => ['fields' => ['Name']]])->
|
$moreClaims = $this->Claims->find()->where(['claim_type' => 2, 'id <>' => $claim->id, 'publisher_id' => isset($claim->publisher) ? $claim->publisher_id : $claim->claim_id])->
|
||||||
where(['Claims.ClaimType' => 2, 'Claims.Id <>' => $claim->Id, 'Claims.PublisherId' => isset($claim->Publisher) ? $claim->Publisher->ClaimId : $claim->ClaimId])->
|
limit(9)->order(['fee' => 'DESC', 'RAND()' => 'DESC'])->toArray();
|
||||||
limit(9)->order(['Claims.Fee' => 'DESC', 'RAND()' => 'DESC'])->toArray();
|
|
||||||
for ($i = 0; $i < count($moreClaims); $i++) {
|
for ($i = 0; $i < count($moreClaims); $i++) {
|
||||||
if ($canConvert && $moreClaims[$i]->Fee > 0 && $moreClaims[$i]->FeeCurrency == 'USD') {
|
if ($canConvert && $moreClaims[$i]->fee > 0 && $moreClaims[$i]->fee_currency == 'USD') {
|
||||||
$moreClaims[$i]->Price = $moreClaims[$i]->Fee / $priceInfo->price;
|
$moreClaims[$i]->price = $moreClaims[$i]->fee / $priceInfo->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($moreClaims[$i]->Stream)) {
|
if (isset($moreClaims[$i]->Stream)) {
|
||||||
|
@ -225,114 +236,20 @@ class MainController extends AppController {
|
||||||
|
|
||||||
// load 10 blocks and transactions
|
// load 10 blocks and transactions
|
||||||
$conn = ConnectionManager::get('default');
|
$conn = ConnectionManager::get('default');
|
||||||
$blocks = $this->Blocks->find()->select(['Height', 'BlockTime', 'TransactionHashes'])->order(['Height' => 'desc'])->limit(10)->toArray();
|
$blocks = $this->Blocks->find()->select(['height', 'block_time', 'transaction_hashes'])->order(['height' => 'desc'])->limit(10)->toArray();
|
||||||
for ($i = 0; $i < count($blocks); $i++) {
|
for ($i = 0; $i < count($blocks); $i++) {
|
||||||
$tx_hashes = json_decode($blocks[$i]->TransactionHashes);
|
$tx_hashes = json_decode($blocks[$i]->transaction_hashes);
|
||||||
$blocks[$i]->TransactionCount = count($tx_hashes);
|
$blocks[$i]->transaction_count = count($tx_hashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $conn->execute('SELECT T.Hash, T.InputCount, T.OutputCount, T.Value, IFNULL(T.TransactionTime, T.CreatedTime) AS TxTime ' .
|
$stmt = $conn->execute('SELECT T.id, T.hash, T.input_count, T.output_count, IFNULL(T.transaction_time, T.created_at) AS TxTime ' .
|
||||||
'FROM Transactions T ORDER BY CreatedTime DESC LIMIT 10');
|
'FROM transaction T ORDER BY created_at DESC LIMIT 10');
|
||||||
$txs = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
$txs = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
|
||||||
$this->set('blocks', $blocks);
|
$this->set('blocks', $blocks);
|
||||||
$this->set('txs', $txs);
|
$this->set('txs', $txs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apiblocksize($timePeriod = '24h') {
|
|
||||||
$this->autoRender = false;
|
|
||||||
|
|
||||||
if (!$this->request->is('get')) {
|
|
||||||
return $this->_jsonError('Invalid HTTP request method.', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
$validPeriods = ['24h', '72h', '168h', '30d', '90d', '1y'];
|
|
||||||
if (!in_array($timePeriod, $validPeriods)) {
|
|
||||||
return $this->_jsonError('Invalid time period specified.', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
$isHourly = (strpos($timePeriod, 'h') !== false);
|
|
||||||
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
|
||||||
$dateFormat = $isHourly ? 'Y-m-d H:00:00' : 'Y-m-d';
|
|
||||||
$sqlDateFormat = $isHourly ? '%Y-%m-%d %H:00:00' : '%Y-%m-%d';
|
|
||||||
$intervalPrefix = $isHourly ? 'PT' : 'P';
|
|
||||||
$start = $now->sub(new \DateInterval($intervalPrefix . strtoupper($timePeriod)));
|
|
||||||
|
|
||||||
$resultSet = [];
|
|
||||||
|
|
||||||
$conn = ConnectionManager::get('default');
|
|
||||||
|
|
||||||
// get avg block sizes for the time period
|
|
||||||
$stmt = $conn->execute("SELECT AVG(BlockSize) AS AvgBlockSize, DATE_FORMAT(FROM_UNIXTIME(BlockTime), '$sqlDateFormat') AS TimePeriod " .
|
|
||||||
"FROM Blocks WHERE DATE_FORMAT(FROM_UNIXTIME(BlockTime), '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
|
|
||||||
$avgBlockSizes = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
foreach ($avgBlockSizes as $size) {
|
|
||||||
if (!isset($resultSet[$size->TimePeriod])) {
|
|
||||||
$resultSet[$size->TimePeriod] = [];
|
|
||||||
}
|
|
||||||
$resultSet[$size->TimePeriod]['AvgBlockSize'] = (float) $size->AvgBlockSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get avg prices
|
|
||||||
$stmt = $conn->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " .
|
|
||||||
"FROM PriceHistory WHERE DATE_FORMAT(Created, '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
|
|
||||||
$avgPrices = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
foreach ($avgPrices as $price) {
|
|
||||||
if (!isset($resultSet[$price->TimePeriod])) {
|
|
||||||
$resultSet[$price->TimePeriod] = [];
|
|
||||||
}
|
|
||||||
$resultSet[$price->TimePeriod]['AvgUSD'] = (float) $price->AvgUSD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_jsonResponse(['success' => true, 'data' => $resultSet]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function apirealtimeblocks() {
|
|
||||||
// load 10 blocks
|
|
||||||
$this->autoRender = false;
|
|
||||||
$this->loadModel('Blocks');
|
|
||||||
$blocks = $this->Blocks->find()->select(['Height', 'BlockTime', 'TransactionHashes'])->order(['Height' => 'desc'])->limit(10)->toArray();
|
|
||||||
for ($i = 0; $i < count($blocks); $i++) {
|
|
||||||
$tx_hashes = json_decode($blocks[$i]->TransactionHashes);
|
|
||||||
$blocks[$i]->TransactionCount = count($tx_hashes);
|
|
||||||
unset($blocks[$i]->TransactionHashes);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_jsonResponse(['success' => true, 'blocks' => $blocks]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function apirealtimetx() {
|
|
||||||
// load 10 transactions
|
|
||||||
$this->autoRender = false;
|
|
||||||
$conn = ConnectionManager::get('default');
|
|
||||||
$stmt = $conn->execute('SELECT T.Hash, T.InputCount, T.OutputCount, T.Value, IFNULL(T.TransactionTime, T.CreatedTime) AS TxTime ' .
|
|
||||||
'FROM Transactions T ORDER BY CreatedTime DESC LIMIT 10');
|
|
||||||
$txs = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
|
|
||||||
$this->_jsonResponse(['success' => true, 'txs' => $txs]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function _formatHashRate($value) {
|
|
||||||
if ($value === 'N/A') {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if ($value > 1000000000000) {
|
|
||||||
return number_format( $value / 1000000000000, 2, '.', '' ) . ' TH';
|
|
||||||
}*/
|
|
||||||
if ($value > 1000000000) {
|
|
||||||
return number_format( $value / 1000000000, 2, '.', '' ) . ' GH/s';
|
|
||||||
}
|
|
||||||
if ($value > 1000000) {
|
|
||||||
return number_format( $value / 1000000, 2, '.', '' ) . ' MH/s';
|
|
||||||
}
|
|
||||||
if ($value > 1000) {
|
|
||||||
return number_format( $value / 1000, 2, '.', '' ) . ' KH/s';
|
|
||||||
}
|
|
||||||
|
|
||||||
return number_format($value) . ' H/s';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function find() {
|
public function find() {
|
||||||
$criteria = $this->request->query('q');
|
$criteria = $this->request->query('q');
|
||||||
|
|
||||||
|
@ -651,52 +568,77 @@ class MainController extends AppController {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function curl_get($url) {
|
public function apiblocksize($timePeriod = '24h') {
|
||||||
$ch = curl_init();
|
$this->autoRender = false;
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
if (!$this->request->is('get')) {
|
||||||
Log::debug('Request execution completed.');
|
return $this->_jsonError('Invalid HTTP request method.', 400);
|
||||||
|
|
||||||
if ($response === false) {
|
|
||||||
$error = curl_error($ch);
|
|
||||||
$errno = curl_errno($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
throw new \Exception(sprintf('The request failed: %s', $error), $errno);
|
|
||||||
} else {
|
|
||||||
curl_close($ch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
$validPeriods = ['24h', '72h', '168h', '30d', '90d', '1y'];
|
||||||
|
if (!in_array($timePeriod, $validPeriods)) {
|
||||||
|
return $this->_jsonError('Invalid time period specified.', 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$isHourly = (strpos($timePeriod, 'h') !== false);
|
||||||
|
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
|
$dateFormat = $isHourly ? 'Y-m-d H:00:00' : 'Y-m-d';
|
||||||
|
$sqlDateFormat = $isHourly ? '%Y-%m-%d %H:00:00' : '%Y-%m-%d';
|
||||||
|
$intervalPrefix = $isHourly ? 'PT' : 'P';
|
||||||
|
$start = $now->sub(new \DateInterval($intervalPrefix . strtoupper($timePeriod)));
|
||||||
|
|
||||||
|
$resultSet = [];
|
||||||
|
|
||||||
|
$conn = ConnectionManager::get('default');
|
||||||
|
|
||||||
|
// get avg block sizes for the time period
|
||||||
|
$stmt = $conn->execute("SELECT AVG(BlockSize) AS AvgBlockSize, DATE_FORMAT(FROM_UNIXTIME(BlockTime), '$sqlDateFormat') AS TimePeriod " .
|
||||||
|
"FROM Blocks WHERE DATE_FORMAT(FROM_UNIXTIME(BlockTime), '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
|
||||||
|
$avgBlockSizes = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
foreach ($avgBlockSizes as $size) {
|
||||||
|
if (!isset($resultSet[$size->TimePeriod])) {
|
||||||
|
$resultSet[$size->TimePeriod] = [];
|
||||||
|
}
|
||||||
|
$resultSet[$size->TimePeriod]['AvgBlockSize'] = (float) $size->AvgBlockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get avg prices
|
||||||
|
$stmt = $conn->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " .
|
||||||
|
"FROM PriceHistory WHERE DATE_FORMAT(Created, '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
|
||||||
|
$avgPrices = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
foreach ($avgPrices as $price) {
|
||||||
|
if (!isset($resultSet[$price->TimePeriod])) {
|
||||||
|
$resultSet[$price->TimePeriod] = [];
|
||||||
|
}
|
||||||
|
$resultSet[$price->TimePeriod]['AvgUSD'] = (float) $price->AvgUSD;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_jsonResponse(['success' => true, 'data' => $resultSet]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _gethashrate() {
|
public function apirealtimeblocks() {
|
||||||
$req = ['method' => 'getnetworkhashps', 'params' => []];
|
// load 10 blocks
|
||||||
try {
|
$this->autoRender = false;
|
||||||
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
$this->loadModel('Blocks');
|
||||||
if (!isset($res->result)) {
|
$blocks = $this->Blocks->find()->select(['Height', 'BlockTime', 'TransactionHashes'])->order(['Height' => 'desc'])->limit(10)->toArray();
|
||||||
return 0;
|
for ($i = 0; $i < count($blocks); $i++) {
|
||||||
}
|
$tx_hashes = json_decode($blocks[$i]->TransactionHashes);
|
||||||
return $res->result;
|
$blocks[$i]->TransactionCount = count($tx_hashes);
|
||||||
} catch (\Exception $e) {
|
unset($blocks[$i]->TransactionHashes);
|
||||||
return 'N/A';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_jsonResponse(['success' => true, 'blocks' => $blocks]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _gettxoutsetinfo() {
|
public function apirealtimetx() {
|
||||||
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
|
// load 10 transactions
|
||||||
try {
|
$this->autoRender = false;
|
||||||
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
$conn = ConnectionManager::get('default');
|
||||||
if (!isset($res->result)) {
|
$stmt = $conn->execute('SELECT T.Hash, T.InputCount, T.OutputCount, T.Value, IFNULL(T.TransactionTime, T.CreatedTime) AS TxTime ' .
|
||||||
return 0;
|
'FROM Transactions T ORDER BY CreatedTime DESC LIMIT 10');
|
||||||
}
|
$txs = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
||||||
return $res->result;
|
|
||||||
} catch (\Exception $e) {
|
$this->_jsonResponse(['success' => true, 'txs' => $txs]);
|
||||||
return 'N/A';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apistatus() {
|
public function apistatus() {
|
||||||
|
@ -868,7 +810,7 @@ class MainController extends AppController {
|
||||||
return $this->_jsonResponse(['success' => true, 'utxo' => $utxo]);
|
return $this->_jsonResponse(['success' => true, 'utxo' => $utxo]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apiutxosupply() {
|
public function apiutxosupply() {
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
$this->loadModel('Addresses');
|
$this->loadModel('Addresses');
|
||||||
|
|
||||||
|
@ -903,6 +845,75 @@ class MainController extends AppController {
|
||||||
return $this->_jsonResponse(['success' => true, 'utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]);
|
return $this->_jsonResponse(['success' => true, 'utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function _formatHashRate($value) {
|
||||||
|
if ($value === 'N/A') {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if ($value > 1000000000000) {
|
||||||
|
return number_format( $value / 1000000000000, 2, '.', '' ) . ' TH';
|
||||||
|
}*/
|
||||||
|
if ($value > 1000000000) {
|
||||||
|
return number_format( $value / 1000000000, 2, '.', '' ) . ' GH/s';
|
||||||
|
}
|
||||||
|
if ($value > 1000000) {
|
||||||
|
return number_format( $value / 1000000, 2, '.', '' ) . ' MH/s';
|
||||||
|
}
|
||||||
|
if ($value > 1000) {
|
||||||
|
return number_format( $value / 1000, 2, '.', '' ) . ' KH/s';
|
||||||
|
}
|
||||||
|
|
||||||
|
return number_format($value) . ' H/s';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function curl_get($url) {
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
Log::debug('Request execution completed.');
|
||||||
|
|
||||||
|
if ($response === false) {
|
||||||
|
$error = curl_error($ch);
|
||||||
|
$errno = curl_errno($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
throw new \Exception(sprintf('The request failed: %s', $error), $errno);
|
||||||
|
} else {
|
||||||
|
curl_close($ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _gethashrate() {
|
||||||
|
$req = ['method' => 'getnetworkhashps', 'params' => []];
|
||||||
|
try {
|
||||||
|
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
|
if (!isset($res->result)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return $res->result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _gettxoutsetinfo() {
|
||||||
|
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
|
||||||
|
try {
|
||||||
|
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
|
||||||
|
if (!isset($res->result)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return $res->result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static function curl_json_post($url, $data, $headers = []) {
|
private static function curl_json_post($url, $data, $headers = []) {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
namespace App\Model\Entity;
|
namespace App\Model\Entity;
|
||||||
|
|
||||||
use Cake\ORM\Entity;
|
use Cake\ORM\Entity;
|
||||||
|
use Cake\ORM\TableRegistry;
|
||||||
|
|
||||||
class Claim extends Entity {
|
class Claim extends Entity {
|
||||||
function getLbryLink() {
|
function getLbryLink() {
|
||||||
$link = $this->name;
|
$link = $this->name;
|
||||||
if (isset($this->Publisher->Name)) {
|
$ClaimModel = TableRegistry::get('Claims');
|
||||||
$link = $this->Publisher->Name . '/' . $link;
|
$publisher = $ClaimModel->find()->select(['name'])->where(['claim_id' => $this->publisher_id])->first();
|
||||||
|
|
||||||
|
if (isset($publisher->name)) {
|
||||||
|
$link = $publisher->name . '/' . $link;
|
||||||
}
|
}
|
||||||
$link = 'lbry://' . $link;
|
$link = 'lbry://' . $link;
|
||||||
return $link;
|
return $link;
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Model\Entity;
|
||||||
use Cake\ORM\Entity;
|
use Cake\ORM\Entity;
|
||||||
use Cake\ORM\TableRegistry;
|
use Cake\ORM\TableRegistry;
|
||||||
|
|
||||||
|
|
||||||
class Transaction extends Entity {
|
class Transaction extends Entity {
|
||||||
public function value() {
|
public function value() {
|
||||||
$OutputModel = TableRegistry::get('Outputs');
|
$OutputModel = TableRegistry::get('Outputs');
|
||||||
|
|
|
@ -41,13 +41,13 @@
|
||||||
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
|
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
|
||||||
$autoThumbText = $claim->getAutoThumbText();
|
$autoThumbText = $claim->getAutoThumbText();
|
||||||
$cost = 'Free';
|
$cost = 'Free';
|
||||||
if (isset($claim->Price) && $claim->Price > 0) {
|
if (isset($claim->price) && $claim->price > 0) {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->price) . ' LBC';
|
||||||
} else if (isset($claim->Fee) && strtolower($claim->FeeCurrency) === 'lbc') {
|
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Fee) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->fee) . ' LBC';
|
||||||
}
|
}
|
||||||
|
|
||||||
$desc = $claim->Description;
|
$desc = $claim->description;
|
||||||
if (strlen(trim($desc)) == 0) {
|
if (strlen(trim($desc)) == 0) {
|
||||||
$desc = '<em>No description available.</em>';
|
$desc = '<em>No description available.</em>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,29 +57,29 @@ if (strlen(trim($desc)) == 0) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php $this->assign('title', 'Claim • ' . $claim->Name) ?>
|
<?php $this->assign('title', 'Claim • ' . $claim->name) ?>
|
||||||
|
|
||||||
<div class="claims-head">
|
<div class="claims-head">
|
||||||
<h3><a href="/claims">LBRY Claims</a> • <?php echo $claim->Name ?></h3>
|
<h3><a href="/claims">LBRY Claims</a> • <?php echo $claim->name ?></h3>
|
||||||
<h4><?php echo $claim->ClaimId ?></h4>
|
<h4><?php echo $claim->claim_id ?></h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="claims-body">
|
<div class="claims-body">
|
||||||
<div class="claim-info">
|
<div class="claim-info">
|
||||||
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
||||||
<?php if (!$claim->IsNSFW && strlen(trim($claim->ThumbnailUrl)) > 0): ?>
|
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
|
||||||
<img src="<?php echo htmlspecialchars($claim->ThumbnailUrl) ?>" alt="" />
|
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<?php if ($claim->ClaimType == 2): ?>
|
<?php if ($claim->claim_type == 2): ?>
|
||||||
<div class="label">Published By</div>
|
<div class="label">Published By</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
<?php if (isset($claim->Publisher)): ?>
|
<?php if (isset($claim->publisher)): ?>
|
||||||
<a href="lbry://<?php echo $claim->Publisher->Name ?>"><?php echo $claim->Publisher->Name ?></a>
|
<a href="lbry://<?php echo $claim->publisher->name ?>"><?php echo $claim->publisher->name ?></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<em>Anonymous</em>
|
<em>Anonymous</em>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -87,17 +87,17 @@ if (strlen(trim($desc)) == 0) {
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="label">Created On</div>
|
<div class="label">Created On</div>
|
||||||
<div class="value"><?php echo \DateTime::createFromFormat('U', $claim->TransactionTime > 0 ? $claim->TransactionTime : $claim->Created->format('U'))->format('j M Y H:i:s') ?> UTC</div>
|
<div class="value"><?php echo \DateTime::createFromFormat('U', $claim->transaction_time > 0 ? $claim->transaction_time : $claim->created_at->format('U'))->format('j M Y H:i:s') ?> UTC</div>
|
||||||
|
|
||||||
<div class="label">Transaction ID</div>
|
<div class="label">Transaction ID</div>
|
||||||
<div class="value"><a href="/tx/<?php echo $claim->TransactionHash ?>#output-<?php echo $claim->Vout ?>"><?php echo $claim->TransactionHash ?></a></div>
|
<div class="value"><a href="/tx/<?php echo $claim->transaction_hash_id ?>#output-<?php echo $claim->vout ?>"><?php echo $claim->transaction_hash_id ?></a></div>
|
||||||
|
|
||||||
<?php if ($claim->ClaimType == 2): ?>
|
<?php if ($claim->claim_type == 2): ?>
|
||||||
<div class="label half-width">Cost</div>
|
<div class="label half-width">Cost</div>
|
||||||
<div class="label half-width">Safe for Work</div>
|
<div class="label half-width">Safe for Work</div>
|
||||||
|
|
||||||
<div class="value half-width"><?php echo $cost ?></div>
|
<div class="value half-width"><?php echo $cost ?></div>
|
||||||
<div class="value half-width"><?php echo $claim->IsNSFW ? 'No' : 'Yes' ?></div>
|
<div class="value half-width"><?php echo $claim->is_nsfw ? 'No' : 'Yes' ?></div>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -105,11 +105,11 @@ if (strlen(trim($desc)) == 0) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="claim-metadata">
|
<div class="claim-metadata">
|
||||||
<?php if ($claim->ClaimType == 1): ?>
|
<?php if ($claim->claim_type == 2): ?>
|
||||||
<div class="title">Identity Claim</div>
|
<div class="title">Identity Claim</div>
|
||||||
<div class="desc">This is an identity claim.</div>
|
<div class="desc">This is an identity claim.</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="title"><?php echo $claim->Title ?></div>
|
<div class="title"><?php echo $claim->title ?></div>
|
||||||
<div class="desc"><?php echo str_replace("\n", '<br />', $desc) ?></div>
|
<div class="desc"><?php echo str_replace("\n", '<br />', $desc) ?></div>
|
||||||
|
|
||||||
<div class="details">
|
<div class="details">
|
||||||
|
@ -117,18 +117,20 @@ if (strlen(trim($desc)) == 0) {
|
||||||
<div class="label half-width">Content Type</div>
|
<div class="label half-width">Content Type</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="value half-width"><?php echo strlen(trim($claim->Author)) > 0 ? $claim->Author : '<em>Unspecified</em>' ?></div>
|
<div class="value half-width"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
|
||||||
<div class="value half-width"><?php echo strlen(trim($claim->ContentType)) > 0 ? $claim->ContentType : '<em>Unspecified</em>' ?></div>
|
<div class="value half-width"><?php echo strlen(trim($claim->content_type)) > 0 ? $claim->content_type : '<em>Unspecified</em>' ?></div>
|
||||||
|
|
||||||
<div class="label half-width">License</div>
|
<div class="label half-width">License</div>
|
||||||
<div class="label half-width">Language</div>
|
<div class="label half-width">Language</div>
|
||||||
|
|
||||||
<div class="value half-width"<?php if(strlen(trim($claim->License)) > 0): ?> title="<?php echo $claim->License ?>"<?php endif; ?>>
|
<!--
|
||||||
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
<div class="value half-width"<?php if(strlen(trim($claim->license)) > 0): ?> title="<?php echo $claim->license ?>"<?php endif; ?>>
|
||||||
|
<?php if (strlen(trim($claim->license_url)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
||||||
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
||||||
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="value half-width"><?php echo strlen(trim($claim->Language)) > 0 ? ($claim->Language == 'en' ? 'English' : '') : '<em>Unspecified</em>' ?></div>
|
-->
|
||||||
|
<div class="value half-width"><?php echo strlen(trim($claim->language)) > 0 ? ($claim->language == 'en' ? 'English' : '') : '<em>Unspecified</em>' ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="<?php echo $claim->getLbryLink() ?>" class="open-lbry-link">Open in LBRY</a>
|
<a href="<?php echo $claim->getLbryLink() ?>" class="open-lbry-link">Open in LBRY</a>
|
||||||
|
@ -140,7 +142,7 @@ if (strlen(trim($desc)) == 0) {
|
||||||
<?php if (count($moreClaims) > 0): ?>
|
<?php if (count($moreClaims) > 0): ?>
|
||||||
|
|
||||||
<div class="more-claims">
|
<div class="more-claims">
|
||||||
<h4><?php echo isset($claim->Publisher) ? 'More from the publisher' : 'Published by this identity' ?></h4>
|
<h4><?php echo isset($claim->publisher) ? 'More from the publisher' : 'Published by this identity' ?></h4>
|
||||||
|
|
||||||
<div class="claims-grid">
|
<div class="claims-grid">
|
||||||
<?php $idx = 1; $row = 1; $rowCount = ceil(count($moreClaims) / 3);
|
<?php $idx = 1; $row = 1; $rowCount = ceil(count($moreClaims) / 3);
|
||||||
|
@ -153,16 +155,16 @@ if (strlen(trim($desc)) == 0) {
|
||||||
|
|
||||||
$autoThumbText = $claim->getAutoThumbText();
|
$autoThumbText = $claim->getAutoThumbText();
|
||||||
$cost = '';
|
$cost = '';
|
||||||
if (isset($claim->Price) && $claim->Price > 0) {
|
if (isset($claim->price) && $claim->price > 0) {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->price) . ' LBC';
|
||||||
} else if (isset($claim->Fee) && strtolower($claim->FeeCurrency) === 'lbc') {
|
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Fee) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->Fee) . ' LBC';
|
||||||
}
|
}
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
$ctTag = $claim->getContentTag();
|
$ctTag = $claim->getContentTag();
|
||||||
?>
|
?>
|
||||||
<div data-id="<?php echo $claim->ClaimId ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
<div data-id="<?php echo $claim->claim_id ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
||||||
<?php if (strlen(trim($cost)) > 0): ?>
|
<?php if (strlen(trim($cost)) > 0): ?>
|
||||||
<div class="price-tag"><?php echo $cost ?></div>
|
<div class="price-tag"><?php echo $cost ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -171,53 +173,55 @@ if (strlen(trim($desc)) == 0) {
|
||||||
<?php if ($ctTag): ?>
|
<?php if ($ctTag): ?>
|
||||||
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($claim->IsNSFW): ?>
|
<?php if ($claim->is_nsfw): ?>
|
||||||
<div class="nsfw">NSFW</div>
|
<div class="nsfw">NSFW</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
||||||
<?php if (!$claim->IsNSFW && strlen(trim($claim->ThumbnailUrl)) > 0): ?>
|
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
|
||||||
<img src="<?php echo htmlspecialchars($claim->ThumbnailUrl) ?>" alt="" />
|
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
<div class="title" title="<?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '') ?>"><?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '<em>No Title</em>') ?></div>
|
<div class="title" title="<?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '') ?>"><?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '<em>No Title</em>') ?></div>
|
||||||
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
||||||
|
|
||||||
<div class="desc"><?php echo strlen(trim($claim->Description)) > 0 ? $claim->Description : '<em>No description available</em>' ?></div>
|
<div class="desc"><?php echo strlen(trim($claim->description)) > 0 ? $claim->description : '<em>No description available</em>' ?></div>
|
||||||
|
|
||||||
<div class="label half-width">Transaction</div>
|
<div class="label half-width">Transaction</div>
|
||||||
<div class="label half-width">Created</div>
|
<div class="label half-width">Created</div>
|
||||||
|
|
||||||
<div class="value half-width"><a href="/tx/<?php echo $claim->TransactionHash ?>#output-<?php echo $claim->Vout ?>" title="<?php echo $claim->TransactionHash ?>"><?php echo $claim->TransactionHash ?></a></div>
|
<div class="value half-width"><a href="/tx/<?php echo $claim->transaction_hash_id ?>#output-<?php echo $claim->vout ?>" title="<?php echo $claim->transaction_hash_id ?>"><?php echo $claim->transaction_hash_id ?></a></div>
|
||||||
<div class="value half-width" title="<?php echo $claim->Created->format('j M Y H:i:s') ?> UTC">
|
<div class="value half-width" title="<?php echo $claim->created_at->format('j M Y H:i:s') ?> UTC">
|
||||||
<?php echo \Carbon\Carbon::createFromTimestamp($claim->Created->format('U'))->diffForHumans(); ?>
|
<?php echo \Carbon\Carbon::createFromTimestamp($claim->created_at->format('U'))->diffForHumans(); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear spacer"></div>
|
<div class="clear spacer"></div>
|
||||||
|
|
||||||
<?php if ($claim->ClaimType == 2): ?>
|
<?php if ($claim->claim_type == 2): ?>
|
||||||
<div class="label half-width">Content Type</div>
|
<div class="label half-width">Content Type</div>
|
||||||
<div class="label half-width">Language</div>
|
<div class="label half-width">Language</div>
|
||||||
|
|
||||||
<div class="value half-width" title="<?php echo $claim->ContentType ?>"><?php echo $claim->ContentType ?></div>
|
<div class="value half-width" title="<?php echo $claim->content_type ?>"><?php echo $claim->content_type ?></div>
|
||||||
<div class="value half-width" title="<?php echo $claim->Language == 'en' ? 'English' : $claim->Language ?>"><?php echo $claim->Language == 'en' ? 'English' : $claim->Language ?></div>
|
<div class="value half-width" title="<?php echo $claim->language == 'en' ? 'English' : $claim->language ?>"><?php echo $claim->language == 'en' ? 'English' : $claim->language ?></div>
|
||||||
|
|
||||||
<div class="clear spacer"></div>
|
<div class="clear spacer"></div>
|
||||||
|
|
||||||
<div class="label half-width">Author</div>
|
<div class="label half-width">Author</div>
|
||||||
<div class="label half-width">License</div>
|
<div class="label half-width">License</div>
|
||||||
|
|
||||||
<div class="value half-width" title="<?php echo strlen(trim($claim->Author)) > 0 ? $claim->Author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->Author)) > 0 ? $claim->Author : '<em>Unspecified</em>' ?></div>
|
<div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
|
||||||
|
<!--
|
||||||
<div class="value half-width" title="<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '' ?>">
|
<div class="value half-width" title="<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '' ?>">
|
||||||
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
||||||
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
||||||
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -254,16 +258,16 @@ if (strlen(trim($desc)) == 0) {
|
||||||
}
|
}
|
||||||
$autoThumbText = $claim->getAutoThumbText();
|
$autoThumbText = $claim->getAutoThumbText();
|
||||||
$cost = '';
|
$cost = '';
|
||||||
if (isset($claim->Price) && $claim->Price > 0) {
|
if (isset($claim->price) && $claim->price > 0) {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->price) . ' LBC';
|
||||||
} else if (isset($claim->Fee) && strtolower($claim->FeeCurrency) === 'lbc') {
|
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||||
$cost = $this->Amount->formatCurrency($claim->Fee) . ' LBC';
|
$cost = $this->Amount->formatCurrency($claim->fee) . ' LBC';
|
||||||
}
|
}
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
$ctTag = $claim->getContentTag();
|
$ctTag = $claim->getContentTag();
|
||||||
?>
|
?>
|
||||||
<div data-id="<?php echo $claim->ClaimId ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
<div data-id="<?php echo $claim->claim_id ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
||||||
<?php if (strlen(trim($cost)) > 0): ?>
|
<?php if (strlen(trim($cost)) > 0): ?>
|
||||||
<div class="price-tag"><?php echo $cost ?></div>
|
<div class="price-tag"><?php echo $cost ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -272,53 +276,56 @@ if (strlen(trim($desc)) == 0) {
|
||||||
<?php if ($ctTag): ?>
|
<?php if ($ctTag): ?>
|
||||||
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($claim->IsNSFW): ?>
|
<?php if ($claim->is_nsfw): ?>
|
||||||
<div class="nsfw">NSFW</div>
|
<div class="nsfw">NSFW</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
||||||
<?php if (!$claim->IsNSFW && strlen(trim($claim->ThumbnailUrl)) > 0): ?>
|
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
|
||||||
<img src="<?php echo htmlspecialchars($claim->ThumbnailUrl) ?>" alt="" />
|
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
<div class="title" title="<?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '') ?>"><?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '<em>No Title</em>') ?></div>
|
<div class="title" title="<?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '') ?>"><?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '<em>No Title</em>') ?></div>
|
||||||
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
||||||
|
|
||||||
<div class="desc"><?php echo strlen(trim($claim->Description)) > 0 ? $claim->Description : '<em>No description available</em>' ?></div>
|
<div class="desc"><?php echo strlen(trim($claim->description)) > 0 ? $claim->description : '<em>No description available</em>' ?></div>
|
||||||
|
|
||||||
<div class="label half-width">Transaction</div>
|
<div class="label half-width">Transaction</div>
|
||||||
<div class="label half-width">Created</div>
|
<div class="label half-width">Created</div>
|
||||||
|
|
||||||
<div class="value half-width"><a href="/tx/<?php echo $claim->TransactionHash ?>#output-<?php echo $claim->Vout ?>" title="<?php echo $claim->TransactionHash ?>"><?php echo $claim->TransactionHash ?></a></div>
|
<div class="value half-width"><a href="/tx/<?php echo $claim->transaction_hash_id ?>#output-<?php echo $claim->Vout ?>" title="<?php echo $claim->transaction_hash_id ?>"><?php echo $claim->transaction_hash_id ?></a></div>
|
||||||
<div class="value half-width" title="<?php echo $claim->Created->format('j M Y H:i:s') ?> UTC">
|
<div class="value half-width" title="<?php echo $claim->created_at->format('j M Y H:i:s') ?> UTC">
|
||||||
<?php echo \Carbon\Carbon::createFromTimestamp($claim->TransactionTime > 0 ? $claim->TransactionTime : $claim->Created->format('U'))->diffForHumans(); ?>
|
<?php echo \Carbon\Carbon::createFromTimestamp($claim->transaction_time > 0 ? $claim->transaction_time : $claim->created_at->format('U'))->diffForHumans(); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear spacer"></div>
|
<div class="clear spacer"></div>
|
||||||
|
|
||||||
<?php if ($claim->ClaimType == 2): ?>
|
<?php if ($claim->claim_type == 2): ?>
|
||||||
<div class="label half-width">Content Type</div>
|
<div class="label half-width">Content Type</div>
|
||||||
<div class="label half-width">Language</div>
|
<div class="label half-width">Language</div>
|
||||||
|
|
||||||
<div class="value half-width" title="<?php echo $claim->ContentType ?>"><?php echo $claim->ContentType ?></div>
|
<div class="value half-width" title="<?php echo $claim->content_type ?>"><?php echo $claim->content_type ?></div>
|
||||||
<div class="value half-width" title="<?php echo $claim->Language == 'en' ? 'English' : $claim->Language ?>"><?php echo $claim->Language == 'en' ? 'English' : $claim->Language ?></div>
|
<div class="value half-width" title="<?php echo $claim->language == 'en' ? 'English' : $claim->language ?>"><?php echo $claim->language == 'en' ? 'English' : $claim->language ?></div>
|
||||||
|
|
||||||
<div class="clear spacer"></div>
|
<div class="clear spacer"></div>
|
||||||
|
|
||||||
<div class="label half-width">Author</div>
|
<div class="label half-width">Author</div>
|
||||||
<div class="label half-width">License</div>
|
<div class="label half-width">License</div>
|
||||||
|
|
||||||
<div class="value half-width" title="<?php echo strlen(trim($claim->Author)) > 0 ? $claim->Author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->Author)) > 0 ? $claim->Author : '<em>Unspecified</em>' ?></div>
|
<div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class="value half-width" title="<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '' ?>">
|
<div class="value half-width" title="<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '' ?>">
|
||||||
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
||||||
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
||||||
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -183,7 +183,8 @@
|
||||||
<div class="recent-claims">
|
<div class="recent-claims">
|
||||||
<h3>Recent Claims</h3>
|
<h3>Recent Claims</h3>
|
||||||
<a class="claim-explorer-link" href="/claims">Claims Explorer</a>
|
<a class="claim-explorer-link" href="/claims">Claims Explorer</a>
|
||||||
<?php $idx = 0; $a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow']; foreach ($recentClaims as $claim):
|
<?php $idx = 0; $a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
|
||||||
|
foreach ($recentClaims as $claim):
|
||||||
$idx++;
|
$idx++;
|
||||||
$autoThumbText = $claim->getAutoThumbText();
|
$autoThumbText = $claim->getAutoThumbText();
|
||||||
$link = $claim->name;
|
$link = $claim->name;
|
||||||
|
@ -226,7 +227,7 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="tx-link" href="/tx/<?php echo $claim->transaction_hash ?>#output-<?php echo $claim->vout ?>" target="_blank">Transaction</a>
|
<a class="tx-link" href="/tx/<?php echo $claim->transaction_hash_id ?>#output-<?php echo $claim->vout ?>" target="_blank">Transaction</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
|
@ -128,10 +128,10 @@
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($blocks as $block): ?>
|
<?php foreach ($blocks as $block): ?>
|
||||||
<tr data-height="<?php echo $block->Height ?>" data-time="<?php echo $block->BlockTime ?>">
|
<tr data-height="<?php echo $block->height ?>" data-time="<?php echo $block->block_time ?>">
|
||||||
<td><a href="/blocks/<?php echo $block->Height ?>" target="_blank"><?php echo $block->Height ?></a></td>
|
<td><a href="/blocks/<?php echo $block->height ?>" target="_blank"><?php echo $block->height ?></a></td>
|
||||||
<td><?php echo \Carbon\Carbon::createFromTimestamp($block->BlockTime)->diffForHumans(); ?></td>
|
<td><?php echo \Carbon\Carbon::createFromTimestamp($block->block_time)->diffForHumans(); ?></td>
|
||||||
<td class="right"><?php echo $block->TransactionCount ?></td>
|
<td class="right"><?php echo $block->transaction_count ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -156,9 +156,9 @@
|
||||||
<tr data-hash="<?php echo $tx->Hash ?>" data-time="<?php echo $tx->TxTime ?>">
|
<tr data-hash="<?php echo $tx->Hash ?>" data-time="<?php echo $tx->TxTime ?>">
|
||||||
<td class="w200"><div><a href="/tx/<?php echo $tx->Hash ?>" target="_blank"><?php echo $tx->Hash ?></a></div></td>
|
<td class="w200"><div><a href="/tx/<?php echo $tx->Hash ?>" target="_blank"><?php echo $tx->Hash ?></a></div></td>
|
||||||
<td><?php echo \Carbon\Carbon::createFromTimestamp($tx->TxTime)->diffForHumans(); ?></td>
|
<td><?php echo \Carbon\Carbon::createFromTimestamp($tx->TxTime)->diffForHumans(); ?></td>
|
||||||
<td class="right"><?php echo $tx->InputCount ?></td>
|
<td class="right"><?php echo $tx->input_count ?></td>
|
||||||
<td class="right"><?php echo $tx->OutputCount ?></td>
|
<td class="right"><?php echo $tx->output_count ?></td>
|
||||||
<td class="right"><?php echo number_format($tx->Value, 8, '.', '') ?> LBC</td>
|
<td class="right"><?php echo number_format($tx->value(), 8, '.', '') ?> LBC</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue