...

View Full Version : breaking apart HTTP_REFERER



Ultragames
08-02-2007, 03:22 AM
I need three parts of information from the HTTP_REFERER.

1) Any sudomains, not including the http:// or a trailing period. This could be mail or even users.johnsmith

2) The domain, not including any folders, files, or trailing / For instance google.com

3) The page, not including any folders, get data, or anchors. For instance contactus.php

This is best done with regex i'm sure, but I am quite horrible at it. Assistance would be lovely. Thank you.

firepages
08-02-2007, 07:39 AM
parse_url() (http://www.php.net/parse_url) is your friend.

s_pradeep
08-02-2007, 08:21 AM
You can also use PEAR Net_URL http://pear.php.net/manual/en/package.networking.net-url.php

Ultragames
08-02-2007, 09:24 AM
aha! I knew there was something like that that I had used before. Thank you very much!

Ultragames
08-02-2007, 11:04 PM
parse_url() does not seperate the subdomain from the domain. Can someone help with that?

firepages
08-03-2007, 12:40 AM
<?php
$url=parse_url('http://deb.centurioncomputers.com.au/testa.php');
$bits=explode('.', $url['host']);

$subdomain = $bits[0];
echo $subdomain;
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum