Well, there is no $HTTP_REFERER, but there is $_SERVER['HTTP_REFERER']. You could use a set of conditionals, or a regular expression.
For an example of conditionals, you could try:
if ((strpos($_SERVER['HTTP_REFERER'], 'sex0r') === FALSE) &&
(strpos($_SERVER['HTTP_REFERER'], 'pr0n') === FALSE)) {
/* it's a clean referer */
}
Pretty easy to adapt.
Although, make sure you don't just rely on referrer--it's often not set.