From 3c0385afadbe501782ce402e194e2544ea10fd47 Mon Sep 17 00:00:00 2001 From: r4sas Date: Mon, 13 Sep 2021 17:21:23 +0000 Subject: [PATCH] add hidden mode (using '?all' in url) Signed-off-by: r4sas --- README.md | 8 +++++--- public/index.php | 12 +++++++---- templates/_page.twig | 19 +++++++++-------- templates/add.twig | 3 +++ templates/all.twig | 2 +- templates/hidden.twig | 48 +++++++++++++++++++++++++++++++++++++++++++ templates/home.twig | 2 +- templates/jump.twig | 3 +++ templates/search.twig | 3 +++ views/404.php | 1 - views/add.php | 6 +++++- views/alive.php | 7 +++---- views/all.php | 11 ++++++---- views/hidden.php | 42 +++++++++++++++++++++++++++++++++++++ views/home.php | 14 ++++++++++--- views/jump.php | 6 +++++- views/latest.php | 2 +- views/search.php | 8 +++++--- 18 files changed, 162 insertions(+), 35 deletions(-) create mode 100644 templates/hidden.twig create mode 100644 views/hidden.php diff --git a/README.md b/README.md index 30c184a..59b42f8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Requirements --- * i2pd with enabled BOB protocol -* `verifyhost` binary built inside i2pd-tools project folder +* `verifyhost` binary built inside i2pd-tools project folder. It must be placed in `bin` directory * PHP and php-fpm 7.2+ * php-intl package on PHP 7.4+ (php7.4-intl as example on Debian with PHP 7.4) * Composer @@ -20,9 +20,11 @@ Installation 1. Clone repository in your webserver working directory. Note: that must not be `/var/www/html` or something like this, your webserver must point to `public` directory of forked project. 2. Fetch requirements by runnning `composer update`. -3. Point your webserver to serving webpages from `public` directory. -4. Create cron jobs for quering and updating hosts lists. +3. Copy `config.php.dist` to `config.php` and conigure project for your needs +4. Point your webserver to serving webpages from `public` directory. +5. Create cron jobs for quering and updating hosts lists. +Configuration examples below are using /home/www/reg.i2p as website homedir. Note that files inside that directory must be owned by php user (usually it is `www-data`): nginx configuration --- diff --git a/public/index.php b/public/index.php index 1ce51df..81ee6f3 100644 --- a/public/index.php +++ b/public/index.php @@ -7,11 +7,11 @@ require __DIR__ . '/../vendor/autoload.php'; /* Initialize pages rounting */ $r = new Router(); -$r->addRoute('^/$', function($url) { +$r->addRoute('^/?(?:\?|$)', function($url) { require __DIR__ . '/../views/home.php'; }); -$r->addRoute('^/add/?$', function($url) { +$r->addRoute('^/add/?(?:\?|$)', function($url) { require __DIR__ . '/../views/add.php'; }); @@ -23,7 +23,7 @@ $r->addRoute('^/all/?([0-9]+)?/?', function($url, $page = 1) { require __DIR__ . '/../views/all.php'; }); -$r->addRoute('^/jump/?(.*)/?', function($url, $query = "") { +$r->addRoute('^/jump/?([^\?/]*)/?(?:\?|$)', function($url, $query = "") { require __DIR__ . '/../views/jump.php'; }); @@ -35,10 +35,14 @@ $r->addRoute('^/latest/?(?:\?|$)', function($url) { require __DIR__ . '/../views/latest.php'; }); -$r->addRoute('^/search/?(.*)/?', function($url, $query = "") { +$r->addRoute('^/search/?([^\?/]*)/?(?:\?|$)', function($url, $query = "") { require __DIR__ . '/../views/search.php'; }); +$r->addRoute('^/hidden/?([0-9]+)?/?(?:\?|$)', function($url, $page = 1) { + require __DIR__ . '/../views/hidden.php'; +}); + $r->addErrorRoute(function() { require __DIR__ . '/../views/404.php'; }); diff --git a/templates/_page.twig b/templates/_page.twig index 26bfd8f..8bd1830 100644 --- a/templates/_page.twig +++ b/templates/_page.twig @@ -18,11 +18,14 @@