Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/srv_address.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
Used person variables
$srv_First_Name="Roland";
$srv_Last_Name="Eschmann";
$srv_Postal_Town="8200 Schaffhausen";
$srv_Address_Line_1="Rheinhof";
*/

include_once(cfg_data_path. "/script/snoopy/Snoopy.class.php");

$proxy_url="http://www.directories.ch/whitepages/base.aspx?language=en&searchtype=adr_simple&do=search&name=";
$proxy_url=$proxy_url.$srv_First_Name.'+'.$srv_Last_Name;//.'&geo=' .substr($srv_Postal_Town,0,4);

if(!isset($snoopy_cache[$proxy_url]))
{
  $Snoopy = new Snoopy;
  $Snoopy->fetchtext($proxy_url);
  $snoopy_cache[$proxy_url]=$Snoopy->results;

  //map link
  //~ $Snoopy->fetchlinks($proxy_url);
  //~ $tmp_link_result_array=$Snoopy->results;
  //~ echo'<pre>';
  //~ print_r($tmp_link_result_array);
  //~ echo'</pre>';
  //~ reset($tmp_link_result_array);
  //~ while(list($tmp,$tmp_link)=each($tmp_link_result_array))
  //~ {
    //~ if(strpos('_'.$tmp_link,'http://www.directories.ch/whitepages/base.aspx?do=entrydetail')==1)
    //~ {
      //~ $srv_Map_Link=urlencode($tmp_link);
      //~ break;
    //~ }
  //~ }

  $srv_Map_Link='http://www.directories.ch/whitepages/base.aspx?do=entryresult&letter=all&name='.$srv_First_Name.'%20'.$srv_Last_Name.'&mapreload=true';
}
$SnoopyResult=$snoopy_cache[$proxy_url];

if($SnoopyResult)
{
  //filter only result
  $StartResult = strpos($SnoopyResult,"Next")+4;
  $EndResult = strpos($SnoopyResult,"Previous",$StartResult);
  $LenResult = strlen($SnoopyResult);
  $Result = substr($SnoopyResult,$StartResult,$LenResult-$StartResult-$EndResult+4);
  $Result = str_replace("MapRouting","<br>",$Result);
  $Result = utf8_encode($Result);
  $Result = str_replace(chr(194),'',$Result);
  $Result = str_replace(chr(160),' ',$Result);

  $Result_array=array();
  $Result_array=explode("<br>", $Result);

  $srv_Address_Count=count($Result_array)-1;

  if(count($Result_array)==2)
  {
    //print_r ($Result_array);
    //echo "<hr>";

    $Probability=0;

    //cut phone nr
    for ($tmp_ii=0; $tmp_ii<(count($Result_array)-1); $tmp_ii++)
    {
      $tmp_return_value_array=explode('|',$Result_array[$tmp_ii]);
      reset($tmp_return_value_array);
      while(list($tmp_pos,$tmp_value)=each($tmp_return_value_array))
      {
        $tmp_value=trim($tmp_value);
        $tmp_return_value_array[$tmp_pos]=$tmp_value;

        if($tmp_value=='Phone')
          $Phone_pos=$tmp_pos;
      }

      $srv_First_Name=$tmp_return_value_array[2];
      $srv_Last_Name=$tmp_return_value_array[1];
      $srv_Postal_Town=$tmp_return_value_array[$Phone_pos-2];
      $srv_Address_Line_1=$tmp_return_value_array[$Phone_pos-4];
      $srv_Address_Line_1_Number=$tmp_return_value_array[$Phone_pos-3];
      $srv_Home_Phone=$tmp_return_value_array[$Phone_pos+1];
      $srv_Phone_Fax=$tmp_return_value_array[$Phone_pos+3];

    }

      //~ if (strpos($Result_array[$tmp_ii],$srv_Address_Line_1))
      //~ {
        //~ $StartPhone = strpos($Result_array[$tmp_ii],"Phone")+5;
        //~ $LenPhone = strlen($Result_array[$tmp_ii]);
        //~ $PhoneNr=substr($Result_array[$tmp_ii],$StartPhone,$LenPhone-$StartPhone);

        //~ $PhoneStar=strpos($PhoneNr,"0");
        //~ if ($PhoneStar)
          //~ $PhoneNr=trim(substr($PhoneNr,$PhoneStar,strlen($PhoneNr)-$PhoneStar));

        //~ if (strpos($Result_array[$tmp_ii],$srv_First_Name)>0) {
          //~ $Probability=$Probability+1;
          //~ }
        //~ if (strpos($Result_array[$tmp_ii],$srv_Last_Name)>0) {
          //~ $Probability=$Probability+1;
          //~ }
        //~ if (strpos($Result_array[$tmp_ii],$PostalTown)>0) {
          //~ $Probability=$Probability+1;
          //~ }
        //~ if (strpos($Result_array[$tmp_ii],$srv_Address_Line_1)>0) {
          //~ $Probability=$Probability+1;
          //~ }
      //~ }


    //~ $variable_array['Service Source']="www.directories.ch/whitepages";
    // $variable_array['Probability']=($Probability/4)*100 ."%";
    //if ($Probability>1) $srv_Phone=$PhoneNr;
  }
}

?>
Return current item: OpenBizMap