tep_get_top_level_domain Function modification
Daemonj <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.suggestions |
|---|---|
| Message-ID | <91cc4b0d1ff62cc1c39a24be33ae1d29@osCommerce-Forums> |
This message was sent from: Suggestions and Proposals
http://forums.oscommerce.com/viewtopic.php?p=178161#178161
----------------------------------------------------------------
I'm not sure how to propose this to the osC team but I figured that this was the best place to start.
I would appreciate it if any of the osC team members would let me know the proper "channels" to follow for this sort of thing.
In a recent thread a person had a problem where their domain of www.domain.co.uk was not setting the cookie. The reason was because the tep_get_top_level_domain function was not accounting for the extra domain qualifier and returning a result of co.uk.
I have modified the function to accommodate for extra qualifiers (regardless of the number) to return the proper domain name.
[code] function tep_get_top_level_domain($url) {
if (strpos($url, '://')) {
$url = parse_url($url);
$url = $url['host'];
}
$domain_array = explode('.', $url);
$domain_size = sizeof($domain_array);
if ($domain_size > 1) {
$domain = '';
for ($i = 1; $i <= $domain_size; $i++) {
$domain .= '.' . $domain_array[$i];
}
if (is_numeric($domain)) {
return false;
} else {
return $domain;
}
} else {
return false;
}
}
[/code]
Feel free to modify the code as you see fit.