@@ -123,11 +123,14 @@ public function getRemoteAddress(): string
123123 $ remoteAddress = $ this ->request ->getClientIp ();
124124 $ localAddresses = ['127.0.0.1 ' , '::1 ' ];
125125
126- if (in_array ($ remoteAddress , $ localAddresses ) && $ this ->getRequestHeaders ()->has ('X-Forwarded-For ' )) {
126+ if (
127+ in_array ($ remoteAddress , $ localAddresses , strict: true )
128+ && $ this ->getRequestHeaders ()->has ('X-Forwarded-For ' )
129+ ) {
127130 $ remoteAddress = $ this ->getRequestHeaders ()->get ('X-Forwarded-For ' );
128131 }
129132
130- return preg_replace ('([^0-9a-z:.]+)i ' , '' , (string ) $ remoteAddress );
133+ return preg_replace (pattern: '([^0-9a-z:.]+)i ' , replacement: '' , subject: (string ) $ remoteAddress );
131134 }
132135
133136 private function isBanned (string $ remoteAddress ): bool
@@ -147,7 +150,7 @@ private function handleSession(?int $cookieId, string $remoteAddress, string $ac
147150 'sid ' ,
148151 );
149152
150- if (!is_null ($ cookieId ) && !$ cookieId != $ this ->userSession ->getCurrentSessionId ()) {
153+ if (!is_null ($ cookieId ) && !$ cookieId !== $ this ->userSession ->getCurrentSessionId ()) {
151154 $ this ->userSession ->setCookie (
152155 UserSession::COOKIE_NAME_SESSION_ID ,
153156 $ this ->userSession ->getCurrentSessionId (),
@@ -180,11 +183,15 @@ private function writeTrackingData(string $action, int|string|null $data, string
180183 . '; '
181184 . $ remoteAddress
182185 . '; '
183- . str_replace ('; ' , ', ' , $ this ->request ->server ->get ('QUERY_STRING ' ) ?? '' )
186+ . str_replace (search: '; ' , replace: ', ' , subject: $ this ->request ->server ->get ('QUERY_STRING ' ) ?? '' )
184187 . '; '
185- . str_replace ('; ' , ', ' , $ this ->request ->server ->get ('HTTP_REFERER ' ) ?? '' )
188+ . str_replace (search: '; ' , replace: ', ' , subject: $ this ->request ->server ->get ('HTTP_REFERER ' ) ?? '' )
186189 . '; '
187- . str_replace ('; ' , ', ' , urldecode ((string ) $ this ->request ->server ->get ('HTTP_USER_AGENT ' )))
190+ . str_replace (
191+ search: '; ' ,
192+ replace: ', ' ,
193+ subject: urldecode ((string ) $ this ->request ->server ->get ('HTTP_USER_AGENT ' )),
194+ )
188195 . '; '
189196 . $ this ->request ->server ->get ('REQUEST_TIME ' )
190197 . "; \n" ;
0 commit comments