Browse Source

add i18n extension, pluralize strings

Signed-off-by: r4sas <r4sas@i2pmail.org>
master
R4SAS 9 months ago
parent
commit
4777b23615
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 3
      composer.json
  2. 89
      composer.lock
  3. 11
      config.php.dist
  4. 18
      lib/twig.php
  5. 0
      messages/.gitkeep
  6. 2
      templates/_page.twig
  7. 2
      templates/alive.twig
  8. 2
      templates/all.twig
  9. 2
      templates/hidden.twig
  10. 18
      templates/home.twig
  11. 15
      templates/search.twig
  12. 10
      views/404.php
  13. 10
      views/add.php
  14. 12
      views/alive.php
  15. 16
      views/all.php
  16. 2
      views/api.php
  17. 10
      views/autojump.php
  18. 12
      views/hidden.php
  19. 39
      views/home.php
  20. 10
      views/jump.php
  21. 10
      views/latest.php
  22. 14
      views/search.php

3
composer.json

@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
"require": {
"php": "^7.2.5",
"twig/twig": "^3.0",
"amphp/parallel": "^1.4"
"amphp/parallel": "^1.4",
"phpmyadmin/twig-i18n-extension": "^4.0"
},
"license": "MIT",
"authors": [

89
composer.lock generated

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4053556a32d0a974795f8ab1ee625ae1",
"content-hash": "6202f57b53ac8b2d5ad750bb4c02ff0f",
"packages": [
{
"name": "amphp/amp",
@ -174,16 +174,16 @@ @@ -174,16 +174,16 @@
},
{
"name": "amphp/parallel",
"version": "v1.4.2",
"version": "v1.4.3",
"source": {
"type": "git",
"url": "https://github.com/amphp/parallel.git",
"reference": "75853e1623efa5aa5e65e986ec9a97db573a5267"
"reference": "3aac213ba7858566fd83d38ccb85b91b2d652cb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/parallel/zipball/75853e1623efa5aa5e65e986ec9a97db573a5267",
"reference": "75853e1623efa5aa5e65e986ec9a97db573a5267",
"url": "https://api.github.com/repos/amphp/parallel/zipball/3aac213ba7858566fd83d38ccb85b91b2d652cb0",
"reference": "3aac213ba7858566fd83d38ccb85b91b2d652cb0",
"shasum": ""
},
"require": {
@ -236,7 +236,7 @@ @@ -236,7 +236,7 @@
],
"support": {
"issues": "https://github.com/amphp/parallel/issues",
"source": "https://github.com/amphp/parallel/tree/v1.4.2"
"source": "https://github.com/amphp/parallel/tree/v1.4.3"
},
"funding": [
{
@ -244,7 +244,7 @@ @@ -244,7 +244,7 @@
"type": "github"
}
],
"time": "2022-12-30T00:21:42+00:00"
"time": "2023-03-23T08:04:23+00:00"
},
{
"name": "amphp/parser",
@ -499,6 +499,62 @@ @@ -499,6 +499,62 @@
],
"time": "2021-10-25T18:29:10+00:00"
},
{
"name": "phpmyadmin/twig-i18n-extension",
"version": "v4.0.1",
"source": {
"type": "git",
"url": "https://github.com/phpmyadmin/twig-i18n-extension.git",
"reference": "c0d0dd171cd1c7733bf152fd44b61055843df052"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpmyadmin/twig-i18n-extension/zipball/c0d0dd171cd1c7733bf152fd44b61055843df052",
"reference": "c0d0dd171cd1c7733bf152fd44b61055843df052",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"twig/twig": "^1.42.3|^2.0|^3.0"
},
"require-dev": {
"phpmyadmin/coding-standard": "^3.0.0",
"phpmyadmin/motranslator": "^5.2",
"phpstan/phpstan": "^0.12.66",
"phpunit/phpunit": "^7 || ^8 || ^9"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpMyAdmin\\Twig\\Extensions\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "The phpMyAdmin Team",
"email": "developers@phpmyadmin.net",
"homepage": "https://www.phpmyadmin.net/team/"
}
],
"description": "Internationalization support for Twig via the gettext library",
"keywords": [
"gettext",
"i18n"
],
"support": {
"issues": "https://github.com/phpmyadmin/twig-i18n-extension/issues",
"source": "https://github.com/phpmyadmin/twig-i18n-extension"
},
"time": "2021-06-10T15:53:38+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.27.0",
@ -666,16 +722,16 @@ @@ -666,16 +722,16 @@
},
{
"name": "twig/twig",
"version": "v3.5.1",
"version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "a6e0510cc793912b451fd40ab983a1d28f611c15"
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a6e0510cc793912b451fd40ab983a1d28f611c15",
"reference": "a6e0510cc793912b451fd40ab983a1d28f611c15",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/106c170d08e8415d78be2d16c3d057d0d108262b",
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b",
"shasum": ""
},
"require": {
@ -684,15 +740,10 @@ @@ -684,15 +740,10 @@
"symfony/polyfill-mbstring": "^1.3"
},
"require-dev": {
"psr/container": "^1.0",
"psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.5-dev"
}
},
"autoload": {
"psr-4": {
"Twig\\": "src/"
@ -726,7 +777,7 @@ @@ -726,7 +777,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.5.1"
"source": "https://github.com/twigphp/Twig/tree/v3.6.0"
},
"funding": [
{
@ -738,7 +789,7 @@ @@ -738,7 +789,7 @@
"type": "tidelift"
}
],
"time": "2023-02-08T07:49:20+00:00"
"time": "2023-05-03T19:06:57+00:00"
}
],
"packages-dev": [],

