#821: Referrer check breaks with UTF-8 URLs

Replacing mb_detect_encoding by a regex working on all PHP installations.
References:
http://stackoverflow.com/questions/2124010/grep-regex-to-match-non-ascii-characters
http://stackoverflow.com/questions/3118185/php-input-filtering-only-english-alphabet