<?php

    
function Eniro() {
        
$tmpname tempnam('/tmp''Eniro');
        
$retval  'UNKNOWN';
        
$phone   preg_replace('/^00358/''0'$this->msisdn);

        
$ch curl_init('http://henkilot.eniro.fi/');
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_COOKIEJAR$tmpname);
        
curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070208 Firefox/2.0.0.2');
        
$result curl_exec($ch);
        
curl_close($ch);

        if (
preg_match('|<form action="(.*)" method=post>|Us'$result$match)) {
            
$ch curl_init('http://fi01.coinlet.com/coinlet/'$match[1]);
            
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
            
curl_setopt($chCURLOPT_COOKIEFILE$tmpname);
            
curl_setopt($chCURLOPT_COOKIEJAR$tmpname);
            
curl_setopt($chCURLOPT_POSTFIELDS"login=XXXX&password=XXXX");
            
curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070208 Firefox/2.0.0.2');
            
$result curl_exec($ch);
            
curl_close($ch);

            if (
preg_match('|HREF="(.*)" TARGET="_parent"|'$result$match)) {
                
$ch curl_init($match[1]);
                
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
                
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
                
curl_setopt($chCURLOPT_COOKIEFILE$tmpname);
                
curl_setopt($chCURLOPT_COOKIEJAR$tmpname);
                
curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070208 Firefox/2.0.0.2');
                
$result curl_exec($ch);
                
curl_close($ch);

                if (
preg_match('|<fieldset class="who">|'$result)) {
                    
$ch curl_init('http://henkilot.eniro.fi/query?what=wp&lang=&search_word='$phone .'&geo_area=');
                    
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
                    
curl_setopt($chCURLOPT_COOKIEFILE$tmpname);
                    
curl_setopt($chCURLOPT_COOKIEJAR$tmpname);
                    
curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070208 Firefox/2.0.0.2');
                    
$result curl_exec($ch);
                    
curl_close($ch);

                    if (
preg_match('|<h3><a class="fn expand" href="#">(.*)</a></h3>|Us'$result$match)) {
                        
$match[1] = trim($match[1]);
                        
$match[1] = html_entity_decode($match[1]);
                        
$retval   $match[1];
                    }
                }
            }
        }

        
unlink($tmpname);
        return 
$retval;
    }