please help!
I'm testing part of a whois program - just the part that finds the extension and then splits the name from the extension. I think the code is commented enough so you can see what I'm trying to achieve. The problem is that it chucks up a parse error telling me that the last line of code is wrong. The last line of code consists only of the php closing tag so I have no clue what's going on (or rather why it's not going on). Any and all help is appreciated . . .
My code follows:
class WhoisClass {
var $wholedomain = ""; //name.extn
var $name = "";
var $extn = "";
var $errArray = array ();
var $errstr = "";
var $whois = "";
var $whoisport = "";
var $whoisip = "";
var $whoisrecurse = "N";
var $validpattern = "";
var $availablepattern = "";
var $extnhandler = "";
var $BUFFER = 0; //read buffer char by char
var $rawwhoisArray = array();
var $resultArray = array();
// constructor
function WhoisClass($domainName) {
$this->wholedomain = strtolower(preg_replace("/[\n\s]/", "", $domainName));
$domparts = explode('.', $this->wholedomain);
$last = array_pop($domparts);
$negOne = array_pop($domparts);
$negTwo = array_pop($parts);
//to cope with 3-level tlds
$this->name = implode ('.', $domparts);
// for 3-level
$this->extn = $negTwo.'.'.$negOne.'.'.$last;
//see if can find a matching 3-level extension in the db
$this->extn = match_extn($this->extn);
if ($extnMatched = TRUE) {
//proceed with whois
//$this->rawwhois = get_whois($this->wholedomain);
} else {
/we push the 'first extension bit' from the extension onto the name to create a 2-level extn/
$domparts = array_push($domparts, $negTwo);
$this->name = implode('.', $wholedomain);
$this->extn = $negOne.'.'.$last;
$this->extn = match_extn($this->extn);
if ($extnMatched = TRUE) {
//proceed with whois
//$this->rawwhois = get_whois($this->wholedomain);
} else {
//and so shunt to name and make 1-level extn
$domparts = array_push ($domparts, $negOne);
$this->name = implode ('.', $domparts);
$this->extn = $last;
$this->extn = match_extn($this->extn);
if ($extnMatched = TRUE) {
//proceed with whois
//$this->rawwhois = get_whois($this->wholedomain);
} else {
//we have no gone through all possible match opportunities
$this->errstr = "Sorry, domain is not supported. Please check your spelling.";
array_push($this->errArray, "/n".$this->errstr);
}
//result stuff
if (count($errArray) != 0){
echo "The following error(s) were encountered:";
foreach($errArray as $line) {
echo "\$errArray: $line.\n";
}
} elseif (count($resultArray)!=0) {
echo "The results for your query on \$wholedomain are as follows:\n";
foreach($resultArray as $line) {
echo "\$resultArray: $line.\n";
}
}//end result stuff
}//end constructor
function match_extn($extn){
$domainQueryDB = new DBClass;
$match_result = query( "SELECT * FROM domaintype WHERE suffix = $this->extn");
if(!empty ($match_result)) {
//take out what we need from the domaintype table by item name
//$myrow = mysql_fetch_array($match_result)
//can we extract from the db as follows?
//$myrow["whois"] = $this->whois;
$this->extnMatched = TRUE;
return $this->extnMatched;
} else {
$this->extnMatched = FALSE;
return $this->extnMatched;
}
}//end function
}//end class
?>