diff --git a/README.md b/README.md
index 5e7a740..ec295ed 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,50 @@
# kvazar-network webapp
-Web-oriented content exploring platform for Kevacoin Blockchain
+Web-oriented content exploring platform for Kevacoin Blockchain
-### demo
-https://kvazar.ml
+### requirements
+```
+php-7.4
+php-curl
+php-mbstring
+php-mysql
+php-sqlite
+php-pdo
+php-bcmath
+php-gd
+```
+#### database
+
+https://github.com/kvazar-network/database
+
+##### MySQL
+
+https://github.com/kvazar-network/webapp/tree/master
+
+##### SQLite
+
+https://github.com/kvazar-network/webapp/tree/sqlite
+
+#### crontab
+
+```
+0 0 * * * /path-to/php /path-to/crontab/sitemap.php > /dev/null 2>&1
+```
+
+### nginx sef_mode example
+
+```
+location / {
+ try_files $uri $uri/ =404 @sef;
+}
+
+location @sef {
+ rewrite ^(/.*)$ /?$1 last;
+}
+```
+
+### examples
+#### web
+https://kvazar.today
+
+#### yggdrasil
+[http://[203:7693:ae20:18a6:7689:cb63:c53d:43c6]](http://[203:7693:ae20:18a6:7689:cb63:c53d:43c6])
diff --git a/cache/index.html b/cache/index.html
new file mode 100644
index 0000000..e69de29
diff --git a/config-default.php b/config-default.php
index cfc0370..1515765 100644
--- a/config-default.php
+++ b/config-default.php
@@ -10,6 +10,11 @@ define('BASE_URL', '/');
define('PAGE_LIMIT', 10);
define('SEF_MODE', false);
+define('BASE_URL', 'https://kvazar.today');
+define('PAGE_LIMIT', 10);
+define('SEF_MODE', true);
+define('CACHE_ENABLED', false);
+
// Database
define('DB_NAME', 'kvazar.dat');
define('DB_USERNAME', '');
diff --git a/crontab/sitemap.php b/crontab/sitemap.php
new file mode 100644
index 0000000..5991e8b
--- /dev/null
+++ b/crontab/sitemap.php
@@ -0,0 +1,59 @@
+';
+$transaction .= '';
+
+$namespace = '';
+$namespace .= '';
+
+$namespaces = [];
+$transactions = [];
+
+foreach ($db->getData(false, false, false, 0, 1000000) as $value) {
+
+ if (!in_array($value['namehash'], $namespaces)) {
+ $namespace .= '' . BASE_URL . '/' . $value['namehash'] . '';
+ }
+
+
+ if (!in_array($value['namehash'], $transactions)) {
+ $transaction .= '' . BASE_URL . '/' . $value['txid'] . '';
+ }
+
+ $namespaces[] = $value['namehash'];
+ $transactions[] = $value['txid'];
+}
+
+$namespace .= '';
+$transaction .= '';
+
+$handle = fopen(dirname(__FILE__) . '/../public/sitemap.transaction.xml', 'w');
+fwrite($handle, $transaction);
+fclose($handle);
+
+
+$handle = fopen(dirname(__FILE__) . '/../public/sitemap.namespace.xml', 'w');
+fwrite($handle, $namespace);
+fclose($handle);
+
+
+// Sitemap
+$sitemap = '';
+$sitemap .= '';
+$sitemap .= ' ';
+$sitemap .= ' ' . BASE_URL . '/sitemap.namespace.xml';
+$sitemap .= ' ';
+$sitemap .= ' ';
+$sitemap .= ' ' . BASE_URL . '/sitemap.transaction.xml';
+$sitemap .= ' ';
+$sitemap .= '';
+
+$handle = fopen(dirname(__FILE__) . '/../public/sitemap.xml', 'w');
+fwrite($handle, $sitemap);
+fclose($handle);
diff --git a/library/icon.php b/library/icon.php
index aee6941..3daeddc 100755
--- a/library/icon.php
+++ b/library/icon.php
@@ -10,7 +10,7 @@ final class Icon {
private $_spriteZ = 800;
- public function generateImageResource($hash, $width, $height, $filter = false) {
+ public function generateImageResource($hash, $width, $height, $filter = false, $radius = 0) {
$this->_width = $width;
$this->_height = $height;
@@ -74,14 +74,27 @@ final class Icon {
imagecopyresampled($resized, $identicon, 0, 0, (imagesx($identicon) - $this->_spriteZ * 3) / 2, (imagesx($identicon) - $this->_spriteZ * 3) / 2, $this->_width, $this->_height, $this->_spriteZ * 3, $this->_spriteZ * 3);
- imagecolortransparent($resized, $bg);
-
if ($filter) {
+
imagefilter($resized, $filter);
}
+ if ($radius) {
+
+ imagearc($resized, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $bg);
+ imagefilltoborder($resized, 0, 0, $bg, $bg);
+ imagearc($resized, $this->_width-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $bg);
+ imagefilltoborder($resized, $this->_width-1, 0, $bg, $bg);
+ imagearc($resized, $radius-1, $this->_height-$radius, $radius*2, $radius*2, 90, 180, $bg);
+ imagefilltoborder($resized, 0, $this->_height-1, $bg, $bg);
+ imagearc($resized, $this->_width-$radius, $this->_height-$radius, $radius*2, $radius*2, 0, 90, $bg);
+ imagefilltoborder($resized, $this->_width-1, $this->_height-1, $bg, $bg);
+
+ imagecolortransparent($resized, $bg);
+ }
+
ob_start();
- imagejpeg($resized, null, 100);
+ imagepng($resized);
imagedestroy($resized);
return ob_get_clean();
}
diff --git a/library/sqlite.php b/library/sqlite.php
index de81c73..057d241 100644
--- a/library/sqlite.php
+++ b/library/sqlite.php
@@ -16,7 +16,7 @@ class SQLite {
}
}
- public function getNamespaceName($namehash) {
+ public function getNamespaceValueByNS($ns) {
try {
@@ -27,13 +27,13 @@ class SQLite {
WHERE `namespace`.`hash` = ?
AND `data`.`ns` = "1"
- AND `data`.`deleted` = "0"
+ -- AND `data`.`deleted` = "0" --
ORDER BY `data`.`blockId` DESC
LIMIT 1');
- $query->execute([$namehash]);
+ $query->execute([$ns]);
$result = $query->fetch();
@@ -46,6 +46,28 @@ class SQLite {
}
}
+ 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 {
@@ -65,7 +87,7 @@ class SQLite {
WHERE `data`.`txid` = ?
AND `data`.`ns` = "0"
- AND `data`.`deleted` = "0"
+ -- AND `data`.`deleted` = "0" --
ORDER BY `block`.`blockId` DESC
@@ -88,7 +110,7 @@ class SQLite {
WHERE `namespace`.`hash` = ?
AND `data`.`ns` = "0"
- AND `data`.`deleted` = "0"
+ -- AND `data`.`deleted` = "0" --
ORDER BY `block`.`blockId` DESC
@@ -116,7 +138,7 @@ class SQLite {
OR `data`.`txid` LIKE :search)
AND `data`.`ns` = "0"
- AND `data`.`deleted` = "0"
+ -- AND `data`.`deleted` = "0" --
ORDER BY `block`.`blockId` DESC
@@ -140,7 +162,7 @@ class SQLite {
JOIN `namespace` ON (`namespace`.`nameSpaceId` = `data`.`nameSpaceId`)
WHERE `data`.`ns` = "0"
- AND `data`.`deleted` = "0"
+ -- AND `data`.`deleted` = "0" --
ORDER BY `block`.`blockId` DESC
diff --git a/public/css/app.css b/public/css/app.css
index 5799f99..7ba85cf 100755
--- a/public/css/app.css
+++ b/public/css/app.css
@@ -1,8 +1,8 @@
button::-moz-focus-inner {
border: 0;
- padding: 0;
- margin-top:-2px;
- margin-bottom: -2px;
+ padding: 0;
+ margin-top:-2px;
+ margin-bottom: -2px;
}
* {
@@ -12,12 +12,19 @@ button::-moz-focus-inner {
input, button {
opacity: 0.8;
- color: #5A526C;
+ color: #18102d;
+ background: #BFBACC;
+ border: 0;
+ border-radius: 3px;
+ height: 18px;
+ line-height: 18px;
+ outline: none;
+ text-align: center;
}
body {
color: #E8E8E8;
- background-color: #000;
+ background-color: #18102d;
font-family: Sans-Serif, Arial;
font-size: 14px;
font-weight: normal;
@@ -88,19 +95,21 @@ img:hover {
}
.b-g::before {
- content: "";
- background-image: linear-gradient(to left, #9B94BF, #000);
- height: 1px;
- width: 360px;
- display: inline-block;
+ content: "";
+ background-image: linear-gradient(to left, #9B94BF, #18102d);
+ height: 1px;
+ width: 50%;
+ max-width: 360px;
+ display: inline-block;
}
.b-g::after {
- content: "";
- background-image: linear-gradient(to right, #9B94BF, #000);
- height: 1px;
- width: 360px;
- display: inline-block;
+ content: "";
+ background-image: linear-gradient(to right, #9B94BF, #18102d);
+ height: 1px;
+ width: 50%;
+ max-width: 360px;
+ display: inline-block;
}
.br-50 {
diff --git a/public/image.php b/public/image.php
index 7f97825..1ef64bf 100755
--- a/public/image.php
+++ b/public/image.php
@@ -1,11 +1,36 @@
generateImageResource(md5($_GET['hash']), 60, 60, false);
+ $width = isset($_GET['width']) ? (int) $_GET['width'] : 60;
+ $height = isset($_GET['height']) ? (int) $_GET['height'] : 60;
+
+ $radius = isset($_GET['radius']) ? (int) $_GET['radius'] : 0;
+
+ header("Content-Type: image/png");
+
+ if (CACHE_ENABLED) {
+
+ $filename = dirname(__FILE__) . '/../cache/' . $hash . '.png';
+
+ if (!file_exists($filename)) {
+
+ $icon = new Icon();
+
+ file_put_contents($filename, $icon->generateImageResource($hash, $width, $height, false, $radius));
+ }
+
+ echo file_get_contents($filename);
+
+ } else {
+
+ $icon = new Icon();
+
+ echo $icon->generateImageResource($hash, $width, $height, false, $radius);
+ }
}
diff --git a/public/index.php b/public/index.php
index e7fbe9b..28cb528 100755
--- a/public/index.php
+++ b/public/index.php
@@ -4,7 +4,7 @@ require_once('../config.php');
require_once('../library/icon.php');
require_once('../library/sqlite.php');
-$query = isset($_GET['q']) ? $_GET['q'] : false;
+$query = isset($_GET['q']) ? preg_replace('/[\W\D\S]+/', '', $_GET['q']) : false;
$ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : false;
$tx = isset($_GET['tx']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['tx']) : false;
$page = (int) isset($_GET['page']) ? $_GET['page'] : 0;
@@ -41,8 +41,18 @@ if ($page > 0) {
$db = new SQLite(DB_NAME, DB_USERNAME, DB_PASSWORD);
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 4cb16a1..0b80271 100755
--- a/public/index.phtml
+++ b/public/index.phtml
@@ -1,24 +1,28 @@
-
+
-
-
-
- | PART | KVAZAR
-
- | KVAZAR
+
+
+
+
+ | PART | KVAZAR
+
+
+ | KVAZAR
+
-
- KVAZAR | PART
-
- | KVAZAR
-
- KVAZAR | Observe Kevacoin Universe
-
+
+ KVAZAR | PART
+
+
+ | | KVAZAR
+
+ KVAZAR | TODAY
+
@@ -29,7 +33,7 @@
-
+
@@ -44,18 +48,18 @@
-
+
@@ -76,20 +80,20 @@
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..d08107c
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,2 @@
+User-Agent: *
+Sitemap: https://kvazar.today/sitemap.xml