note 68224 added to function.parse-url

From: Date: Tue, 18 Jul 2006 20:58:03 +0000
Subject: note 68224 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-114901@lists.php.net to get a copy of this message
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>'; } ?> ---- Server IP: 216.194.113.175 Probable Submitter: 72.17.236.212 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- http://master.php.net/note/edit/68224 Del: integrated -- http://master.php.net/note/delete/68224/integrated Del: useless -- http://master.php.net/note/delete/68224/useless Del: bad code -- http://master.php.net/note/delete/68224/bad+code Del: spam -- http://master.php.net/note/delete/68224/spam Del: non-english -- http://master.php.net/note/delete/68224/non-english Del: in docs -- http://master.php.net/note/delete/68224/in+docs Del: other reasons-- http://master.php.net/note/delete/68224 Reject -- http://master.php.net/note/reject/68224 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114901) next »