I agree with the other replies on this thread. That code there is an interesting one, is quite long, but it's very easy to understand and sounds like it does its job.
I don't have a use for a download protection code as I don't have anything on my site which users can download, however, if I ever did have things which were up for download, there's a high chance I'd include a code similar to this one.
(I wouldn't want users from other people's websites coming to my website via a hyperlink to download something. They'd coming onto the website when they aren't actually browsing it or using it like a normal website, they'd be coming only to download, hence they would be using my bandwidth. Additionally, most of the users wouldn't realise they'd been referred to a different site that this other webmaster doesn't own and the users would still think they're on this other website).
As for the parse url, i've just researched it for you on the php manual section of the official php website.
QUOTE
Quote from
http://uk2.php.net/manual/en/function.parse-url.phpThis function parses a URL and returns an associative array containing any of the various components of the URL that are present.
This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly.
Basically, i haven't ever used the parse_url function but from what I understand it separates the address into each various sections, such as host and port.
Here is another quotation from the php manual. This is the section of the manual which states the various section which can be retrieved by using this parse_url function which s2city used in his code.
QUOTE
Return Values
On seriously malformed URLs, parse_url() may return FALSE and emit a E_WARNING. Otherwise an associative array is returned, whose components may be (at least one):
scheme - e.g. http
host
port
user
pass
path
query - after the question mark ?
fragment - after the hashmark #
If the component parameter is specified a string is returned instead of an array.
Hopefully you will find this post easy to understand.
Thanks for sharing your download protection with us s2city. Even though I most likely won't have a need to use the code, there's bound to be a lot of users that do need to use it and I feel quite confident in saying quite a few users will use your code, even if they don't give you feedback on their views

Comment/Reply (w/o sign-up)