11
config.php.dist

@ -40,4 +40,15 @@ $options = [ @@ -40,4 +40,15 @@ $options = [
'fullhour' => 8, // make hosts full-check at that hour (0-23). Usage of out-of-range value or at other hours, checker will validate only enabled domains.
'checkthreads' => 64, // checker threads amount
'exportperiod' => 4, // lists update period in hours as configured in crontab, used only for fomatting home page
];
/* Twig template engine configuration */
$twigTplDir = __DIR__ . '/templates'; // templates directory
$twigMsgDir = __DIR__ . '/messages'; // translations directory
$twigConfig = [
'cache' => __DIR__ . '/cache',
'auto_reload' => true,
];

18
lib/twig.php

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php';
use PhpMyAdmin\Twig\Extensions\I18nExtension;
/* Initialize Twig engine */
$loader = new \Twig\Loader\FilesystemLoader($twigTplDir);
$twig = new \Twig\Environment($loader, $twigConfig);
/* Enabling and configuring i18n extension */
$twig->addExtension(new I18nExtension());
bindtextdomain('regi2p', $twigMsgDir);
bind_textdomain_codeset('regi2p', 'UTF-8');
textdomain('regi2p');

0
messages/.gitkeep

2
templates/_page.twig

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
{% if all %}
<input type="hidden" name="all" value="true">
{% endif %}
<input type="text" name="q" class="text-input search__text-input" maxlength="67" placeholder="Search address">
<input type="text" name="q" class="text-input search__text-input" minlength="3" maxlength="67" placeholder="Search address" required>
<button type="submit" class="search__btn">
<svg enable-background="new 0 0 32 32" id="search_svg" version="1.1" viewBox="0 0 32 32" width="20px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="search_1_">

2
templates/alive.twig

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<div class="container">
<div class="alive-hosts">
<p class="important title" align="center">
Alive domains
Alive domains ({% trans %}one record{% plural records %}{{ count }} records{% endtrans %})
</p>
<table class="table">

2
templates/all.twig

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<div class="all-hosts">
<p class="important title" align="center">
All domains
All domains ({% trans %}one record{% plural records %}{{ count }} records{% endtrans %})
</p>
<table class="table">

2
templates/hidden.twig

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<div class="container">
<div class="alive-hosts">
<p class="important title" align="center">
Hidden domains
Hidden domains ({% trans %}one record{% plural records %}{{ count }} records{% endtrans %})
</p>
<table class="table">

18
templates/home.twig

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
<p>
<b>Info:</b><br>
Hosts check is done every hour.<br>
The problem with adding domains in the period from 08/28/22 to 09/15/22 has been fixed. Sorry for the inconvenience.<br> {# to be removed later #}
<br>
Supported commands:
<ul>
@ -30,7 +29,7 @@ @@ -30,7 +29,7 @@
<p>
<b>Static links to lists:</b><br>
Lists are updated every 4 hours.
Lists are updated every {% trans %}hour{% plural exportperiod %}{{ count }} hours{% endtrans %}.
<ul>
<li>Basic list: <a href="/export/hosts-basic.txt">/export/hosts-basic.txt</a> - contains short list of alive popular services</li>
<li>Alive list: <a href="/export/hosts.txt">/export/hosts.txt</a></li>
@ -43,18 +42,20 @@ @@ -43,18 +42,20 @@
Although there are no specific rules for domain registration, we do have the policy on dead domain records.<br>
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>{{ 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>
<li>{% trans %}one day{% plural delnewdays %}{{ count }} days{% endtrans %} if last seen less than {% trans %}one day{% plural newdays %}{{ count }} days{% endtrans %} since registration</li>
<li>{% trans %}one day{% plural delactdays %}{{ count }} days{% endtrans %} if last seen less than {% trans %}one day{% plural olddays %}{{ count }} days{% endtrans %} since registration</li>
<li>{% trans %}one day{% plural delstabdays %}{{ count }} days{% endtrans %} if last seen more than {% trans %}one day{% plural olddays %}{{ count }} days{% endtrans %} 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>
Domains that are inaccessible before the disabling date for {% trans %}one day{% plural hidedays %}{{ count }} days{% endtrans %}
will be hidden from <a href="/alive">alive</a> list and 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 activation %}
<p>
<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.
Your domain will appear in the listing within {% trans %}one hour{% plural actdelay %}{{ count }} hours{% endtrans %}.
However, your domain must be alive within {% trans %}a hour{% plural actseen %}the last {{ count }} hours{% endtrans %} before the activation is due.
</p>
{% endif %}
@ -90,7 +91,8 @@ @@ -90,7 +91,8 @@
<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 (currently hidden {% if all %}<a href="/hidden?all">{% endif %}{{ blackcnt }} domain(s){% if all %}</a>{% endif %})
<li>Domains with offensive content will be hidden from the list (currently hidden {% if all %}<a href="/hidden?all">{% endif %}
{% trans %}one domain{% plural blackcnt %}{{ count }} domains{% endtrans %}{% if all %}</a>{% endif %})
<ul>
<li>they can be found using the search and jump links</li>
<li>adding <i>?all</i> to page address (like <i>/alive?all</i>) will show them</li>

15
templates/search.twig

@ -4,19 +4,20 @@ @@ -4,19 +4,20 @@
{% block content %}
<div class="container">
{% if result|length > 0 %}
<h3 class="title">Query result for "{{ query }}"</h3>
<div class="disclaimer">
<span>
Note: only first {{ limit }} record(s) are shown
</span>
</div>
{% if result.error|length > 0 %}
<h3 class="title">Incorrect Query!</h3>
<div class="disclaimer">
<span>
<b>{{ result.error }}</b>
</span>
</div>
{% else %}
<h3 class="title">Query result for "{{ query }}"</h3>
<div class="disclaimer">
<span>
Note: only {% trans %}one record is{% plural limit %}first {{ count }} records are{% endtrans %} shown
</span>
</div>
<table class="table">
<thead class="table__head">
<tr class="table__row">
@ -51,7 +52,7 @@ @@ -51,7 +52,7 @@
{% endif %}
<div class="form__field">
<label for="q">Query:</label>
<input class="text-input search-page__text-input" type="text" id="q" name="q" maxlength="67" placeholder="domain.i2p" required>
<input class="text-input search-page__text-input" type="text" id="q" name="q" minlength="3" maxlength="67" placeholder="domain.i2p" required>
</div>
<div class="form__field">
<label for="q">Alive only:</label>

10
views/404.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$template = $twig->load('404.twig');
echo $template->render();

10
views/add.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$all = false;
$record = "";

12
views/alive.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$all = false;
$offset = $options["tableitems"] * ($page - 1);
@ -35,4 +27,4 @@ $STH->setFetchMode(PDO::FETCH_ASSOC); @@ -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]);

16
views/all.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$all = false;
$offset = $options["tableitems"] * ($page - 1);
@ -22,14 +14,14 @@ if (isset($_GET["all"])) @@ -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]);

2
views/api.php

@ -7,7 +7,7 @@ $data = []; @@ -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;

10
views/autojump.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$utils = new App\Utils;

12
views/hidden.php

@ -10,15 +10,7 @@ if (isset($_GET["all"])) { @@ -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` @@ -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]);

39
views/home.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$all = false;
$pdo = (new App\DB($options))->pdo;
@ -26,20 +18,21 @@ $STH = $pdo->query ("SELECT COUNT(*) FROM `hosts` WHERE `blacklisted` = 1"); @@ -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');

10
views/jump.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$utils = new App\Utils;

10
views/latest.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$all = false;

14
views/search.php

@ -1,14 +1,6 @@ @@ -1,14 +1,6 @@
<?php
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';
$utils = new App\Utils;
@ -19,6 +11,8 @@ $all = false; @@ -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)) { @@ -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]);

Loading…
Cancel
Save