summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sp_utils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 8c64b55..e5c2942 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -19,6 +19,24 @@ const char* get_ipaddr() {
19 return fwd_ip; 19 return fwd_ip;
20 } 20 }
21 21
22 /* Some hosters (like heroku, see
23 * https://github.com/jvoisin/snuffleupagus/issues/336) are clearing the
24 * environment variables, so we don't have access to them, hence why we're
25 * resorting to $_SERVER['REMOTE_ADDR'].
26 */
27 if (!Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER])) {
28 const zval* const globals_client_ip =
29 zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]),
30 "REMOTE_ADDR", sizeof("REMOTE_ADDR") - 1);
31 if (globals_client_ip) {
32 if (Z_TYPE_P(globals_client_ip) == IS_STRING) {
33 if (Z_STRLEN_P(globals_client_ip) != 0) {
34 return estrdup(Z_STRVAL_P(globals_client_ip));
35 }
36 }
37 }
38 }
39
22 return default_ipaddr; 40 return default_ipaddr;
23} 41}
24 42