From 92d03d0b9d63df8ab88058b6b1641a46f6915c5b Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:24:25 +0300 Subject: [PATCH 1/7] remove php-sqlite from mysql branch --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ec295ed..68a601d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ php-7.4 php-curl php-mbstring php-mysql -php-sqlite php-pdo php-bcmath php-gd From bfdfda3d397b39ae268d9bce3a76293ed64e1f67 Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:33:45 +0300 Subject: [PATCH 2/7] define $_db variable --- library/mysql.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/mysql.php b/library/mysql.php index 5976746..2b56286 100755 --- a/library/mysql.php +++ b/library/mysql.php @@ -2,6 +2,8 @@ class MySQL { + private _$db; + public function __construct() { try { From 0af74b89fb7927da6f337d78af45aa1906f48f1f Mon Sep 17 00:00:00 2001 From: d47081 Date: Fri, 15 Jul 2022 10:48:14 +0300 Subject: [PATCH 3/7] 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 fb6c0f6..9462806 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/mysql.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 be2fc4aed1ad6e7d4d85e956d0abb23e4514d24c Mon Sep 17 00:00:00 2001 From: d47081 <108541346+d47081@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:24:14 +0300 Subject: [PATCH 4/7] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 68a601d..728af6a 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,7 @@ location @sef { } ``` -### examples -#### web -https://kvazar.today +### exampleshttps://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 43b7f03091bfb4bf30b8680c2ea4ba3efbdd4f0d Mon Sep 17 00:00:00 2001 From: d47081 <108541346+d47081@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:24:26 +0300 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 728af6a..b9f1d69 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ location @sef { } ``` -### exampleshttps://kvazar.today +### examples #### yggdrasil [http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]](http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]) From 28b395476b2e04a8990a9177e2520f2ce45647f6 Mon Sep 17 00:00:00 2001 From: d47081 Date: Tue, 14 Mar 2023 02:06:49 +0200 Subject: [PATCH 6/7] resolve merge #8 conflicts --- README.md | 47 ------------ library/mysql.php | 183 ---------------------------------------------- public/index.php | 130 -------------------------------- 3 files changed, 360 deletions(-) delete mode 100644 README.md delete mode 100755 library/mysql.php delete mode 100755 public/index.php diff --git a/README.md b/README.md deleted file mode 100644 index b9f1d69..0000000 --- a/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# kvazar-network webapp -Web-oriented content exploring platform for Kevacoin Blockchain - -### requirements -``` -php-7.4 -php-curl -php-mbstring -php-mysql -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 - -#### yggdrasil -[http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]](http://[203:9fd0:95df:54d7:29db:5ee1:fe2d:95c7]) diff --git a/library/mysql.php b/library/mysql.php deleted file mode 100755 index 2b56286..0000000 --- a/library/mysql.php +++ /dev/null @@ -1,183 +0,0 @@ -_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->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); - - } catch(PDOException $e) { - trigger_error($e->getMessage()); - } - } - - public function getNamespaceValueByNS($ns) { - - try { - - $query = $this->_db->prepare('SELECT `data`.`value` AS `value` - - FROM `data` - JOIN `namespace` ON (`namespace`.`nameSpaceId` = `data`.`nameSpaceId`) - - WHERE `namespace`.`hash` = ? - AND `data`.`ns` = "1" - -- AND `data`.`deleted` = "0" -- - - ORDER BY `data`.`blockId` DESC - - LIMIT 1'); - - $query->execute([$ns]); - - return $query->rowCount() ? $query->fetch()['value'] : []; - - } catch(PDOException $e) { - - trigger_error($e->getMessage()); - return false; - } - } - - 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 { - - if ($txid) { - - $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`.`txid` = ? - AND `data`.`ns` = "0" - -- AND `data`.`deleted` = "0" -- - - ORDER BY `block`.`blockId` DESC - - LIMIT ' . (int) $start . ',' . (int) $limit); - - $query->execute([$txid]); - - } else if ($namehash) { - - $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 `namespace`.`hash` = ? - AND `data`.`ns` = "0" - -- AND `data`.`deleted` = "0" -- - - ORDER BY `block`.`blockId` DESC - - LIMIT ' . (int) $start . ',' . (int) $limit); - - $query->execute([$namehash]); - - } else if ($search) { - - $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`.`key` LIKE :search - OR `data`.`value` LIKE :search - OR `block`.`blockId` LIKE :search - OR `namespace`.`hash` LIKE :search - OR `data`.`txid` LIKE :search) - - AND `data`.`ns` = "0" - -- AND `data`.`deleted` = "0" -- - - ORDER BY `block`.`blockId` DESC - - LIMIT ' . (int) $start . ',' . (int) $limit); - - $query->bindValue(':search', '%' . $search . '%', PDO::PARAM_STR); - - $query->execute(); - - } else { - - $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`.`deleted` = "0" -- - - ORDER BY `block`.`blockId` DESC - - LIMIT ' . (int) $start . ',' . (int) $limit); - - $query->execute(); - } - - - return $query->rowCount() ? $query->fetchAll() : []; - - } catch(PDOException $e) { - - trigger_error($e->getMessage()); - return false; - } - } -} diff --git a/public/index.php b/public/index.php deleted file mode 100755 index 9462806..0000000 --- a/public/index.php +++ /dev/null @@ -1,130 +0,0 @@ - 34) { - $tx = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); - } else { - $page = (int) $q[1]; - } - } - - if (isset($q[2])) { - if (strlen($q[2]) == 34) { - $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[2]); - } else { - $page = (int) $q[2]; - } - } -} - -if ($page > 0) { - $limit = PAGE_LIMIT * $page - PAGE_LIMIT; -} else { - $limit = PAGE_LIMIT * $page; -} - -$db = new MySQL(); - -if ($ns) { - - $namespaceHash = $ns; - $namespaceValue = $db->getNamespaceValueByNS($ns); - -} else if ($tx) { - - $namespaceHash = $db->getNamespaceHashByTX($tx); - $namespaceValue = $db->getNamespaceValueByNS($namespaceHash); - -} else { - - $namespaceHash = false; - $namespaceValue = false; -} - -$data = []; -foreach ($db->getData($ns, $tx, $query, $limit, PAGE_LIMIT) as $value) { - $data[] = [ - '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'])), - ]; -} - -if (SEF_MODE) { - - if (in_array($page, [0, 1])) { - $newer = false; - } else { - if ($page == 2) { - $newer = ($ns ? $ns : ''); - } else { - $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)); - } - } else { - $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) { - if ($page) { - $hrefThisPage = $ns . '/' . $page; - } else { - $hrefThisPage = $ns; - } -} else { - if ($page) { - $hrefThisPage = $page; - } else { - $hrefThisPage = ''; - } -} - -require_once('index.phtml'); From 50a7183dba1ac4515a4b7aa578e546ebb9935958 Mon Sep 17 00:00:00 2001 From: d47081 Date: Tue, 14 Mar 2023 02:15:10 +0200 Subject: [PATCH 7/7] resolve merge #8 conflicts --- README.md | 0 public/index.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md create mode 100644 public/index.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..e69de29