include_once(FWK_PATH.'common/curl.php'); class MGlobal { function __construct($siren) { $timeout=5; $c_cof = curl_init(); $c_soc = curl_init(); $c_pou = curl_init(); // Définit l'URL ainsi que d'autres options curl_setopt($c_cof, CURLOPT_URL, 'http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren='.$siren); curl_setopt($c_cof, CURLOPT_HEADER, 0); curl_setopt($c_cof, CURLOPT_TIMEOUT, $timeout); curl_setopt($c_cof, CURLOPT_REFERER, ''); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_HEADER, 0); // Création du gestionnaire multiple $mh = curl_multi_init(); // Ajoute les deux gestionnaires curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; // Exécute le gestionnaire do { curl_multi_exec($mh,$running); } while($running > 0); // Ferme tous les gestionnaires curl_multi_remove_handle($ch1); curl_multi_remove_handle($ch2); curl_multi_close($mh); // $iDb=new WDB(); $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;
}
}
?>