From bbb8d8be4fbee03c0da27f2c0b6360da535b0d19 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 21 Mar 2020 22:47:34 +0000 Subject: [PATCH] docker docs --- README.md | 23 ++++++++++------------- ext/ipban/main.php | 39 ++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 6b0a1d54..3c1190d2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ``` - _________.__ .__ .__ ________ - / _____/| |__ |__| _____ _____ |__| ____ \_____ \ - \_____ \ | | \ | | / \ / \ | |_/ __ \ / ____/ - / \| Y \| || Y Y \| Y Y \| |\ ___/ / \ - /_______ /|___| /|__||__|_| /|__|_| /|__| \___ >\_______ \ - \/ \/ \/ \/ \/ \/ - + _________.__ .__ .__ ________ + / _____/| |__ |__| _____ _____ |__| ____ \_____ \ + \_____ \ | | \ | | / \ / \ | |_/ __ \ / ____/ + / \| Y \| || Y Y \| Y Y \| |\ ___/ / \ + /_______ /|___| /|__||__|_| /|__|_| /|__| \___ >\_______ \ + \/ \/ \/ \/ \/ \/ + ``` # Shimmie @@ -60,14 +60,11 @@ Once you have an image which has passed all tests, you can then run it to get a live system: ``` -docker run -p 0.0.0.0:8123:8000 shimmie +docker run -p 0.0.0.0:8123:8000 -v /mnt/shimmie-data:/app/data shimmie ``` -Then you can visit your server on port 8123 to see the site. - -Note that the docker image is entirely self-contained and has no persistence -(assuming you use the sqlite database); each `docker run` will give a clean -un-installed image. +Then you can visit your server on port 8123 to see the site, with data +stored in /mnt/shimmie-data on your local drive. ### Upgrade from earlier versions diff --git a/ext/ipban/main.php b/ext/ipban/main.php index a9f331b7..69de8ebe 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -100,8 +100,6 @@ class IPBan extends Extension { global $cache, $config, $database, $page, $_shm_user_classes; - $d = @$_GET['DEBUG']; - // Get lists of banned IPs and banned networks $ips = $cache->get("ip_bans"); $networks = $cache->get("network_bans"); @@ -127,24 +125,11 @@ class IPBan extends Extension } // Check if our current IP is in either of the ban lists - $remote = $_SERVER['REMOTE_ADDR']; - $active_ban_id = null; - if (isset($ips[$remote])) { - $active_ban_id = $ips[$remote]; - } else { - foreach ($networks as $range => $ban_id) { - if (ip_in_range($remote, $range)) { - $active_ban_id = $ban_id; - } - } - } + $active_ban_id = ( + $this->find_active_ban($ips, $_SERVER['REMOTE_ADDR'], $networks) || + $this->find_active_ban($ips, @$_SERVER['HTTP_X_FORWARDED_FOR'], $networks) + ); - if ($d) { - print($remote); - print("\n"); - print($active_ban_id); - print("\n"); - } // If an active ban is found, act on it if (!is_null($active_ban_id)) { $row = $database->get_row("SELECT * FROM bans WHERE id=:id", ["id"=>$active_ban_id]); @@ -365,4 +350,20 @@ class IPBan extends Extension $this->set_version("ext_ipban_version", 10); } } + + public function find_active_ban($ips, $remote, $networks) + { + if(!$remote) return null; + $active_ban_id = null; + if (isset($ips[$remote])) { + $active_ban_id = $ips[$remote]; + } else { + foreach ($networks as $range => $ban_id) { + if (ip_in_range($remote, $range)) { + $active_ban_id = $ban_id; + } + } + } + return $active_ban_id; + } }