note 68224 deleted from function.parse-url by didou

From: Date: Sat, 03 Feb 2007 03:06:14 +0000
Subject: note 68224 deleted from function.parse-url by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122609@lists.php.net to get a copy of this message
Note Submitter: christopher DOT aiken AT gmail DOT com ---- I was looking for a very simple way to get the absolute domain names of hosts that make posts to my scripts. I wanted to check that the absolute domain (not the fully qualified host) was legitimate in mysql db. I came up with this as it feels simple and clean. <?php /* * Christopher Aiken * Revised: 7/18/2006 * Parses and shows the host and absolute domain * from the previous page that referred to this current page. * * Very useful to check that a domain is allowed to * reference / call a script especially for submissions. * */ if (isset($_SERVER['HTTP_REFERER'])) { $referer = parse_url($_SERVER['HTTP_REFERER']); $host = $referer['host']; echo 'Host is: '.$host.'<br>'; $host = str_replace(".","/",$host); $domain = dirname($host).'.'.basename($host); $domain = basename($domain); echo 'Domain is: '.$domain.'<br>'; } ?>

« previous php.notes (#122609) next »