minor improvments

This commit is contained in:
sparc 2005-07-16 11:10:31 +00:00
parent 8af958e153
commit 102eb7990f
2 changed files with 39 additions and 29 deletions

View file

@ -26,6 +26,7 @@
*/
require_once('getdate.whois');
require_once('genutil.whois');
function generic_whois ( $rawdata, $items, $dateformat='mdy' )
@ -49,13 +50,8 @@ while (list($key,$val)=each($rawdata))
{
$pos=strpos($val,$match);
if ($pos!==false)
{ $parts=explode('.',$field);
$var="\$r";
while (list($fn,$mn)=each($parts))
if ($mn=='')
$var.='[]';
else $var.="[\"".$mn."\"]";
{
$var="\$r".getvarname($field);
$itm=trim(substr($val,$pos+strlen($match)));
if ($itm!='')
eval($var."=\"".$itm."\";");

View file

@ -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]);