File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ public function __construct()
50
50
'X-Longitude ' => $ _SERVER ['GEOIP_LONGITUDE ' ]
51
51
];
52
52
}
53
+ $ clientIpAddress = $ this ->getClientIP ();
54
+ $ this ->headers ['X-Forwarded-For ' ] = $ clientIpAddress ;
53
55
$ this ->encryption = DI ::container ()->get (EncryptionProvider::class);
54
56
$ this ->secureStorage = DI ::container ()->get (SecureCookieProvider::class);
55
57
$ this ->secureStorage ->setEncryptionProvider ($ this ->encryption );
@@ -107,6 +109,22 @@ public function setEncryptionProvider(EncryptionInterface $encryptionProvider):
107
109
return $ this ;
108
110
}
109
111
112
+ /**
113
+ * looks for a user's IP address
114
+ *
115
+ * @return string
116
+ */
117
+ public function getClientIP (){
118
+ if (array_key_exists ('HTTP_X_FORWARDED_FOR ' , $ _SERVER )){
119
+ return $ _SERVER ["HTTP_X_FORWARDED_FOR " ];
120
+ }else if (array_key_exists ('REMOTE_ADDR ' , $ _SERVER )) {
121
+ return $ _SERVER ["REMOTE_ADDR " ];
122
+ }else if (array_key_exists ('HTTP_CLIENT_IP ' , $ _SERVER )) {
123
+ return $ _SERVER ["HTTP_CLIENT_IP " ];
124
+ }
125
+ return '' ;
126
+ }
127
+
110
128
/**
111
129
* Ensures that externally supplied providers are set
112
130
*
You can’t perform that action at this time.
0 commit comments