Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

tep_get_top_level_domain Function modification


Daemonj

Recommended Posts

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.

 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; 

   } 

 }

Feel free to modify the code as you see fit.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Okay, will do.

 

Thanks! :)

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...