From 102eb7990f46f85a65bd96e7a45f0ecacc90fec7 Mon Sep 17 00:00:00 2001 From: sparc Date: Sat, 16 Jul 2005 11:10:31 +0000 Subject: [PATCH] minor improvments --- generic2.whois | 12 ++++------- generic3.whois | 56 +++++++++++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/generic2.whois b/generic2.whois index 07476b7..1b849a4 100755 --- a/generic2.whois +++ b/generic2.whois @@ -26,6 +26,7 @@ */ require_once('getdate.whois'); +require_once('genutil.whois'); function generic_whois ( $rawdata, $items, $dateformat='mdy' ) @@ -48,14 +49,9 @@ while (list($key,$val)=each($rawdata)) while (list($field, $match)=each($items)) { $pos=strpos($val,$match); - if ($pos!==false) - { $parts=explode('.',$field); - $var="\$r"; - while (list($fn,$mn)=each($parts)) - if ($mn=='') - $var.='[]'; - else $var.="[\"".$mn."\"]"; - + if ($pos!==false) + { + $var="\$r".getvarname($field); $itm=trim(substr($val,$pos+strlen($match))); if ($itm!='') eval($var."=\"".$itm."\";"); diff --git a/generic3.whois b/generic3.whois index 66d0b02..c9888a7 100644 --- a/generic3.whois +++ b/generic3.whois @@ -128,44 +128,57 @@ if (!is_array($array)) return array(); $items = array ( - 'phone:' => 'phone', 'fax..:' => 'fax', 'fax-' => 'fax', 'fax:' => 'fax', '[fax]' => 'fax', + '(fax)' => 'fax', + 'phone:' => 'phone', 'email:' => 'email', 'company name:' => 'organization', 'first name:' => 'name.first', 'last name:' => 'name.last', 'street:' => 'address.street', 'language:' => '', - 'location:' => 'address.city' + 'location:' => 'address.city', + 'name:' => 'name', + 'fax.' => 'fax', + 'tel.' => 'phone' ); while (list($key,$val)=each($array)) { - reset($items); + $ok=true; - while (list($match,$field)=each($items)) - { - $pos=strpos(strtolower($val),$match); - if ($pos===false) continue; - $itm=trim(substr($val,$pos+strlen($match))); - if ($field!='') - { - eval("\$r".getvarname($field)."=\$itm;"); - } - $val=trim(substr($val,0,$pos)); - if ($val=='') - unset($array[$key]); - else - $array[$key]=$val; - break; - } + while ($ok) + { + reset($items); + $ok=false; - if ($val=="") continue; + while (list($match,$field)=each($items)) + { + $pos=strpos(strtolower($val),$match); + if ($pos===false) continue; + $itm=trim(substr($val,$pos+strlen($match))); + if ($field!='') + { + eval("\$r".getvarname($field)."=\$itm;"); + } + $val=trim(substr($val,0,$pos)); - if (!preg_match("/[^0-9\(\)\-\.\+ ]/", $val)) + if ($val=='') + unset($array[$key]); + else + { + $array[$key]=$val; + $ok=true; + } + break; + } + } + if ($val=='') continue; + + if (!preg_match("/[^0-9\(\)\-\.\+ ]/", $val) && strlen($val)>5) { if (isset($r['phone'])) $r['fax']=$val; @@ -177,6 +190,7 @@ while (list($key,$val)=each($array)) if (strstr($val,'@')) { + $val=str_replace("\t",' ',$val); $parts=explode(' ',$val); $top=count($parts)-1; $r['email']=str_replace('(','',$parts[$top]);