'010', 'AI'=>'012', 'AJ'=>'014', 'AK'=>'016', 'AT'=>'028', 'AU'=>'030', 'BH'=>'040', 'BI'=>'042', 'BJ'=>'044', 'BK'=>'048', 'BT'=>'060', 'BU'=>'062', 'BV'=>'064', 'BW'=>'066', 'BX'=>'068', 'BY'=>'070', 'BZ'=>'072', 'CA'=>'074', 'CD'=>'080', 'CE'=>'082', 'CF'=>'084', 'CG'=>'086', 'CH'=>'092', 'CI'=>'094', 'CJ'=>'096', 'CK'=>'098', 'CO'=>'110', '1A'=>'112', 'DA'=>'120', 'DC'=>'124', 'DD'=>'126', 'DF'=>'130', 'DG'=>'132', 'DH'=>'134', 'DI'=>'136', 'DK'=>'140', 'DL'=>'142', 'DR'=>'154', 'DP'=>'154', 'DU'=>'156', 'DV'=>'169', 'DW'=>'164', 'DX'=>'166', 'EA'=>'172-169', 'EB'=>'174', 'EC'=>'176', 'EE'=>'180', 'EH'=>'156-195', 'FA'=>'210-209', 'FB'=>'209', 'FC'=>'210', 'FD'=>'214-215', 'FE'=>'215', 'FF'=>'214', 'FH'=>'217', 'FI'=>'218', 'FK'=>'209+215+217', 'FL'=>'210+214+218', 'FM'=>'222', 'FN'=>'224', 'FO'=>'226', 'FQ'=>'230', 'FR'=>'232', 'FS'=>'234', 'FT'=>'236', 'FU'=>'238', 'FV'=>'240', 'FW'=>'242', 'FX'=>'244', 'FY'=>'250', 'FZ'=>'252', 'GA'=>'254', 'GE'=>'262', 'GF'=>'264', 'GG'=>'270', 'GP'=>'280', 'GU'=>'294', 'GW'=>'270+280+294', 'HD'=>'290', 'HH'=>'300', 'HI'=>'290-300', 'HK'=>'306', 'HL'=>'232+280+290', 'HM'=>'264+294+300+306', 'HN'=>'310', 'YY'=>'374', 'YZ'=>'378', 'YP'=>'376', ); function __construct() { $this->partGetSession(); $this->partConnection(); } function __destruct() { $this->partSaveSession(); } function getInfosDisponbiles($siren) { $this->siren=$siren; $this->partConnection(); return $this->partVitrine(true); } function listBilans($siren) { $tabRet=array(); $tab=$this->getInfosDisponbiles($siren); if ($tab['erreur']=='') { $tabS=@array_reverse(@array_keys($tab['bilans']['S'])); // Réel simplifié $tabN=@array_reverse(@array_keys($tab['bilans']['N'])); // Réel normal $tabC=@array_reverse(@array_keys($tab['bilans']['C'])); // CONSOLIDE $tabA=@array_reverse(@array_keys($tab['bilans']['A'])); // Assurance $tabB=@array_reverse(@array_keys($tab['bilans']['B'])); // Banque foreach ($tabS as $num=>$millesime) { $delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabS[$num+1]))*12) +round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabS[$num+1])); $delta2=round((Wdate::dateT('d/m/Y','Y',$tabS[$num+1])-Wdate::dateT('d/m/Y','Y',$tabS[$num+2]))*12) +round(Wdate::dateT('d/m/Y','m',$tabS[$num+1])-Wdate::dateT('d/m/Y','m',$tabS[$num+2])); $tabRet['S'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'), 'dureeExercice' =>$delta1, 'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabS[$num+1]), 'dureeExercicePre' =>$delta2, 'monnaie' =>'EUR', 'source' =>0, 'ref' =>$tab['bilans']['S'][$millesime], ); } foreach ($tabN as $num=>$millesime) { $delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabN[$num+1]))*12) +round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabN[$num+1])); $delta2=round((Wdate::dateT('d/m/Y','Y',$tabN[$num+1])-Wdate::dateT('d/m/Y','Y',$tabN[$num+2]))*12) +round(Wdate::dateT('d/m/Y','m',$tabN[$num+1])-Wdate::dateT('d/m/Y','m',$tabN[$num+2])); $tabRet['N'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'), 'dureeExercice' =>$delta1, 'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabN[$num+1]), 'dureeExercicePre' =>$delta2, 'monnaie' =>'EUR', 'source' =>0, 'ref' =>$tab['bilans']['N'][$millesime], ); } foreach ($tabC as $num=>$millesime) { $delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabC[$num+1]))*12) +round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabC[$num+1])); $delta2=round((Wdate::dateT('d/m/Y','Y',$tabC[$num+1])-Wdate::dateT('d/m/Y','Y',$tabC[$num+2]))*12) +round(Wdate::dateT('d/m/Y','m',$tabC[$num+1])-Wdate::dateT('d/m/Y','m',$tabC[$num+2])); $tabRet['C'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'), 'dureeExercice' =>$delta1, 'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabC[$num+1]), 'dureeExercicePre' =>$delta2, 'monnaie' =>'EUR', 'source' =>0, 'ref' =>$tab['bilans']['C'][$millesime], ); } foreach ($tabA as $num=>$millesime) { } foreach ($tabB as $num=>$millesime) { } } return $tabRet; } function getBilan($refBilan) { return $this->partBilan($refBilan); } function getIdentite($siren) { $this->siren=$siren; return $this->partIdentite(); } private function partConnection() { if (!$this->wrncsrv2 || time()>$this->timeOut) { $this->timeOut=time()+900; $this->url=$this->urlRacine.'/index.ow'; $page=getUrl($this->url, '', '', $this->urlRacine, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; //echo date('Y/m/d - H:i:s') ." - Initialisation URL = $this->url (Code retour = $this->codeRetour)
".EOL; $fp=fopen('./euridile_connexion1.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); if (preg_match('//i', $this->body, $matches)) $this->url=$this->urlRacine.'/'.$matches[1]; else debugLog('E',"Erreur de communication - Redirection impossible sur ".$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__); debugLog('I','Redirection trouvée sur la page '.$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__); if (preg_match('/\.ow\?WRNCSRV2=(.*)$/i', $matches[1], $matches)) { $this->wrncsrv2=$matches[1]; debugLog('I','Session partenaire WRNCSRV2='.$this->wrncsrv2,__LINE__,__FILE__,__FUNCTION__,__CLASS__); } else debugLog('E','Impossible d\'identifier le numéro de session partenaire',__LINE__,__FILE__,__FUNCTION__,__CLASS__); $page=getUrl($this->url, '', '',$this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; debugLog('D',"Page d'accueil URL = $this->url (Code retour = $this->codeRetour)",__LINE__,__FILE__,__FUNCTION__,__CLASS__); $fp=fopen('./euridile_connexion2.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); if (preg_match('/
body, $matches)) { $postData=array('IDENT'=>'OK', 'MDP'=>'3180', 'cliref'=>'K5K3X5', 'PASS'=>'3180', 'WRNCSRV2'=>$this->wrncsrv2); /** @todo Fair une fonction qui gère les URL commençant par ./ ou ../ ou / afin de pouvoir les concatener **/ $this->url=$this->urlRacine.str_replace('..','',$matches[1]); debugLog('D',"Authentification possible vers $this->url",__LINE__,__FILE__,__FUNCTION__,__CLASS__); } else debugLog('E',"Authentification impossible car formulaire indisponible",__LINE__,__FILE__,__FUNCTION__,__CLASS__); sleep(1); $page=getUrl($this->url,'', $postData, $this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; //echo date('Y/m/d - H:i:s') ." - Après authentification = $this->url (Code retour = $this->codeRetour)
".EOL; $fp=fopen('./euridile_connexion3.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); if(preg_match('/\/'.$this->weur.'\/iden_evaluation_type_(.*)/i', $this->body, $matches)) { $tabTmp=explode('"', $matches[0]); $this->url=$this->urlRacine.$tabTmp[0]; debugLog('D',"Page de recherche recherche trouvée = $this->url>",__LINE__,__FILE__,__FUNCTION__,__CLASS__); } else debugLog('E',"Erreur de communication - Recherche introuvable !",__LINE__,__FILE__,__FUNCTION__,__CLASS__); $this->curPage='recherche'; } //else echo date('Y/m/d - H:i:s') ." - Deja connecte !
".EOL; return true; } private function partInitRecherche() { if ($this->curPage<>'recherche') { //$this->url=$this->urlRacine.'/weur2/ff_page_general.ow?WRNCSRV2='.$this->wrncsrv2.'&g_InfoChoix=IDEN_MC'; $this->url=$this->urlRacine.'/weur3/accueil.ow?WRNCSRV2='.$this->wrncsrv2.'&APPEL=tousnosdocs'; $page=getUrl($this->url, '', '',$this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; if(preg_match('/\/'.$this->weur.'\/iden_evaluation_type_(.*)/i', $this->body, $matches)) { $tabTmp=explode('"', $matches[0]); $this->url=$this->urlRacine.$tabTmp[0]; debugLog('D',"Page de recherche recherche trouvée = $this->url>",__LINE__,__FILE__,__FUNCTION__,__CLASS__); } else debugLog('E',"Erreur de communication - Recherche introuvable !",__LINE__,__FILE__,__FUNCTION__,__CLASS__); $this->curPage='recherche'; $fp=fopen('./euridile_recherche.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); } } private function partVitrine($listeDocuments=false) { if ($this->curPage<>'recherche') $this->partInitRecherche(); $iDb=new WDB('jo'); /* $ret=$iDb->select( 'rncs_vitrine', 'siren, erreur, rcs, nom, adresse1, cp, ville, fj_lib, naf_code, naf_lib, bilans, dateUpdate', "siren=$this->siren", false, MYSQL_ASSOC); if (count($ret)) { /** On vérifie qu'aucune annonce n'a été publié depuis au bodacc ** $tabRet=$ret[0]; $ret=$iDb->select( 'bodacc_detail', 'count(*)', "siren=$this->siren AND Bodacc_Date_Parution>='".$tabRet['dateUpdate']."'"); if ($ret[0][0]==0) { $tabRet['bilans']=unserialize($tabRet['bilans']); return $tabRet; } }*/ $tabRet=$tabBilan=array(); $tabRet['siren']=$this->siren; $tabRet['erreur']=''; $postData=array('codcom_srch'=>'', 'entrep_srch'=>$this->siren, // 'contient'=>'contient', // contient=Contient, debute=Débute par, contientque=ne contient que les termes saisis // 'phoneme'=>'non', // non=A l'identique, oui=approchant 'codpos_srch'=>'', 'commune_srch'=>'', 'adress_srch'=>'', 'x'=>rand(0,80), 'y'=>rand(0,17), 'WRNCSRV2'=>$this->wrncsrv2); $page=getUrl($this->url,'', $postData, $this->referer, false, 'www.euridile.com'); echo date('Y/m/d - H:i:s') ." - Vitrine = $this->url (Code retour = $this->codeRetour)
".EOL; $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $fp=fopen('./euridile_vitrine1.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); if (preg_match('/\/weur2\/iden_saisie_criteres\.ow/i', $this->body)) { $tabRet['erreur']='Siren inconnu'; $this->curPage='recherche'; echo date('Y/m/d - H:i:s') ." - Vitrine : Erreur recherche = $this->url (Code retour = $this->codeRetour)
".EOL; return $tabRet; } echo date('Y/m/d - H:i:s') ." - Vitrine : Après recherche = $this->url (Code retour = $this->codeRetour)
".EOL; $this->url=$this->urlRacine.'/'.$this->weur.'/iden_visu_vitrine.ow?WRNCSRV2='.$this->wrncsrv2; $page=getUrl($this->urlRacine.'/'.$this->weur.'/bandeau_gauche_general.ow?WRNCSRV2='.$this->wrncsrv2,'', '', $this->referer, false, 'www.euridile.com','',0.1); $page=getUrl($this->urlRacine.'/'.$this->weur.'/bandeau_haut_general.ow?WRNCSRV2='.$this->wrncsrv2,'', '', $this->referer, false, 'www.euridile.com','',0.1); $page=getUrl($this->url,'','',$this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $fp=fopen('./euridile_vitrine2.log', 'w'); fwrite($fp,print_r($page,true)); fwrite($fp,print_r($tabRet,true)); fclose($fp); echo date('Y/m/d - H:i:s') ." - Vitrine : Frame = $this->url (Code retour = $this->codeRetour)
".EOL; $this->curPage='vitrine'; $tabRet['rcs']=@getTextInHtml($this->body, ' RCS : ', '',''); if (($tabRet['rcs']*1)<>($tabRet['siren']*1)) { $tabRet['erreur']='Siren inconnu'; return $tabRet; } $tabRet['nom']=@getTextInHtml($this->body, ' ', '', ''); $tabRet['adresse1']=@getTextInHtml($this->body, '
', '', ''); $strTmp=@getTextInHtml($this->body, '
', '', ''); if (preg_match("/^([0-9]{5,5})([\D]*)/i", $strTmp, $matches)) { $tabRet['cp']=trim($matches[1]); $tabRet['ville']=trim($matches[2]); } else { $tabRet['cp']=''; $tabRet['ville']=$strTmp; } $tabRet['fj_lib']=@getTextInHtml($this->body, "\n".'
', '', ''); $strTmp=@getTextInHtml($this->body, '
', '', ''); $tabTmp=explode(' - ', $strTmp); $tabRet['naf_code']=$tabTmp[0]; $tabRet['naf_lib']=$tabTmp[1]; $matches=explode("body); for ($i=1; isset($matches[$i]); $i++) { $tabTmp=explode("','", $matches[$i]); $idBilan=$tabTmp[0]; $tabTmp=explode('|', $idBilan); $dateBilan=$tabTmp[1]; switch ($tabTmp[2]) { case 'SC': $typeBilan='N'; break; // Réel normal case 'SS': $typeBilan='S'; break; // Réel simplifié case 'CC': $typeBilan='C'; break; // CONSOLIDE case 'SA': $typeBilan='A'; break; // Assurance case 'SB': $typeBilan='B'; break; // Banque default: $this->logEuridileError('Type de bilan non pris en charge : "'. $tabTmp[2] .'"'); } $tabBilan[$typeBilan][$dateBilan]=$idBilan; } $tabRet['bilans']=$tabBilan; /* if ($listeDocuments) { $this->partVitrineDocuments(); } */ $fp=fopen('./euridile_vitrine.log', 'w'); fwrite($fp,print_r($page,true)); fwrite($fp,print_r($tabRet,true)); fclose($fp); $tabInsert=$tabRet; $tabInsert['bilans']=serialize($tabRet['bilans']); if (!$iDb->insert( 'rncs_vitrine', $tabInsert)) $iDb->update( 'rncs_vitrine', $tabInsert, "siren=$this->siren"); /** @todo S'il y a un enregistrement, prévoir son update **/ return $tabRet; } private function partVitrineDocuments() { if ($this->curPage='vitrine') $this->partVitrine(); $tabRet=$tabBilan=array(); $tabRet['siren']=$this->siren; $tabRet['erreur']=''; $this->url=$this->urlRacine.'/weur2/ff_page_general.ow?WRNCSRV2='.$this->wrncsrv2. '&g_InfoChoix=CMD_IN&first=actes&filtre_document=no&g_Onglet=info'; $page=getUrl($this->url,'','',$this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->url=$this->urlRacine.'/weur2/cmd_panier_informations_numerises.ow?WRNCSRV2='.$this->wrncsrv2; $page=getUrl($this->urlRacine.'/weur2/bandeau_gauche_general.ow?WRNCSRV2='.$this->wrncsrv2,'','',$this->referer, false, 'www.euridile.com','',0.1); $page=getUrl($this->urlRacine.'/weur2/bandeau_haut_general.ow?WRNCSRV2='.$this->wrncsrv2,'', '', $this->referer, false, 'www.euridile.com','',0.1); $page=getUrl($this->url,'','',$this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; preg_match('/
/i','',str_replace("\r",'', str_replace("\n",'', $this->body))); $tabTmp=explode('
', $acte); $acte=$tabTmp2[0]; } if ($i<>0) { $tabTmp2=explode('', $acte); if (preg_match('/
 ', $tabTmp2[1]); $nom=trim(strip_tags($tabTmp3[0])); $prenom=trim(strip_tags($tabTmp3[1])); $naiss=trim(strip_tags($tabTmp2[3])); if (strpos($naiss, 'Né(e) le')===false) { $fonction=$naiss; } else { $tabTmp3=explode(' à ', $naiss); $naiss_date=trim(str_replace('Né(e) le ', '', strip_tags($tabTmp3[0]))); $naiss=trim(strip_tags($tabTmp3[1])); $tabTmp3=explode('(', $naiss); $naiss_ville=trim(strip_tags($tabTmp3[0])); $naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1]))); $fonction=trim(strip_tags($tabTmp2[5])); } $tabTmp=explode(' née ', $prenom); $prenom=$tabTmp[0]; $naiss_nom=$tabTmp[1]; $tabRet['dirigeants'][$ndir]=array( 'nom'=>$nom, 'prenom'=>$prenom, 'naiss_nom'=>$naiss_nom, 'naiss_date'=>$naiss_date, 'naiss_ville'=>$naiss_ville, 'naiss_depPays'=>$naiss_depPays, 'fonction'=>$fonction); } // Dirigeants - Administrateurs $strTmp=trim(@getTextInHtml($this->body, 'Les administrateurs', "",'')); if ($strTmp<>'') { $tabTmp=explode("", $strTmp); foreach ($tabTmp as $nadm=>$dir) { $tabTmp2=explode('', $dir); $tabTmp3=explode('
 ', $tabTmp2[1]); $nom=trim(strip_tags($tabTmp3[0])); $prenom=trim(strip_tags($tabTmp3[1])); $naiss=trim(strip_tags($tabTmp2[3])); if (strpos($naiss, 'Né(e) le')===false) { $naiss_date=$naiss_ville=$naiss_depPays=''; $fonction=$naiss; } else { $tabTmp3=explode(' à ', $naiss); $naiss_date=trim(str_replace('Né(e) le ', '', strip_tags($tabTmp3[0]))); $naiss=trim(strip_tags($tabTmp3[1])); $tabTmp3=explode('(', $naiss); $naiss_ville=trim(strip_tags($tabTmp3[0])); $naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1]))); $fonction=trim(strip_tags($tabTmp2[5])); } $tabTmp=explode(' née ', $prenom); $prenom=$tabTmp[0]; $naiss_nom=$tabTmp[1]; $tabRet['dirigeants'][$nadm+$ndir+1]=array( 'nom'=>$nom, 'prenom'=>$prenom, 'naiss_nom'=>$naiss_nom, 'naiss_date'=>$naiss_date, 'naiss_ville'=>$naiss_ville, 'naiss_depPays'=>$naiss_depPays, 'fonction'=>$fonction); } } // Etablissements $strTmp=@getTextInHtml($this->body, 'Les établissements', "",''); $tabTmp=explode("", $strTmp); foreach ($tabTmp as $netab=>$dir) { $cp=$ville=$ensEtab=''; $j=0; $tabTmp2=explode('', $dir); for($i=1; $i<=9; $i=$i+2) { $next=$i+2; $strTmp=trim(strip_tags($tabTmp2[$i])); if (preg_match("/^([0-9]{5,5})([\D]*)/i", $strTmp, $matches)) { $adresse[$j]=''; $cp=trim($matches[1]); $ville=trim($matches[2]); break; } else $adresse[$j]=$strTmp; $j++; } /** Gestion des cas où la 1ère ligne d'adresse contient l'enseigne de l'établissement */ if (strtoupper($adresse[0])==strtoupper($tabRet['enseigne'])) { $ensEtab=$adresse[0]; array_shift($adresse); } $strTmp=trim(strip_tags($tabTmp2[$next])); $tabTmp3=explode(' - ', $strTmp); $tabRet['etablissements'][$netab]=array( 'enseigne'=>$ensEtab, 'adresse1'=>$adresse[0], 'adresse2'=>$adresse[1], 'adresse3'=>$adresse[2], 'cp'=>$cp, 'ville'=>$ville, 'naf_code'=>$tabTmp3[0], 'naf_lib'=>$tabTmp3[1]); } $fp=fopen('./euridile_identite.log', 'w'); fwrite($fp,print_r($page,true)); fclose($fp); $tabInsert=$tabRet; $tabInsert['procedures']=serialize($tabRet['procedures']); $tabInsert['dirigeants']=serialize($tabRet['dirigeants']); $tabInsert['etablissements']=serialize($tabRet['etablissements']); $iDb->insert( 'rncs_entrep', $tabInsert); return $tabRet; } private function partBilan($idBilanPart) { if ($this->curPage<>'vitrine') $this->partVitrine(); $url=$this->urlRacine.'/'.$this->weur."/paie_abonnes_livraison_directe_informations.ow?flag_type_acces_direct_infos=$idBilanPart&WRNCSRV2=".$this->wrncsrv2; $page=getUrl($url, '', '', $this->referer, false, 'www.euridile.com'); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; if (preg_match('/body, $matches)) $this->url=$matches[1]; else $this->logEuridileError('Erreur redir vers Bilan INPI'); $page=getUrl($this->url, '', '',$this->referer, false); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $urlInpi='http://modules.euridile.inpi.fr'; // http://modules.euridile.inpi.fr/accesproduits.ow?MODUSRV1=2701291735122345 if (preg_match('/body, $matches)) $this->url=$urlInpi.'/'.$matches[1]; else $this->logEuridileError('Erreur redir vers Bilan INPI 2'); $page=getUrl($this->url, '', '',$this->referer, false); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $tabTmp=explode('=', $this->url); $modusrv1=$tabTmp[1]; // http://modules.euridile.inpi.fr/analyse/TOTAL_BILAN/f_total_bilan.ow?MODUSRV1=2701221057921108 if (preg_match('/body, $matches)) $this->url=$urlInpi.$matches[1]; else $this->logEuridileError('Erreur redir vers Bilan INPI 3'); $page=getUrl($this->url, '', '',$this->referer, false); $this->referer=$this->url; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; //*die($this->url); getUrl($urlInpi.'/analyse/TOTAL_BILAN/menu.ow?MODUSRV1='.$modusrv1,'', '', $this->referer, false); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1,'','',$this->referer, false); $this->referer=$urlInpi.'/analyse/TOTAL_BILAN/menu.ow?MODUSRV1='.$modusrv1; $this->body=$page['body']; $this->codeRetour=$page['code']; $this->header=$page['header']; $tabTmp=explode('|', $idBilanPart); $dateBilan=$tabTmp[1]; $tabBilan=array(); $tabBilan['SIREN']=$this->siren; $tabBilan['DATE_FRAICHE_BILAN']=date('Ymd'); $tabBilan['DATE_CLOTURE']=$dateBilan; switch ($tabTmp[2]) { case 'SC': // Bilans réels Normal $tabBilan['TYPE_BILAN']='N'; // http://modules.euridile.inpi.fr/comptesAvecContexte.ow?MODUSRV1=2712291618629017&PAGE=ACTIFSC (déjà vue) $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=PASSIFSC','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=CPTRESSC','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=ANXSC','','',$this->referer, false); $this->body.=$page['body']; /** Lecture et découpage du bilan **/ $body=strtoupper($this->body); preg_match_all('/bgcolor="#e6efff">([A-Z0-9]{2,2})(?:<\/font>|)<\/TD>/i', $body, $matches); $tabP=$matches[1]; $tabPostes=array(); foreach ($tabP as $iPoste=>$poste) { if ($poste<>'ZR') { $strTmp=str_replace("\n",'',@getTextInHtml($body, 'BGCOLOR="#E6EFFF">'.$poste, ' ','')); $strTmp2=preg_replace('/bgcolor="#e6efff">(?:[A-Z0-9]{2,2})(?:<\/font>|)<\/TD>(.*)/i', '', $strTmp); $tabTmp=explode(' ', $strTmp2); for ($j=0; $j<3;$j++) { if ($j==0) $indice=''; elseif ($j==1) $indice=1; else $indice=2; if (isset($tabTmp[$j])) { $tabPostes[$poste.$indice]=trim(str_replace(' ', '', str_replace('-->', '', str_replace('&NBSP;', '', strip_tags($tabTmp[$j]))))); if ($tabPostes[$poste.$indice]=='') unset($tabPostes[$poste.$indice]); elseif (!is_numeric($tabPostes[$poste.$indice])) unset($tabPostes[$poste.$indice]); } } } } $strTmp=@getTextInHtml($this->body, 'Montants exprimés en : ', '',''); //milliers d'Euros (KE) $tabTmp=explode('(', $strTmp); if ($tabTmp[1]=='KE)') { $tabBilan['MONNAIE']='EUR'; $tabBilan['MONNAIE_ORI']='EUR'; $tabBilan['MONNAIE_LIV_UNITE']='K'; } else $this->logEuridileError('Devise INPI non gérée : '.$strTmp); $tabBilan['DATE_CLOTURE_PRE']=@getTextInHtml($this->body, 'Exercices, clos le : ', ' ',''); $tabBilan['DUREE_MOIS']=@getTextInHtml($this->body, 'Durée des exercices : ', '',''); $tabBilan['DUREE_MOIS_PRE']=@getTextInHtml($this->body, 'Durée des exercices : ', ' ',''); $tabBilan['POSTES']=$tabPostes; break; case 'SS': // Bilans réels simplifiés $tabBilan['TYPE_BILAN']='S'; //http://modules.euridile.inpi.fr/comptesAvecContexte.ow?MODUSRV1=2712250539227157&PAGE=ACTPASSS (déjà vue) $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=CPTRESSS','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=IMMAMOSS','','',$this->referer, false); $this->body.=$page['body']; /** Lecture et découpage du bilan **/ $body=strtoupper($this->body); preg_match_all('/bgcolor="#e6efff">([0-9]{3,3})(?:<\/font>|)<\/TD>/i', $body, $matches); $tabP=$matches[1]; $tabPostes=array(); foreach ($tabP as $iPoste=>$poste) { if ($poste<>'ZR') { $poste=''.$poste; $strTmp=str_replace("\n",'',@getTextInHtml($body, 'BGCOLOR="#E6EFFF">'.$poste, ' ','')); $strTmp2=preg_replace('/bgcolor="#e6efff">(?:[0-9]{3,3})(?:<\/font>|)<\/TD>(.*)/i', '', $strTmp); $tabTmp=explode(' ', $strTmp2); for ($j=0; $j<3;$j++) { if ($j==0) $indice=''; elseif ($j==1) $indice='a'; else $indice='b'; if (isset($tabTmp[$j])) { $tabPostes[$poste.$indice]=trim(str_replace(' ', '', str_replace('-->', '', str_replace('&NBSP;', '', strip_tags($tabTmp[$j]))))); if ($tabPostes[$poste.$indice]=='') unset($tabPostes[$poste.$indice]); elseif (!is_numeric($tabPostes[$poste.$indice])) unset($tabPostes[$poste.$indice]); } } } } $strTmp=@getTextInHtml($this->body, 'Montants exprimés en : ', '',''); //milliers d'Euros (KE) $tabTmp=explode('(', $strTmp); if ($tabTmp[1]=='KE)') { $tabBilan['MONNAIE']='EUR'; $tabBilan['MONNAIE_ORI']='EUR'; $tabBilan['MONNAIE_LIV_UNITE']='K'; } else $this->logEuridileError('Devise INPI non gérée : '.$strTmp); $tabBilan['DATE_CLOTURE_PRE']=@getTextInHtml($this->body, 'Exercices, clos le : ','',''); $tabBilan['DUREE_MOIS']=@getTextInHtml($this->body, 'Durée des exercices : ', '',''); $tabBilan['DUREE_MOIS_PRE']=@getTextInHtml($this->body, 'Durée des exercices : ', ' ',''); $tabBilan['POSTES']=$tabPostes; break; case 'CC': // Bilans Consolidés $tabBilan['TYPE_BILAN']='C'; // http://modules.euridile.inpi.fr/comptesAvecContexte.ow?MODUSRV1=2712304993629995&PAGE=ACTIFCC (déjà vue) $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=PASSIFCC','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=CPTRESCC','','',$this->referer, false); $this->body.=$page['body']; /** Lecture et découpage du bilan **/ $body=strtoupper($this->body); preg_match_all('/bgcolor="#e6efff">([A-Z0-9]{2,2})(?:<\/font>|)<\/TD>/i', $body, $matches); $tabP=$matches[1]; $tabPostes=array(); foreach ($tabP as $iPoste=>$poste) { if ($poste<>'ZR') { $strTmp=str_replace("\n",'',@getTextInHtml($body, 'BGCOLOR="#E6EFFF">'.$poste, ' ','')); $strTmp2=preg_replace('/bgcolor="#e6efff">(?:[A-Z0-9]{2,2})(?:<\/font>|)<\/TD>(.*)/i', '', $strTmp); $tabTmp=explode(' ', $strTmp2); for ($j=0; $j<3;$j++) { if ($j==0) $indice=''; elseif ($j==1) $indice=1; else $indice=2; if (isset($tabTmp[$j])) { $tabPostes[$poste.$indice]=trim(str_replace(' ', '', str_replace('-->', '', str_replace('&NBSP;', '', strip_tags($tabTmp[$j]))))); if ($tabPostes[$poste.$indice]=='') unset($tabPostes[$poste.$indice]); elseif (!is_numeric($tabPostes[$poste.$indice])) unset($tabPostes[$poste.$indice]); } } } } $strTmp=@getTextInHtml($this->body, 'Montants exprimés en : ', '',''); //milliers d'Euros (KE) $tabTmp=explode('(', $strTmp); if ($tabTmp[1]=='KE)') { $tabBilan['MONNAIE']='EUR'; $tabBilan['MONNAIE_ORI']='EUR'; $tabBilan['MONNAIE_LIV_UNITE']='K'; } else $this->logEuridileError('Devise INPI non gérée : '.$strTmp); $tabBilan['DATE_CLOTURE_PRE']=@getTextInHtml($this->body, 'Exercices, clos le : ', '',''); $tabBilan['DUREE_MOIS']=@getTextInHtml($this->body, 'Durée des exercices : ', '',''); $tabBilan['DUREE_MOIS_PRE']=@getTextInHtml($this->body, 'Durée des exercices : ', ' ',''); $tabBilan['POSTES']=$tabPostes; break; case 'SA': // Assurance $tabBilan['TYPE_BILAN']='A'; // http://modules.euridile.inpi.fr/comptesAvecContexte.ow?MODUSRV1=2712304993629995&PAGE=ACTIFCC (déjà vue) /* $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=PASSIFCC','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=CPTRESCC','','',$this->referer, false); $this->body.=$page['body']; /** Lecture et découpage du bilan ** $body=strtoupper($this->body); preg_match_all('/bgcolor="#e6efff">([A-Z0-9]{2,2})(?:<\/font>|)<\/TD>/i', $body, $matches); $tabP=$matches[1];*/ $tabPostes=array();/* foreach ($tabP as $iPoste=>$poste) { if ($poste<>'ZR') { $strTmp=str_replace("\n",'',@getTextInHtml($body, 'BGCOLOR="#E6EFFF">'.$poste, ' ','')); $strTmp2=preg_replace('/bgcolor="#e6efff">(?:[A-Z0-9]{2,2})(?:<\/font>|)<\/TD>(.*)/i', '', $strTmp); $tabTmp=explode(' ', $strTmp2); for ($j=0; $j<3;$j++) { if ($j==0) $indice=''; elseif ($j==1) $indice=1; else $indice=2; if (isset($tabTmp[$j])) { $tabPostes[$poste.$indice]=trim(str_replace(' ', '', str_replace('-->', '', str_replace('&NBSP;', '', strip_tags($tabTmp[$j]))))); if ($tabPostes[$poste.$indice]=='') unset($tabPostes[$poste.$indice]); elseif (!is_numeric($tabPostes[$poste.$indice])) unset($tabPostes[$poste.$indice]); } } } } $strTmp=@getTextInHtml($this->body, 'Montants exprimés en : ', '',''); //milliers d'Euros (KE) $tabTmp=explode('(', $strTmp); if ($tabTmp[1]=='KE)') { $tabBilan['MONNAIE']='EUR'; $tabBilan['MONNAIE_ORI']='EUR'; $tabBilan['MONNAIE_LIV_UNITE']='K'; } else die('Devise INPI non gérée : '.$strTmp);*/ $tabBilan['DATE_CLOTURE_PRE']=@getTextInHtml($this->body, 'Exercices, clos le : ', '',''); $tabBilan['DUREE_MOIS']=@getTextInHtml($this->body, 'Durée des exercices : ', '',''); $tabBilan['DUREE_MOIS_PRE']=@getTextInHtml($this->body, 'Durée des exercices : ', ' ',''); $tabBilan['POSTES']=$tabPostes; break; case 'SB': // Banque $tabBilan['TYPE_BILAN']='B'; // http://modules.euridile.inpi.fr/comptesAvecContexte.ow?MODUSRV1=2712304993629995&PAGE=ACTIFCC (déjà vue) /* $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=PASSIFCC','','',$this->referer, false); $this->body.=$page['body']; sleep(1); $page=getUrl($urlInpi.'/comptesAvecContexte.ow?MODUSRV1='.$modusrv1.'&PAGE=CPTRESCC','','',$this->referer, false); $this->body.=$page['body']; /** Lecture et découpage du bilan ** $body=strtoupper($this->body); preg_match_all('/bgcolor="#e6efff">([A-Z0-9]{2,2})(?:<\/font>|)<\/TD>/i', $body, $matches); $tabP=$matches[1];*/ $tabPostes=array();/* foreach ($tabP as $iPoste=>$poste) { if ($poste<>'ZR') { $strTmp=str_replace("\n",'',@getTextInHtml($body, 'BGCOLOR="#E6EFFF">'.$poste, ' ','')); $strTmp2=preg_replace('/bgcolor="#e6efff">(?:[A-Z0-9]{2,2})(?:<\/font>|)<\/TD>(.*)/i', '', $strTmp); $tabTmp=explode(' ', $strTmp2); for ($j=0; $j<3;$j++) { if ($j==0) $indice=''; elseif ($j==1) $indice=1; else $indice=2; if (isset($tabTmp[$j])) { $tabPostes[$poste.$indice]=trim(str_replace(' ', '', str_replace('-->', '', str_replace('&NBSP;', '', strip_tags($tabTmp[$j]))))); if ($tabPostes[$poste.$indice]=='') unset($tabPostes[$poste.$indice]); elseif (!is_numeric($tabPostes[$poste.$indice])) unset($tabPostes[$poste.$indice]); } } } } $strTmp=@getTextInHtml($this->body, 'Montants exprimés en : ', '',''); //milliers d'Euros (KE) $tabTmp=explode('(', $strTmp); if ($tabTmp[1]=='KE)') { $tabBilan['MONNAIE']='EUR'; $tabBilan['MONNAIE_ORI']='EUR'; $tabBilan['MONNAIE_LIV_UNITE']='K'; } else die('Devise INPI non gérée : '.$strTmp);*/ $tabBilan['DATE_CLOTURE_PRE']=@getTextInHtml($this->body, 'Exercices, clos le : ', '',''); $tabBilan['DUREE_MOIS']=@getTextInHtml($this->body, 'Durée des exercices : ', '',''); $tabBilan['DUREE_MOIS_PRE']=@getTextInHtml($this->body, 'Durée des exercices : ', ' ',''); $tabBilan['POSTES']=$tabPostes; break; default: return array(); break; } $this->curPage='bilan'; $fp=fopen('./euridile_bilan.log', 'w'); fwrite($fp,$this->body); fclose($fp); return $tabBilan; } function bilanSimplifie2Normal($bilanRS) { $bilanRN=array(); foreach ($this->tabBS2BN as $posteRN => $formule) { if (preg_match('/\+|\-/', $formule)) { $tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE); //$bilanRN[$posteRN]=0; $scalc=''; foreach ($tabTmp as $i=>$tab) { if ($i==0) { $bilanRN[$posteRN]=$bilanRS[$tab[0]]; $scalc.=$bilanRS[$tab[0]]; } else { $signe=$formule[$tab[1]-1]; $scalc.=$signe; if ($signe=='+') $bilanRN[$posteRN]+=$bilanRS[$tab[0]]; elseif ($signe=='-') $bilanRN[$posteRN]-=$bilanRS[$tab[0]]; $scalc.=$bilanRS[$tab[0]]; } } $bilanRN[$posteRN]=$bilanRN[$posteRN]." (formule=$formule soit $scalc)"; } else $bilanRN[$posteRN]=$bilanRS[$formule]; } if ($bilanRS['240']<>0) { $bilanRN['BL']=$bilanRS['050']; $bilanRN['BM']=$bilanRS['052']; } else { $bilanRN['BN']=$bilanRS['050']; $bilanRN['BO']=$bilanRS['052']; } if ($bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0) $bilanRN['GC']=$bilanRS['256']; elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0) $bilanRN['GD']=$bilanRS['256']; if ($bilanRS['584']<>0) { $bilanRN['HB']=$bilanRS['584']; $bilanRN['HA']=$bilanRS['290']-$bilanRS['584']; } else $bilanRN['HA']=$bilanRS['290']; if ($bilanRS['582']<>0) { $bilanRN['HF']=$bilanRS['582']; $bilanRN['HE']=$bilanRS['582']-$bilanRS['300']; } else $bilanRN['HE']=$bilanRS['300']; return $bilanRN; } private function partSaveSession() { $fp=fopen('/tmp/php_rncs_session.id', 'w'); fwrite($fp,$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer); fclose($fp); } private function partGetSession() { $strTmp=@file_get_contents('/tmp/php_rncs_session.id'); if ($strTmp) { $tabTmp=explode('^', $strTmp); $this->wrncsrv2=$tabTmp[0]; $this->timeOut=$tabTmp[1]; $this->curPage=$tabTmp[2]; $this->siren=$tabTmp[3]; $this->url=$tabTmp[4]; $this->referer=$tabTmp[5]; } else $this->timeOut=0; } private function logEuridileError($message) { $fp=fopen('./euridile_error.log', 'w'); fwrite($fp,date('Y/m/d H:i:s')." - Erreur : $message (".$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer.')'.EOL); fwrite($fp,$this->body.EOL.'-------------------------------------------------------------------------------------'.EOL); fclose($fp); } } ?>