I know almost nothing on PHP, but am I ever learning fast deugging this project.
I have this application that I download. Using my VB skills, I cleaned up all the bugs but one, and for the life of me I can't figure it out. The attached routine is supposed to strip off the .com (or any suffix) from a domain name entered into a search field. Logically (using my VB skills) it looks like it should work; however, it strips off the domain part and leaves the suffix. Backwards from what is intended. Could someone please point out where the logic is skewed??
function Check_Domain_Format()
{
if (empty($this->domain)) Error_Handle(LANG_ERR_no_domain);
while (substr($this->domain, -1) == ".")
{
$this->domain = substr($this->domain, 0, -1);
}
$tdomain = strrchr($this->domain, ".");
if($tdomain)
$this->domain = substr($tdomain, 1);
$this->domain = ereg_replace("[^a-zA-Z0-9-]*([a-zA-Z0-9-]*)[^a-zA-Z0-9-]*", "\\1", $this->domain);
if (empty($this->domain)) Error_Handle(LANG_ERR_no_domain);
if (strlen($this->domain.$this->ext) > 67) Error_Handle(LANG_ERR_too_long);
}
😉