Browse Source

various security, functional and validation changes

Signed-off-by: r4sas <r4sas@i2pmail.org>
master
R4SAS 3 years ago
parent
commit
ff0db3d8d4
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 4
      export.php
  2. 14
      fetch.php
  3. 24
      lib/utils.php
  4. 36
      public/css/style.css
  5. 4
      public/index.php
  6. 1
      templates/_page.twig
  7. 7
      templates/_pagination.twig
  8. 6
      templates/alive.twig
  9. 6
      templates/all.twig
  10. 28
      templates/home.twig
  11. 15
      templates/jump.twig
  12. 6
      templates/latest.twig
  13. 6
      templates/search.twig
  14. 10
      views/alive.php
  15. 2
      views/autojump.php
  16. 8
      views/home.php
  17. 2
      views/jump.php
  18. 7
      views/latest.php

4
export.php

@ -8,7 +8,7 @@ date_default_timezone_set ('UTC'); @@ -8,7 +8,7 @@ date_default_timezone_set ('UTC');
$pdo = (new App\DB($options))->pdo;
$util = new App\Utils;
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial`, `disabled`, `hidden` FROM hosts");
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `approved`, `initial`, `disabled`, `hidden`, `blacklisted` FROM hosts");
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
$curr_time = time();
@ -41,7 +41,7 @@ foreach ($hosts as $host) @@ -41,7 +41,7 @@ foreach ($hosts as $host)
array_push($export_full, $domain . "=" . $host["base64"]);
array_push($export_addr_full, $domain . "," . $host["base32"]);
if (($options["approval"] == false || $host["approved"] == 1) && $host["hidden"] == 0 && $host["disabled"] == 0)
if (($options["approval"] == false || $host["approved"] == 1) && $host["hidden"] == 0 && $host["disabled"] == 0 && $host["blacklisted"] == 0)
{
if (($last_seen + $hideoffs) > $curr_time) {
array_push($export_live, $domain . "=" . $host["base64"]);

14
fetch.php

@ -22,7 +22,7 @@ $STH = $pdo->query ("SELECT `name`, `url`, `modified`, `etag` FROM `subscription @@ -22,7 +22,7 @@ $STH = $pdo->query ("SELECT `name`, `url`, `modified`, `etag` FROM `subscription
$lists = $STH->fetchAll(PDO::FETCH_ASSOC);
foreach ($lists as $list) {
echo "Processing " . $list['name'] . " subscription...";
echo "Processing " . $list['name'] . " subscription... ";
if (!empty($list['modified']))
$aContext['http']['header'] = 'If-Modified-Since: ' . $list['modified'] . '\r\n';
@ -37,7 +37,7 @@ foreach ($lists as $list) { @@ -37,7 +37,7 @@ foreach ($lists as $list) {
$f_meta = stream_get_meta_data($f);
if (strpos($f_meta['wrapper_data'][0], "200") === false) {
echo " no changes." . PHP_EOL;
echo "no changes (" . $f_meta['wrapper_data'][0]. ")" . PHP_EOL;
continue;
}
@ -45,13 +45,16 @@ foreach ($lists as $list) { @@ -45,13 +45,16 @@ foreach ($lists as $list) {
$etag = $util->getResponseHeader("Etag", $f_meta['wrapper_data']);
if (!empty($lastmod) || !empty($etag)) {
$pdo->exec("UPDATE `subscriptions` SET " . (!empty($lastmod) ? ("`modified` = '" . $lastmod . "' ") : "") . (!empty($etag) ? ("`etag` = '" . $etag . "' ") : "") . "WHERE `name` = '" . $list['name'] . "'");
$pdo->exec("UPDATE `subscriptions` SET" . (!empty($lastmod) ? (" `modified` = '" . $lastmod . "'") : "") . (!empty($etag) ? ((!empty($lastmod) ? "," : "") . " `etag` = '" . $etag . "'") : "") . " WHERE `name` = '" . $list['name'] . "'");
}
// reset line
echo " fetching updated list." . PHP_EOL;
echo "fetching updated list." . PHP_EOL;
while (($buffer = fgets($f, 4096)) !== false) {
if (substr($buffer, 0, 1) === "#")
continue;
$domain = "";
$record = $util->parseHostRecord($buffer);
@ -69,6 +72,7 @@ foreach ($lists as $list) { @@ -69,6 +72,7 @@ foreach ($lists as $list) {
}
if (!$util->isValidBase64($record['b64'])) {
echo "Error while validating " . $record['host'] . ": invalid or unsupported base64 (len: " . strlen($record['b64']) . ")" . PHP_EOL;
continue;
}
@ -91,7 +95,7 @@ foreach ($lists as $list) { @@ -91,7 +95,7 @@ foreach ($lists as $list) {
continue;
}
if(isset($record['commands']) && !$pdo->query("SELECT COUNT(*) FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1")->fetchColumn()) {
if(!$pdo->query("SELECT COUNT(*) FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1")->fetchColumn()) {
$base32 = $util->b32from64($record['b64']);
$pdo->exec("INSERT INTO `hosts` (`host`, `base64`, `base32`, `approved`) VALUES ('" . $domain . "', '" . $record["b64"] . "', '" . $base32 . "', 1)");

24
lib/utils.php

@ -153,15 +153,33 @@ class Utils { @@ -153,15 +153,33 @@ class Utils {
{
$len = strlen($data);
if($len < 5 || $len > 255) // rfc2181, section 11
if($len < 5 || $len > 255) // 255 max: rfc2181, section 11
{
$result = "Domain must be longer than 5 and lesser than 255 chars.";
return false;
}
if(preg_match('/\.b32\.i2p$/', $data))
if(preg_match('/(?:^b32|\.b32)\.i2p$/', $data))
{
$result = "Domain can't end with .b32.i2p.";
$result = "Domain can't be b32.i2p or end with .b32.i2p.";
return false;
}
if(preg_match('/(?:^console|\.console)\.i2p$/', $data))
{
$result = "Domain can't be console.i2p or end with .console.i2p.";
return false;
}
if(preg_match('/(?:^proxy|\.proxy)\.i2p$/', $data))
{
$result = "Domain can't be proxy.i2p or end with .proxy.i2p.";
return false;
}
if(preg_match('/(?:^router|\.router)\.i2p$/', $data))
{
$result = "Domain can't be router.i2p or end with .router.i2p.";
return false;
}

36
public/css/style.css

@ -35,6 +35,12 @@ main { @@ -35,6 +35,12 @@ main {
margin-bottom: 5px;
}
.container_main li ul {
padding-left: 22px;
margin-bottom: unset;
margin-top: 5px;
}
.container_main b {
font-size: 18px;
margin-bottom: 5px;
@ -187,6 +193,7 @@ abbr { @@ -187,6 +193,7 @@ abbr {
flex-flow: row nowrap;
align-items: stretch;
justify-content: space-between;
background: #c1c1c1;
}
.main-menu__item {
@ -368,10 +375,6 @@ abbr { @@ -368,10 +375,6 @@ abbr {
color: #ddddff;
}
.table__row td:last-of-type {
white-space: nowrap;
}
.table__cell {
padding: 8px;
}
@ -381,6 +384,16 @@ abbr { @@ -381,6 +384,16 @@ abbr {
font-weight: bold;
}
.table__cell_date {
white-space: nowrap;
max-width: 225px;
text-align: center;
}
.table__cell_full-b32 {
user-select: all;
}
.pagination {
margin-top: 40px;
display: flex;
@ -596,6 +609,7 @@ abbr { @@ -596,6 +609,7 @@ abbr {
flex-flow: column nowrap;
align-items: stretch;
justify-content: flex-start;
background: unset;
}
.main-menu__item {
@ -628,10 +642,6 @@ abbr { @@ -628,10 +642,6 @@ abbr {
min-width: 48px;
}
.table__cell_full-b32 {
display: none;
}
.text-input {
padding: 0 6px;
font-size: 16px;
@ -658,4 +668,14 @@ abbr { @@ -658,4 +668,14 @@ abbr {
.main-menu__item {
min-width: 45vw;
}
.table__cell_date {
white-space: unset;
}
}
@media screen and (max-width: 530px) {
.table__cell_full-b32 {
display: none;
}
}

4
public/index.php

@ -15,7 +15,7 @@ $r->addRoute('^/add/?$', function($url) { @@ -15,7 +15,7 @@ $r->addRoute('^/add/?$', function($url) {
require __DIR__ . '/../views/add.php';
});
$r->addRoute('^/alive/?([0-9]+)?/?', function($url, $page = 1) {
$r->addRoute('^/alive/?([0-9]+)?/?(?:\?|$)', function($url, $page = 1) {
require __DIR__ . '/../views/alive.php';
});
@ -31,7 +31,7 @@ $r->addRoute('^/autojump/?(.*)/?', function($url, $query = "") { @@ -31,7 +31,7 @@ $r->addRoute('^/autojump/?(.*)/?', function($url, $query = "") {
require __DIR__ . '/../views/autojump.php';
});
$r->addRoute('^/latest/?$', function($url) {
$r->addRoute('^/latest/?(?:\?|$)', function($url) {
require __DIR__ . '/../views/latest.php';
});

1
templates/_page.twig

@ -15,7 +15,6 @@ @@ -15,7 +15,6 @@
{% endblock %}
</head>
<body>
<!-- <div id="loadOverlay" style="background-color:#333; position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000;"></div> -->
<header class="header">
<div class="header__top">
<div class="logo header__logo">

7
templates/_pagination.twig

@ -24,17 +24,16 @@ @@ -24,17 +24,16 @@
</li>
{% if 1 != loop.index %}
<li class="pagination__item">
<a href="#" class="pagination__link"><span>...</span>
</a>
<div class="pagination__link"><span>...</span></div>
</li>
{% endif %}
{% elseif 0 == (current + nearbyPagesLimit) - loop.index and (current + nearbyPagesLimit) < total %}
<li class="pagination__item pagination__item_see-more"><a href="#" class=" pagination__link_see-more pagination__link"><span>...</span></a></li>
<li class="pagination__item pagination__item_see-more"><div class="pagination__link_see-more pagination__link"><span>...</span></div></li>
{% elseif 0 < (current - nearbyPagesLimit) - loop.index %}
{% elseif 0 > (current + nearbyPagesLimit) - loop.index %}
{% else %}
{% if current == loop.index %}
<li class="active pagination__item pagination__item_active"><a href="#" class="pagination__link"><span aria-current="page">{{ loop.index }}</span></a></li>
<li class="active pagination__item pagination__item_active"><div class="pagination__link"><span aria-current="page">{{ loop.index }}</span></div></li>
{% else %}
{% if loop.index == 1 %}
<li class="pagination__item"><a href="{{ main_url }}" class="pagination__link">{{ loop.index }}</a></li>

6
templates/alive.twig

@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
<th class="table__cell"><abbr title="Address Helper">AH</abbr></th>
<th class="table__cell"><abbr title="Base32 address">B32</abbr></th>
<th class="table__cell table__cell_full-b32">Full Base32</th>
<th class="table__cell">Last seen</th>
<th class="table__cell table__cell_date">Last seen</th>
</tr>
</thead>
<tbody class="table__body">
@ -28,8 +28,8 @@ @@ -28,8 +28,8 @@
{% endif %}
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
<td class="table__cell">{{ host.last_seen }}</td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}</td>
<td class="table__cell table__cell_date">{{ host.last_seen }}</td>
</tr>
{% endfor %}
</tbody>

6
templates/all.twig

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<th class="table__cell"><abbr title="Address Helper">AH</abbr></th>
<th class="table__cell"><abbr title="Base32 address">B32</abbr></th>
<th class="table__cell table__cell_full-b32">Full Base32</th>
<th class="table__cell">Last seen</th>
<th class="table__cell table__cell_date">Last seen</th>
</tr>
</thead>
<tbody class="table__body">
@ -25,8 +25,8 @@ @@ -25,8 +25,8 @@
<td class="table__cell"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }} rel="external nofollow noopener noreferrer" target="_blank"">A</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
<td class="table__cell">{{ host.last_seen != '0000-00-00 00:00:00' ? host.last_seen : 'Never' }}</td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}</td>
<td class="table__cell table__cell_date">{{ host.last_seen != '0000-00-00 00:00:00' ? host.last_seen : 'Never' }}</td>
</tr>
{% endfor %}
</tbody>

28
templates/home.twig

@ -42,17 +42,17 @@ @@ -42,17 +42,17 @@
Your domain will become open for registration again (disabled) if it is dead for:
<ul>
<li>{{ delnewdays }} days if last seen less than {{ newdays }} days since registration</li>
<li>{{ delapprdays }} days if last seen less than {{ olddays }} days since registration</li>
<li>{{ delactdays }} days if last seen less than {{ olddays }} days since registration</li>
<li>{{ delstabdays }} days if last seen more than {{ olddays }} days since registration</li>
</ul>
Domains that are inaccessible before the disabling date for {{ hidedays }} days, will be hidden from <a href="/alive">alive</a> list, removed from export lists, but will still be checked every hour.<br>
When domain dead for amount days stated above, it will be marked as disabled, opened for registration and will be checked once a day for availability at {{ fullhour }} o'clock UTC.
</p>
{% if approval %}
{% if activation %}
<p>
<b>Approval:</b><br>
Your domain will generally be approved within {{ apprdelay }} hour(s). However, your domain must be alive within the last {{ apprseen }} hour(s) before the approval is due.
<b>Activation:</b><br>
Your domain will appear in the listing within {{ actdelay }} hour(s). However, your domain must be alive within the last {{ actseen }} hour(s) before the activation is due.
</p>
{% endif %}
@ -66,6 +66,24 @@ @@ -66,6 +66,24 @@
{% endfor %}
</ul>
</p>
</div>
{% endif %}
<p>
<b>Terms of use:</b>
<ul>
<li>Service owner is not responsible about content published on submitted domains</li>
<li>Submited domains processed automaticly. No human involved in process</li>
<li>Domains with offensive content will be hidden from the list
<ul>
<li>they can be found using the search and jump links</li>
<li>adding <code>?all</code> to page address (like <code>/alive?all</code>) will show them</li>
<li>such domains won't be exported to subscriptions</li>
<li>if you disagree with some eepsite's content - we won't do anything, only specific categories might be hidden</li>
</ul>
</li>
<li>Any complaints should be sent to <a href="http://sportloto.i2p" target="_blank">Sportloto</a></li>
<li>You can contact with reg.i2p site owners on Ilita IRC network (irc.ilita.i2p or irc.r4sas.i2p or irc.acetone.i2p) at #dev, #en or #ru channels</li>
</ul>
</p>
</div>
{% endblock %}

15
templates/jump.twig

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
{% if autojump %}
{% if not result %}
<meta http-equiv="refresh" content="2; URL=/jump/" />
{% elseif result.error|length > 0 %}
{% elseif result.error|length > 0 or result.blacklisted == 1 %}
{# Skipping redirect #}
{% elseif result.uri|length > 0 %}
<meta http-equiv="refresh" content="4; URL=http://{{ result.host }}/{{ result.uri }}{% if '?' in result.uri %}&{% else %}?{% endif %}i2paddresshelper={{ result.base64 }}" />
@ -30,11 +30,24 @@ @@ -30,11 +30,24 @@
<div class="jumper__succ">
<h3 class="jumper__title title">Query result for "{{ result.host }}"</h3>
{% if autojump %}
{% if result.blacklisted == 1 %}
<div class="jumper__line line">
Site is found, but autoredirect is disabled because <font color="red">site marked as offensive</font>. Press link below to continue anyway.
</div>
<br>
{% else %}
<div class="jumper__line line">
Site is found. You will be redirected soon...
</div>
<br>
{% endif %}
{% endif %}
{% if not autojump and result.blacklisted == 1 %}
<div class="jumper__line line">
Note: <font color="red">site marked as offensive</font>. Press link below to continue anyway.
</div>
<br>
{% endif %}
<div class="jumper__line line">
<span>
Addresshelper:

6
templates/latest.twig

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<th class="table__cell"><abbr title="Address Helper">AH</abbr></th>
<th class="table__cell"><abbr title="Base32 address">B32</abbr></th>
<th class="table__cell table__cell_full-b32">Full Base32</th>
<th class="table__cell"><abbr title="Hover to see last seen time">Added</abbr></th>
<th class="table__cell table__cell_date"><abbr title="Hover to see last seen time">Added</abbr></th>
</tr>
</thead>
<tbody class="table__body">
@ -29,8 +29,8 @@ @@ -29,8 +29,8 @@
{% endif %}
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
<td class="table__cell" title="{{ host.last_seen }}">{{ host.add_date }}</td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}</td>
<td class="table__cell table__cell_date" title="{{ host.last_seen }}">{{ host.add_date }}</td>
</tr>
{% endfor %}
</tbody>

6
templates/search.twig

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
<th class="table__cell"><abbr title="Address Helper">AH</abbr></th>
<th class="table__cell"><abbr title="Base32 address">B32</abbr></th>
<th class="table__cell table__cell_full-b32">Full Base32</th>
<th class="table__cell">Last seen</th>
<th class="table__cell table__cell_date">Last seen</th>
</tr>
</thead>
<tbody class="table__body">
@ -33,8 +33,8 @@ @@ -33,8 +33,8 @@
<td class="table__cell"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
<td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}.b32.i2p</td>
<td class="table__cell">{{ host.last_seen != '0000-00-00 00:00:00' ? host.last_seen : 'Never' }}</td>
<td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}</td>
<td class="table__cell table__cell_date">{{ host.last_seen != '0000-00-00 00:00:00' ? host.last_seen : 'Never' }}</td>
</tr>
{% endfor %}
</tbody>

10
views/alive.php

@ -10,13 +10,18 @@ $twig = new \Twig\Environment($loader, [ @@ -10,13 +10,18 @@ $twig = new \Twig\Environment($loader, [
'auto_reload' => true,
]);
$all = false;
$offset = $options["tableitems"] * ($page - 1);
$pdo = (new App\DB($options))->pdo;
if (isset($_GET["all"]))
$all = true;
/* Get records amount */
$STH = $pdo->query ("SELECT COUNT(*) as `count` FROM `hosts` " .
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0");
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0" .
($all ? "" : " AND `blacklisted` = 0"));
$STH->setFetchMode (PDO::FETCH_ASSOC);
$records = $STH->fetch()["count"];
@ -24,7 +29,8 @@ $pages = intdiv($records, $options["tableitems"]) + 1; @@ -24,7 +29,8 @@ $pages = intdiv($records, $options["tableitems"]) + 1;
/* Get records with limit */
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` " .
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0 " .
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0" .
($all ? " " : " AND `blacklisted` = 0 ") .
"LIMIT " . $offset . ", " . $options["tableitems"]);
$STH->setFetchMode(PDO::FETCH_ASSOC);
$rows = $STH->fetchAll();

2
views/autojump.php

@ -40,7 +40,7 @@ else if(!empty($domain) && $utils->isValidDomain($domain, $error)) { @@ -40,7 +40,7 @@ else if(!empty($domain) && $utils->isValidDomain($domain, $error)) {
$pdo = (new App\DB($options))->pdo;
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen`, `blacklisted` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
$STH->setFetchMode(PDO::FETCH_ASSOC);
$row = $STH->fetchAll();

8
views/home.php

@ -21,13 +21,13 @@ if ($options['fetcher']) { @@ -21,13 +21,13 @@ if ($options['fetcher']) {
}
$vars = array(
'approval' => $options['approval'],
'apprdelay' => $options['approvedelay'],
'apprseen' => $options['approveseen'],
'activation' => $options['approval'],
'actdelay' => $options['approvedelay'],
'actseen' => $options['approveseen'],
'newdays' => $options['newdays'],
'olddays' => $options['olddays'],
'delnewdays' => $options['delnewdays'],
'delapprdays' => $options['delapprdays'],
'delactdays' => $options['delapprdays'],
'delstabdays' => $options['delstabdays'],
'hidedays' => $options['hidedays'],
'fullhour' => $options['fullhour'],

2
views/jump.php

@ -46,7 +46,7 @@ else if(!empty($domain) && $utils->isValidDomain($domain, $error)) { @@ -46,7 +46,7 @@ else if(!empty($domain) && $utils->isValidDomain($domain, $error)) {
$pdo = (new App\DB($options))->pdo;
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
$STH = $pdo->query("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen`, `blacklisted` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1");
$STH->setFetchMode(PDO::FETCH_ASSOC);
$row = $STH->fetchAll();

7
views/latest.php

@ -10,10 +10,15 @@ $twig = new \Twig\Environment($loader, [ @@ -10,10 +10,15 @@ $twig = new \Twig\Environment($loader, [
'auto_reload' => true,
]);
$all = false;
$pdo = (new App\DB($options))->pdo;
if (isset($_GET["all"]))
$all = true;
/* Get records with limit */
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen` FROM `hosts` WHERE `disabled` = 0 ORDER BY `add_date` DESC LIMIT " . $options["tableitems"]);
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `add_date`, `last_seen` FROM `hosts` WHERE `disabled` = 0" . ($all ? "" : " AND `blacklisted` = 0") . " ORDER BY `add_date` DESC LIMIT " . $options["tableitems"]);
$STH->setFetchMode(PDO::FETCH_ASSOC);
$rows = $STH->fetchAll();

Loading…
Cancel
Save