Browse Source

implement RSS feed

pull/8/head
d47081 2 years ago
parent
commit
f17f470e9e
  1. 18
      public/index.php
  2. 3
      public/index.phtml
  3. 16
      public/rss.phtml

18
public/index.php

@ -8,6 +8,7 @@ $query = isset($_GET['q']) ? preg_replace('/[\W\D\S]+/', '', $_GET['q']) : @@ -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) { @@ -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) { @@ -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');
}

3
public/index.phtml

@ -97,6 +97,9 @@ @@ -97,6 +97,9 @@
</form>
</div>
<div class="t-center px-16 pb-27">
<?php if (!$tx) { ?>
<div class="pb-16 f-s-12"><a href="?rss">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="f-s-12 c-1">Sources distributed under the MIT License. Ownership of all content belongs to the authors.</div>
</div>

16
public/rss.phtml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<?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; ?>/?rss" rel="self" type="application/rss+xml" />
<title><?php echo $namespaceValue ? $namespaceValue : 'KVAZAR'; ?></title>
<description>Observe Kevacoin Universe</description>
<?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>
</item>
<?php } ?>
</channel>
</rss>
Loading…
Cancel
Save