diff --git a/library/mysql.php b/library/mysql.php index d702a97..5976746 100755 --- a/library/mysql.php +++ b/library/mysql.php @@ -16,7 +16,7 @@ class MySQL { } } - public function getNamespaceName($namehash) { + public function getNamespaceValueByNS($ns) { try { @@ -33,7 +33,7 @@ class MySQL { LIMIT 1'); - $query->execute([$namehash]); + $query->execute([$ns]); return $query->rowCount() ? $query->fetch()['value'] : []; @@ -44,6 +44,28 @@ class MySQL { } } + public function getNamespaceHashByTX($txid) { + + try { + + $query = $this->_db->prepare('SELECT `namespace`.`hash` + + FROM `namespace` + JOIN `data` ON (`data`.`nameSpaceId` = `namespace`.`nameSpaceId`) + + WHERE `data`.`txid` = ?'); + + $query->execute([$txid]); + + return $query->rowCount() ? $query->fetch()['hash'] : []; + + } catch(PDOException $e) { + + trigger_error($e->getMessage()); + return false; + } + } + public function getData($namehash = false, $txid = false, $search = false, $start = 0, $limit = 10) { try { diff --git a/public/index.php b/public/index.php index 4e6f0f1..a57a611 100755 --- a/public/index.php +++ b/public/index.php @@ -41,8 +41,18 @@ if ($page > 0) { $db = new MySQL(); if ($ns) { - $namespaceValue = $db->getNamespaceName($ns); + + $namespaceHash = $ns; + $namespaceValue = $db->getNamespaceValueByNS($ns); + +} else if ($tx) { + + $namespaceHash = $db->getNamespaceHashByTX($tx); + $namespaceValue = $db->getNamespaceValueByNS($namespaceHash); + } else { + + $namespaceHash = false; $namespaceValue = false; } diff --git a/public/index.phtml b/public/index.phtml index 6a21556..37f44b4 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -5,23 +5,25 @@ - - - - <?php echo $namespaceValue ? $namespaceValue : $ns; ?> | PART <?php echo $page; ?> | KVAZAR - - - <?php echo $namespaceValue ? $namespaceValue : $ns; ?> | KVAZAR + + + + + <?php echo $namespaceValue ? $namespaceValue : $ns; ?> | PART <?php echo $page; ?> | KVAZAR + + + <?php echo $namespaceValue ? $namespaceValue : $ns; ?> | KVAZAR + - - KVAZAR | PART <?php echo $page; ?> - - - <?php echo $tx && isset($data[0]['key']) ? $data[0]['key'] : $tx; ?> | KVAZAR - - KVAZAR | Observe Kevacoin Universe - + + KVAZAR | PART <?php echo $page; ?> + + + <?php echo $tx && isset($data[0]['key']) ? $data[0]['key'] : $tx; ?> | <?php echo ($namespaceValue ? $namespaceValue : ($namespaceHash ? $namespaceHash : false)); ?> | KVAZAR + + KVAZAR | Observe Kevacoin Universe +