jmoon
jmoon

Reputation: 576

how do i check hosts in php?

I want to match by hostname and I can't figure out how,

example: i want to force all links to be from oi*.tinypic.com or i*.tinypic.com. However people bypass my current validation by using then adding hash at the back of the URL like .jpg#tinypic, if i use stripos() to prevent abuse on the forum.

also, how do i check it's well formed url, of https or http? I'm using parse_url() and doing if (!$var) but it sometimes doesn't work for some reason i don't know

Upvotes: 0

Views: 82

Answers (1)

Amadan
Amadan

Reputation: 198324

Use parse_url() on the referer, then use strpos only on host part.

When parse_url() doesn't work, what is the result? print_r is your friend.

Upvotes: 1

Related Questions