Révision | bf44d376c9e956659e3ba90679d9990ebfe9c433 (tree) |
---|---|
l'heure | 2021-12-11 01:33:20 |
Auteur | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2178 counter plugin: Ignore REMOTE_ADDR
Introduce PLUGIN_COUNTER_IGNORE_REMOTE_ADDR constant.
If true, the plugin always count up counter for all requests.
This option is for reverse proxy or load balancer environments.
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // counter.inc.php |
4 | 4 | // Copyright |
5 | -// 2002-2019 PukiWiki Development Team | |
5 | +// 2002-2021 PukiWiki Development Team | |
6 | 6 | // 2002 Y.MASUI GPL2 http://masui.net/pukiwiki/ masui@masui.net |
7 | 7 | // License: GPL2 |
8 | 8 | // |
@@ -10,6 +10,8 @@ | ||
10 | 10 | |
11 | 11 | // Counter file's suffix |
12 | 12 | define('PLUGIN_COUNTER_SUFFIX', '.count'); |
13 | +// Ignore REMOTE_ADDR : TRUE for reverse proxy / load balancer environment | |
14 | +define('PLUGIN_COUNTER_IGNORE_REMOTE_ADDR', FALSE); | |
13 | 15 | // Use Database (1) or not (0) |
14 | 16 | define('PLUGIN_COUNTER_USE_DB', 0); |
15 | 17 | // Database Connection setting |
@@ -148,6 +150,9 @@ function plugin_counter_get_count($page) | ||
148 | 150 | |
149 | 151 | // Anothoer day? |
150 | 152 | $remote_addr = $_SERVER['REMOTE_ADDR']; |
153 | + if (! $remote_addr) { | |
154 | + $remote_addr = '_'; | |
155 | + } | |
151 | 156 | $count_up = FALSE; |
152 | 157 | if ($c['date'] != $default['date']) { |
153 | 158 | $modify = TRUE; |
@@ -158,7 +163,7 @@ function plugin_counter_get_count($page) | ||
158 | 163 | $c['today'] = 1; |
159 | 164 | $c['total']++; |
160 | 165 | $count_up = TRUE; |
161 | - } else if ($c['ip'] != $remote_addr) { | |
166 | + } else if ($c['ip'] != $remote_addr || PLUGIN_COUNTER_IGNORE_REMOTE_ADDR) { | |
162 | 167 | // Not the same host |
163 | 168 | $modify = TRUE; |
164 | 169 | $c['ip'] = $remote_addr; |