From 5a2d4e842b8acf1d565cff609c57a5e9c9767bf9 Mon Sep 17 00:00:00 2001 From: 0chan <0chan@disroot.org> Date: Thu, 9 Feb 2023 18:33:36 +0600 Subject: [PATCH] CF proxy IP forwarding + Overboard regeneration check --- config.php | 6 ++++++ getpage.php | 7 ++++++- modlog.php | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config.php b/config.php index e3a534b..21c03ac 100644 --- a/config.php +++ b/config.php @@ -121,6 +121,12 @@ if (!$cache_loaded) { $cf['I0_SAGE_DISABLED'] = false; // Disable sage function if you don't want anyone to abuse CSAM necroposting $cf['I0_DISABLE_BAD_PROXY_POSTING'] = false; // If CF can't get user's GeoIP - then the proxy is marked as bad (xx country) $cf['I0_DISABLE_TOR_POSTING'] = false; // Disable posting with T1 country detected by CF + if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) { + $cf['I0_USER_IP'] = $_SERVER['HTTP_X_FORWARDED_FOR']; // for use with CF IP forwarding + } else { + $cf['I0_USER_IP'] = $_SERVER['REMOTE_ADDR']; + } + // --------------------------------------- CSS styles --------------------------------------- $cf['KU_STYLES'] = 'modern:newdark:photon'; // Styles which are available to be used for the boards, separated by colons, in lower case. These will be displayed next to [Home] [Manage] if KU_STYLESWIKUHER is set to true diff --git a/getpage.php b/getpage.php index 44209d4..f61f1f9 100644 --- a/getpage.php +++ b/getpage.php @@ -32,7 +32,12 @@ if ($is_index) if ($board == I0_OVERBOARD_DIR) { if ($page == 'catalog') http_response_code(404); - $rendered_page = RegenerateOverboard(null, $page); + if (I0_OVERBOARD_ENABLED) { + $rendered_page = RegenerateOverboard(null, $page); + } else { + $rendered_page = 0; + } + do_redirect(KU_BOARDSPATH . '/' . I0_OVERBOARD_DIR . '/' . ((int)$rendered_page===0 ? '' : $rendered_page.'.html'), true); } diff --git a/modlog.php b/modlog.php index 1a62576..8e31cc7 100644 --- a/modlog.php +++ b/modlog.php @@ -10,7 +10,7 @@ $dwoo = new Dwoo(); $dwoo_data = new Dwoo_Data(); // Determine the User ID -if ((I0_IPLESS_MODE=='true' || (I0_IPLESS_MODE=='auto' && $_SERVER['REMOTE_ADDR']=='127.0.0.1'))) { +if ((I0_IPLESS_MODE=='true' || (I0_IPLESS_MODE=='auto' && I0_USER_IP =='127.0.0.1'))) { if (isset($_COOKIE['I0_persistent_id'])) { $user_id = $_COOKIE['I0_persistent_id']; } @@ -20,7 +20,7 @@ if ((I0_IPLESS_MODE=='true' || (I0_IPLESS_MODE=='auto' && $_SERVER['REMOTE_ADDR' $user_id = substr($user_id, 0, 45); } else { - $user_id = $_SERVER['REMOTE_ADDR']; + $user_id = I0_USER_IP; } $entries = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "modlog` WHERE `category`>=3 ORDER BY `timestamp` DESC");