check HTTP Referer to check if we come from public.php or from a internal page.
Necessary to detect public access also if a user is logged in.