require_once 'common/curl.php';
class MIdentite {
public $body = '';
public $header = '';
public $codeRetour = 0;
function __construct($siren) {
$referer='';
$url='http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?nsiren='.$siren;
$page=getUrl($url, '', '', $referer, false, 'www.cofacerating.fr');
$this->body=$page['body'];
$this->codeRetour=$page['code'];
$this->header=$page['header'];
$tabRet['nscrl']=@getTextInHtml($this->body, '&nscrl=', '=','&');
$strTmp=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '
Raison sociale ', ' | ','')))));
$tmp=explode(' ', $strTmp);
$tabRet['raisonSociale']=trim($tmp[0]);
unset($tmp[0]);
$tabRet['adresse']=trim(strip_tags(implode(',', $tmp)));
$tabRet['tel']=trim(@getTextInHtml($this->body, ' | Téléphone ', ' | ', ' '));
$tabRet['fax']=trim(@getTextInHtml($this->body, 'Télécopie | ', '
', ''));
$tabRet['web']=trim(@getTextInHtml($this->body, '>Adresse internet
', ''));
$tabRet['mail']=trim(@getTextInHtml($this->body, ''));
$bourse=trim(@getTextInHtml($this->body, 'Ville Bourse', 'class="tabval">', ''));
$tmp=explode('
', $bourse);
$tabRet['bourseIsin']=trim($tmp[0]);
$tabRet['bourseMarche']=trim($tmp[1]);
$tabRet['bourseVille']=trim($tmp[2]);
/*
$infosDispo=trim(@getTextInHtml($this->body, 'Liste Produits
', '
'));
$tabTmp=explode('(.*)<\/a>/i', $lien, $matches);
if ($matches[2]<>'') $this->tabInfos[$matches[2]]=$matches[1];
if (substr($matches[2], 0, 12)=='rapport éco.') $this->infoEco='http://www.cofacerating.fr/portail/entreprise_identite/'.$matches[1];
elseif (substr($matches[2], 0, 6)=='bilan ') $this->tabBilans[]=substr($matches[2], 6,strlen($matches[2])-6);
}*/
$tabRet['activite']=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, 'Libellé code activité | ', '', ' | ')))));
$tabRet['naf']=trim(@getTextInHtml($this->body, 'Etablissements ', '', ' | '))));
/*$urlPEtab='http://www.score3.fr/etablissements.shtml?page=1&siren='.$siren;
$refererPEtab=$urlP;
}
*/
$tabRet['effectif']=trim(@getTextInHtml($pou, 'Effectifs | ', '', ' |
'));
$strTmp=trim(@getTextInHtml($pou, 'Date d\'immatriculation | ', '', ' |
'));
if (strlen($strTmp)==4)
$strTmp='01/01/'.$strTmp;
elseif (strlen($strTmp)==7)
$strTmp='01/'.$strTmp;
$tabRet['dateImmatriculation']=WDate::dateT('d/m/Y','Y-m-d',$strTmp);
$strTmp=trim(@getTextInHtml($pou, 'Date de fin d\'exploitation | ', '', ' |
'));
if (strlen($strTmp)==4)
$strTmp='01/01/'.$strTmp;
elseif (strlen($strTmp)==7)
$strTmp='01/'.$strTmp;
$tabRet['dateFermeture']=WDate::dateT('d/m/Y','Y-m-d',$strTmp);
if($tabRet['tel']=='' || $tabRet['tel']=='0')
$tabRet['tel']=trim(@getTextInHtml($pou, 'Téléphone | ', '', ' |
'));
if($tabRet['fax']=='' || $tabRet['fax']=='0')
$tabRet['fax']=trim(@getTextInHtml($pou, 'Fax | ', '', ' |
'));
$strTmp=trim(@getTextInHtml($pou, 'Activité principale | ', '', ' |
'));
$tabRet['nafLib']=trim(strtr(substr($strTmp,0,strlen($strTmp)-6),'()',' '));
if ($tabRet['naf']=='')
$tabRet['naf']=trim(strtr(substr($strTmp,-6),'()',' '));
$strTmp=trim(@getTextInHtml($pou, 'Chiffre d\'affaires | ', '', ' |
'));
$tabRet['tca']=$strTmp;
$tabRet['score_pouey']=trim(@getTextInHtml($pou, ''));
$tabRet['score_conan']=trim(@getTextInHtml($pou, ''));
$tabRet['score_afdcc']=trim(@getTextInHtml($pou, ''));
$tabRet['vigilance'] =trim(@getTextInHtml($pou, ''));
if ($this->codeRetour==200)
return true;
return false;
}
}
?>