-1

So, I'm debugging a PHP repository and I came across the following lines

if (strpos($_SERVER['HTTP_HOST'],  'selfcaredocument.com') !== false)
{
header("Location: https://iammes.care");
exit;
}

Is this used for security, to not allow access to the page from a URL? I don't understand what it does. I'd like to know more, if you can give me a little more information. My understanding of strpos is that it is used to find the occurrence of a string. But what is the real purpose of its usage in the example?

Ballard
  • 869
  • 11
  • 25
Ilyes Negadi
  • 107
  • 2
  • 8
  • your question is not clear about what you are looking for. Is this post helpful for you - https://stackoverflow.com/questions/6987479/how-to-use-strpos-to-determine-if-a-string-exists-in-input-string ? – Al-Amin Oct 19 '20 at 17:19

1 Answers1

0

'HTTP_HOST'

Contents of the Host: header from the current request, if there is one.

See: https://www.php.net/manual/en/reserved.variables.server.php

So if the HTTP_HOST is selfcaredocument.com or contains it, the client will be redirected to a different page.

I would confidently say that this is not a security measure. My guess would be that there is active traffic pointing to the mentioned domain, of which the owner would now like redirected.

Ballard
  • 869
  • 11
  • 25