How would the condition be written to ensure a page is either accessed by xmlhttp request from my site or from an allowed outside domain?
You spelt referrer correctly but unfortunately the person who wrote the HTTP spec couldn't! You need to use HTTP_REFERER.
HTTP_REFERER
You might also want to escape the dot \. so it only matches a dot and not everything.
\.