require_once 'framework/common/curl.php'; class MCoface { public $body = ''; public $header = ''; public $codeRetour = 0; public $nscrl = 0; // Numéro interne SCRL public $rcsVille=''; public $rcsType=''; public $rSocAdrCPVille=''; // RaisonSocialeAdresseVille (utile pour le débug) public $raisonSociale=''; // Raison Sociale public $adresse=''; // Adresse complète (avec CP et Cille) public $sigle=''; public $enseigne=''; public $nbEtab=''; public $adrNumVoie; public $adrIndRep; public $adrTypeVoie; public $adrLibVoie; public $adrCP; public $adrVille; public $tel=''; public $fax=''; public $web=''; public $mail=''; public $activite=''; // Activité Déclarée au bodacc public $naf=''; // NAF public $nafLib=''; public $bourseIsin=''; public $bourseMarche=''; public $bourseVille=''; public $tabInfos=array(); public $tabBilans=array(); public $infoEco=false; public $capitalType=''; public $capitalMontant=''; public $capitalDevise =''; public $steInactive = ''; public $dateCreation=''; // Notion INSEE public $dateImmatriculation=''; // Notion Greffe et RNCS uniquement public $fj=''; public $nationalite=''; public $enBourse=''; public $effectif=''; public $tabDirigeants=array(); public $strLiensFi=''; public $strElemsFi=''; public $derExerciceAnnee=''; public $derExerciceDuree=''; public $derExerciceDClot=''; public $derExerciceCA=''; public $derExerciceResultat=''; public $derExerciceDevise=''; public $dateFermeture=''; public $score_pouey=''; public $score_conan=''; public $score_afdcc=''; public $vigilance=''; public $tabJug=array(); public $tabAct=array(); public $tabFil=array(); public $tabEtab=array(); function __construct($siren) { $referer=''; $url='http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren='.$siren; $page=getUrl($url, '', '', $referer, false, 'www.cofacerating.fr', '', 10); $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $this->nscrl=@getTextInHtml($this->body, '&nscrl=', '=','&'); $this->rSocAdrCPVille=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '
(.*)<\/span> - Participation<\/span> : (.*) % (.*)<\/span> - Participation<\/span> :(.*)% CA (.*)<\/span>(.*)
(.*)<\/p>/isU', $strTmp, $matches)) {
foreach ($matches[1] as $i=>$nom) {
$this->tabAct[$i]['nom']=trim($nom);
$this->tabAct[$i]['pct']=trim($matches[2][$i]);
$this->tabAct[$i]['rcs']=trim(str_replace('RCS : ','',strip_tags($matches[3][$i])));
}
}
/** Filiales **/
$strTmp=trim(@getTextInHtml($this->body, 'FILIALES
', '', ''));
if(preg_match_all('/
(.*)<\/p>/isU', $strTmp, $matches)) {
foreach ($matches[1] as $i=>$nom) {
$this->tabFil[$i]['nom']=trim($nom);
$this->tabFil[$i]['pct']=trim($matches[2][$i]);
$this->tabFil[$i]['rcs']=trim(str_replace('RCS :','',strip_tags($matches[3][$i])));
}
}
/** CA et Résultat **/
$strTmp=trim(@getTextInHtml($this->body, 'PRINCIPAUX ELEMENTS FINANCIERS
', '
', '
/isU', $strTmp, $matches)) {
$this->derExerciceAnnee=trim($matches[1]);
$this->derExerciceCA=trim(str_replace(':',' ', $matches[2]));
}
if(preg_match('/Résultat(.*)<\/span>(.*)$/isU', $strTmp, $matches)) {
$this->derExerciceResultat=trim(str_replace(':',' ', $matches[2]));
}
$infoBilan=print_r($page, true);
$fp=fopen('./infobilan.html', 'w');
fwrite($fp, $infoBilan);
fclose($fp);
}
if ($this->nbEtab=='' || $this->nbEtab=='0') {
$this->nbEtab=trim(strip_tags(str_replace('afficher la liste...', '', @getTextInHtml($pou, ' '))));
$urlPEtab='http://www.score3.fr/etablissements.shtml?page=1&siren='.$siren;
$refererPEtab=$urlP;
$page=getUrl($urlPEtab, '', '', $refererPEtab, false, 'www.score3.fr');
$pou2=$page['body'];
if(preg_match_all('/Etablissements ', '', ' (\d*)<\/td> ', '(.*)<\/td><\/tr><\/table>/isU', $pou2, $matches)) {
foreach ($matches[1] as $i=>$nic) {
$strEtab=$matches[2][$i];
$this->tabEtab[$i]['siren']=$siren;
$this->tabEtab[$i]['nic']=$nic;
$this->tabEtab[$i]['siret']=$siren.$nic;
$this->tabEtab[$i]['enseigne']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '', '">', '')))));
$this->tabEtab[$i]['adresse']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '', '">', '
')))));
$strTmp=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '', '
', '')))));
$tabTmp=explode(' ', $strTmp);
$this->tabEtab[$i]['cp']=$tabTmp[0];
unset($tabTmp[0]);
$this->tabEtab[$i]['ville']=implode(' ',$tabTmp);
$strTmp=trim(strip_tags(@getTextInHtml($strEtab, '', '">', ')')));
$tabTmp=explode('(', $strTmp);
$this->tabEtab[$i]['naf_code']=$tabTmp[1];
$this->tabEtab[$i]['naf_lib']=trim(str_replace(chr(160),' ',utf8_decode($tabTmp[0])));
if (preg_match('/
T.l\.(.*)$/i',$strEtab,$matches2))
$this->tabEtab[$i]['tel']=trim(str_replace(chr(160),' ',utf8_decode($matches2[1])));
else $this->tabEtab[$i]['tel']='';
}
}
$this->nbEtab=count($this->tabEtab);
$fp=fopen('./pouet_etab.html', 'w');
fwrite($fp, $pou2);
fclose($fp);
}
if ($this->effectif=='' || $this->effectif=='0' || $this->effectif=='NC')
$this->effectif=trim(@getTextInHtml($pou, ' '));
if ($this->dateImmatriculation=='' || $this->dateImmatriculation=='0')
$this->dateImmatriculation=trim(@getTextInHtml($pou, 'Effectifs ', '', ' '));
if ($this->dateFermeture=='' || $this->dateFermeture=='0')
$this->dateFermeture=trim(@getTextInHtml($pou, 'Date d\'immatriculation ', '', ' '));
if ($this->tel=='' || $this->tel=='0')
$this->tel=trim(@getTextInHtml($pou, 'Date de fin d\'exploitation ', '', ' '));
if ($this->fax=='' || $this->fax=='0')
$this->fax=trim(@getTextInHtml($pou, 'Téléphone ', '', ' '));
$strTmp=trim(@getTextInHtml($pou, 'Procédures collectives', 'Fax ', '', ' (.*)<\/td> (.*)<\/td><\/tr>/isU', $strTmp, $matches)) {
foreach ($matches[1] as $i=>$jug) {
$this->tabJug[$i]['date']=$matches[1][$i];
$this->tabJug[$i]['juge']=$matches[2][$i];
}
}
$this->score_pouey=trim(@getTextInHtml($pou, ''));
$this->score_conan=trim(@getTextInHtml($pou, ''));
$this->score_afdcc=trim(@getTextInHtml($pou, ''));
$this->vigilance =trim(@getTextInHtml($pou, ''));
if(preg_match('/Date de l\'exercice<\/td> (.*) sur (\d*) mois<\/td><\/tr>/isU', $pou, $matches)) {
$this->derExerciceDClot=trim($matches[1]);
$this->derExerciceDuree=trim($matches[2]);
}
/* Siret SIEGE
2 Fonction, Nom Prénoù ET Date NAissance du PP
5 Liste des actes
*/
if ($this->codeRetour==200)
return true;
return false;
}
}
?>