Browse Source

Merge pull request #8 from kvazar-network/sqlite

Merge Sqlite updates into the Master branch
pull/9/head
d47081 2 years ago committed by GitHub
parent
commit
7e4b18b2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 50
      README.md
  2. 12
      config-default.php
  3. 12
      crontab/sitemap.php
  4. 4
      library/icon.php
  5. 268
      library/sqlite.php
  6. 23
      public/css/app.css
  7. 174
      public/index.php
  8. 43
      public/index.phtml
  9. 21
      public/rss.phtml

50
README.md

@ -0,0 +1,50 @@
<<<<<<< HEAD
# kvazar-network webapp
Web-oriented content exploring platform for Kevacoin Blockchain
### requirements
```
php-8^
php-curl
php-mbstring
php-sqlite3
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])
=======
>>>>>>> master

12
config-default.php

@ -6,14 +6,16 @@ ini_set('display_startup_errors', '1');
error_reporting(E_ALL); error_reporting(E_ALL);
// Application // Application
define('BASE_URL', 'https://kvazar.today'); define('BASE_URL', 'https://kvazar.today/');
define('PAGE_LIMIT', 10); define('PAGE_LIMIT', 10);
define('SEF_MODE', true);
define('CACHE_ENABLED', false); define('CACHE_ENABLED', false);
define('TRENDS_ENABLED', false); // alpha
define('TRENDS_SECONDS_OFFSET', 2592000);
define('TRENDS_MIN_LENGHT', 4);
define('TRENDS_LIMIT', 40);
// Database // Database
define('DB_HOST', 'localhost'); define('DB_NAME', '../kvazar.sqlite');
define('DB_PORT', '3306');
define('DB_NAME', '');
define('DB_USERNAME', ''); define('DB_USERNAME', '');
define('DB_PASSWORD', ''); define('DB_PASSWORD', '');

12
crontab/sitemap.php

@ -1,9 +1,9 @@
<?php <?php
require_once(dirname(__FILE__) . '/../config.php'); require_once(dirname(__FILE__) . '/../config.php');
require_once(dirname(__FILE__) . '/../library/mysql.php'); require_once(dirname(__FILE__) . '/../library/sqlite.php');
$db = new MySQL(); $db = new SQLite(DB_NAME, DB_USERNAME, DB_PASSWORD);
// Generate url sets // Generate url sets
$transaction = '<?xml version="1.0" encoding="UTF-8"?>'; $transaction = '<?xml version="1.0" encoding="UTF-8"?>';
@ -18,12 +18,12 @@ $transactions = [];
foreach ($db->getData(false, false, false, 0, 1000000) as $value) { foreach ($db->getData(false, false, false, 0, 1000000) as $value) {
if (!in_array($value['namehash'], $namespaces)) { if (!in_array($value['namehash'], $namespaces)) {
$namespace .= '<loc>' . BASE_URL . '/' . $value['namehash'] . '</loc>'; $namespace .= '<loc>' . BASE_URL . $value['namehash'] . '</loc>';
} }
if (!in_array($value['namehash'], $transactions)) { if (!in_array($value['namehash'], $transactions)) {
$transaction .= '<loc>' . BASE_URL . '/' . $value['txid'] . '</loc>'; $transaction .= '<loc>' . BASE_URL . $value['txid'] . '</loc>';
} }
$namespaces[] = $value['namehash']; $namespaces[] = $value['namehash'];
@ -47,10 +47,10 @@ fclose($handle);
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>'; $sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
$sitemap .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $sitemap .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$sitemap .= ' <sitemap>'; $sitemap .= ' <sitemap>';
$sitemap .= ' <loc>' . BASE_URL . '/sitemap.namespace.xml</loc>'; $sitemap .= ' <loc>' . BASE_URL . 'sitemap.namespace.xml</loc>';
$sitemap .= ' </sitemap>'; $sitemap .= ' </sitemap>';
$sitemap .= ' <sitemap>'; $sitemap .= ' <sitemap>';
$sitemap .= ' <loc>' . BASE_URL . '/sitemap.transaction.xml</loc>'; $sitemap .= ' <loc>' . BASE_URL . 'sitemap.transaction.xml</loc>';
$sitemap .= ' </sitemap>'; $sitemap .= ' </sitemap>';
$sitemap .= '</sitemapindex>'; $sitemap .= '</sitemapindex>';

4
library/icon.php

@ -165,7 +165,7 @@ final class Icon {
for ($i = 0; $i < count($shape); $i++) for ($i = 0; $i < count($shape); $i++)
$shape[$i] = $shape[$i] * $this->_spriteZ; $shape[$i] = $shape[$i] * $this->_spriteZ;
imagefilledpolygon($sprite, $shape, count($shape) / 2, $fg); imagefilledpolygon($sprite, $shape, $fg);
for ($i = 0; $i < $rotation; $i++) for ($i = 0; $i < $rotation; $i++)
$sprite = imagerotate($sprite, 90, $bg); $sprite = imagerotate($sprite, 90, $bg);
@ -215,7 +215,7 @@ final class Icon {
for ($i = 0; $i < count($shape); $i++) for ($i = 0; $i < count($shape); $i++)
$shape[$i] = $shape[$i] * $this->_spriteZ; $shape[$i] = $shape[$i] * $this->_spriteZ;
if (count($shape) > 0) if (count($shape) > 0)
imagefilledpolygon($sprite, $shape, count($shape) / 2, $fg); imagefilledpolygon($sprite, $shape, $fg);
return $sprite; return $sprite;
} }

268
library/sqlite.php

@ -0,0 +1,268 @@
<?php
class SQLite {
private PDO $_db;
public function __construct(string $database, string $username, string $password) {
try {
$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);
$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());
}
}
public function getNamespaceValueByNS(string $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]);
$result = $query->fetch();
return $result ? $result['value'] : '';
} catch(PDOException $e) {
trigger_error($e->getMessage());
return false;
}
}
public function getNamespaceHashByTX(string $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(string $namehash = '', string $txid = '', string $search = '', int $start = 0, int $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();
}
$result = $query->fetchAll();
return $result ? $result : [];
} catch(PDOException $e) {
trigger_error($e->getMessage());
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;
}
}
}

23
public/css/app.css

@ -12,8 +12,8 @@ button::-moz-focus-inner {
input, button { input, button {
opacity: 0.8; opacity: 0.8;
color: #18102d; color: #000;
background: #BFBACC; background: #ABA6B7;
border: 0; border: 0;
border-radius: 3px; border-radius: 3px;
height: 18px; height: 18px;
@ -23,8 +23,8 @@ input, button {
} }
body { body {
color: #E8E8E8; color: #BFBACC;
background-color: #18102d; background-color: #000;
font-family: Sans-Serif, Arial; font-family: Sans-Serif, Arial;
font-size: 14px; font-size: 14px;
font-weight: normal; font-weight: normal;
@ -32,12 +32,7 @@ body {
} }
a { a {
color: #BFBACC; color: #ABA6B7;
text-decoration: none;
}
a {
color: #BFBACC;
text-decoration: none; text-decoration: none;
-moz-transition: all .5s ease-in; -moz-transition: all .5s ease-in;
-o-transition: all .5s ease-in; -o-transition: all .5s ease-in;
@ -47,7 +42,7 @@ a {
} }
a:hover { a:hover {
color: #E8E8E8; color: #BFBACC;
-webkit-transition: all .5s ease-in; /* issue #2 */ -webkit-transition: all .5s ease-in; /* issue #2 */
} }
@ -96,7 +91,7 @@ img:hover {
.b-g::before { .b-g::before {
content: ""; content: "";
background-image: linear-gradient(to left, #9B94BF, #18102d); background-image: linear-gradient(to left, #9B94BF, #000);
height: 1px; height: 1px;
width: 50%; width: 50%;
max-width: 360px; max-width: 360px;
@ -105,7 +100,7 @@ img:hover {
.b-g::after { .b-g::after {
content: ""; content: "";
background-image: linear-gradient(to right, #9B94BF, #18102d); background-image: linear-gradient(to right, #9B94BF, #000);
height: 1px; height: 1px;
width: 50%; width: 50%;
max-width: 360px; max-width: 360px;
@ -127,7 +122,7 @@ img:hover {
.c-1:active, .c-1:active,
.c-1:visited, .c-1:visited,
.c-1:hover { .c-1:hover {
color: #ABA6B7; color: #BFBACC;
} }
.c-2, .c-2,

174
public/index.php

@ -0,0 +1,174 @@
<<<<<<< HEAD
<?php
require_once('../config.php');
require_once('../library/icon.php');
require_once('../library/sqlite.php');
$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', urldecode($_GET['q'])) : '';
$ns = '';
$tx = '';
$page = 0;
if (isset($_SERVER['REQUEST_URI'])) {
$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]) == 64) {
$tx = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]);
} else if (preg_match('/[0-9]+/', $q[1])) {
$page = (int) $q[1];
}
}
if (isset($q[2])) {
if ($q[2] == 'rss') {
$rss = true;
} else if (strlen($q[2]) == 34) {
$ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[2]);
} 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 {
$limit = PAGE_LIMIT * $page;
}
$db = new SQLite(DB_NAME, DB_USERNAME, DB_PASSWORD);
if ($ns) {
$namespaceHash = $ns;
$namespaceValue = $db->getNamespaceValueByNS($ns);
} else if ($tx) {
$namespaceHash = $db->getNamespaceHashByTX($tx);
$namespaceValue = $db->getNamespaceValueByNS($namespaceHash);
} else {
$namespaceHash = false;
$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[] = [
'namehash' => $value['namehash'],
'block' => $value['block'],
'txid' => $value['txid'],
'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'])),
];
}
$older = false;
$newer = false;
if (!in_array($page, [0, 1])) {
if ($page == 2) {
$newer = ($ns ? $ns : '');
} else {
$newer = ($ns ? $ns . '/' . ($page - 1) : ($page - 1));
}
if ($query) {
$newer = $newer . '?q=' . $query;
}
}
if ($data) {
if (in_array($page, [0, 1])) {
$older = ($ns ? $ns . '/2' : '2');
} else {
$older = ($ns ? $ns . '/' . ($page + 1) : ($page + 1));
}
if ($query) {
$older = $older . '?q=' . $query;
}
}
if ($ns) {
if ($page) {
$hrefThisPage = $ns . '/' . $page;
} else {
$hrefThisPage = $ns;
}
} else {
if ($page) {
$hrefThisPage = $page;
} else {
$hrefThisPage = '';
}
}
if ($rss) {
header('Content-type: application/xml');
require_once('rss.phtml');
} else {
require_once('index.phtml');
}
=======
>>>>>>> master

43
public/index.phtml

@ -1,11 +1,11 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="/css/app.css?v=4" /> <link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>css/app.css?v=9" />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="description" content="Open Source Content Exploring Platform for Kevacoin Blockchain" /> <meta name="description" content="Open Source Content Exploring Platform for Kevacoin Blockchain" />
<?php if ($namespaceHash) { ?> <?php if ($namespaceHash) { ?>
<link rel="icon" type="image/png" href="/image.php?hash=<?php echo $namespaceHash; ?>&radius=30" /> <link rel="icon" type="image/png" href="<?php echo BASE_URL; ?>image.php?hash=<?php echo $namespaceHash; ?>&radius=30" />
<?php } ?> <?php } ?>
<?php if ($ns) { ?> <?php if ($ns) { ?>
<?php if ($page) { ?> <?php if ($page) { ?>
@ -20,6 +20,8 @@
<meta name="robots" content="noindex,follow" /> <meta name="robots" content="noindex,follow" />
<?php } else if ($tx) { ?> <?php } else if ($tx) { ?>
<title><?php echo $tx && isset($data[0]['key']) ? $data[0]['key'] : $tx; ?> | <?php echo ($namespaceValue ? $namespaceValue : ($namespaceHash ? $namespaceHash : false)); ?> | KVAZAR</title> <title><?php echo $tx && isset($data[0]['key']) ? $data[0]['key'] : $tx; ?> | <?php echo ($namespaceValue ? $namespaceValue : ($namespaceHash ? $namespaceHash : false)); ?> | KVAZAR</title>
<?php } else if ($query) { ?>
<title>KVAZAR | SEARCH | <?php echo $query; ?></title>
<?php } else { ?> <?php } else { ?>
<title>KVAZAR | TODAY</title> <title>KVAZAR | TODAY</title>
<?php } ?> <?php } ?>
@ -29,11 +31,11 @@
<div class="t-center px-16 pt-54"> <div class="t-center px-16 pt-54">
<div class="mx-a mw-560 px-16"> <div class="mx-a mw-560 px-16">
<div class="mb-20"> <div class="mb-20">
<a class="logo f-s-20 c-0" href="/">KVAZAR</a> <a class="logo f-s-20 c-0" href="<?php echo BASE_URL; ?>">KVAZAR</a>
</div> </div>
<?php if ($ns) { ?> <?php if ($ns) { ?>
<div class="mx-a mw-560 px-16 pb-16"> <div class="mx-a mw-560 px-16 pb-16">
<img class="br-50 shine" src="/image.php?hash=<?php echo $ns; ?>" alt="<?php echo $ns; ?>" /> <img class="br-50 shine" src="<?php echo BASE_URL; ?>image.php?hash=<?php echo $ns; ?>" alt="<?php echo $ns; ?>" />
</div> </div>
<?php } ?> <?php } ?>
<div class="mb-36 c-1"><?php echo $namespaceValue ? $namespaceValue : 'Observe Kevacoin Universe'; ?></div> <div class="mb-36 c-1"><?php echo $namespaceValue ? $namespaceValue : 'Observe Kevacoin Universe'; ?></div>
@ -42,24 +44,30 @@
<div class="t-center px-16 pb-36"> <div class="t-center px-16 pb-36">
<div class="b-g"></div> <div class="b-g"></div>
</div> </div>
<?php if ($trends && !$ns && !$tx && !$page && !$q) { ?>
<div class="t-center px-16">
<div class="mx-a mw-560 px-16">
<?php foreach ($trends as $trend) { ?>
#<a href="<?php echo BASE_URL; ?>?q=<?php echo $trend; ?>"><?php echo $trend; ?></a>
<?php } ?>
</div>
</div>
<div class="t-center px-16 py-27">
<div class="b-g"></div>
</div>
<?php } ?>
<?php foreach ($data as $item) { ?> <?php foreach ($data as $item) { ?>
<div class="t-center px-16"> <div class="t-center px-16">
<div class="mx-a mw-560 px-16"> <div class="mx-a mw-560 px-16">
<?php if (!$ns) { ?> <?php if (!$ns) { ?>
<div class="mx-a mw-560 mb-16"> <div class="mx-a mw-560 mb-16">
<?php if (SEF_MODE) { ?> <a href="<?php echo BASE_URL; ?><?php echo $item['namehash']; ?>">
<a href="/<?php echo $item['namehash']; ?>"> <img class="br-50" src="<?php echo BASE_URL; ?>image.php?hash=<?php echo $item['namehash']; ?>" alt="<?php echo $item['namehash']; ?>" />
<img class="br-50" src="/image.php?hash=<?php echo $item['namehash']; ?>" alt="<?php echo $item['namehash']; ?>" />
</a>
<?php } else { ?>
<a href="/?ns=<?php echo $item['namehash']; ?>">
<img class="br-50" src="/image.php?hash=<?php echo $item['namehash']; ?>" alt="<?php echo $item['namehash']; ?>" />
</a> </a>
<?php } ?>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!$tx) { ?> <?php if (!$tx) { ?>
<a class="d-block" href="/<?php echo (SEF_MODE ? $item['txid'] : '?tx=' . $item['txid']); ?>"> <a class="d-block" href="<?php echo BASE_URL; ?><?php echo $item['txid']; ?>">
<?php } ?> <?php } ?>
<div class="f-s-16 mb-16 of-a"> <div class="f-s-16 mb-16 of-a">
<?php echo $item['key']; ?> <?php echo $item['key']; ?>
@ -80,23 +88,26 @@
<?php if (!$tx && ($newer !== false || $older !== false)) { ?> <?php if (!$tx && ($newer !== false || $older !== false)) { ?>
<div class="t-center pt-16 pb-27"> <div class="t-center pt-16 pb-27">
<?php if ($newer !== false) { ?> <?php if ($newer !== false) { ?>
<a href="/<?php echo $newer; ?>"<?php echo $newer ? ' rel="nofollow"' : false; ?>>newer</a> <a href="<?php echo BASE_URL; ?><?php echo $newer; ?>"<?php echo $newer ? ' rel="nofollow"' : false; ?>>newer</a>
<?php } ?> <?php } ?>
<?php if ($newer !== false && $older !== false) { ?> <?php if ($newer !== false && $older !== false) { ?>
| |
<?php } ?> <?php } ?>
<?php if ($older !== false) { ?> <?php if ($older !== false) { ?>
<a href="/<?php echo $older; ?>"<?php echo $older ? ' rel="nofollow"' : false; ?>>older</a> <a href="<?php echo BASE_URL; ?><?php echo $older; ?>"<?php echo $older ? ' rel="nofollow"' : false; ?>>older</a>
<?php } ?> <?php } ?>
</div> </div>
<?php } ?> <?php } ?>
<div class="t-center px-16 pb-27"> <div class="t-center px-16 pb-27">
<form name="namespace" action="/" method="GET"> <form name="namespace" action="<?php echo BASE_URL; ?>" method="GET">
<input class="p-8" type="text" name="q" value="<?php echo ($query ? $query : ''); ?>" placeholder="key, value, block, ns, txid" autocomplete="off" /> <input class="p-8" type="text" name="q" value="<?php echo ($query ? $query : ''); ?>" placeholder="key, value, block, ns, txid" autocomplete="off" />
<!--<button class="p-8 cursor-pointer" type="submit">Search</button>--> <!--<button class="p-8 cursor-pointer" type="submit">Search</button>-->
</form> </form>
</div> </div>
<div class="t-center px-16 pb-27"> <div class="t-center px-16 pb-27">
<?php if (!$tx && !$page) { ?>
<div class="pb-16 f-s-12"><a href="<?php echo BASE_URL; ?><?php echo ($query ? '?q=' . $query . '&rss' : ($ns ? $ns . '/rss' : 'rss')); ?>" rel="nofollow">RSS</a></div>
<?php } ?>
<div class="pb-16 f-s-12 c-1"><a href="https://github.com/kvazar-network/webapp">KVAZAR Webapp</a> is the content exploring platform for <a href="https://kevacoin.org">Kevacoin Blockchain</a>.</div> <div class="pb-16 f-s-12 c-1"><a href="https://github.com/kvazar-network/webapp">KVAZAR Webapp</a> is the content exploring platform for <a href="https://kevacoin.org">Kevacoin Blockchain</a>.</div>
<div class="f-s-12 c-1">Sources distributed under the MIT License. Ownership of all content belongs to the authors.</div> <div class="f-s-12 c-1">Sources distributed under the MIT License. Ownership of all content belongs to the authors.</div>
</div> </div>

21
public/rss.phtml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="<?php echo BASE_URL; ?><?php echo ($ns ? $ns . '/rss' :
($query ? '?q=' . $query . '&amp;rss' : 'rss')); ?>" rel="self" type="application/rss+xml"></atom:link>
<title>KVAZAR - <?php echo ($namespaceValue ? $namespaceValue :
($namespaceHash ? $namespaceHash :
($query ? 'SEARCH - ' . $query : 'TODAY'))); ?></title>
<description>Observe Kevacoin Universe</description>
<link><?php echo BASE_URL; ?><?php echo ($ns ? $ns : ($query ? '?q=' . $query : false)); ?></link>
<?php foreach ($data as $item) { ?>
<item>
<title><?php echo $item['key']; ?></title>
<guid><?php echo BASE_URL; ?><?php echo $item['txid']; ?></guid>
<pubDate><?php echo $item['time']; ?></pubDate>
<description><?php echo $item['value']; ?></description>
<link><?php echo BASE_URL; ?><?php echo $item['txid']; ?></link>
</item>
<?php } ?>
</channel>
</rss>
Loading…
Cancel
Save