@@ -51,7 +52,7 @@
{% endif %}
-
+
diff --git a/views/404.php b/views/404.php
index 18b90fb..fdcce21 100644
--- a/views/404.php
+++ b/views/404.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$template = $twig->load('404.twig');
echo $template->render();
diff --git a/views/add.php b/views/add.php
index c2dcf5f..879b7ad 100644
--- a/views/add.php
+++ b/views/add.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$all = false;
$record = "";
diff --git a/views/alive.php b/views/alive.php
index aa08f85..8956643 100644
--- a/views/alive.php
+++ b/views/alive.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$all = false;
$offset = $options["tableitems"] * ($page - 1);
@@ -35,4 +27,4 @@ $STH->setFetchMode(PDO::FETCH_ASSOC);
$rows = $STH->fetchAll();
$template = $twig->load('alive.twig');
-echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'all' => $all]);
+echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);
diff --git a/views/all.php b/views/all.php
index 9c9d157..6ed7b7e 100644
--- a/views/all.php
+++ b/views/all.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$all = false;
$offset = $options["tableitems"] * ($page - 1);
@@ -22,14 +14,14 @@ if (isset($_GET["all"]))
$all = true;
/* Get records amount */
-$STH = $pdo->query ("SELECT COUNT(*) FROM `hosts`");
+$STH = $pdo->query ("SELECT COUNT(*) FROM `hosts`" . ($all ? "" : " WHERE `blacklisted` = 0"));
$records = $STH->fetchColumn();
$pages = intdiv($records, $options["tableitems"]) + 1;
/* Get records with limit */
-$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` LIMIT " . $offset . ", " . $options["tableitems"]);
+$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts`" . ($all ? "" : " WHERE `blacklisted` = 0") . " LIMIT " . $offset . ", " . $options["tableitems"]);
$rows = $STH->fetchAll(PDO::FETCH_ASSOC);
$template = $twig->load('all.twig');
-echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'all' => $all]);
+echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);
diff --git a/views/api.php b/views/api.php
index e2bd086..7fdf961 100644
--- a/views/api.php
+++ b/views/api.php
@@ -7,7 +7,7 @@ $data = [];
$pdo = (new App\DB($options))->pdo;
-header('Content-Type: application/json');
+header('Content-Type: application/json; charset=utf-8');
if (isset($_GET["all"]))
$all = true;
diff --git a/views/autojump.php b/views/autojump.php
index 35bcfcc..1fec61b 100644
--- a/views/autojump.php
+++ b/views/autojump.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$utils = new App\Utils;
diff --git a/views/hidden.php b/views/hidden.php
index d4d52fd..8fc8011 100644
--- a/views/hidden.php
+++ b/views/hidden.php
@@ -10,15 +10,7 @@ if (isset($_GET["all"])) {
exit();
}
-require_once __DIR__ . '/../vendor/autoload.php';
-require_once __DIR__ . '/../config.php';
-
-/* Initialize Twig engine */
-$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
-$twig = new \Twig\Environment($loader, [
- 'cache' => __DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$offset = $options["tableitems"] * ($page - 1);
@@ -38,4 +30,4 @@ $STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts`
$rows = $STH->fetchAll(PDO::FETCH_ASSOC);
$template = $twig->load('hidden.twig');
-echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'all' => $all]);
+echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);
diff --git a/views/home.php b/views/home.php
index 338415a..78667df 100644
--- a/views/home.php
+++ b/views/home.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$all = false;
$pdo = (new App\DB($options))->pdo;
@@ -26,20 +18,21 @@ $STH = $pdo->query ("SELECT COUNT(*) FROM `hosts` WHERE `blacklisted` = 1");
$blackcnt = $STH->fetchColumn();
$vars = array(
- 'activation' => $options['approval'],
- 'actdelay' => $options['approvedelay'],
- 'actseen' => $options['approveseen'],
- 'newdays' => $options['newdays'],
- 'olddays' => $options['olddays'],
- 'delnewdays' => $options['delnewdays'],
- 'delactdays' => $options['delapprdays'],
- 'delstabdays' => $options['delstabdays'],
- 'hidedays' => $options['hidedays'],
- 'fullhour' => $options['fullhour'],
- 'fetcher' => $options['fetcher'],
- 'subscrs' => $subscrs,
- 'blackcnt' => $blackcnt,
- 'all' => $all
+ 'activation' => $options['approval'],
+ 'actdelay' => $options['approvedelay'],
+ 'actseen' => $options['approveseen'],
+ 'newdays' => $options['newdays'],
+ 'olddays' => $options['olddays'],
+ 'delnewdays' => $options['delnewdays'],
+ 'delactdays' => $options['delapprdays'],
+ 'delstabdays' => $options['delstabdays'],
+ 'hidedays' => $options['hidedays'],
+ 'fullhour' => $options['fullhour'],
+ 'fetcher' => $options['fetcher'],
+ 'exportperiod' => $options['exportperiod'],
+ 'subscrs' => $subscrs,
+ 'blackcnt' => $blackcnt,
+ 'all' => $all
);
$template = $twig->load('home.twig');
diff --git a/views/jump.php b/views/jump.php
index 259f9c8..556e828 100644
--- a/views/jump.php
+++ b/views/jump.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$utils = new App\Utils;
diff --git a/views/latest.php b/views/latest.php
index cdcb668..dbf98d8 100644
--- a/views/latest.php
+++ b/views/latest.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$all = false;
diff --git a/views/search.php b/views/search.php
index 669e49c..7ea0d55 100644
--- a/views/search.php
+++ b/views/search.php
@@ -1,14 +1,6 @@
__DIR__ . '/../cache',
- 'auto_reload' => true,
-]);
+require_once __DIR__ . '/../lib/twig.php';
$utils = new App\Utils;
@@ -19,6 +11,8 @@ $all = false;
if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST["q"]) > 67) {
$result["error"] = "Request is too long, max length is 67 chars";
+} else if (isset($query) && !empty($query) && strlen($query) < 3 || isset($_POST["q"]) && strlen($_POST["q"]) < 3) {
+ $result["error"] = "Request is too short, min length is 3 chars";
} else if (isset($query) && !empty($query)) {
$q = htmlspecialchars($query);
} else if (isset($_POST["q"])) {
@@ -50,4 +44,4 @@ if(!empty($q)) {
}
$template = $twig->load('search.twig');
-echo $template->render(['query' => $q ?: 'removed request', 'result' => $result, 'limit' => $options["tableitems"], 'all' => $all]);
+echo $template->render(['query' => $q ?: '', 'result' => $result, 'limit' => $options["tableitems"], 'all' => $all]);