From 808b11fb7d620ba689a36f0c13778b8f38e9761a Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 8 Aug 2021 13:10:00 +0300 Subject: [PATCH 01/43] init sqlite edition --- config-default.php | 8 +++----- library/{mysql.php => sqlite.php} | 6 +++--- public/index.php | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) rename library/{mysql.php => sqlite.php} (96%) mode change 100755 => 100644 diff --git a/config-default.php b/config-default.php index 469c419..cfc0370 100644 --- a/config-default.php +++ b/config-default.php @@ -6,13 +6,11 @@ ini_set('display_startup_errors', '1'); error_reporting(E_ALL); // Application -define('BASE_URL', 'https://kvazar.ml'); +define('BASE_URL', '/'); define('PAGE_LIMIT', 10); -define('SEF_MODE', true); +define('SEF_MODE', false); // Database -define('DB_HOST', 'localhost'); -define('DB_PORT', '3306'); -define('DB_NAME', ''); +define('DB_NAME', 'kvazar.dat'); define('DB_USERNAME', ''); define('DB_PASSWORD', ''); diff --git a/library/mysql.php b/library/sqlite.php old mode 100755 new mode 100644 similarity index 96% rename from library/mysql.php rename to library/sqlite.php index fa9c3b3..0b2a779 --- a/library/mysql.php +++ b/library/sqlite.php @@ -1,12 +1,12 @@ _db = new PDO('mysql:dbname=' . DB_NAME . ';host=' . DB_HOST . ';port=' . DB_PORT . ';charset=utf8', DB_USERNAME, DB_PASSWORD, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']); + $this->_db = new PDO('sqlite:' . $database, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']); $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->_db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->_db->setAttribute(PDO::ATTR_TIMEOUT, 600); diff --git a/public/index.php b/public/index.php index 287cf2e..d259e9b 100755 --- a/public/index.php +++ b/public/index.php @@ -2,7 +2,7 @@ require_once('../config.php'); require_once('../library/icon.php'); -require_once('../library/mysql.php'); +require_once('../library/sqlite.php'); $query = isset($_GET['q']) ? $_GET['q'] : false; $ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : false; @@ -38,7 +38,7 @@ if ($page > 0) { $limit = PAGE_LIMIT * $page; } -$db = new MySQL(); +$db = new SQLite(DB_NAME, DB_USERNAME, DB_PASSWORD); if ($ns) { $namespaceValue = $db->getNamespaceName($ns); From 3e7beba89cc62c03b462f787fe229f03e57c51dd Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 8 Aug 2021 13:54:40 +0300 Subject: [PATCH 02/43] fix data selection --- library/sqlite.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/sqlite.php b/library/sqlite.php index 0b2a779..de81c73 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -35,7 +35,9 @@ class SQLite { $query->execute([$namehash]); - return $query->rowCount() ? $query->fetch()['value'] : []; + $result = $query->fetch(); + + return $result ? $result['value'] : false; } catch(PDOException $e) { @@ -147,8 +149,9 @@ class SQLite { $query->execute(); } + $result = $query->fetchAll(); - return $query->rowCount() ? $query->fetchAll() : []; + return $result ? $result : []; } catch(PDOException $e) { From 55b347d6948e675f1478c318c2b4b8084de88b1b Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 11 Aug 2021 10:54:49 +0300 Subject: [PATCH 03/43] trim key/value --- public/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.php b/public/index.php index d259e9b..e7fbe9b 100755 --- a/public/index.php +++ b/public/index.php @@ -53,8 +53,8 @@ foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { 'block' => $value['block'], 'txid' => $value['txid'], 'time' => date('d-m-Y H:i', $value['time']), - 'key' => nl2br($value['key']), - 'value' => nl2br($value['value']), + 'key' => nl2br(trim($value['key'])), + 'value' => nl2br(trim($value['value'])), ]; } From 0072c3629591c5ff4832461ba126d058d8d3bbfd Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 15 Jul 2022 10:21:45 +0300 Subject: [PATCH 04/43] remove duplicated constants --- config-default.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config-default.php b/config-default.php index 1515765..5c79e45 100644 --- a/config-default.php +++ b/config-default.php @@ -6,10 +6,6 @@ ini_set('display_startup_errors', '1'); error_reporting(E_ALL); // Application -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); From 998ef993c81482bd32999cd9dac47b34cf4a2598 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:23:52 +0300 Subject: [PATCH 05/43] remove php-mysql from sqlite branch --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ec295ed..712262a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Web-oriented content exploring platform for Kevacoin Blockchain php-7.4 php-curl php-mbstring -php-mysql php-sqlite php-pdo php-bcmath From 81bac68ecf50fc76e2f99c6ce7532705fe05dfb6 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:26:12 +0300 Subject: [PATCH 06/43] change database extension --- config-default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-default.php b/config-default.php index 5c79e45..9c38eab 100644 --- a/config-default.php +++ b/config-default.php @@ -12,6 +12,6 @@ define('SEF_MODE', true); define('CACHE_ENABLED', false); // Database -define('DB_NAME', 'kvazar.dat'); +define('DB_NAME', 'kvazar.sqlite'); define('DB_USERNAME', ''); define('DB_PASSWORD', ''); From 2ff3106a50bdaf1717cf0270a1431d1dca81e609 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:28:03 +0300 Subject: [PATCH 07/43] change database path --- config-default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-default.php b/config-default.php index 9c38eab..614f2de 100644 --- a/config-default.php +++ b/config-default.php @@ -12,6 +12,6 @@ define('SEF_MODE', true); define('CACHE_ENABLED', false); // Database -define('DB_NAME', 'kvazar.sqlite'); +define('DB_NAME', '../kvazar.sqlite'); define('DB_USERNAME', ''); define('DB_PASSWORD', ''); From 0a87fe0d94f4fc552f4b24bb5bd20214bd6db03c Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:34:25 +0300 Subject: [PATCH 08/43] define $_db variable --- library/sqlite.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/sqlite.php b/library/sqlite.php index 057d241..4e149ad 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -2,6 +2,8 @@ class SQLite { + private _$db; + public function __construct($database, $username, $password) { try { From 4b11bb62214fc1de4db07d670bcee4a99ffff858 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:46:57 +0300 Subject: [PATCH 09/43] implement database structure auto-initiation --- library/sqlite.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/library/sqlite.php b/library/sqlite.php index 4e149ad..b7e0d21 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -13,6 +13,54 @@ class SQLite { $this->_db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->_db->setAttribute(PDO::ATTR_TIMEOUT, 600); + $this->_db->query(' + CREATE TABLE IF NOT EXISTS "namespace"( + "nameSpaceId" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("nameSpaceId">=0), + "timeIndexed" INTEGER NOT NULL CHECK("timeIndexed">=0), + "hash" CHAR(34) NOT NULL, + CONSTRAINT "hash_UNIQUE" + UNIQUE("hash") + ) + '); + + $this->_db->query(' + CREATE TABLE IF NOT EXISTS "block"( + "blockId" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("blockId">=0), + "timeIndexed" INTEGER NOT NULL CHECK("timeIndexed">=0), + "lostTransactions" INTEGER NOT NULL CHECK("lostTransactions">=0) + ) + '); + + $this->_db->query(' + CREATE TABLE IF NOT EXISTS "data"( + "dataId" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("dataId">=0), + "nameSpaceId" INTEGER NOT NULL CHECK("nameSpaceId">=0), + "blockId" INTEGER NOT NULL CHECK("blockId">=0), + "time" INTEGER NOT NULL CHECK("time">=0), + "timeIndexed" INTEGER NOT NULL CHECK("timeIndexed">=0), + "size" INTEGER NOT NULL, + "ns" TEXT NOT NULL CHECK("ns" IN(\'0\', \'1\')), + "deleted" TEXT NOT NULL CHECK("deleted" IN(\'0\', \'1\')), + "txid" CHAR(64) NOT NULL, + "key" TEXT NOT NULL, + "value" TEXT NOT NULL, + CONSTRAINT "txid_UNIQUE" + UNIQUE("txid"), + CONSTRAINT "fk_data_namespace" + FOREIGN KEY("nameSpaceId") + REFERENCES "namespace"("nameSpaceId"), + CONSTRAINT "fk_data_block" + FOREIGN KEY("blockId") + REFERENCES "block"("blockId") + ) + + '); + + $this->_db->query('CREATE INDEX IF NOT EXISTS "data.fk_data_namespase_idx" ON "data" ("nameSpaceId")'); + $this->_db->query('CREATE INDEX IF NOT EXISTS "data.fk_data_block_idx" ON "data" ("blockId")'); + $this->_db->query('CREATE INDEX IF NOT EXISTS "data.deleted_INDEX" ON "data" ("deleted")'); + $this->_db->query('CREATE INDEX IF NOT EXISTS "data.ns_INDEX" ON "data" ("ns")'); + } catch(PDOException $e) { trigger_error($e->getMessage()); } From 2d109cb9f626cea23187f0922cb87c6ec94c0550 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:47:53 +0300 Subject: [PATCH 10/43] add space separator --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 28cb528..6c0c8f3 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']) ? preg_replace('/[\W\D\S]+/', '', $_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; From 6e4376a0f42dd3cabb2bc847f75707d0608eedc5 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 16:36:09 +0300 Subject: [PATCH 11/43] fix syntax typo --- library/sqlite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/sqlite.php b/library/sqlite.php index b7e0d21..d2c33bc 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -2,7 +2,7 @@ class SQLite { - private _$db; + private $_db; public function __construct($database, $username, $password) { From 76ed2d5a04ad8e9a3206396cec1b5b26aa56848a Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 16:51:05 +0300 Subject: [PATCH 12/43] upgrade driver to PHP 8 --- library/sqlite.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/sqlite.php b/library/sqlite.php index d2c33bc..cb2a4db 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -2,13 +2,13 @@ class SQLite { - private $_db; + private PDO $_db; - public function __construct($database, $username, $password) { + public function __construct(string $database, string $username, string $password) { try { - $this->_db = new PDO('sqlite:' . $database, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']); + $this->_db = new PDO('sqlite:' . $database, $username, $password); $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->_db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->_db->setAttribute(PDO::ATTR_TIMEOUT, 600); @@ -66,7 +66,7 @@ class SQLite { } } - public function getNamespaceValueByNS($ns) { + public function getNamespaceValueByNS(string $ns) { try { @@ -96,7 +96,7 @@ class SQLite { } } - public function getNamespaceHashByTX($txid) { + public function getNamespaceHashByTX(string $txid) { try { @@ -118,7 +118,7 @@ class SQLite { } } - public function getData($namehash = false, $txid = false, $search = false, $start = 0, $limit = 10) { + public function getData(bool $namehash = false, bool $txid = false, bool $search = false, int $start = 0, int $limit = 10) { try { From a067e13ae6d1e3e2b629b408565cb1f89577dc16 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 16:51:24 +0300 Subject: [PATCH 13/43] update dependencies --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 712262a..73859fa 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ Web-oriented content exploring platform for Kevacoin Blockchain ### requirements ``` -php-7.4 +php-8^ php-curl php-mbstring -php-sqlite +php-sqlite3 php-pdo php-bcmath php-gd From e4782a642a78c67cd8ab1a80e1e490b58f3ec969 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:01:52 +0300 Subject: [PATCH 14/43] change driver to SQLite --- crontab/sitemap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crontab/sitemap.php b/crontab/sitemap.php index 5991e8b..f10828c 100644 --- a/crontab/sitemap.php +++ b/crontab/sitemap.php @@ -1,9 +1,9 @@ '; From b69634ee3018c1d2c8d4b583cab51fadcf090d45 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:08:26 +0300 Subject: [PATCH 15/43] fix returning data types --- library/sqlite.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/sqlite.php b/library/sqlite.php index cb2a4db..7328a21 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -87,7 +87,7 @@ class SQLite { $result = $query->fetch(); - return $result ? $result['value'] : false; + return $result ? $result['value'] : ''; } catch(PDOException $e) { @@ -109,7 +109,7 @@ class SQLite { $query->execute([$txid]); - return $query->rowCount() ? $query->fetch()['hash'] : []; + return $query->rowCount() ? $query->fetch()['hash'] : ''; } catch(PDOException $e) { From a8bd6c5e5a17fc97014ec7fb8610806427bfa218 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:12:28 +0300 Subject: [PATCH 16/43] remove deprecated paramethers --- library/icon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/icon.php b/library/icon.php index 3daeddc..4df6a58 100755 --- a/library/icon.php +++ b/library/icon.php @@ -165,7 +165,7 @@ final class Icon { for ($i = 0; $i < count($shape); $i++) $shape[$i] = $shape[$i] * $this->_spriteZ; - imagefilledpolygon($sprite, $shape, count($shape) / 2, $fg); + imagefilledpolygon($sprite, $shape, $fg); for ($i = 0; $i < $rotation; $i++) $sprite = imagerotate($sprite, 90, $bg); @@ -215,7 +215,7 @@ final class Icon { for ($i = 0; $i < count($shape); $i++) $shape[$i] = $shape[$i] * $this->_spriteZ; if (count($shape) > 0) - imagefilledpolygon($sprite, $shape, count($shape) / 2, $fg); + imagefilledpolygon($sprite, $shape, $fg); return $sprite; } From 987b00a724222482c966d8a0bbe683869e9c7761 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:43:11 +0300 Subject: [PATCH 17/43] fix data types --- library/sqlite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/sqlite.php b/library/sqlite.php index 7328a21..76e054c 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -118,7 +118,7 @@ class SQLite { } } - public function getData(bool $namehash = false, bool $txid = false, bool $search = false, int $start = 0, int $limit = 10) { + public function getData(string $namehash = '', string $txid = '', string $search = '', int $start = 0, int $limit = 10) { try { From f17f470e9eb0b21f089b6f1e4dfbdf556f649726 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:50:27 +0300 Subject: [PATCH 18/43] implement RSS feed --- public/index.php | 18 ++++++++++++++---- public/index.phtml | 3 +++ public/rss.phtml | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 public/rss.phtml diff --git a/public/index.php b/public/index.php index 6c0c8f3..618dcb3 100755 --- a/public/index.php +++ b/public/index.php @@ -8,6 +8,7 @@ $query = isset($_GET['q']) ? preg_replace('/[\W\D\S]+/', '', $_GET['q']) : $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; +$rss = isset($_GET['rss']) ? true : false; if (SEF_MODE && isset($_SERVER['QUERY_STRING'])) { @@ -62,9 +63,9 @@ foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { 'namehash' => $value['namehash'], 'block' => $value['block'], 'txid' => $value['txid'], - 'time' => date('d-m-Y H:i', $value['time']), - 'key' => nl2br(trim($value['key'])), - 'value' => nl2br(trim($value['value'])), + 'time' => date(($rss ? 'r' : 'd-m-Y H:i'), $value['time']), + 'key' => $rss ? htmlentities(strip_tags(trim($value['key'])), ENT_XML1) : nl2br(trim($value['key'])), + 'value' => $rss ? htmlentities(strip_tags(trim($value['value'])), ENT_XML1): nl2br(trim($value['value'])), ]; } @@ -127,4 +128,13 @@ if ($ns) { } } -require_once('index.phtml'); +if ($rss) { + + header('Content-type: application/xml'); + require_once('rss.phtml'); + +} else { + + require_once('index.phtml'); + +} diff --git a/public/index.phtml b/public/index.phtml index 0b80271..a768d8a 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -97,6 +97,9 @@
+ + +
KVAZAR Webapp is the content exploring platform for Kevacoin Blockchain.
Sources distributed under the MIT License. Ownership of all content belongs to the authors.
diff --git a/public/rss.phtml b/public/rss.phtml new file mode 100644 index 0000000..8972c2a --- /dev/null +++ b/public/rss.phtml @@ -0,0 +1,16 @@ + + + + + <?php echo $namespaceValue ? $namespaceValue : 'KVAZAR'; ?> + Observe Kevacoin Universe + + + <?php echo $item['key']; ?> + / + + + + + + \ No newline at end of file From 9595cbcadad6fbbf2cc926574609f56198785d52 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 17:57:18 +0300 Subject: [PATCH 19/43] change URI to URL --- config-default.php | 2 +- public/index.php | 4 ++-- public/index.phtml | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config-default.php b/config-default.php index 614f2de..e21f176 100644 --- a/config-default.php +++ b/config-default.php @@ -6,7 +6,7 @@ ini_set('display_startup_errors', '1'); error_reporting(E_ALL); // Application -define('BASE_URL', 'https://kvazar.today'); +define('BASE_URL', 'https://kvazar.today/'); define('PAGE_LIMIT', 10); define('SEF_MODE', true); define('CACHE_ENABLED', false); diff --git a/public/index.php b/public/index.php index 618dcb3..2f509fb 100755 --- a/public/index.php +++ b/public/index.php @@ -83,9 +83,9 @@ if (SEF_MODE) { if ($data) { if (in_array($page, [0, 1])) { - $older = ($ns ? $ns . '/2' : '/2'); + $older = ($ns ? $ns . '/2' : '2'); } else { - $older = ($ns ? $ns . '/' . ($page + 1) : '/' . ($page + 1)); + $older = ($ns ? $ns . '/' . ($page + 1) : ($page + 1)); } } else { $older = false; diff --git a/public/index.phtml b/public/index.phtml index a768d8a..448bf97 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,11 +1,11 @@ - + - + @@ -29,7 +29,7 @@
@@ -48,18 +48,18 @@ - +
@@ -80,18 +80,18 @@
-
+
From 8b57fa75b032870d1390586c6da739f09e8391ba Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:01:21 +0300 Subject: [PATCH 20/43] hide RSS link on pagination pages --- public/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.phtml b/public/index.phtml index 448bf97..e90357d 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -97,7 +97,7 @@
- +
KVAZAR Webapp is the content exploring platform for Kevacoin Blockchain.
From 14e4ef6c89ce390fd569a210e4562678905a2894 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:02:38 +0300 Subject: [PATCH 21/43] add rel="nofollow" to RSS link --- public/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.phtml b/public/index.phtml index e90357d..df07cc1 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -98,7 +98,7 @@
- +
KVAZAR Webapp is the content exploring platform for Kevacoin Blockchain.
Sources distributed under the MIT License. Ownership of all content belongs to the authors.
From fe42d53e105a4e4cb6c78fb063c362d57d094b44 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:10:00 +0300 Subject: [PATCH 22/43] update search filtering rules --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 2f509fb..0f958ee 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']) ? preg_replace('/[\W\D\S]+/', '', $_GET['q']) : false; +$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', $_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; From 63f6b8798261ab50905d0bbdcb8f38664cf5f9dc Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:13:24 +0300 Subject: [PATCH 23/43] add search request RSS support --- public/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.phtml b/public/index.phtml index df07cc1..193303b 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -98,7 +98,7 @@
- +
KVAZAR Webapp is the content exploring platform for Kevacoin Blockchain.
Sources distributed under the MIT License. Ownership of all content belongs to the authors.
From 7be863ce84f61abe4b500b16480869bf71b3a70e Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:19:59 +0300 Subject: [PATCH 24/43] disable SEF pagination on search request --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 0f958ee..dfb3253 100755 --- a/public/index.php +++ b/public/index.php @@ -69,7 +69,7 @@ foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { ]; } -if (SEF_MODE) { +if (SEF_MODE && !$query) { if (in_array($page, [0, 1])) { $newer = false; From 7feed325ca5b68c42ec4505344b1b405a06952a9 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 18:22:24 +0300 Subject: [PATCH 25/43] fix double slashes in the URL --- public/rss.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/rss.phtml b/public/rss.phtml index 8972c2a..b8c3945 100644 --- a/public/rss.phtml +++ b/public/rss.phtml @@ -1,13 +1,13 @@ - + <?php echo $namespaceValue ? $namespaceValue : 'KVAZAR'; ?> Observe Kevacoin Universe <?php echo $item['key']; ?> - / + From d97e4f0c4c792c8d2d6e0d166ad6f2d472601a88 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 19:42:41 +0300 Subject: [PATCH 26/43] fix rss links --- public/index.php | 8 ++++++-- public/index.phtml | 2 +- public/rss.phtml | 31 ++++++++++++++++++------------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/public/index.php b/public/index.php index dfb3253..799f665 100755 --- a/public/index.php +++ b/public/index.php @@ -15,7 +15,9 @@ if (SEF_MODE && isset($_SERVER['QUERY_STRING'])) { $q = explode('/', $_SERVER['QUERY_STRING']); if (isset($q[1])) { - if (strlen($q[1]) == 34) { + if ($q[1] == 'rss') { + $rss = true; + } else if (strlen($q[1]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); } else if (strlen($q[1]) > 34) { $tx = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); @@ -25,7 +27,9 @@ if (SEF_MODE && isset($_SERVER['QUERY_STRING'])) { } if (isset($q[2])) { - if (strlen($q[2]) == 34) { + if ($q[2] == 'rss') { + $rss = true; + } else if (strlen($q[2]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[2]); } else { $page = (int) $q[2]; diff --git a/public/index.phtml b/public/index.phtml index 193303b..4b1036f 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -98,7 +98,7 @@
- +
KVAZAR Webapp is the content exploring platform for Kevacoin Blockchain.
Sources distributed under the MIT License. Ownership of all content belongs to the authors.
diff --git a/public/rss.phtml b/public/rss.phtml index b8c3945..bec3882 100644 --- a/public/rss.phtml +++ b/public/rss.phtml @@ -1,16 +1,21 @@ - - - <?php echo $namespaceValue ? $namespaceValue : 'KVAZAR'; ?> - Observe Kevacoin Universe - - - <?php echo $item['key']; ?> - - - - - - + + + <?php echo ($namespaceValue ? $namespaceValue : + ($namespaceHash ? $namespaceHash : + ($query ? $query : 'KVAZAR'))); ?> + Observe Kevacoin Universe + + + + <?php echo $item['key']; ?> + + + + + + + \ No newline at end of file From 0e394fcc267e2801b4303d27fcda02fe478d097c Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 19:47:27 +0300 Subject: [PATCH 27/43] remove optional sef mode --- config-default.php | 1 - public/index.php | 25 ++----------------------- public/index.phtml | 14 ++++---------- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/config-default.php b/config-default.php index e21f176..d43ae2a 100644 --- a/config-default.php +++ b/config-default.php @@ -8,7 +8,6 @@ error_reporting(E_ALL); // Application define('BASE_URL', 'https://kvazar.today/'); define('PAGE_LIMIT', 10); -define('SEF_MODE', true); define('CACHE_ENABLED', false); // Database diff --git a/public/index.php b/public/index.php index 799f665..2c3ac01 100755 --- a/public/index.php +++ b/public/index.php @@ -10,7 +10,7 @@ $tx = isset($_GET['tx']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['tx']) : $page = (int) isset($_GET['page']) ? $_GET['page'] : 0; $rss = isset($_GET['rss']) ? true : false; -if (SEF_MODE && isset($_SERVER['QUERY_STRING'])) { +if (isset($_SERVER['QUERY_STRING'])) { $q = explode('/', $_SERVER['QUERY_STRING']); @@ -73,7 +73,7 @@ foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { ]; } -if (SEF_MODE && !$query) { +if (!$query) { if (in_array($page, [0, 1])) { $newer = false; @@ -95,27 +95,6 @@ if (SEF_MODE && !$query) { $older = false; } -} else { - - if (in_array($page, [0, 1])) { - $newer = false; - } else { - if ($page == 2) { - $newer = ($ns ? '?ns=' . $ns : ($query ? '?q=' . $query : '')); - } else { - $newer = ($ns ? '?ns=' . $ns . '&page=' . ($page - 1) : '?page=' . ($page - 1) . ($query ? '&q=' . $query : '')); - } - } - - if ($data) { - if (in_array($page, [0, 1])) { - $older = ($ns ? '?ns=' . $ns . '&page=2' : '?page=2' . ($query ? '&q=' . $query : '')); - } else { - $older = ($ns ? '?ns=' . $ns . '&page=' . ($page + 1) : '?page=' . ($page + 1) . ($query ? '&q=' . $query : '')); - } - } else { - $older = false; - } } if ($ns) { diff --git a/public/index.phtml b/public/index.phtml index 4b1036f..5acbde8 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -47,19 +47,13 @@
- - - <?php echo $item['namehash']; ?> - - - - <?php echo $item['namehash']; ?> - - + + <?php echo $item['namehash']; ?> +
- +
From 2922454c36689681b20e2a69e497d578167d1a66 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 19:48:35 +0300 Subject: [PATCH 28/43] add missed BASE_URL --- public/index.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.phtml b/public/index.phtml index 5acbde8..cf61057 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -33,7 +33,7 @@
- <?php echo $ns; ?> + <?php echo $ns; ?>
@@ -48,7 +48,7 @@
From 4a2674440f5bfa18e77ba6c27390e55eea48d078 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 19:49:51 +0300 Subject: [PATCH 29/43] unify data types --- public/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/index.php b/public/index.php index 2c3ac01..09ca3f2 100755 --- a/public/index.php +++ b/public/index.php @@ -4,9 +4,9 @@ require_once('../config.php'); require_once('../library/icon.php'); require_once('../library/sqlite.php'); -$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', $_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; +$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', $_GET['q']) : ''; +$ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : ''; +$tx = isset($_GET['tx']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['tx']) : ''; $page = (int) isset($_GET['page']) ? $_GET['page'] : 0; $rss = isset($_GET['rss']) ? true : false; From a6f9bd095fb384f47776a15420590f4bc965767a Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 19:56:08 +0300 Subject: [PATCH 30/43] fix pagination variables definition --- public/index.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/public/index.php b/public/index.php index 09ca3f2..4760aca 100755 --- a/public/index.php +++ b/public/index.php @@ -73,28 +73,23 @@ foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { ]; } -if (!$query) { +$older = false; +$newer = false; - if (in_array($page, [0, 1])) { - $newer = false; +if (!in_array($page, [0, 1])) { + if ($page == 2) { + $newer = ($ns ? $ns : ''); } else { - if ($page == 2) { - $newer = ($ns ? $ns : ''); - } else { - $newer = ($ns ? $ns . '/' . ($page - 1) : ($page - 1)); - } + $newer = ($ns ? $ns . '/' . ($page - 1) : ($page - 1)); } +} - if ($data) { - if (in_array($page, [0, 1])) { - $older = ($ns ? $ns . '/2' : '2'); - } else { - $older = ($ns ? $ns . '/' . ($page + 1) : ($page + 1)); - } +if ($data) { + if (in_array($page, [0, 1])) { + $older = ($ns ? $ns . '/2' : '2'); } else { - $older = false; + $older = ($ns ? $ns . '/' . ($page + 1) : ($page + 1)); } - } if ($ns) { From e44e4202c2b30c9656f29d995ad944cb0df77263 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 20:18:29 +0300 Subject: [PATCH 31/43] add custom search titles --- public/index.phtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/index.phtml b/public/index.phtml index cf61057..6e51084 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -20,6 +20,8 @@ <?php echo $tx && isset($data[0]['key']) ? $data[0]['key'] : $tx; ?> | <?php echo ($namespaceValue ? $namespaceValue : ($namespaceHash ? $namespaceHash : false)); ?> | KVAZAR + + KVAZAR | SEARCH | <?php echo $query; ?> KVAZAR | TODAY From 2a7b06636892900c7bb2d426f33564624633f48b Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 20:25:19 +0300 Subject: [PATCH 32/43] fix search pagination --- public/index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/index.php b/public/index.php index 4760aca..dc28e30 100755 --- a/public/index.php +++ b/public/index.php @@ -82,6 +82,10 @@ if (!in_array($page, [0, 1])) { } else { $newer = ($ns ? $ns . '/' . ($page - 1) : ($page - 1)); } + + if ($query) { + $newer = $newer . '?q=' . $query; + } } if ($data) { @@ -90,6 +94,10 @@ if ($data) { } else { $older = ($ns ? $ns . '/' . ($page + 1) : ($page + 1)); } + + if ($query) { + $older = $older . '?q=' . $query; + } } if ($ns) { From 0e4eef44919cc3e8dd27ce7239034801bda47852 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 20:47:30 +0300 Subject: [PATCH 33/43] update background color --- public/css/app.css | 8 ++++---- public/index.phtml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 7ba85cf..3a6cf3b 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -12,7 +12,7 @@ button::-moz-focus-inner { input, button { opacity: 0.8; - color: #18102d; + color: #171028; background: #BFBACC; border: 0; border-radius: 3px; @@ -24,7 +24,7 @@ input, button { body { color: #E8E8E8; - background-color: #18102d; + background-color: #171028; font-family: Sans-Serif, Arial; font-size: 14px; font-weight: normal; @@ -96,7 +96,7 @@ img:hover { .b-g::before { content: ""; - background-image: linear-gradient(to left, #9B94BF, #18102d); + background-image: linear-gradient(to left, #9B94BF, #171028); height: 1px; width: 50%; max-width: 360px; @@ -105,7 +105,7 @@ img:hover { .b-g::after { content: ""; - background-image: linear-gradient(to right, #9B94BF, #18102d); + background-image: linear-gradient(to right, #9B94BF, #171028); height: 1px; width: 50%; max-width: 360px; diff --git a/public/index.phtml b/public/index.phtml index 6e51084..c5d5225 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,7 +1,7 @@ - + From 2efdca3f4a52ed0b00d54952ff3da8fc2ea01aa2 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 22:38:54 +0300 Subject: [PATCH 34/43] change background color to dark --- public/css/app.css | 8 ++++---- public/index.phtml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 3a6cf3b..634101c 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -12,7 +12,7 @@ button::-moz-focus-inner { input, button { opacity: 0.8; - color: #171028; + color: #000; background: #BFBACC; border: 0; border-radius: 3px; @@ -24,7 +24,7 @@ input, button { body { color: #E8E8E8; - background-color: #171028; + background-color: #000; font-family: Sans-Serif, Arial; font-size: 14px; font-weight: normal; @@ -96,7 +96,7 @@ img:hover { .b-g::before { content: ""; - background-image: linear-gradient(to left, #9B94BF, #171028); + background-image: linear-gradient(to left, #9B94BF, #000); height: 1px; width: 50%; max-width: 360px; @@ -105,7 +105,7 @@ img:hover { .b-g::after { content: ""; - background-image: linear-gradient(to right, #9B94BF, #171028); + background-image: linear-gradient(to right, #9B94BF, #000); height: 1px; width: 50%; max-width: 360px; diff --git a/public/index.phtml b/public/index.phtml index c5d5225..8fb2c84 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,7 +1,7 @@ - + From e0c3f733b1063eec399cea146e6d3a676de743e1 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 23:08:42 +0300 Subject: [PATCH 35/43] update font colors --- public/css/app.css | 12 ++++++------ public/index.phtml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 634101c..9783dc3 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -13,7 +13,7 @@ button::-moz-focus-inner { input, button { opacity: 0.8; color: #000; - background: #BFBACC; + background: #ABA6B7; border: 0; border-radius: 3px; height: 18px; @@ -23,7 +23,7 @@ input, button { } body { - color: #E8E8E8; + color: #BFBACC; background-color: #000; font-family: Sans-Serif, Arial; font-size: 14px; @@ -32,12 +32,12 @@ body { } a { - color: #BFBACC; + color: #ABA6B7; text-decoration: none; } a { - color: #BFBACC; + color: #ABA6B7; text-decoration: none; -moz-transition: all .5s ease-in; -o-transition: all .5s ease-in; @@ -47,7 +47,7 @@ a { } a:hover { - color: #E8E8E8; + color: #BFBACC; -webkit-transition: all .5s ease-in; /* issue #2 */ } @@ -127,7 +127,7 @@ img:hover { .c-1:active, .c-1:visited, .c-1:hover { - color: #ABA6B7; + color: #BFBACC; } .c-2, diff --git a/public/index.phtml b/public/index.phtml index 8fb2c84..feaf21b 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,7 +1,7 @@ - + From 132b8c337173d4d7a17879c1b7de1922bf6c073b Mon Sep 17 00:00:00 2001 From: d47081 Date: Sat, 16 Jul 2022 00:48:22 +0300 Subject: [PATCH 36/43] add semantic feed titles --- public/rss.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/rss.phtml b/public/rss.phtml index bec3882..9a6b565 100644 --- a/public/rss.phtml +++ b/public/rss.phtml @@ -3,9 +3,9 @@ - <?php echo ($namespaceValue ? $namespaceValue : - ($namespaceHash ? $namespaceHash : - ($query ? $query : 'KVAZAR'))); ?> + KVAZAR - <?php echo ($namespaceValue ? $namespaceValue : + ($namespaceHash ? $namespaceHash : + ($query ? 'SEARCH - ' . $query : 'TODAY'))); ?> Observe Kevacoin Universe From 35035fc536d710ca957e38ff2addde8486e7675f Mon Sep 17 00:00:00 2001 From: d47081 Date: Sat, 16 Jul 2022 09:20:10 +0300 Subject: [PATCH 37/43] rollback bg colors --- public/css/app.css | 6 +++--- public/index.phtml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 9783dc3..a5be674 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -24,7 +24,7 @@ input, button { body { color: #BFBACC; - background-color: #000; + background-color: #18102d; font-family: Sans-Serif, Arial; font-size: 14px; font-weight: normal; @@ -96,7 +96,7 @@ img:hover { .b-g::before { content: ""; - background-image: linear-gradient(to left, #9B94BF, #000); + background-image: linear-gradient(to left, #9B94BF, #18102d); height: 1px; width: 50%; max-width: 360px; @@ -105,7 +105,7 @@ img:hover { .b-g::after { content: ""; - background-image: linear-gradient(to right, #9B94BF, #000); + background-image: linear-gradient(to right, #9B94BF, #18102d); height: 1px; width: 50%; max-width: 360px; diff --git a/public/index.phtml b/public/index.phtml index feaf21b..39c2b87 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,7 +1,7 @@ - + From 6f2174edbd173b338d18295c256535512a804424 Mon Sep 17 00:00:00 2001 From: d47081 Date: Sat, 16 Jul 2022 09:46:03 +0300 Subject: [PATCH 38/43] update bg colors --- public/css/app.css | 6 +++--- public/index.phtml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index a5be674..9783dc3 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -24,7 +24,7 @@ input, button { body { color: #BFBACC; - background-color: #18102d; + background-color: #000; font-family: Sans-Serif, Arial; font-size: 14px; font-weight: normal; @@ -96,7 +96,7 @@ img:hover { .b-g::before { content: ""; - background-image: linear-gradient(to left, #9B94BF, #18102d); + background-image: linear-gradient(to left, #9B94BF, #000); height: 1px; width: 50%; max-width: 360px; @@ -105,7 +105,7 @@ img:hover { .b-g::after { content: ""; - background-image: linear-gradient(to right, #9B94BF, #18102d); + background-image: linear-gradient(to right, #9B94BF, #000); height: 1px; width: 50%; max-width: 360px; diff --git a/public/index.phtml b/public/index.phtml index 39c2b87..11d126c 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -1,7 +1,7 @@ - + From 6392359c0dff0035ae91d806685d310320c2172c Mon Sep 17 00:00:00 2001 From: d47081 Date: Sat, 16 Jul 2022 12:37:40 +0300 Subject: [PATCH 39/43] remove style definition duplicate --- public/css/app.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 9783dc3..f67d71b 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -31,11 +31,6 @@ body { line-height: 1.8; } -a { - color: #ABA6B7; - text-decoration: none; -} - a { color: #ABA6B7; text-decoration: none; From 38c860f0fa5e8203b87780e46ecdea9ef0387c6c Mon Sep 17 00:00:00 2001 From: d47081 Date: Sat, 16 Jul 2022 16:24:24 +0300 Subject: [PATCH 40/43] fix URL paths --- crontab/sitemap.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crontab/sitemap.php b/crontab/sitemap.php index f10828c..5058d43 100644 --- a/crontab/sitemap.php +++ b/crontab/sitemap.php @@ -18,12 +18,12 @@ $transactions = []; foreach ($db->getData(false, false, false, 0, 1000000) as $value) { if (!in_array($value['namehash'], $namespaces)) { - $namespace .= '' . BASE_URL . '/' . $value['namehash'] . ''; + $namespace .= '' . BASE_URL . $value['namehash'] . ''; } if (!in_array($value['namehash'], $transactions)) { - $transaction .= '' . BASE_URL . '/' . $value['txid'] . ''; + $transaction .= '' . BASE_URL . $value['txid'] . ''; } $namespaces[] = $value['namehash']; @@ -47,10 +47,10 @@ fclose($handle); $sitemap = ''; $sitemap .= ''; $sitemap .= ' '; -$sitemap .= ' ' . BASE_URL . '/sitemap.namespace.xml'; +$sitemap .= ' ' . BASE_URL . 'sitemap.namespace.xml'; $sitemap .= ' '; $sitemap .= ' '; -$sitemap .= ' ' . BASE_URL . '/sitemap.transaction.xml'; +$sitemap .= ' ' . BASE_URL . 'sitemap.transaction.xml'; $sitemap .= ' '; $sitemap .= ''; From 6f8d35ff0dc79fd0e6ca4065bbd4710ad93409d4 Mon Sep 17 00:00:00 2001 From: d47081 <108541346+d47081@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:25:28 +0300 Subject: [PATCH 41/43] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 73859fa..9b94c8b 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ location @sef { ``` ### examples -#### web -https://kvazar.today #### yggdrasil -[http://[203:7693:ae20:18a6:7689:cb63:c53d:43c6]](http://[203:7693:ae20:18a6:7689:cb63:c53d:43c6]) +[http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]](http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]) From a0eba92cc7fe296359c46b495a5dca0b84c17a16 Mon Sep 17 00:00:00 2001 From: d47081 Date: Thu, 27 Oct 2022 15:30:31 +0300 Subject: [PATCH 42/43] implement optional trends block --- config-default.php | 5 +++++ library/sqlite.php | 34 ++++++++++++++++++++++++++++++++++ public/index.php | 42 ++++++++++++++++++++++++++++++++++++++++++ public/index.phtml | 12 ++++++++++++ 4 files changed, 93 insertions(+) diff --git a/config-default.php b/config-default.php index d43ae2a..e6bb98d 100644 --- a/config-default.php +++ b/config-default.php @@ -10,6 +10,11 @@ define('BASE_URL', 'https://kvazar.today/'); define('PAGE_LIMIT', 10); define('CACHE_ENABLED', false); +define('TRENDS_ENABLED', false); // alpha +define('TRENDS_SECONDS_OFFSET', 2592000); +define('TRENDS_MIN_LENGHT', 4); +define('TRENDS_LIMIT', 40); + // Database define('DB_NAME', '../kvazar.sqlite'); define('DB_USERNAME', ''); diff --git a/library/sqlite.php b/library/sqlite.php index 76e054c..fa4aaf1 100644 --- a/library/sqlite.php +++ b/library/sqlite.php @@ -231,4 +231,38 @@ class SQLite { return false; } } + + public function getTrends(int $offset = 0) { + + try { + + $query = $this->_db->prepare('SELECT `block`.`blockId` AS `block`, + `namespace`.`hash` AS `namehash`, + `data`.`time` AS `time`, + `data`.`key` AS `key`, + `data`.`value` AS `value`, + `data`.`txid` AS `txid` + + FROM `data` + JOIN `block` ON (`block`.`blockId` = `data`.`blockId`) + JOIN `namespace` ON (`namespace`.`nameSpaceId` = `data`.`nameSpaceId`) + + WHERE `data`.`ns` = "0" + AND `data`.`time` >= ' . (int) $offset . ' + -- AND `data`.`deleted` = "0" -- + + ORDER BY `block`.`blockId` DESC'); + + $query->execute(); + + $result = $query->fetchAll(); + + return $result ? $result : []; + + } catch(PDOException $e) { + + trigger_error($e->getMessage()); + return false; + } + } } diff --git a/public/index.php b/public/index.php index dc28e30..d3cd76a 100755 --- a/public/index.php +++ b/public/index.php @@ -61,6 +61,48 @@ if ($ns) { $namespaceValue = false; } +$trends = []; + +if (TRENDS_ENABLED) { + + foreach ($db->getTrends(time() - TRENDS_SECONDS_OFFSET) as $value) { + + foreach ((array) explode(' ', strip_tags(html_entity_decode(nl2br(trim($value['key']))))) as $trend) { + + if (strlen($trend) >= TRENDS_MIN_LENGHT) { + + $trend = strtolower($trend); + + if (isset($trends[$trend])) { + $trends[$trend]++; + } else { + $trends[$trend] = 1; + } + } + } + + foreach ((array) explode(' ', strip_tags(html_entity_decode(nl2br(trim($value['value']))))) as $trend) { + + if (strlen($trend) >= TRENDS_MIN_LENGHT) { + + $trend = strtolower($trend); + + if (isset($trends[$trend])) { + $trends[$trend]++; + } else { + $trends[$trend] = 1; + } + } + } + } + + arsort($trends); + + $trends = array_slice($trends, 0, TRENDS_LIMIT); + + $trends = array_flip($trends); +} + $data = []; foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { $data[] = [ diff --git a/public/index.phtml b/public/index.phtml index 11d126c..5bdd177 100755 --- a/public/index.phtml +++ b/public/index.phtml @@ -44,6 +44,18 @@
+ +
+
+ + # + +
+
+
+
+
+
From c8704dd82422b7b5401bd4424ad76bc1bf7b8b08 Mon Sep 17 00:00:00 2001 From: d47081 Date: Thu, 27 Oct 2022 16:25:04 +0300 Subject: [PATCH 43/43] remove mod rewrite relations --- public/index.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/public/index.php b/public/index.php index d3cd76a..8dd0d04 100755 --- a/public/index.php +++ b/public/index.php @@ -4,24 +4,23 @@ require_once('../config.php'); require_once('../library/icon.php'); require_once('../library/sqlite.php'); -$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', $_GET['q']) : ''; -$ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : ''; -$tx = isset($_GET['tx']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['tx']) : ''; -$page = (int) isset($_GET['page']) ? $_GET['page'] : 0; -$rss = isset($_GET['rss']) ? true : false; +$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', urldecode($_GET['q'])) : ''; +$ns = ''; +$tx = ''; +$page = 0; -if (isset($_SERVER['QUERY_STRING'])) { +if (isset($_SERVER['REQUEST_URI'])) { - $q = explode('/', $_SERVER['QUERY_STRING']); + $q = explode('/', $_SERVER['REQUEST_URI']); if (isset($q[1])) { if ($q[1] == 'rss') { $rss = true; } else if (strlen($q[1]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); - } else if (strlen($q[1]) > 34) { + } else if (strlen($q[1]) == 64) { $tx = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); - } else { + } else if (preg_match('/[0-9]+/', $q[1])) { $page = (int) $q[1]; } } @@ -31,12 +30,16 @@ if (isset($_SERVER['QUERY_STRING'])) { $rss = true; } else if (strlen($q[2]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[2]); - } else { + } else if (preg_match('/[0-9]+/', $q[2])) { $page = (int) $q[2]; } } } +if ($query) { + $rss = isset($_GET['rss']) ? true : false; +} + if ($page > 0) { $limit = PAGE_LIMIT * $page - PAGE_LIMIT; } else {