Forum Moderators: coopster
$found = ereg('\www.',$surl);
if ($found) {
$url = $surl;
} else {
$url = 'www.'.$surl;
}
[edited by: dreamcatcher at 5:33 pm (utc) on May 6, 2010]
[edit reason] use example.com, thanks. [/edit]
if(preg_match('/^[a-z\d][a-z\d\-]{1,62}\.([a-z]{2,4}|[a-z]{2,3}\.[a-z]{2})(\/[^\/]+)*?\/?(\.?:[\d]+)?(\?.*)?$/i', $surl)) {
// URL, no subdomains at all
} else {
// No subdomains, might not be URL
}
$found = ereg('\www.',$surl);
if(preg_match('/^[a-z\d][a-z\d\-]{1,62}\.([a-z]{2,4}|[a-z]{2,3}\.[a-z]{2})(\/[^\/]+)*?\/?(\.?:[\d]+)?(\?.*)?$/i', $surl)) {
// URL, no subdomains at all
} else {
// No subdomains, might not be URL
}
if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {
// Is there a referrer? Is it usable? (empty?)
$ref = $_SERVER['HTTP_REFERER'];
} else {
$ref = "No referrer";
}
// Check IP address.
if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
// Again, is there an IP address and is it not empty?
$ip = $_SERVER['REMOTE_ADDR'];
} else {
// Sometimes, when going through a proxy and such, you can use this
// You can use the ternary operator to save space, etc
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = "No IP";
}
}
// Split our URL into bits.
$url = explode("/",$ref);
if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {
// Is there a referrer? Is it usable? (empty?)
$ref = $_SERVER['HTTP_REFERER'];
} else {
$ref = "No referrer";
}
// Check IP address.
if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
// Again, is there an IP address and is it not empty?
$ip = $_SERVER['REMOTE_ADDR'];
} else {
// Sometimes, when going through a proxy and such, you can use this
// You can use the ternary operator to save space, etc
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = "No IP";
}
}
// Split our URL into bits.
$url = explode("/",$ref);
// Take the 3rd part of the url (the main site)
$surl = $url[2];
// Check to see if it contains the www. at the begining
$found = ereg('\www.',$surl);
if ($found) {
$url = $surl;
} else {
$url = 'www.'.$surl;
}
$query = "SELECT website, hits FROM referers WHERE website = '$url'";