Compare commits

...
8 Commits
Author SHA1 Message Date
Niko Storni 70c04cca47 fully upgrade phpcake 2018-12-03 18:09:10 -05:00
Niko Storni ed508182b5 fix more deprecations 2018-12-03 17:55:33 -05:00
Niko Storni 3d28c44fde fix deprecations
change default statusCode to 200
2018-12-03 17:52:22 -05:00
Niko Storni 6c61179546 add caching to api
update deprecated methods
swap qr library
2018-12-03 17:27:41 -05:00
Akinwale Ariwodola 3eab838967 composer package updates 2018-12-03 17:26:01 +00:00
Akinwale Ariwodola e8d3ead2c7 update home page style to accommodate new difficulty values 2018-12-03 18:23:59 +01:00
Akinwale Ariwodola 5983c61820 Merge pull request #46 from lbryio/hot-wallet
add additional hot wallet
2018-11-28 16:04:09 +01:00
marcdeb1 d98e9a3fb2 Improve search (#40)
* Added search page results
* Added getContentTag and getAutoThumbText to Claims model
* Order in search results
2018-11-28 16:03:41 +01:00
36 changed files with 1218 additions and 454 deletions

No files matched your search

+3 -3
View File
@@ -6,14 +6,14 @@
"license": "MIT",
"require": {
"php": ">=5.6",
"cakephp/cakephp": "3.4.*",
"cakephp/cakephp": "^3.6",
"mobiledetect/mobiledetectlib": "2.*",
"cakephp/migrations": "~1.0",
"cakephp/plugin-installer": "~1.0",
"mdanter/ecc": "^0.5.0",
"nesbot/carbon": "~1.18",
"endroid/qrcode": "^2.2.2",
"predis/predis": "^1.1.1"
"predis/predis": "^1.1.1",
"endroid/qr-code": "^3.5"
},
"require-dev": {
"psy/psysh": "@stable",
Generated
+842 -226
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -1,4 +1,6 @@
<?php
namespace App\config;
return [
/**
* Debug Level:
+4 -29
View File
@@ -15,22 +15,19 @@
// You can remove this if you are confident that your PHP version is sufficient.
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.', E_USER_ERROR);
}
trigger_error('Your PHP version must be equal or higher than 5.6.0 to}
/*
* You can remove this if you are confident you have intl installed.
*/
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.', E_USER_ERROR);
}
trigger_error('You must enable the intl extension to}
/*
* You can remove this if you are confident you have mbstring installed.
*/
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.', E_USER_ERROR);
}
trigger_error('You must enable the mbstring extension to}
/*
* Configure paths required to find CakePHP + general filepath
@@ -49,20 +46,6 @@ require __DIR__ . '/paths.php';
*/
require CORE_PATH . 'config' . DS . 'bootstrap.php';
use Cake\Cache\Cache;
use Cake\Console\ConsoleErrorHandler;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\Plugin;
use Cake\Database\Type;
use Cake\Datasource\ConnectionManager;
use Cake\Error\ErrorHandler;
use Cake\Log\Log;
use Cake\Mailer\Email;
use Cake\Network\Request;
use Cake\Utility\Inflector;
use Cake\Utility\Security;
/*
* Read configuration file and inject configuration into various
@@ -153,7 +136,7 @@ ConnectionManager::setConfig(Configure::consume('Datasources'));
Email::setConfigTransport(Configure::consume('EmailTransport'));
Email::setConfig(Configure::consume('Email'));
Log::setConfig(Configure::consume('Log'));
Security::salt(Configure::consume('Security.salt'));
Security::setSalt(Configure::consume('Security.salt'));
/*
* The default crypto extension in 3.0 is OpenSSL.
@@ -213,13 +196,5 @@ Type::build('timestamp')
*
*/
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
Configure::load('lbry');
+2
View File
@@ -12,6 +12,8 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace App\config;
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\Core\Plugin;
+2
View File
@@ -1,5 +1,7 @@
<?php
namespace App\config;
return [
'Lbry' => [
'RpcUrl' => 'http://user:password@127.0.0.1:9245',
+2
View File
@@ -11,6 +11,8 @@
* @since 3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace App\config;
/**
* Use the DS to separate the directories in other defines
+39
View File
@@ -0,0 +1,39 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.5.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
/*
* You can empty out this file, if you are certain that you match all requirements.
*/
/*
* You can remove this if you are confident that your PHP version is sufficient.
*/
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have intl installed.
*/
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have mbstring installed.
*/
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
+1 -11
View File
@@ -18,10 +18,6 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Plugin;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;
/**
* The default class to use for all routes
@@ -71,10 +67,4 @@ Router::scope('/', function (RouteBuilder $routes) {
$routes->connect('/api/v1/claims/browse', ['controller' => 'Claims', 'action' => 'apibrowse']);
//$routes->fallbacks(DashedRoute::class);
});
/**
* Load all plugin routes. See the Plugin documentation on
* how to customize the loading of plugin routes.
*/
Plugin::routes();
});
Regular → Executable
View File
File mode changed.
+14 -2
View File
@@ -12,9 +12,11 @@
* @since 3.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\BaseApplication;
use Cake\Routing\Middleware\AssetMiddleware;
@@ -40,13 +42,23 @@ class Application extends BaseApplication
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(ErrorHandlerMiddleware::class)
// Handle plugin/theme assets like CakePHP normally does.
->add(AssetMiddleware::class)
// Apply routing
->add(RoutingMiddleware::class);
return $middleware;
}
public function bootstrap()
{
parent::bootstrap(); // TODO: Change the autogenerated stub
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
$this->addPlugin(\DebugKit\Plugin::class);
}
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ class Installer
if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
return $arg;
}
throw new Exception('This is not a valid answer. Please choose Y or n.');
throw new \Exception('This is not a valid answer. Please choose Y or n.');
};
$setFolderPermissions = $io->askAndValidate(
'<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
+6 -5
View File
@@ -36,6 +36,7 @@ class AppController extends Controller
* e.g. `$this->loadComponent('Security');`
*
* @return void
* @throws \Exception
*/
public function initialize()
{
@@ -61,17 +62,17 @@ class AppController extends Controller
public function beforeRender(Event $event)
{
if (!array_key_exists('_serialize', $this->viewVars) &&
in_array($this->response->type(), ['application/json', 'application/xml'])
in_array($this->response->getType(), ['application/json', 'application/xml'])
) {
$this->set('_serialize', true);
}
}
protected function _jsonResponse($object = [], $statusCode = null)
protected function _jsonResponse($object = [], $statusCode = 200)
{
$this->response->statusCode($statusCode);
$this->response->type('json');
$this->response->body(json_encode($object));
$this->response->withStatus($statusCode);
$this->response->withType('json');
$this->response->withStringBody(json_encode($object));
}
protected function _jsonError($message, $statusCode = null) {
+5 -4
View File
@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Controller\AppController;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
@@ -11,10 +12,10 @@ class ClaimsController extends AppController {
$this->loadModel('Claims');
$pageLimit = 48;
$beforeId = intval($this->request->query('before'));
$afterId = intval($this->request->query('after'));
$sort = trim($this->request->query('sort'));
$nsfw = trim($this->request->query('nsfw'));
$beforeId = intval($this->request->getQuery('before'));
$afterId = intval($this->request->getQuery('after'));
$sort = trim($this->request->getQuery('sort'));
$nsfw = trim($this->request->getQuery('nsfw'));
switch ($sort) {
case 'popular':
// TODO: sort by upvote/downvote score
+2
View File
@@ -14,6 +14,7 @@
*/
namespace App\Controller;
use App\Controller\AppController;
use Cake\Event\Event;
/**
@@ -27,6 +28,7 @@ class ErrorController extends AppController
* Initialization hook method.
*
* @return void
* @throws \Exception
*/
public function initialize()
{
+62 -34
View File
@@ -2,17 +2,18 @@
namespace App\Controller;
use Mdanter\Ecc\EccFactory;
use Mdanter\Ecc\Crypto\Signature\Signer;
use Mdanter\Ecc\Serializer\PublicKey\PemPublicKeySerializer;
use Mdanter\Ecc\Serializer\PublicKey\DerPublicKeySerializer;
use Mdanter\Ecc\Serializer\Signature\DerSignatureSerializer;
use App\Controller\AppController;
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\LabelAlignment;
use Endroid\QrCode\QrCode;
use Mdanter\Ecc\Crypto\Signature\Signer;
use Mdanter\Ecc\EccFactory;
use Mdanter\Ecc\Serializer\PublicKey\DerPublicKeySerializer;
use Mdanter\Ecc\Serializer\PublicKey\PemPublicKeySerializer;
use Mdanter\Ecc\Serializer\Signature\DerSignatureSerializer;
class MainController extends AppController {
@@ -20,6 +21,8 @@ class MainController extends AppController {
const lbcPriceKey = 'lbc.price';
const txOutSetInfo = 'lbrcrd.tosi';
const bittrexMarketUrl = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC';
const blockchainTickerUrl = 'https://blockchain.info/ticker';
@@ -127,7 +130,7 @@ class MainController extends AppController {
// paginate claims
$offset = 0;
$pageLimit = 96;
$page = intval($this->request->query('page'));
$page = intval($this->request->getQuery('page'));
$conn = ConnectionManager::get('default');
$stmt = $conn->execute('SELECT COUNT(Id) AS Total FROM Claims');
@@ -328,10 +331,7 @@ class MainController extends AppController {
}
public function find() {
$criteria = $this->request->query('q');
if ($criteria === null || strlen(trim($criteria)) == 0) {
return $this->redirect('/');
}
$criteria = $this->request->getQuery('q');
$this->loadModel('Blocks');
$this->loadModel('Claims');
@@ -354,7 +354,7 @@ class MainController extends AppController {
// Claim ID
$claim = $this->Claims->find()->select(['ClaimId'])->where(['ClaimId' => $criteria])->first();
if ($claim) {
return $this->redirect('/claim/' . $claim->ClaimId);
return $this->redirect('/claims/' . $claim->ClaimId);
}
} else if (strlen(trim($criteria)) === 64) { // block or tx hash
// Try block hash first
@@ -369,16 +369,16 @@ class MainController extends AppController {
}
} else {
// finally, try exact claim name match
$claim = $this->Claims->find()->select(['ClaimId'])->where(['Name' => $criteria])->first();
if ($claim) {
return $this->redirect('/claims/' . $claim->ClaimId);
$claims = $this->Claims->find()->distinct(['Claims.ClaimId'])->where(['Name' => $criteria])->order(['Claims.Created' => 'DESC'])->limit(10)->toArray();
if (count($claims) == 1) {
return $this->redirect('/claims/' . $claims[0]->ClaimId);
}
else {
$this->set('claims', $claims);
}
}
// Not found, redirect to index
return $this->redirect('/');
}
public function blocks($height = null) {
$this->loadModel('Blocks');
@@ -386,7 +386,7 @@ class MainController extends AppController {
// paginate blocks
$offset = 0;
$pageLimit = 50;
$page = intval($this->request->query('page'));
$page = intval($this->request->getQuery('page'));
$conn = ConnectionManager::get('default');
$stmt = $conn->execute('SELECT COUNT(Id) AS Total FROM Blocks');
@@ -454,7 +454,7 @@ class MainController extends AppController {
$this->loadModel('Outputs');
$this->loadModel('Claims');
$sourceAddress = $this->request->query('address');
$sourceAddress = $this->request->getQuery('address');
$tx = $this->Transactions->find()->select(
['Id', 'BlockHash', 'InputCount', 'OutputCount', 'Hash', 'Value', 'TransactionTime', 'TransactionSize', 'Created', 'Version', 'LockTime', 'Raw'])->where(['Hash' => $hash])->first();
@@ -551,7 +551,7 @@ class MainController extends AppController {
$offset = 0;
$pageLimit = 50;
$numTransactions = 0;
$page = intval($this->request->query('page'));
$page = intval($this->request->getQuery('page'));
$canTag = false;
$totalRecvAmount = 0;
@@ -584,7 +584,7 @@ class MainController extends AppController {
$stmt = $conn->execute('SELECT COUNT(TransactionId) AS Total FROM TransactionsAddresses WHERE AddressId = ?', [$addressId]);
$count = $stmt->fetch(\PDO::FETCH_OBJ);
$numTransactions = $count->Total;
$all = $this->request->query('all');
$all = $this->request->getQuery('all');
if ($all === 'true') {
$offset = 0;
$pageLimit = $numTransactions;
@@ -700,17 +700,47 @@ class MainController extends AppController {
}
}
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;
protected function _gettxoutsetinfo() {
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$txOutSetInfo = new \stdClass();
$txOutSetInfo->time = $now->format('c');
$shouldRefreshSet = false;
if (!$this->redis) {
$shouldRefreshSet = true;
} else {
if (!$this->redis->exists(self::txOutSetInfo)) {
$shouldRefreshSet = true;
} else {
$txOutSetInfo = json_decode($this->redis->get(self::txOutSetInfo));
$lastTOSIDt = new \DateTime($txOutSetInfo->time);
$diff = $now->diff($lastTOSIDt);
$diffMinutes = $diff->i;
if ($diffMinutes >= 15 || $txOutSetInfo->set == 0) { // 15 minutes (or if the price is 0)
$shouldRefreshSet = true;
}
}
return $res->result;
} catch (\Exception $e) {
return 'N/A';
}
if ($shouldRefreshSet) {
$req = ['method' => 'gettxoutsetinfo', 'params' => []];
try {
$res = json_decode(self::curl_json_post(self::$rpcurl, json_encode($req)));
if (!isset($res->result)) {
$txOutSetInfo->tosi = 'N/A';
}
$txOutSetInfo->tosi = $res->result;
} catch (\Exception $e) {
$txOutSetInfo->tosi = 'N/A';
}
$txOutSetInfo->time = $now->format('c');
if ($this->redis) {
$this->redis->set(self::txOutSetInfo, json_encode($txOutSetInfo));
}
}
return (isset($txOutSetInfo->tosi)) ? $txOutSetInfo->tosi : 'N/A';
}
public function apistatus() {
@@ -939,6 +969,4 @@ class MainController extends AppController {
// Close any open file handle
return $response;
}
}
?>
}
+4 -3
View File
@@ -14,9 +14,10 @@
*/
namespace App\Controller;
use App\Controller\AppController;
use Cake\Core\Configure;
use Cake\Network\Exception\ForbiddenException;
use Cake\Network\Exception\NotFoundException;
use Cake\Http\Exception\ForbiddenException;
use Cake\Http\Exception\NotFoundException;
use Cake\View\Exception\MissingTemplateException;
/**
@@ -33,7 +34,7 @@ class PagesController extends AppController
* Displays a view
*
* @param string ...$path Path segments.
* @return void|\Cake\Network\Response
* @return \Cake\Http\Response
* @throws \Cake\Network\Exception\ForbiddenException When a directory traversal attempt.
* @throws \Cake\Network\Exception\NotFoundException When the view file could not
* be found or \Cake\View\Exception\MissingTemplateException in debug mode.
+1 -1
View File
@@ -2,9 +2,9 @@
namespace App\Model\Behavior;
use Cake\Event\Event;
use Cake\ORM\Behavior;
use Cake\ORM\Entity;
use Cake\Event\Event;
use Cake\Routing\Router;
class SimpleAuditBehavior extends Behavior {
+27
View File
@@ -18,6 +18,33 @@ class Claim extends Entity {
$link = '/claims/' . $this->ClaimId;
return $link;
}
function getContentTag() {
$ctTag = null;
if (substr($this->ContentType, 0, 5) === 'audio') {
$ctTag = 'audio';
} else if (substr($this->ContentType, 0, 5) === 'video') {
$ctTag = 'video';
} else if (substr($this->ContentType, 0, 5) === 'image') {
$ctTag = 'image';
}
if (!$ctTag && $this->ClaimType == 1) {
$ctTag = 'identity';
}
return $ctTag;
}
function getAutoThumbText() {
$autoThumbText = '';
if ($this->ClaimType == 1) {
$autoThumbText = strtoupper(substr($this->Name, 1, min( strlen($this->Name), 3 )));
} else {
$str = (strlen(trim($this->Title)) > 0) ? $this->Title : $this->Name;
$autoThumbText = strtoupper(substr($str, 0, min (strlen($str), 2 )));
}
return $autoThumbText;
}
}
?>
+2 -2
View File
@@ -8,8 +8,8 @@ class AddressesTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Addresses');
$this->setPrimaryKey('Id');
$this->setTable('Addresses');
$this->addBehavior('SimpleAudit');
}
+3 -5
View File
@@ -8,11 +8,9 @@ class BlocksTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Blocks');
$this->setPrimaryKey('Id');
$this->setTable('Blocks');
$this->addBehavior('SimpleAudit');
}
}
?>
}
+3 -5
View File
@@ -8,11 +8,9 @@ class ClaimStreamsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('ClaimStreams');
$this->setPrimaryKey('Id');
$this->setTable('ClaimStreams');
//$this->addBehavior('SimpleAudit');
}
}
?>
}
+3 -5
View File
@@ -8,8 +8,8 @@ class ClaimsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Claims');
$this->setPrimaryKey('Id');
$this->setTable('Claims');
//$this->addBehavior('SimpleAudit');
$this->addAssociations([
@@ -31,6 +31,4 @@ class ClaimsTable extends Table {
]
]);
}
}
?>
}
+3 -5
View File
@@ -8,8 +8,8 @@ class InputsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Inputs');
$this->setPrimaryKey('Id');
$this->setTable('Inputs');
$this->addBehavior('SimpleAudit');
@@ -25,6 +25,4 @@ class InputsTable extends Table {
]
]);
}
}
?>
}
+3 -5
View File
@@ -8,8 +8,8 @@ class OutputsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Outputs');
$this->setPrimaryKey('Id');
$this->setTable('Outputs');
$this->addBehavior('SimpleAudit');
@@ -32,6 +32,4 @@ class OutputsTable extends Table {
]
]);
}
}
?>
}
+3 -5
View File
@@ -8,9 +8,7 @@ class PriceHistoryTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('PriceHistory');
$this->setPrimaryKey('Id');
$this->setTable('PriceHistory');
}
}
?>
}
+3 -5
View File
@@ -8,11 +8,9 @@ class TagAddressRequestsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('TagAddressRequests');
$this->setPrimaryKey('Id');
$this->setTable('TagAddressRequests');
$this->addBehavior('SimpleAudit');
}
}
?>
}
+3 -5
View File
@@ -8,11 +8,9 @@ class TransactionsTable extends Table {
public function initialize(array $config) {
parent::initialize($config);
$this->primaryKey('Id');
$this->table('Transactions');
$this->setPrimaryKey('Id');
$this->setTable('Transactions');
$this->addBehavior('SimpleAudit');
}
}
?>
}
+1 -3
View File
@@ -219,6 +219,4 @@ class AuxShell extends Shell {
return $response;
}
}
?>
}
+12 -12
View File
@@ -1339,8 +1339,8 @@ print_r($response); print_r($json);
$inputs[] = [
'PrevoutHash' => $in['txid'],
'PrevoutN' => $in['vout'],
'ScriptSigAsm' => $in['scriptSig']['asm'],
'ScriptSigHex' => $in['scriptSig']['hex'],
'ScriptSigAsm' => $in->scriptSig['asm'],
'ScriptSigHex' => $in->scriptSig['hex'],
'Sequence' => $in['sequence']
];
}
@@ -1350,16 +1350,16 @@ print_r($response); print_r($json);
$outputs[] = [
'Vout' => $out['vout'],
'Value' => bcdiv($out['value'], 100000000, 8),
'Type' => isset($out['scriptPubKey']['type']) ? $out['scriptPubKey']['type'] : '',
'ScriptPubKeyAsm' => isset($out['scriptPubKey']['asm']) ? $out['scriptPubKey']['asm'] : '',
'ScriptPubKeyHex' => isset($out['scriptPubKey']['hex']) ? $out['scriptPubKey']['hex'] : '',
'RequiredSignatures' => isset($out['scriptPubKey']['reqSigs']) ? $out['scriptPubKey']['reqSigs'] : '',
'Hash160' => isset($out['scriptPubKey']['hash160']) ? $out['scriptPubKey']['hash160'] : '',
'Addresses' => isset($out['scriptPubKey']['addresses']) ? json_encode($out['scriptPubKey']['addresses']) : null
'Type' => isset($out->scriptPubKey['type']) ? $out->scriptPubKey['type'] : '',
'ScriptPubKeyAsm' => isset($out->scriptPubKey['asm']) ? $out->scriptPubKey['asm'] : '',
'ScriptPubKeyHex' => isset($out->scriptPubKey['hex']) ? $out->scriptPubKey['hex'] : '',
'RequiredSignatures' => isset($out->scriptPubKey['reqSigs']) ? $out->scriptPubKey['reqSigs'] : '',
'Hash160' => isset($out->scriptPubKey['hash160']) ? $out->scriptPubKey['hash160'] : '',
'Addresses' => isset($out->scriptPubKey['addresses']) ? json_encode($out->scriptPubKey['addresses']) : null
];
if (isset($out['scriptPubKey']['addresses'])) {
foreach ($out['scriptPubKey']['addresses'] as $address) {
if (isset($out->scriptPubKey['addresses'])) {
foreach ($out->scriptPubKey['addresses'] as $address) {
$addresses[$address] = $address;
}
}
@@ -1983,10 +1983,10 @@ print_r($response); print_r($json);
$return = $define[$tx_type];
if ($tx_type === 'p2pk') {
$return['hash160'] = self::hash160($data[$define[$tx_type]['data_index_for_hash']]);
$return['addresses'][0] = self::hash160_to_address($return['hash160'], self::pubKeyAddress[0]);
$return->addresses[0] = self::hash160_to_address($return['hash160'], self::pubKeyAddress[0]);
} else {
$return['hash160'] = $data[$define[$tx_type]['data_index_for_hash']];
$return['addresses'][0] = self::hash160_to_address($return['hash160'], ($tx_type === 'p2sh') ? self::scriptAddress[0] : self::pubKeyAddress[0]); // TODO: Pay to claim transaction?
$return->addresses[0] = self::hash160_to_address($return['hash160'], ($tx_type === 'p2sh') ? self::scriptAddress[0] : self::pubKeyAddress[0]); // TODO: Pay to claim transaction?
}
unset($return['data_index_for_hash']);
}
+6 -45
View File
@@ -39,12 +39,7 @@
<?php if (isset($claim)):
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
$autoThumbText = '';
if ($claim->ClaimType == 1) { $autoThumbText = strtoupper(substr($claim->Name, 1, min( strlen($claim->Name), 10 ))); } else {
$str = str_replace(' ', '', (strlen(trim($claim->Title)) > 0) ? $claim->Title : $claim->Name);
$autoThumbText = strtoupper(mb_substr($str, 0, min( strlen($str), 10 )));
}
$autoThumbText = $claim->getAutoThumbText();
$cost = 'Free';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
@@ -115,7 +110,7 @@ if (strlen(trim($desc)) == 0) {
<div class="desc">This is an identity claim.</div>
<?php else: ?>
<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="label half-width">Author</div>
@@ -156,7 +151,7 @@ if (strlen(trim($desc)) == 0) {
$row++;
}
$autoThumbText = '';
$autoThumbText = $claim->getAutoThumbText();
$cost = '';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
@@ -165,24 +160,7 @@ if (strlen(trim($desc)) == 0) {
}
// content type
$ctTag = null;
if (substr($claim->ContentType, 0, 5) === 'audio') {
$ctTag = 'audio';
} else if (substr($claim->ContentType, 0, 5) === 'video') {
$ctTag = 'video';
} else if (substr($claim->ContentType, 0, 5) === 'image') {
$ctTag = 'image';
}
if (!$ctTag && $claim->ClaimType == 1) {
$ctTag = 'identity';
}
if ($claim->ClaimType == 1) { $autoThumbText = strtoupper(substr($claim->Name, 1, min( strlen($claim->Name), 10 ))); } else {
$str = str_replace(' ', '', (strlen(trim($claim->Title)) > 0) ? $claim->Title : $claim->Name);
$autoThumbText = strtoupper(mb_substr($str, 0, min( strlen($str), 10 )));
}
$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; ?>">
<?php if (strlen(trim($cost)) > 0): ?>
@@ -274,7 +252,7 @@ if (strlen(trim($desc)) == 0) {
if ($idx % 3 == 0) {
$row++;
}
$autoThumbText = '';
$autoThumbText = $claim->getAutoThumbText();
$cost = '';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
@@ -283,24 +261,7 @@ if (strlen(trim($desc)) == 0) {
}
// content type
$ctTag = null;
if (substr($claim->ContentType, 0, 5) === 'audio') {
$ctTag = 'audio';
} else if (substr($claim->ContentType, 0, 5) === 'video') {
$ctTag = 'video';
} else if (substr($claim->ContentType, 0, 5) === 'image') {
$ctTag = 'image';
}
if (!$ctTag && $claim->ClaimType == 1) {
$ctTag = 'identity';
}
if ($claim->ClaimType == 1) { $autoThumbText = strtoupper(substr($claim->Name, 1, min( strlen($claim->Name), 10 ))); } else {
$str = str_replace(' ', '', (strlen(trim($claim->Title)) > 0) ? $claim->Title : $claim->Name);
$autoThumbText = strtoupper(mb_substr($str, 0, min( strlen($str), 10 )));
}
$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; ?>">
<?php if (strlen(trim($cost)) > 0): ?>
+134
View File
@@ -0,0 +1,134 @@
<?php $this->start('script'); ?>
<script type="text/javascript">
var resizeCards = function() {
var claimInfo = $('.claim-info');
var claimMtdt = $('.claim-metadata');
if (claimMtdt.outerHeight() < claimInfo.outerHeight()) {
claimMtdt.outerHeight(claimInfo.outerHeight());
} else if (claimInfo.outerHeight() < claimMtdt.outerHeight()) {
claimInfo.outerHeight(claimMtdt.outerHeight());
}
};
window.onload = function() {
resizeCards();
};
$(document).ready(function() {
resizeCards();
$('.claim-grid-item img,.claim-info img').on('error', function() {
var img = $(this);
var parent = img.parent();
var text = parent.attr('data-autothumb');
img.remove();
parent.append(
$('<div></div>').attr({'class': 'autothumb' }).text(text)
);
});
$(document).on('click', '.claim-grid-item', function() {
var id = $(this).attr('data-id');
location.href = '/claims/' + id;
});
});
</script>
<?php $this->end(); ?>
<?php echo $this->element('header') ?>
<?php $this->assign('title', 'Search Results') ?>
<div class="claims-head">
<h3>Search results</h3>
</div>
<div class="claims-grid">
<?php if (isset($claims) && count($claims) > 0): ?>
<?php
$idx = 1;
$row = 1;
$rowCount = ceil(count($claims) / 3);
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
foreach ($claims as $claim):
$last_row = ($row == $rowCount);
if ($idx % 3 == 0) {
$row++;
}
$autoThumbText = $claim->getAutoThumbText();
$cost = '';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
} else if (isset($claim->Fee) && strtolower($claim->FeeCurrency) === 'lbc') {
$cost = $this->Amount->formatCurrency($claim->Fee) . ' LBC';
}
// content type
$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; ?>">
<?php if (strlen(trim($cost)) > 0): ?>
<div class="price-tag"><?php echo $cost ?></div>
<?php endif; ?>
<div class="tags">
<?php if ($ctTag): ?>
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
<?php endif; ?>
<?php if ($claim->IsNSFW): ?>
<div class="nsfw">NSFW</div>
<?php endif; ?>
</div>
<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): ?>
<img src="<?php echo htmlspecialchars($claim->ThumbnailUrl) ?>" alt="" />
<?php else: ?>
<div class="autothumb"><?php echo $autoThumbText ?></div>
<?php endif; ?>
</div>
<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="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="label half-width">Transaction</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" title="<?php echo $claim->Created->format('j M Y H:i:s') ?> UTC">
<?php echo \Carbon\Carbon::createFromTimestamp($claim->Created->format('U'))->diffForHumans(); ?>
</div>
<div class="clear spacer"></div>
<?php if ($claim->ClaimType == 2): ?>
<div class="label half-width">Content Type</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->Language == 'en' ? 'English' : $claim->Language ?>"><?php echo $claim->Language == 'en' ? 'English' : $claim->Language ?></div>
<div class="clear spacer"></div>
<div class="label half-width">Author</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->License)) > 0 ? $claim->License : '' ?>">
<?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 if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php $idx++; endforeach; ?>
<?php else: ?>
<div class="no-results">No results were found.</div>
<?php endif; ?>
<div class="clear"></div>
</div>
<?php echo $this->element('pagination') ?>
+7 -23
View File
@@ -113,7 +113,7 @@
<div class="home-container">
<div class="home-container-cell">
<div class="main">
<div class="title">LBRY Block Explorer</div><br>
<div class="title">LBRY Block Explorer</div><br/>
<form method="get" action="/find">
<input class="search-input" name="q" type="text" placeholder="Enter a block height or hash, claim id or name, transaction hash or address" />
<div class="ctls">
@@ -127,22 +127,22 @@
</div>
<div class="stats">
<div class="box">
<div class="box box-20">
<div class="title">Block Height</div>
<div class="value"><?php echo $recentBlocks[0]->Height ?></div>
</div>
<div class="box">
<div class="box box-30">
<div class="title">Difficulty</div>
<div class="value" title="<?php echo $recentBlocks[0]->Difficulty ?>"><?php echo number_format($recentBlocks[0]->Difficulty, 2, '.', '') ?></div>
</div>
<div class="box">
<div class="box box-30">
<div class="title">Network</div>
<div class="value"><?php echo $hashRate ?></div>
</div>
<div class="box last">
<div class="box box-20 last">
<div class="title">Price</div>
<div class="value"><?php echo $lbcUsdPrice ?></div>
</div>
@@ -185,7 +185,7 @@
<a class="claim-explorer-link" href="/claims">Claims Explorer</a>
<?php $idx = 0; $a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow']; foreach ($recentClaims as $claim):
$idx++;
$autoThumbText = '';
$autoThumbText = $claim->getAutoThumbText();
$link = $claim->Name;
$rawLink = $claim->Name;
if (isset($claim->Publisher->Name)) {
@@ -196,23 +196,7 @@
$rawLink = 'lbry://' . $rawLink;
// content type
$ctTag = null;
if (substr($claim->ContentType, 0, 5) === 'audio') {
$ctTag = 'audio';
} else if (substr($claim->ContentType, 0, 5) === 'video') {
$ctTag = 'video';
} else if (substr($claim->ContentType, 0, 5) === 'image') {
$ctTag = 'image';
}
if (!$ctTag && $claim->ClaimType == 1) {
$ctTag = 'identity';
}
if ($claim->ClaimType == 1) { $autoThumbText = strtoupper(substr($claim->Name, 1, min( strlen($claim->Name), 3 ))); } else {
$str = (strlen(trim($claim->Title)) > 0) ? $claim->Title : $claim->Name;
$autoThumbText = strtoupper(substr($str, 0, min (strlen($str), 2 )));
}
$ctTag = $claim->getContentTag();
?>
<div data-id="<?php echo $claim->ClaimId ?>" class="claim-box<?php if ($idx == 5): ?> last<?php endif; ?>">
<div class="tags">
+4 -4
View File
@@ -92,14 +92,14 @@
$setAddressIds = [];
foreach ($inputs as $in):
?>
<div id="input-<?php echo $in->Id ?>" class="input <?php if (isset($in['InputAddresses']) && count($in['InputAddresses']) > 0 && $in['InputAddresses'][0]->Address == $sourceAddress): ?>is-source<?php endif; ?>">
<div id="input-<?php echo $in->Id ?>" class="input <?php if (isset($in['InputAddresses']) && count($in['InputAddresses']) > 0 && $in->inputAddresses[0]->Address == $sourceAddress): ?>is-source<?php endif; ?>">
<?php if ($in['IsCoinbase']): ?>
<div>Block Reward (New Coins)</div>
<?php else: ?>
<?php if (strlen(trim($in->Value)) == 0): ?>
<div>Incomplete data</div>
<?php else:
$addr = $in['InputAddresses'][0];
$addr = $in->inputAddresses[0];
if (!isset($setAddressIds[$addr->Address])):
$setAddressIds[$addr->Address] = 1; ?>
@@ -134,7 +134,7 @@
<?php
foreach ($outputs as $out): ?>
<div id="output-<?php echo $out->Vout ?>" class="output <?php if (isset($out['OutputAddresses']) && count($out['OutputAddresses']) > 0 && $out['OutputAddresses'][0]->Address == $sourceAddress): ?>is-source<?php endif; ?>">
<div id="output-<?php echo $out->Vout ?>" class="output <?php if (isset($out['OutputAddresses']) && count($out['OutputAddresses']) > 0 && $out->outputAddresses[0]->Address == $sourceAddress): ?>is-source<?php endif; ?>">
<div class="labels">
<?php if($out->Claim && ($out->IsClaim or $out->IsSupportClaim or $out->IsUpdateClaim)): ?><a class="view-claim" href="<?php echo $out->Claim->getExplorerLink() ?>">View</a><?php endif; ?>
<?php if($out->IsSupportClaim): ?><div class="support">SUPPORT</div><?php endif; ?>
@@ -145,7 +145,7 @@
<?php if (strlen(trim($out['Value'])) == 0): ?>
<div>Incomplete data</div>
<?php else:
$addr = $out['OutputAddresses'][0];
$addr = $out->outputAddresses[0];
if (!isset($setAddressIds[$addr->Address])):
$setAddressIds[$addr->Address] = 1; ?>
+5 -5
View File
@@ -59,8 +59,8 @@ $cakeDescription = 'CakePHP: the rapid development PHP framework';
<div id="url-rewriting-warning" class="alert url-rewriting">
<ul>
<li class="bullet problem">
URL rewriting is not properly configured on your server.<br />
1) <a target="_blank" href="http://book.cakephp.org/3.0/en/installation.html#url-rewriting">Help me configure it</a><br />
URL rewriting is not properly configured on your server.<br/>
1) <a target="_blank" href="http://book.cakephp.org/3.0/en/installation.html#url-rewriting">Help me configure it</a><br/>
2) <a target="_blank" href="http://book.cakephp.org/3.0/en/development/configuration.html#general-configuration">I don't / can't use URL rewriting</a>
</li>
</ul>
@@ -139,7 +139,7 @@ $cakeDescription = 'CakePHP: the rapid development PHP framework';
if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes();
if (isset($errorMsg['message'])):
$errorMsg .= '<br />' . $attributes['message'];
$errorMsg .= '<br/>' . $attributes['message'];
endif;
endif;
}
@@ -148,7 +148,7 @@ $cakeDescription = 'CakePHP: the rapid development PHP framework';
<?php if ($connected): ?>
<li class="bullet success">CakePHP is able to connect to the database.</li>
<?php else: ?>
<li class="bullet problem">CakePHP is NOT able to connect to the database.<br /><?= $errorMsg ?></li>
<li class="bullet problem">CakePHP is NOT able to connect to the database.<br/><?= $errorMsg ?></li>
<?php endif; ?>
</ul>
</div>
@@ -188,7 +188,7 @@ $cakeDescription = 'CakePHP: the rapid development PHP framework';
<div class="columns large-12 text-center">
<h3 class="more">More about Cake</h3>
<p>
CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Front Controller and MVC.<br />
CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Front Controller and MVC.<br/>
Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.
</p>
</div>
+4 -1
View File
@@ -88,6 +88,7 @@ border-radius: 0 8px 8px 0 }
.claims-grid .claim-grid-item .link { font-size: 95%; font-weight: 300; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; line-height: 20px; height: 20px; margin-top: 6px }
.claims-grid .claim-grid-item .label { font-size: 80%; color: #1e88e5 }
.claims-grid .no-results {font-style: italic; width: 100%; height: 300px; text-align: center; font-size: 90%; color: grey; }
.claims-grid .claim-grid-item .value { font-weight: 300; word-break: break-word; word-wrap: break-word; font-size: 95%; line-height: 24px; height: 24px }
.claims-grid .claim-grid-item .half-width { width: 155px; float: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px }
.claims-grid .claim-grid-item .spacer { height: 16px }
@@ -219,7 +220,9 @@ footer .content .page-time { position: absolute; right: 12px; bottom: 0px; paddi
.stats-main h3 { font-weight: 300; margin: 0 0 12px 0 }
.stats { width: 1000px; margin: 0 auto 48px auto; box-shadow: 0 2px 6px rgba(0,0,0,.175); border: 1px solid rgba(0,0,0,.15); padding: 24px; cursor: default }
.stats .box { padding: 24px 0; border-right: 1px solid #ccc; float: left; text-align: center; width: 25% }
.stats .box { padding: 24px 0; border-right: 1px solid #ccc; float: left; text-align: center }
.stats .box-20 { width: 20% }
.stats .box-30 { width: 30% }
.stats .box .title { color: #1e88e5; font-size: 90% }
.stats .box .value { font-size: 180%; font-weight: 300; margin-top: 8px }
.stats .box.last { border-color: transparent }