2010-11-29 16:12:32 +00:00
< ? php
2010-11-04 15:17:32 +00:00
require_once 'framework/common/curl.php' ;
2010-11-04 11:21:31 +00:00
class MMarques {
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
private $body = '' ;
private $header = '' ;
private $codeRetour = 0 ;
private $wrncsrv2 = false ;
private $reference = 0 ;
private $timeOut = 0 ;
private $url = '' ;
private $urlRacine = 'http://bases-marques.inpi.fr/' ;
private $weur = 'weur3' ; // Version Web 3 d'Euridile
private $referer = '' ;
private $curPage = '' ;
private $cookie = '' ;
private $iDb ;
private $iInsee ;
2012-12-17 16:35:12 +00:00
public $siren ;
2010-11-04 11:21:31 +00:00
function __construct () {
//$this->partGetSession();
$this -> partConnection ();
2011-02-02 10:32:50 +00:00
$this -> iDb = new WDB ( 'bopi' );
2010-11-04 11:21:31 +00:00
$this -> iInsee = new MInsee ();
}
function __destruct () {
//$this->partSaveSession();
}
2012-12-17 16:35:12 +00:00
2010-11-29 16:12:32 +00:00
/** Liste des marques pour un siren donné ou détail d 'une marque d' une entreprise
2012-12-17 16:35:12 +00:00
* @ param $siren int
2010-11-29 16:12:32 +00:00
* @ param $idDepot int Numéro de la marque ou Néant / 0 si liste des marques
*/
function getMarques ( $siren , $idDepot = 0 ) {
//SELECT `id`, `typeMarque`, ``, `rayonMarque`, `urlImage`, `idMarque`, `deposantMarque`, `numeroMarque`, `classesMarque`, `idObjetPdf`, `periMarque`, `idObjetImg`, `detailDeposant`, `sirenDeposant`, `sirenValide`, `idSirenage`, `detailMandataire`, `detailNumero`, `detailStatut`, `dateDepot`, `lieuDepot`, `infoMarque`, `adresseCorresp`, `dateExpir`, `dateInsert` FROM `marques`
$marques = array ();
$strSql = " 1 " ;
if ( $siren > 0 ) $strSql .= " AND sirenDeposant= $siren " ;
2012-12-17 16:35:12 +00:00
if ( $idDepot > 0 ) $strSql .= " AND numeroMarque= $idDepot " ;
2013-02-07 16:21:14 +00:00
$res = $this -> iDb -> select ( 'marques' , 'nomMarque, rayonMarque, detailDeposant, sirenDeposant, dateDepot, lieuDepot, numeroMarque, classesMarque, periMarque, detailDeposant, detailMandataire, detailStatut, dateExpir, idObjetImg, idObjetPdf' , " $strSql ORDER BY dateDepot DESC " );
2010-11-29 16:12:32 +00:00
if ( count ( $res ) > 0 ) {
foreach ( $res as $i => $marque ) {
if ( $marque [ 'nomMarque' ] == ' ' ) $nomMarque = '(figurative)' ;
else $nomMarque = $marque [ 'nomMarque' ];
2013-02-07 16:21:14 +00:00
$marques [ $i ] = array (
'nomMarque' => $nomMarque ,
'rayonMarque' => $marque [ 'rayonMarque' ],
'detailDeposant' => $marque [ 'detailDeposant' ],
'detailMandataire' => $marque [ 'detailMandataire' ],
'detailStatut' => $marque [ 'detailStatut' ],
'sirenDeposant' => $marque [ 'sirenDeposant' ],
'dateDepot' => $marque [ 'dateDepot' ],
'lieuDepot' => $marque [ 'lieuDepot' ],
'classesMarque' => $marque [ 'classesMarque' ],
'periMarque' => $marque [ 'periMarque' ],
'dateExpir' => $marque [ 'dateExpir' ],
'numeroMarque' => $marque [ 'numeroMarque' ],
'imgLink' => $marque [ 'idObjetImg' ],
'pdfLink' => $marque [ 'idObjetPdf' ],
);
2010-11-29 16:12:32 +00:00
if ( $idDepot <> 0 ) {
if ( $marque [ 'numeroMarque' ] == $idDepot ) {
2013-02-07 16:21:14 +00:00
//Recherche des fichiers
if ( file_exists ( DOC_WEB_LOCAL . " marques/ $idDepot .jpeg " ) &&
2010-11-29 16:12:32 +00:00
filesize ( DOC_WEB_LOCAL . " marques/ $idDepot .jpeg " ) > 42 )
$marques [ $i ][ 'UrlLien' ] = DOC_WEB_URL . " marques/ $idDepot .jpeg " ;
2012-12-17 16:35:12 +00:00
elseif ( file_exists ( DOC_WEB_LOCAL . " marques/ $idDepot .gif " ) &&
2010-11-29 16:12:32 +00:00
filesize ( DOC_WEB_LOCAL . " marques/ $idDepot .gif " ) > 42 )
$marques [ $i ][ 'UrlLien' ] = DOC_WEB_URL . " marques/ $idDepot .gif " ;
else
$marques [ $i ][ 'UrlLien' ] = '' ;
2013-02-07 16:21:14 +00:00
//Produits et Services
$resPS = $this -> iDb -> select ( 'marques_classes' , 'remarque' , " numeroMarque= $idDepot " );
if ( count ( $resPS ) > 0 ) {
$txt = array ();
foreach ( $resPS as $item ) {
$txt [] = $item [ 'remarque' ];
}
$marques [ $i ][ 'PS' ] = $txt ;
}
//Historique
$resHisto = $this -> iDb -> select ( 'marques_histo' , 'histo2' , " numeroMarque= $idDepot ORDER BY dat DESC " );
if ( count ( $resHisto ) > 0 ) {
$txt = array ();
foreach ( $resHisto as $item ) {
$txt [] = $item [ 'histo2' ];
}
$marques [ $i ][ 'histo' ] = $txt ;
}
return array ( $marques [ $i ]);
2010-11-29 16:12:32 +00:00
}
}
}
return $marques ;
}
return false ;
}
2012-12-17 16:35:12 +00:00
/** Récupère la liste des marques correspondantes aux paramètres
*
* @ param $numMarque int Numéro de la marque ou Néant / 0 si liste des marques
* @ param $raisonSociale string Raison Sociale de l ' entreprise ayant déposée la / les marque ( s )
* @ param $objet string Nom partiel ou complet de la / les marque ( s )
* @ param $dateDepot date Date de dépot / enregistrement de la marque au format SSAA - MM - JJ
* @ param $detail bool Par défaut false
*/
function getListeMarques ( $numMarque , $raisonSociale = '' , $objet = '' , $dateDepot = '' , $detail = false ) {
2011-06-10 10:08:21 +00:00
$nbTests = 0 ;
2012-12-17 16:35:12 +00:00
$base = array ( 'Fr' => 'on' ,
'Commu' => 'on' ,
'Inter' => 'on' );
2011-06-10 10:08:21 +00:00
while ( 1 ) {
2010-11-04 11:21:31 +00:00
$nbResultatsTot = false ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( $numMarque == false || $numMarque * 1 == 0 ) $numMarque = '' ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> url = 'http://bases-marques.inpi.fr/Typo3_INPI_Marques/marques_resultats_liste.html' ;
2012-12-17 16:35:12 +00:00
$post = array ( 'baseFr' => $base [ 'Fr' ], // Marques en vigueur : françaises
'baseCommu' => $base [ 'Commu' ], // Marques en vigueur : communautaires
'baseInter' => $base [ 'Inter' ], // Marques en vigueur : internationales
// 'limite'=>'on', // Limiter aux marques mises à jour il y a moins d'une semaine
'expiredMark' => 'on' , // Marques françaises non en vigueur
'objet' => urlencode ( $objet ), // Nom de la marque
'classification' => '' , // Classification des produits et services (01-34=Produits, 35-45=Services)
2010-11-04 11:21:31 +00:00
'deposant' => urlencode ( $raisonSociale ), // Nom du déposant
2012-12-17 16:35:12 +00:00
'numero' => $numMarque ,
'dtedepot' => $dateDepot , // SSAA-MM-JJ
2010-11-04 11:21:31 +00:00
'recherche' => 'recherche' );
$tDeb = microtime ( true );
$page = getUrl ( $this -> url , $this -> cookie , $post , $this -> referer , false , '' , '' , 21 , 3 );
$this -> referer = $this -> url ;
$duree = round ( microtime ( true ) - $tDeb , 3 );
$body = $page [ 'body' ];
2012-12-17 16:35:12 +00:00
// print_r($page);
// die();
2010-11-04 11:21:31 +00:00
if ( preg_match ( " /<div id= \" errors \" ><script>alert \ ('- Votre recherche a donné(.*)réponses \ . Seuls les(.*)premiers résultats seront affich/Uis " , $body , $matches )) {
$nbResultatsTot = trim ( $matches [ 1 ]);
$nbResultats = trim ( $matches [ 2 ]);
2012-12-17 16:35:12 +00:00
$nbTests ++ ;
if ( $dateDepot <> '' && $nbTests == 1 ) $base = array ( 'Fr' => 'on' , 'Commu' => '' , 'Inter' => '' );
//elseif ($dateDepot<>'' && $nbTests==2) $base=array('Fr'=>'','Commu'=>'on','Inter'=>'');
else
2011-06-10 10:08:21 +00:00
break ;
2012-12-17 16:35:12 +00:00
} elseif ( preg_match ( '/<div class="txtresultats">(?:.*)<p><strong>(.*)<\/strong> résultats trouvés pour votre requête/Uis' , $body , $matches )) {
// OK
2010-11-04 11:21:31 +00:00
$nbResultatsTot = trim ( $matches [ 1 ]);
$nbResultats = $nbResultatsTot ;
2011-06-10 10:08:21 +00:00
break ;
2010-11-04 11:21:31 +00:00
} elseif ( preg_match ( '/<div class="noresult">(?:.*)<p class="b">Vous n\'obtenez pas de résultats pour votre recherche(.*)<\/p>/Uis' , $body , $matches )) {
$nbResultatsTot = $nbResultats = 0 ;
2011-06-10 10:08:21 +00:00
break ;
} elseif ( preg_match ( '/<div id="errors"><script>alert(?:.*)Vous devez renseigner le nom de la marque(?:.*)<\/script><\/div>/Uis' , $body , $matches ) && $numMarque == '' ) {
echo " Pas de résultat pour cette recherche : " . EOL ;
print_r ( $post );
print_r ( $page );
$nbTests ++ ;
if ( $nbTests > 1 )
die ( " PAS de résultat pour cette recherche, essai n° $nbTests ! " . EOL );
2010-11-04 11:21:31 +00:00
} else {
2011-06-10 10:08:21 +00:00
$this -> partConnection ();
echo " Pas de résultat pour cette recherche : " . EOL ;
/*
2010-11-04 11:21:31 +00:00
print_r ( $post );
print_r ( $page );
2011-06-10 10:08:21 +00:00
die ( " PAS de résultat pour cette recherche ! " . EOL ); */
return false ;
}
// if ($nbResultatsTot!==false)
// break;
2011-09-22 13:00:18 +00:00
}
2010-11-04 11:21:31 +00:00
$nbPages = ceil ( $nbResultats / 10 );
echo " $nbResultatsTot résultats trouvés ( $nbResultats soit $nbPages pages) " . EOL ;
$pageCour = 1 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
while ( $pageCour <= $nbPages ) {
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$tabTmp = explode ( '<div class="resliste avecimage">' , $body );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//print_r($tabTmp);
foreach ( $tabTmp as $iTmp => $strMarques ) {
if ( $iTmp == 0 ) continue ;
$tabMarque = array ();
if ( preg_match ( '/<div class="numero">(\d+)<\/div>/Uis' , $strMarques , $matches )) {
$numeroTotal = trim ( $matches [ 1 ]);
$tabMarque [ 'numeroTotal' ] = $numeroTotal ;
}
2012-12-17 16:35:12 +00:00
if ( preg_match ( '/<div class="titre"><a href="Typo3_INPI_Marques\/marques_fiche_resultats\.html\?index=(\d+)" title="(.*)">(.*)<\/a><\/div>(?:.*)<div class="titre">(?:\s*)<a href="Typo3_INPI_Marques\/marques_fiche_resultats\.html\?index=(?:\d+)" title="Description">(.*)<\/a>/Uis' , $strMarques , $matches )) {
2010-11-04 11:21:31 +00:00
$numeroPage = trim ( $matches [ 1 ]);
$tabMarque [ 'numeroPage' ] = $numeroPage ;
2012-12-17 16:35:12 +00:00
$tabMarque [ 'typeMarque' ] = trim ( $matches [ 3 ]);
2010-11-04 11:21:31 +00:00
$tabMarque [ 'typeMarque' ] = trim ( $matches [ 2 ]);
2012-12-17 16:35:12 +00:00
$tabMarque [ 'nomMarque' ] = trim ( utf8_decode ( $matches [ 4 ]));
2010-11-04 11:21:31 +00:00
}
if ( preg_match ( '/<div class="type">(.*)<\/div>/Uis' , $strMarques , $matches ))
$tabMarque [ 'rayonMarque' ] = trim ( html_entity_decode ( utf8_decode ( $matches [ 1 ])));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( " /<img src='Typo3_INPI_Marques \ /getFirstThumb \ ?idObjet=(.*)' alt='(.*)' class='avimg' \ />/Uis " , $strMarques , $matches )) {
$tabMarque [ 'urlImage' ] = 'Typo3_INPI_Marques/getFirstThumb?idObjet=' . trim ( $matches [ 1 ]);
$tabMarque [ 'idMarque' ] = trim ( $matches [ 1 ]);
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<span class="intitule">Déposant(?:.*)<div class="donnee">(.*)<\/div>/Uis' , $strMarques , $matches ))
$tabMarque [ 'deposantMarque' ] = trim ( utf8_decode ( $matches [ 1 ]));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<span class="intitule">Numéro(?:.*)<span>(.*)<\/span>/Uis' , $strMarques , $matches ))
$tabMarque [ 'numeroMarque' ] = trim ( $matches [ 1 ]);
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<span class="intitule">Classe(?:.*)<div class="donnee">(.*)<\/div>/Uis' , $strMarques , $matches ))
$tabMarque [ 'classesMarque' ] = trim ( $matches [ 1 ]);
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( $detail ) {
randsleep ( TMIN , TMAX );
$url = $this -> urlRacine . 'Typo3_INPI_Marques/marques_fiche_resultats.html?index=' . $numeroPage ;
$tDeb = microtime ( true );
$page = getUrl ( $url , $this -> cookie , '' , $this -> referer , false , '' , '' , 21 , 3 );
$referer = $url ;
$duree = round ( microtime ( true ) - $tDeb , 3 );
$body = $page [ 'body' ];
//echo $body.EOL;
2012-12-17 16:35:12 +00:00
/* < div class = " txtresultats " >
< p >< strong > 303 </ strong > r & eacute ; sultats trouv & eacute ; s pour votre requ & ecirc ; te : < strong > date de d & eacute ; p & ocirc ; t : 1989 - 04 - 19 , dans les marques en
vigueur en France </ strong ></ p >
</ div >
& nbsp ;
< div class = " clear " ></ div >
<!-- DEBUT DES ONGLETS -->
< div class = " fiche " >
< ul >
< li class = " couleur " >< div > Notice compl & egrave ; te </ div ></ li >
< li class = " gris " >< div > Copie de la marque au BOPI non disponible </ div ></ li >
</ ul >
< div class = " cartouchecouleur blocblanc " >
< div class = " bas " >
< div class = " blanc " >
< div class = " ajout " >< a href = 'Typo3_INPI_Marques/ajoutListe?page=1&idObjet=1525144_201236_fmark' title = ' A
jouter & agrave ; ma liste '><img src=' fileadmin / www . inpi - marques . fr / templates / images / rouge / picto_ajouter_liste . gif ' alt=' Ajouter & agrave ; ma liste ' /> Ajouter & agrave ; ma l
iste </ a ></ div >
< div class = " images " >< p >< u >< strong > Marque française </ strong ></ u ></ p >< img src = ' Typo3_INPI_Marques / getImg ?
doc = 1525144_201236_ fmark & pos = 001 ' alt=' ' class=' null ' /></ div >
< ? xml version = " 1.0 " encoding = " UTF-8 " ?>
< div >< p style = " color:red; " >< strong > Marque française non en vigueur </ strong ></ p >< p >< strong > Marque </ strong >  : Â
AL DENTE </ p >< p >< strong > Classification de Nice </ strong > Â : Â
35 Â
; Â 38 Â
; Â 41 Â
</ p >< p >< strong > Produits et services </ strong ></ p >< p >< ul >< li >< span > Aide dans l 'exploitation ou la direction d' une entreprise industrielle ou c
ommerciale , service de publicité et de promotion se chargeant essentiellement de communication au public , de promotion des ventes , de déclarations ou d ' annonces par tou
s les moyens de diffusion et concernant toutes sortes de marchandises et de services , de distribution de prospectus et d 'échantillons;service de Presse et d' information
, communication radiophonique , téléphonique , télématique , télévisuelle , téléscription et transmission de messages permettant à une personne de converser avec une autre ,
de transmettre des messages d 'une personne à une autre ou de placer une personne en communication orale ou visuelle avec une autre; éducation, institution d' enseigneme
nt , éditions de livres et revues , abonnement et distribution de journaux , organisation de concours en matière d ' enseignement , et de jeu </ span ></ li ></ ul ></ p >< p >< strong > D
éposant </ strong >  : Â
GILIBERT Jean - Michel ,, Â 14 , rue Michel Chasles , 75012 PARIS , Â FR </ p >< p xmlns : xs = " http://www.w3.org/2001/XMLSchema " xmlns : java = " http://xml.apache.org/x
slt / java " xmlns:cal= " java . util . Calendar " xmlns:sf= " java . text . SimpleDateFormat " ><strong>Numéro</strong> : 1525144</p><p style= " color : red ; " ><strong>Statut</strong> : Marq
gist
rement ancienne loiÂ
Â
( BOPIÂ 1989 - 39 ) </ li ></ ul ></ p ></ div >
< p class = " right " >< a href = " Typo3_INPI_Marques/marques_erreur_contact.html?idObjet=1525144_201236_fmark " class = " lien " title = " Signalez
une erreur sur cette notice " >Signalez une erreur sur cette notice</a></p>
< div class = " clear " ></ div >
< div class = " copyright " > Source INPI </ div >
</ div >
</ div >
</ div >
</ div >
<!-- FIN DES ONGLETS -->*/
2010-11-04 11:21:31 +00:00
//die();
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<div><a target="_blank" href="Typo3_INPI_Marques\/getPdf\?idObjet=(.*)">Copie de la marque au BOPI<\/a><\/div>/Uis' , $body , $matches ))
$tabMarque [ 'idObjetPdf' ] = trim ( $matches [ 1 ]);
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//infoMarque
if ( preg_match ( '/<div><p style="color\:red;"><strong>(.*)<\/strong><\/p>/Uis' , $body , $matches ))
$tabMarque [ 'infoMarque' ] = trim ( utf8_decode ( $matches [ 1 ]));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( " /<div class= \" images \" ><p><u><strong>(.*)< \ /strong>< \ /u>< \ /p><img src='Typo3_INPI_Marques \ /getImg \ ?doc=(.*)' alt='(.*)' class='null' \ />< \ /div>/Uis " , $body , $matches )) {
$tabMarque [ 'periMarque' ] = trim ( utf8_decode ( $matches [ 1 ]));
$tabMarque [ 'idObjetImg' ] = trim ( $matches [ 2 ]);
if ( $tabMarque [ 'idObjetImg' ] <> '' ) {
$url = $this -> urlRacine . 'Typo3_INPI_Marques/getImg?doc=' . $tabMarque [ 'idObjetImg' ];
$tDeb = microtime ( true );
$page = getUrl ( $url , $this -> cookie , '' , $referer , false , '' , '' , 21 , 3 );
$duree = round ( microtime ( true ) - $tDeb , 3 );
if ( $page [ 'code' ] == 200 ) {
$ext = trim ( '.' . strtr ( preg_replace ( '/^image\//' , '' , preg_replace ( '/;.*/' , '' , $page [ 'header' ][ 'Content-Type' ])), array ( '?' => '' )));
//die("'".DOC_WEB_LOCAL.'marques/'.$tabMarque['numeroMarque'].$ext."'");
$fp =@ fopen ( DOC_WEB_LOCAL . 'marques/' . $tabMarque [ 'numeroMarque' ] . $ext , 'a' );
@ fwrite ( $fp , $page [ 'body' ]);
@ fclose ( $fp );
}
//die();
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<p><strong>Produits et services<\/strong><\/p>(.*)<\/ul><\/p>/Uis' , $body , $matches )) {
$tabClasses = array ();
if ( preg_match_all ( '/<li><span>(.*)<\/span><\/li>/Uis' , $matches [ 1 ], $matches2 )) {
foreach ( $matches2 [ 1 ] as $iC => $classe ) {
$tabClasses [ $iC ] = trim ( utf8_decode ( $classe ));
}
}
$tabMarque [ 'classes' ] = $tabClasses ;
2012-12-17 16:35:12 +00:00
}
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<p><strong>Déposant<\/strong>(.*)<\/p>/Uis' , $body , $matches )) {
$tabMarque [ 'detailDeposant' ] = trim ( html_entity_decode ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' )))));
if ( preg_match ( '/\(SIREN(.*)\)/Uis' , $tabMarque [ 'detailDeposant' ], $matches )) {
$tabMarque [ 'sirenDeposant' ] = trim ( $matches [ 1 ]);
$tabMarque [ 'sirenValide' ] = $this -> iInsee -> valideSiren ( $tabMarque [ 'sirenDeposant' ]);
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//adresseCorresp
if ( preg_match ( '/<p><strong>Adresse pour la correspondance<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'adresseCorresp' ] = trim ( html_entity_decode ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' )))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<p><strong>Mandataire<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'detailMandataire' ] = trim ( html_entity_decode ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' )))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<strong>Numéro<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'detailNumero' ] = trim ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' ))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<strong>Statut<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'detailStatut' ] = trim ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' ))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<strong>Date de dépô t \/ Enregistrement<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'dateDepot' ] = trim ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' ))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//dateExpir
if ( preg_match ( '/<strong>Date prévue pour l\'expiration<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'dateExpir' ] = trim ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' ))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<strong>Lieu de dépô t<\/strong>(.*)<\/p>/Uis' , $body , $matches ))
$tabMarque [ 'lieuDepot' ] = trim ( utf8_decode ( strtr ( $matches [ 1 ], array ( 'Â ' => ' ' , ':' => ' ' ))));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//pays
if ( preg_match ( '/<p><strong>Pays désignés<\/strong><\/p><p>(.*)<\/p>/Uis' , $body , $matches )) {
$tabPays = array ();
if ( preg_match_all ( '/<li>(.*)<\/li>/Uis' , $matches [ 1 ], $matches2 )) {
foreach ( $matches2 [ 1 ] as $iH => $histo )
$tabPays [] = trim ( utf8_decode ( str_replace ( 'Â ' , ' ' , $histo )));
}
$tabMarque [ 'pays' ] = $tabPays ;
}
//priorite
if ( preg_match ( '/<p><strong>Priorité<\/strong><\/p><p>(.*)<\/p>/Uis' , $body , $matches )) {
$tabPrio = array ();
if ( preg_match_all ( '/<li>(.*)<\/li>/Uis' , $matches [ 1 ], $matches2 )) {
foreach ( $matches2 [ 1 ] as $iH => $histo )
$tabPrio [] = trim ( utf8_decode ( str_replace ( 'Â ' , ' ' , $histo )));
}
$tabMarque [ 'priorite' ] = $tabPrio ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<strong>Historique<\/strong>(.*)<\/p><\/div>/Uis' , $body , $matches )) {
$tabHisto = array ();
if ( preg_match_all ( '/<li>(.*)<\/li>/Uis' , $matches [ 1 ], $matches2 )) {
foreach ( $matches2 [ 1 ] as $iH => $histo ) {
$tabTmp2 = explode ( " Â \n " , $histo );
$tabHisto [ $iH ] = array ( 'lib' => trim ( utf8_decode ( str_replace ( 'Â ' , ' ' , $tabTmp2 [ 0 ]))),
'dat' => trim ( utf8_decode ( str_replace ( 'Â ' , ' ' , $tabTmp2 [ 1 ]))),
'pub' => trim ( utf8_decode ( str_replace ( 'Â ' , ' ' , $tabTmp2 [ 2 ]))),
'histo' => trim ( $histo ),
'histo2' => trim ( utf8_decode ( $histo )),
);
}
}
$tabMarque [ 'historique' ] = $tabHisto ;
}
}
$dateInsert = date ( 'YmdHis' );
$tabInsert = $tabMarque ;
2012-12-17 16:35:12 +00:00
$idTxtUnique = trim ( strtoupper ( preg_replace ( '/[^a-z0-9]/i' , '' , $tabInsert [ 'detailDeposant' ])));
if ( $idTxtUnique <> '' )
$tabInsert [ 'idTxtUnique' ] = $idTxtUnique ;
2010-11-04 11:21:31 +00:00
unset ( $tabInsert [ 'numeroTotal' ]);
unset ( $tabInsert [ 'numeroPage' ]);
unset ( $tabInsert [ 'pays' ]);
unset ( $tabInsert [ 'priorite' ]);
unset ( $tabInsert [ 'classes' ]);
unset ( $tabInsert [ 'historique' ]);
$tabInsert [ 'dateInsert' ] = $dateInsert ;
2012-12-17 16:35:12 +00:00
//print_r($tabInsert);
//die();
2010-11-04 11:21:31 +00:00
$ret = $this -> iDb -> insert ( 'marques' , $tabInsert );
if ( ! $ret && mysql_errno () <> 1062 ) {
echo " Erreur 'marques' : " . mysql_error () . EOL ;
die ();
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// Insertion du détail des classes
foreach ( $tabMarque [ 'classes' ] as $i => $classe ) {
$tabInsert = array ( 'id' => $ret ,
'id2' => $i ,
'numeroMarque' => $tabMarque [ 'numeroMarque' ],
'remarque' => $classe ,
'dateInsert' => $dateInsert ,
);
$ret2 = $this -> iDb -> insert ( 'marques_classes' , $tabInsert );
if ( ! $ret2 && mysql_errno () <> 1062 ) {
echo " Erreur 'marques_classes' : " . mysql_error () . EOL ;
print_r ( $tabInsert );
print_r ( $tabMarque [ 'classes' ]);
2011-06-10 10:08:21 +00:00
die ( " Erreur 'marques_classes' : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
}
}
// Insertion des pays si besoin
foreach ( $tabMarque [ 'pays' ] as $i => $pays ) {
$tabInsert = array ( 'id' => $ret ,
'id2' => $i ,
'numeroMarque' => $tabMarque [ 'numeroMarque' ],
'pays' => $pays ,
'dateInsert' => $dateInsert ,
);
$ret2 = $this -> iDb -> insert ( 'marques_pays' , $tabInsert );
if ( ! $ret2 && mysql_errno () <> 1062 ) {
echo " Erreur 'marques_pays' : " . mysql_error () . EOL ;
print_r ( $tabInsert );
print_r ( $tabMarque [ 'pays' ]);
2011-06-10 10:08:21 +00:00
die ( " Erreur 'marques_pays' : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// Insertion des priorite
foreach ( $tabMarque [ 'priorite' ] as $i => $prio ) {
$tabInsert = array ( 'id' => $ret ,
'id2' => $i ,
'numeroMarque' => $tabMarque [ 'numeroMarque' ],
'priorite' => $prio ,
'dateInsert' => $dateInsert ,
);
$ret2 = $this -> iDb -> insert ( 'marques_priorite' , $tabInsert );
if ( ! $ret2 && mysql_errno () <> 1062 ) {
echo " Erreur 'marques_priorite' : " . mysql_error () . EOL ;
print_r ( $tabInsert );
print_r ( $tabMarque [ 'priorite' ]);
2011-06-10 10:08:21 +00:00
die ( " Erreur 'marques_priorite' : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
}
}
// Insertion de l'historique
foreach ( $tabMarque [ 'historique' ] as $i => $tabInsert ) {
$tabInsert [ 'id' ] = $ret ;
$tabInsert [ 'id2' ] = $i ;
$tabInsert [ 'numeroMarque' ] = $tabMarque [ 'numeroMarque' ];
$tabInsert [ 'dateInsert' ] = $dateInsert ;
$ret2 = $this -> iDb -> insert ( 'marques_histo' , $tabInsert );
if ( ! $ret2 && mysql_errno () <> 1062 ) {
echo " Erreur 'marques_histo' : " . mysql_error () . EOL ;
print_r ( $tabInsert );
print_r ( $tabMarque [ 'historique' ]);
2011-06-10 10:08:21 +00:00
die ( " Erreur 'marques_histo' : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
}
}
2012-12-17 16:35:12 +00:00
print_r ( $tabMarque );
2010-11-04 11:21:31 +00:00
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$pageCour ++ ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> url = " http://bases-marques.inpi.fr/Typo3_INPI_Marques/marques_resultats_liste.html?page= $pageCour " ;
$tDeb = microtime ( true );
$page = getUrl ( $this -> url , $this -> cookie , '' , $this -> referer , false , '' , '' , 21 , 3 );
$this -> referer = $this -> url ;
$duree = round ( microtime ( true ) - $tDeb , 3 );
$body = $page [ 'body' ];
}
return $nbResultatsTot ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
function getEditionPdf ( $type = 'marques' , $annee , $num = false ) {
//$type='marques';
//$type='brevets';
//$type='dessins';
//janvier 2005 pour les BOPI Brevets et depuis janvier 2006 pour les BOPI Marques et Dessins et modèles.
if ( $annee < 2005 ) $annee = 2005 ;
elseif ( $annee > date ( 'Y' )) $annee = date ( 'Y' );
if ( $annee == date ( 'Y' ) && $num >= date ( 'W' )) $num = date ( 'W' );
if ( $num > 52 || $num < 1 ) $num = false ;
if ( $num > 0 && $num < 10 ) $num = '0' . $num * 1 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$an = substr ( $annee , 0 , 2 );
$referer = " http://www.inpi.fr/fr/services-et-prestations/bases-de-donnees-gratuites/bulletins-officiels-de-la-pi-bopi.html " ;
2012-12-17 16:35:12 +00:00
$url = $nom = array ( 0 => '' );
2010-11-04 11:21:31 +00:00
switch ( $type ) {
case 'brevets' :
$url [ 1 ] = " http://www.inpi.fr/fileadmin/mediatheque/BOPI/brevets/ $annee /bopi $an " . $num . 'complet.pdf' ;
$nom [ 1 ] = 'bopi_' . $type . '_' . $annee . '-' . $num . '.pdf' ;
break ;
case 'marques' :
$url [ 1 ] = " http://www.inpi.fr/fileadmin/mediatheque/BOPI/marques/ $annee / $annee - " . $num . 'v1.pdf' ;
$url [ 2 ] = " http://www.inpi.fr/fileadmin/mediatheque/BOPI/marques/ $annee / $annee - " . $num . 'v2.pdf' ;
$nom [ 1 ] = 'bopi_' . $type . '_' . $annee . '-' . $num . 'v1.pdf' ;
$nom [ 2 ] = 'bopi_' . $type . '_' . $annee . '-' . $num . 'v2.pdf' ;
break ;
case 'dessins' :
$url [ 1 ] = " http://www.inpi.fr/fileadmin/mediatheque/BOPI/dessins_et_modeles/ $annee /dm $an " . $num . '.pdf' ;
$nom [ 1 ] = 'bopi_' . $type . '_' . $annee . '-' . $num . '.pdf' ;
break ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$tDeb = microtime ( true );
for ( $iEd = 1 ; $iEd < 3 ; $iEd ++ ) {
if ( $iEd > 1 && $type <> 'marques' ) break ;
$tabPdf = getPdfInfo ( DOC_WEB_LOCAL . 'marques/' . $nom [ $iEd ]);
if ( ! $tabPdf ) {
$page = getUrl ( $url [ $iEd ], '' , '' , $referer , false , '' , '' , 300 , 2 );
2012-12-17 16:35:12 +00:00
if ( $page [ 'code' ] == 200 ) {
2010-11-04 11:21:31 +00:00
$duree = round ( microtime ( true ) - $tDeb , 3 );
$body = $page [ 'body' ];
$fp =@ fopen ( DOC_WEB_LOCAL . 'marques/' . $nom [ $iEd ], 'a' );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
$tabPdf = getPdfInfo ( DOC_WEB_LOCAL . 'marques/' . $nom [ $iEd ]);
randsleep ( TMIN , TMAX );
}
}
if ( $tabPdf ) {
$fichierTxt = DOC_WEB_LOCAL . 'marques/' . str_replace ( '.pdf' , '.txt' , $nom [ $iEd ]);
2012-12-17 16:35:12 +00:00
@ exec ( 'pdftotext ' . DOC_WEB_LOCAL . 'marques/' . $nom [ $iEd ] . ' ' . $fichierTxt );
2010-11-04 11:21:31 +00:00
$strBopi = file_get_contents ( $fichierTxt );
2012-12-17 16:35:12 +00:00
if ( MODE_VERBOSE ) {
$sizeKo = round ( strlen ( $strBopi ) / 1024 , 1 );
echo date ( 'Y/m/d - H:i:s' ) . " - Conversion du fichier ' " . $nom [ $iEd ] . " en TXT ( $sizeKo Ko) " . EOL ;
}
2010-11-04 11:21:31 +00:00
$nbMarques = 0 ;
$tabMarques = array ();
2012-12-17 16:35:12 +00:00
if ( preg_match_all ( '/N(?:°|o) National \: ([0-9\s]{6,15})Dépô t du \: ((?:[0-9]{1,2}|1er)(?:\D+)(?:\d\d\d\d))(.*)/Uim' , $strBopi , $matches )) {
2010-11-04 11:21:31 +00:00
//print_r($matches);
2012-12-17 16:35:12 +00:00
//die();
2010-11-04 11:21:31 +00:00
foreach ( $matches [ 1 ] as $i => $numMarque ) {
$numMarqueTxt = strtr ( $numMarque , array ( " \n " => '' , " \r " => '' ));
$numMarque = str_replace ( ' ' , '' , $numMarqueTxt );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$dateDepot = WDate :: dateT ( 'dMY' , 'Ymd' , strtr ( str_replace ( 'Dépôt du : ' , '' , utf8_decode ( $matches [ 2 ][ $i ])), array ( " \n " => '' , " \r " => '' , ' ' => '' )));
echo $nom [ $iEd ] . " - $i , Marque numéro $numMarque du $dateDepot " . EOL ;
$tabMarques [ $nbMarques ] = array ( 'nomPdf' => $nom [ $iEd ],
'idMarquePdf' => $nbMarques ,
'numMarque' => $numMarque ,
'numMarqueTxt' => $numMarqueTxt ,
'anneeMarque' => substr ( $numMarqueTxt , 0 , 2 ),
'numeroMarque' => str_replace ( ' ' , '' , substr ( $numMarqueTxt , 2 )),
'dateDepot' => $dateDepot ,
'dateInsert' => date ( 'YmdHis' ),
);
$nbMarques ++ ;
}
2012-12-17 16:35:12 +00:00
unlink ( $fichierTxt );
} else {
2010-11-04 11:21:31 +00:00
$nbMarques = 'NULL' ;
2012-12-17 16:35:12 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Erreur : Impossible d'extraire les marques du fichier ' " . $nom [ $iEd ] . " ! " . EOL ;
if ( MODE_VERBOSE ) die ();
}
2010-11-04 11:21:31 +00:00
$tabInsert = array ( 'nomPdf' => $nom [ $iEd ],
'datePdf' => @ date ( 'YmdHis' , strtotime ( $page [ 'header' ][ 'Last-Modified' ])),
'codeHttp' => $page [ 'code' ],
'pdfSizeWeb' => @ $page [ 'header' ][ 'Content-Length' ],
'pdfSize' => $tabPdf [ 'pdfSize' ],
'pdfVer' => $tabPdf [ 'version' ],
'pdfPage' => $tabPdf [ 'nbPages' ],
'nbMarques' => $nbMarques ,
'dateInsert' => date ( 'YmdHis' ),
);
$ret = $this -> iDb -> insert ( 'infos_bopi' , $tabInsert );
2011-06-10 10:08:21 +00:00
if ( ! $ret && mysql_errno () <> 1062 ) die ( " Erreur 'infos_bopi' 1 : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
foreach ( $tabMarques as $i => $tabInsert ) {
$ret = $this -> iDb -> insert ( 'infos_bopi_marques' , $tabInsert );
2011-06-10 10:08:21 +00:00
if ( ! $ret && mysql_errno () <> 1062 ) die ( " Erreur 'infos_bopi' 1 : " . mysql_error () . EOL );
2010-11-04 11:21:31 +00:00
}
}
}
return true ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
function getInfosDisponbiles ( $siren ) {
$this -> siren = $siren ;
$this -> partConnection ();
return $this -> partVitrine ( true );
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
function listBilans ( $siren ) {
$tabRet = array ();
$tab = $this -> getInfosDisponbiles ( $siren );
2012-12-17 16:35:12 +00:00
if ( $tab [ 'erreur' ] == '' ) {
2010-11-04 11:21:31 +00:00
$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 ) {
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
}
foreach ( $tabB as $num => $millesime ) {
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
}
}
return $tabRet ;
}
function getBilan ( $refBilan ) {
return $this -> partBilan ( $refBilan );
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
function getIdentite ( $siren ) {
$this -> siren = $siren ;
return $this -> partIdentite ();
}
private function partConnection () {
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$url = 'http://bases-marques.inpi.fr/Typo3_INPI_Marques/marques_recherche_numero.html' ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$tDeb = microtime ( true );
$page = getUrl ( $url , $this -> cookie , '' , '' , false , '' , '' , 21 );
$duree = round ( microtime ( true ) - $tDeb , 3 );
$body = $page [ 'body' ];
$this -> referer = $url ;
$this -> cookie = $page [ 'header' ][ 'Set-Cookie' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
return true ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( ! $this -> wrncsrv2 || time () > $this -> timeOut ) {
$this -> timeOut = time () + 900 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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)<br/>".EOL;
$fp = fopen ( './euridile_connexion1.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
if ( preg_match ( '/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)">/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__ );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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 ( '/<form method="POST" name="abonnement" ACTION="(.*)" /i' , $this -> 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__ );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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)<br/>".EOL;
$fp = fopen ( './euridile_connexion3.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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__ );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> curPage = 'recherche' ;
} //else echo date('Y/m/d - H:i:s') ." - Deja connecte !<br/>".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__ );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> curPage = 'recherche' ;
$fp = fopen ( './euridile_recherche.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
private function partVitrine ( $listeDocuments = false ) {
if ( $this -> curPage <> 'recherche' )
$this -> partInitRecherche ();
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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 )) {
2012-12-17 16:35:12 +00:00
/** On vérifie qu 'aucune annonce n' a été publié depuis au bodacc
2010-11-04 11:21:31 +00:00
**
$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' ] = '' ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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 )<br/> " . 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 );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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 )<br/> " . EOL ;
return $tabRet ;
}
echo date ( 'Y/m/d - H:i:s' ) . " - Vitrine : Après recherche = $this->url (Code retour = $this->codeRetour )<br/> " . EOL ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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 );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - Vitrine : Frame = $this->url (Code retour = $this->codeRetour )<br/> " . EOL ;
$this -> curPage = 'vitrine' ;
$tabRet [ 'rcs' ] =@ getTextInHtml ( $this -> body , ' <TR><TD WIDTH="60%"><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2>RCS : <B>' , '<B>' , '</B>' );
if (( $tabRet [ 'rcs' ] * 1 ) <> ( $tabRet [ 'siren' ] * 1 )) {
$tabRet [ 'erreur' ] = 'Siren inconnu' ;
return $tabRet ;
}
$tabRet [ 'nom' ] =@ getTextInHtml ( $this -> body , ' <TR><TD WIDTH="60%"><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2><B>' , '<B>' , '</B>' );
$tabRet [ 'adresse1' ] =@ getTextInHtml ( $this -> body , '<TR><TD WIDTH="100%" COLSPAN="2"> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2 BGCOLOR=#FFF0D0> <TR><TD><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2><B>' , '<B>' , '</B>' );
$strTmp =@ getTextInHtml ( $this -> body , '</B></FONT> </TD></TR> <TR><TD><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2><B>' , '<B>' , '</B>' );
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 " . '<TR><TD WIDTH="100%" COLSPAN="2"><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2><B>' , '<B>' , '</B>' );
$strTmp =@ getTextInHtml ( $this -> body , '</FONT></TD></TR><TR><TD WIDTH="100%" COLSPAN="2"><FONT COLOR=#100070 FACE="ARIAL,HELVETICA" SIZE=2><B>' , '<B>' , '</B>' );
$tabTmp = explode ( ' - ' , $strTmp );
$tabRet [ 'naf_code' ] = $tabTmp [ 0 ];
$tabRet [ 'naf_lib' ] = $tabTmp [ 1 ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$matches = explode ( " <A HREF= \" javascript:OpenHtmlWindow('paie_abonnes_livraison_directe_informations.ow','Compte_Annuel',' " , $this -> 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 ] . '"' );
2012-12-17 16:35:12 +00:00
}
2010-11-04 11:21:31 +00:00
$tabBilan [ $typeBilan ][ $dateBilan ] = $idBilan ;
}
$tabRet [ 'bilans' ] = $tabBilan ;
/* if ( $listeDocuments ) {
2012-12-17 16:35:12 +00:00
$this -> partVitrineDocuments ();
2010-11-04 11:21:31 +00:00
}
2012-12-17 16:35:12 +00:00
*/
2010-11-04 11:21:31 +00:00
$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 ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
private function partVitrineDocuments () {
if ( $this -> curPage = 'vitrine' )
$this -> partVitrine ();
$tabRet = $tabBilan = array ();
$tabRet [ 'siren' ] = $this -> siren ;
$tabRet [ 'erreur' ] = '' ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
preg_match ( '/<OPTION VALUE="' . $this -> siren . '\|(.*)\|IMM\|COUR">/i' , $this -> body , $matches );
$tabDossier = array ( 'libelle' => 'Dossier d\'immatriculation principale' ,
'idBalise' => 'IMMcombo' ,
'idLien' => str_replace ( '<OPTION VALUE="' , '' , str_replace ( '">' , '' , $matches [ 0 ])));
$body = preg_replace ( '/(.*)<\/TABLE> +<\/TD><\/TR><TR><TD WIDTH=70% ALIGN=LEFT><FONT SIZE=2 FACE=ARIAL>/i' , '' , str_replace ( " \r " , '' , str_replace ( " \n " , '' , $this -> body )));
$tabTmp = explode ( '<TD ALIGN=RIGHT WIDTH=30% VALIGN=TOP><SELECT NAME=ACTcombo' , $body );
$tabActes = array ();
foreach ( $tabTmp as $i => $acte ) {
if ( ! isset ( $tabTmp [ $i + 1 ])) {
$tabTmp2 = explode ( '</TD></TR></TABLE>' , $acte );
$acte = $tabTmp2 [ 0 ];
}
if ( $i <> 0 ) {
$tabTmp2 = explode ( '<TR><TD WIDTH=70% ALIGN=LEFT><FONT SIZE=2 FACE=ARIAL>' , $acte );
if ( preg_match ( '/<OPTION VALUE="' . $this -> siren . '\|(.*)\|ACT\|(.*)\|(.*)\|(.*)\|TELE">/i' , $tabTmp2 [ 0 ], $matches ))
$vecteur = 'TELE' ;
elseif ( preg_match ( '/<OPTION VALUE="' . $this -> siren . '\|(.*)\|ACT\|(.*)\|(.*)\|(.*)\|COUR">/i' , $tabTmp2 [ 0 ], $matches ))
$vecteur = 'COUR' ;
if ( $i <> 1 ) {
$tabTmp2 = explode ( '<TR><TD WIDTH=70% ALIGN=LEFT><FONT SIZE=2 FACE=ARIAL>' , $tabTmp [ $i - 1 ]);
$strLibPre = $tabTmp2 [ 1 ];
} else $strLibPre = $tabTmp [ 0 ];
$tabActes [ $i - 1 ] = array ( 'vecteur' => $vecteur ,
'libelle' => trim ( strip_tags ( preg_replace ( '/(.*)<BR>/i' , '' , $strLibPre ))),
'idBalise' => 'ACTcombo' . ( $i - 1 ),
'date' => $matches [ 2 ],
'nbPages' => $matches [ 4 ],
'numero' => $matches [ 3 ],
'idLien' => str_replace ( '<OPTION VALUE="' , '' , str_replace ( '">' , '' , $matches [ 0 ])));
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Recherche des comptes déposés **/
$tabTmp = preg_split ( '/<SELECT NAME=(TT|BL|CM|GS)FAM(\d)/i' , $body );
$tabCpt = array ();
$nb = count ( $tabTmp );
2012-12-17 16:35:12 +00:00
for ( $i = 1 ; $i < $nb ; $i ++ ) {
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<OPTION VALUE="' . $this -> siren . '\|(.*)\|BIL\|(.*)\|(.*)\|(TT|BL|CM|GS)\|(.*)\|(.*)\|TELE">/i' , $tabTmp [ $i ], $matches ))
$vecteur = 'TELE' ;
elseif ( preg_match ( '/<OPTION VALUE="' . $this -> siren . '\|(.*)\|BIL\|(.*)\|(.*)\|(TT|BL|CM|GS)\|(.*)\|(.*)\|COUR">/i' , $tabTmp [ $i ], $matches ))
$vecteur = 'COUR' ;
switch ( $matches [ 3 ]) {
case 'SC' : $typeBilan = 'N' ; $bil = 'Bilan réel normal' ; break ; // Réel normal
case 'SS' : $typeBilan = 'S' ; $bil = 'Bilan réel simplifié' ; break ; // Réel simplifié
case 'CC' : $typeBilan = 'C' ; $bil = 'Bilan consolidé' ; break ; // CONSOLIDE
case 'SA' : $typeBilan = 'A' ; $bil = 'Bilan d\'assurance' ; break ; // Assurance
case 'SB' : $typeBilan = 'B' ; $bil = 'Bilan de banque' ; break ; // Banque
default : $this -> logEuridileError ( 'Type de bilan non pris en charge : "' . $tabTmp [ 2 ] . '"' );
}
switch ( $matches [ 4 ]) {
case 'TT' : $lib = 'Comptes annuels complets' ; break ;
case 'BL' : $lib = 'Bilan et compte de résultat' ; break ;
case 'CM' : $lib = 'Rapport des CAC' ; break ;
case 'GS' : $lib = 'Rapport de gestion' ; break ;
default : $this -> logEuridileError ( 'Type d\'annexe de compte inconnu' ); break ;
}
$tabCpt [ $i - 1 ] = array ( 'vecteur' => $vecteur ,
'libelle' => $bil . ' - ' . $lib ,
'idBalise' => $matches [ 4 ] . 'FAM' . $i ,
'typeBilan' => $typeBilan ,
'date' => $matches [ 2 ],
'nbPages' => $matches [ 5 ],
'numero' => $matches [ 6 ],
'idLien' => str_replace ( '<OPTION VALUE="' , '' , str_replace ( '">' , '' , $matches [ 0 ])));
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** @ todo gestion des commandes :
< FORM NAME = FORMADDCART ACTION = " ../weur2/cmd_panier_informations_numerises_gestion.ow " METHOD = POST TARGET = _top >
< INPUT TYPE = " HIDDEN " NAME = " dejatraite " value = " " >
2012-12-17 16:35:12 +00:00
< INPUT TYPE = IMAGE SRC = images / boutons / valider . gif ALT = " Valider " BORDER = 0 >
2010-11-04 11:21:31 +00:00
< INPUT TYPE = " HIDDEN " NAME = " WRNCSRV2 " VALUE = " 171932431532858 " >
< SELECT NAME = ACTcombo0 > // 1 select par acte de depot de 0 à N !!!
< SELECT NAME = IMMcombo > // Dossier immatriculiation principal
// Comptes Réel Normal
< SELECT NAME = TTFAM1 // Année1 : Comptes Annuels complet
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|TT|22|33319263105122AN9201:33319263105122BL9201:33319263105122CM9201:33319263105122GS9201|TELE " >
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|TT|22|33319263105122AN9201:33319263105122BL9201:33319263105122CM9201:33319263105122GS9201|COUR " >
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
< SELECT NAME = BLFAM1 // Année 1 : Bilan, Compte de résultat
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|BL|4|33319263105122BL9201|TELE " >
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|BL|4|33319263105122BL9201|COUR " >
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
< SELECT NAME = CMFAM1 // Année 1 : Rapport des CAC
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|CM|2|33319263105122CM9201|TELE " >
< SELECT NAME = GSFAM1 // Année 1 : Rapport de Gestion
< OPTION VALUE = " 333192631|BILANS SERVICE|BIL|31/12/2005|SC|GS|4|33319263105122GS9201|TELE " >
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// Comptes consolidés
2012-12-17 16:35:12 +00:00
< select name = " TTFAM6 "
2010-11-04 11:21:31 +00:00
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|TT|159|55210055404122AN7501:55210055404122BL7501:55210055404122CM7501:55210055404122GS7501|TELE " >
< select name = " BLFAM6 "
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|BL|3|55210055404122BL7501|TELE " >
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|BL|3|55210055404122BL7501|COUR " > Courrier
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|BL|159|55210055404122AN7501:55210055404122BL7501:55210055404122CM7501:55210055404122GS7501|INCLUS " >
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
< select name = " CMFAM6 "
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|CM|3|55210055404122CM7501|TELE " >
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|CM|3|55210055404122CM7501|COUR " >
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|CM|159|55210055404122AN7501:55210055404122BL7501:55210055404122CM7501:55210055404122GS7501|INCLUS " >
< select name = " GSFAM6 "
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|GS|108|55210055404122GS7501|TELE " >
< option value = " 552100554|PEUGEOT SA|BIL|31/12/2004|SC|GS|159|55210055404122AN7501:55210055404122BL7501:55210055404122CM7501:55210055404122GS7501|INCLUS " >
**/
$tabRet = array ( 'actes' => $tabActes ,
'comptes' => $tabCpt ,
'dossier' => $tabDossier );
print_r ( $tabRet );
die ();
$fp = fopen ( './euridile_vitrineDocs.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
//echo date('Y/m/d - H:i:s') ." - Vitrine Documents = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
die ();
return $tabRet ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/*private*/ function partChercheDirigeant ( $nomPrenom ) {
if ( $this -> curPage <> 'recherche' )
$this -> partInitRecherche ();
$tabRet = $tabBilan = array ();
//$tabRet['siren']=$this->siren;
$tabRet [ 'erreur' ] = '' ;
$postData = array ( 'codcom_srch' => '' ,
'entrep_srch' => urlencode ( $nomPrenom ),
'contient' => 'contient' , // contient=Contient, debute=Débute par, contientque=ne contient que les termes saisis
'phoneme' => 'non' , // non=A l'identique, oui=approchant
'adress_srch' => '' ,
'codpos_srch' => '' ,
'commune_srch' => '' ,
'x' => rand ( 0 , 72 ),
'y' => rand ( 0 , 20 ),
'WRNCSRV2' => $this -> wrncsrv2 );
$page = getUrl ( $this -> url , '' , $postData , $this -> referer , false , 'www.euridile.com' );
//echo date('Y/m/d - H:i:s') ." - Recherche Dirigeant = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
$this -> referer = $this -> url ;
$this -> body = $page [ 'body' ];
$this -> codeRetour = $page [ 'code' ];
$this -> header = $page [ 'header' ];
$this -> url = $this -> urlRacine . '/weur2/iden_req_multibase_deno.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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$fp = fopen ( './euridile_recherche2.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
/** Entreprises trouvées **/
//../weur2/iden_selection_bases.ow?WRNCSRV2=1711245812917368&infosBase=EURENT|densig|entreprise(s)|234 TARGET=_top>Entreprise(s)
if ( preg_match ( '/\/weur2\/iden_selection_bases\.ow\?WRNCSRV2=' . $this -> wrncsrv2 . '&infosBase=EURENT\|densig\|entreprise\(s\)\|(.*) TARGET=_top>Ent/i' , $this -> body , $matches )) {
$fctEntUrl = preg_replace ( '/ (.*)/' , '' , $matches [ 0 ]);
$fctEntNb = $matches [ 1 ];
}
/** Fonctions de direction trouvées **/
if ( preg_match ( '/\/weur2\/iden_selection_bases\.ow\?WRNCSRV2=' . $this -> wrncsrv2 . '&infosBase=EURDIR\|dirig\|dirigeant\(s\)\|(.*) TARGET=_top>Dir/i' , $this -> body , $matches )) {
$fctDirUrl = preg_replace ( '/ (.*)/' , '' , $matches [ 0 ]);
$fctDirNb = $matches [ 1 ];
}
/** Fonctions d'administration trouvée **/
//../weur2/iden_selection_bases.ow?WRNCSRV2=1711245812917368&infosBase=EURDIR|admin|administrateur(s)|44 TARGET=_top>Administrateur(s)
if ( preg_match ( '/\/weur2\/iden_selection_bases\.ow\?WRNCSRV2=' . $this -> wrncsrv2 . '&infosBase=EURDIR\|admin\|administrateur\(s\)\|(.*) TARGET=_top>Adm/i' , $this -> body , $matches )) {
$fctAdmUrl = preg_replace ( '/ (.*)/' , '' , $matches [ 0 ]);
$fctAdmNb = $matches [ 1 ];
2012-12-17 16:35:12 +00:00
}
2010-11-04 11:21:31 +00:00
//echo date('Y/m/d - H:i:s') ." - Résultat : $fctDirNb dirigeant(s), $fctAdmNb administrateur(s) et $fctEntNb entreprise(s)".EOL;
//echo date('Y/m/d - H:i:s') ." - URL : $fctDirUrl".EOL;
$this -> url = $this -> urlRacine . $fctDirUrl ;
$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' ];
$fp = fopen ( './euridile_recherche3.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/\/weur2\/iden_affinage_critere\.ow/i' , $this -> body )) {
/** Visualisation du formulaire d'affinage **/
$this -> url = $this -> urlRacine . '/weur2/iden_affinage_critere.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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** On outrepasse l'affinage **/
$this -> url = $this -> urlRacine . '/weur2/iden_req_multibase_affinage_critere.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' ];
/*
$fp = fopen ( './euridile_recherche_affinage.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
die ();
$tabRet [ 'erreur' ] = 'Trop de choix possibles' ;
$this -> curPage = 'autre' ;
echo date ( 'Y/m/d - H:i:s' ) . " - Multipropositions, trop de choix possibles = $this->url (Code retour = $this->codeRetour )<br/> " . EOL ;
return $tabRet ;
*/
} elseif ( ! preg_match ( '/\/weur2\/iden_req_multibase_liste\.ow/i' , $this -> body )) {
$tabRet [ 'erreur' ] = 'Erreur inconnue' ;
$this -> curPage = 'autre' ;
//echo date('Y/m/d - H:i:s') ." - Page de Multipropositions erreur inconnue = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
return $tabRet ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Liste des entreprises dirigées */
$this -> url = $this -> urlRacine . '/weur2/iden_req_multibase_liste.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' ];
$fp = fopen ( './euridile_recherche4.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$body = str_replace ( " \r " , '' , str_replace ( " \n " , '' , $this -> body ));
$tabTmp = explode ( '<TABLE BORDER=0><TR><TD><FONT SIZE=2 FACE=ARIAL><A HREF="../weur2/ff_page_general.ow?WRNCSRV2=' . $this -> wrncsrv2 . '&g_InfoChoix=IDEN_VI&rcs=' , $body );
array_shift ( $tabTmp );
$tabEntrep = array ();
for ( $i = 0 , $nbPages = 0 ; $i < $fctDirNb ; $i ++ ) {
if ( $i % 10 == 0 ) {
$nbPages ++ ;
$this -> url = $this -> urlRacine . '/weur2/iden_req_superindex_liste_suite.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' ];
$body = str_replace ( " \r " , '' , str_replace ( " \n " , '' , $this -> body ));
$tabTmp2 = explode ( '<TABLE BORDER=0><TR><TD><FONT SIZE=2 FACE=ARIAL><A HREF="../weur2/ff_page_general.ow?WRNCSRV2=' . $this -> wrncsrv2 . '&g_InfoChoix=IDEN_VI&rcs=' , $body );
array_shift ( $tabTmp2 );
for ( $j = 0 ; isset ( $tabTmp2 [ $j ]); $j ++ )
$tabTmp [( $nbPages * 10 ) + $j ] = $tabTmp2 [ $j ];
}
$tabTmp2 = explode ( '</TD></TR>' , $tabTmp [ $i ]);
$siren = substr ( $tabTmp2 [ 0 ], 0 , 9 );
$raisonSoc = trim ( preg_replace ( '/(.*)<B>/i' , '' , preg_replace ( '/<\/B>(.*)/i' , '' , $tabTmp2 [ 0 ])));
$cpVille = trim ( strip_tags ( $tabTmp2 [ 1 ]));
$cp = substr ( $cpVille , 0 , 5 );
$ville = substr ( $cpVille , 6 , strlen ( $cpVille ) - 6 );
$tabTmp3 = explode ( ' : ' , trim ( strip_tags ( $tabTmp2 [ 2 ])));
$fonction = $tabTmp3 [ 0 ];
$nomPrenom = $tabTmp3 [ 1 ];
$tabTmp3 = explode ( ' - ' , trim ( strip_tags ( $tabTmp2 [ 3 ])));
$nafCod = $tabTmp3 [ 0 ];
$nafLib = $tabTmp3 [ 1 ];
$tabEntrep [] = array ( 'siren' => $siren ,
'raisonSociale' => $raisonSoc ,
'cp' => $cp ,
'ville' => $ville ,
'fonction' => $fonction ,
'nomPrenom' => $nomPrenom ,
'naf' => $nafCod ,
'nafLib' => $nafLib );
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
print_r ( $tabEntrep );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> curPage = 'autre' ;
return ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> url = $this -> urlRacine . '/weur2/iden_visu_vitrine.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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
//echo date('Y/m/d - H:i:s') ." - Vitrine : Frame = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
$this -> curPage = 'vitrine' ;
$matches = explode ( " <A HREF= \" javascript:OpenHtmlWindow('paie_abonnes_livraison_directe_informations.ow','Compte_Annuel',' " , $this -> 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 ] . '"' );
2012-12-17 16:35:12 +00:00
}
2010-11-04 11:21:31 +00:00
$tabBilan [ $typeBilan ][ $dateBilan ] = $idBilan ;
}
$tabRet [ 'bilans' ] = $tabBilan ;
$fp = fopen ( './euridile_vitrine.log' , 'w' );
fwrite ( $fp , print_r ( $page , true ));
fclose ( $fp );
return $tabRet ;
}
private function partListeActes () {
//http://www.euridile.com/weur2/ff_page_general.ow?WRNCSRV2=1717224430910945&g_InfoChoix=CMD_IN&first=actes&filtre_document=no&g_Onglet=info
// 2 cadres classiques +
//weur2/cmd_panier_informations_numerises.ow?WRNCSRV2=1717224430910945
}
private function partIdentite () {
if ( $this -> curPage <> 'vitrine' )
$this -> partVitrine ();
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$iDb = new WDB ( 'jo' );
$ret = $iDb -> select ( 'rncs_entrep' ,
'siren, rcs, nom, adresse1, adresse2, adresse3, cp, ville, naiss_date, naiss_lieu, sexe, enseigne, sigle, ' .
'fj_lib, naf_code, naf_lib, date_crea, date_imma, greffe, num_gestion, capital_mnt, capital_dev, nationalite, ' .
'nb_etab, indRadiation, date_radiation, indProcol, dateUpdate, procedures, dirigeants, etablissements' ,
" siren= $this->siren ORDER BY dateUpdate DESC LIMIT 0,1 " , false , MYSQL_ASSOC );
if ( count ( $ret )) {
2012-12-17 16:35:12 +00:00
/** On vérifie qu 'aucune annonce n' a été publié depuis au bodacc
2010-11-04 11:21:31 +00:00
**/
$tabRet = $ret [ 0 ];
$ret = $iDb -> select ( 'bodacc_detail' , 'count(*)' ,
" siren= $this->siren AND Bodacc_Date_Parution>=' " . $tabRet [ 'dateUpdate' ] . " ' " );
if ( $ret [ 0 ][ 0 ] == 0 ) {
$tabRet [ 'procedures' ] = unserialize ( $tabRet [ 'procedures' ]);
$tabRet [ 'dirigeants' ] = unserialize ( $tabRet [ 'dirigeants' ]);
$tabRet [ 'etablissements' ] = unserialize ( $tabRet [ 'etablissements' ]);
return $tabRet ;
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$url = $this -> urlRacine . '/' . $this -> weur . '/paie_abonnes_livraison_directe_informations.ow?flag_type_acces_direct_infos=FIC&WRNCSRV2=' . $this -> wrncsrv2 ;
$page = getUrl ( $url , '' , '' , $this -> referer , false , 'www.euridile.com' );
$this -> body = $page [ 'body' ];
$this -> codeRetour = $page [ 'code' ];
$this -> header = $page [ 'header' ];
//echo date('Y/m/d - H:i:s') ." - Fiche d'identité = $url (Code retour = $this->codeRetour)<br/>".EOL;
//$this->curPage='vitrine';
$tabRet = array ();
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/**@ todo Traiter le cas données provisoires :
< TR >< TD bgcolor = '#fff0d0' >< FONT COLOR = #100070 FACE=ARIAL SIZE=2><B><!-- Données provisoires --> En cours d'immatriculation, données provisoires</B></FONT></TD></TR><TR><TD bgcolor=#fff0d0><FONT COLOR=#100070 FACE=ARIAL SIZE=2>Nombre d'établissements : <FONT COLOR=#100070 FACE=ARIAL SIZE=2><B></B></TD></TR>
</ TABLE >
*/
// Identité
$tabRet [ 'siren' ] = $this -> siren ;
$tabRet [ 'codeRetour' ] = $this -> codeRetour ;
$tabRet [ 'rcs' ] =@ getTextInHtml ( $this -> body , 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : ' , '<b>' , '</b>' );
$strTmp =@ getTextInHtml ( $this -> body , 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : <b>' , 'FACE="ARIAL,HELVETICA" SIZE=2><b>' , '<img src=\'images/rouge.gif\'' );
$tabTmp = explode ( '</TD>' , $strTmp );
$tabRet [ 'nom' ] = strip_tags ( $tabTmp [ 0 ]);
// ... adresse
for ( $i = 1 ; $i < 5 ; $i ++ ) {
2012-12-17 16:35:12 +00:00
if ( strpos ( $tabTmp [ $i ], 'Nom commercial - Enseigne :' ) === false &&
2010-11-04 11:21:31 +00:00
strpos ( $tabTmp [ $i ], 'Sigle :' ) === false ) {
$ligne = trim ( strip_tags ( $tabTmp [ $i ]));
if ( preg_match ( " /^([0-9] { 5,5})([ \ D]*)/i " , $ligne , $matches )) {
$tabRet [ 'cp' ] = trim ( $matches [ 1 ]);
$tabRet [ 'ville' ] = trim ( $matches [ 2 ]);
break ;
} else $tabRet [ 'adresse' . $i ] = $ligne ;
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$pp_nais = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Date et lieu de naissance :' , '<B>' , '</B>' )));
$tabTmp = explode ( ' à ' , $pp_nais );
$tabRet [ 'naiss_date' ] = trim ( str_replace ( 'Né(e) le ' , '' , strip_tags ( $tabTmp [ 0 ])));
$tabRet [ 'naiss_lieu' ] = trim ( strip_tags ( $tabTmp [ 1 ]));
$tabRet [ 'sexe' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Sexe :' , '<B>' , '</B>' )));
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$tabRet [ 'enseigne' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Nom commercial - Enseigne :' , '<B>' , '</B>' )));
$tabRet [ 'sigle' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Sigle :' , '<B>' , '</B>' )));
$tabRet [ 'fj_lib' ] =@ getTextInHtml ( $this -> body , 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Forme juridique :' , '<B>' , '</B>' );
$strTmp =@ getTextInHtml ( $this -> body , 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Activité :' , '<B>' , '</B>' );
$tabTmp = explode ( ' - ' , $strTmp );
$tabRet [ 'naf_code' ] = $tabTmp [ 0 ];
$tabRet [ 'naf_lib' ] = $tabTmp [ 1 ];
$tabRet [ 'date_crea' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Date de création :' , '<B>' , '</B>' )));
$tabRet [ 'date_imma' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Date d\'immatriculation :' , '<B>' , '</B>' )));
$tabRet [ 'greffe' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Greffe :' , '<B>' , '</B>' )));
$tabRet [ 'num_gestion' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>N°de gestion :' , '<B>' , '</B>' )));
$strTmp =@ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Capital :' , '<B>' , '</B>' );
if ( preg_match ( '/([0-9\.,\s]*)([\D]*)/i' , $strTmp , $matches )) {
$tabRet [ 'capital_mnt' ] = trim ( str_replace ( ' ' , '' , str_replace ( ',' , '.' , $matches [ 1 ])));
$tabRet [ 'capital_dev' ] = $matches [ 2 ];
}
else {
$tabRet [ 'capital_mnt' ] = 0 ;
$tabRet [ 'capital_dev' ] = '' ;
}
$tabRet [ 'nationalite' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Nationalité :' , '<B>' , '</B>' )));
$tabRet [ 'nb_etab' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Nombre d\'établissements :' , '<B>' , '</B>' )));
if ( strpos ( $this -> body , 'FACE=ARIAL SIZE=2><B>Radiation</B>' ) > 0 ) {
$tabRet [ 'indRadiation' ] = true ;
$tabRet [ 'date_radiation' ] = trim ( strip_tags ( @ getTextInHtml ( $this -> body , 'FACE=ARIAL SIZE=2>Entreprise radiée le :' , '<B>' , '</B>' )));
} else
$tabRet [ 'indRadiation' ] = false ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// Procédures collectives
if ( strpos ( $this -> body , 'FACE=ARIAL SIZE=2><B>Les procédures collectives</B>' ) > 0 ) {
$tabRet [ 'indProcol' ] = true ;
$strTmp =@ getTextInHtml ( $this -> body , '<B>Les procédures collectives</B></FONT>' , " <img src='./images/rouge.gif' width=4 height=4 border='0'> " ,
'</TABLE>' );
$tabTmp = explode ( " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , $strTmp );
foreach ( $tabTmp as $nproc => $proc ) {
$tabTmp2 = explode ( '</TD></TR>' , $proc );
$tabTmp3 = explode ( ' du ' , $tabTmp2 [ 0 ]);
$tabTmp2 = explode ( '<TD WIDTH=99% ALIGN=LEFT BGCOLOR=#fff0d0 colspan=2><FONT COLOR=#100070 FACE=ARIAL SIZE=2>' , $proc );
$tabInter = array ();
for ( $nInter = 1 ; isset ( $tabTmp2 [ $nInter ]); $nInter ++ ) {
$tabTmp4 = explode ( '</TD></TR>' , $tabTmp2 [ $nInter ]);
$tabInter [] = array ( 'type' => trim ( strip_tags ( $tabTmp4 [ 0 ])),
'nom' => trim ( str_replace ( ' ' , '' , strip_tags ( $tabTmp4 [ 1 ]))),
'adresse' => trim ( str_replace ( ' ' , '' , strip_tags ( $tabTmp4 [ 2 ]))),
'cpVille' => trim ( str_replace ( ' ' , '' , strip_tags ( $tabTmp4 [ 3 ]))));
}
$tabRet [ 'procedures' ][ $nproc ] = array ( 'type' => trim ( strip_tags ( $tabTmp3 [ 0 ])),
'date' => trim ( strip_tags ( $tabTmp3 [ 1 ])),
'intervenant' => $tabInter );
}
}
else $tabRet [ 'indProcol' ] = false ;
// Dirigeants
$strTmp =@ getTextInHtml ( $this -> body , '<B>Les dirigeants</B></FONT>' , " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , '</TABLE>' );
$tabTmp = explode ( " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , $strTmp );
foreach ( $tabTmp as $ndir => $dir ) {
$tabTmp2 = explode ( '</TD>' , $dir );
$tabTmp3 = explode ( '</B> ' , $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 , '<B>Les administrateurs</B></FONT>' , " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , '</TABLE>' ));
if ( $strTmp <> '' ) {
$tabTmp = explode ( " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , $strTmp );
foreach ( $tabTmp as $nadm => $dir ) {
$tabTmp2 = explode ( '</TD>' , $dir );
$tabTmp3 = explode ( '</B> ' , $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 );
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// Etablissements
$strTmp =@ getTextInHtml ( $this -> body , '<B>Les établissements</B></FONT>' , " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , '</TABLE>' );
$tabTmp = explode ( " <img src='./images/rouge.gif' width=4 height=4 border='0'> " , $strTmp );
foreach ( $tabTmp as $netab => $dir ) {
$cp = $ville = $ensEtab = '' ; $j = 0 ;
$tabTmp2 = explode ( '</TD>' , $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 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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 );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$tabInsert = $tabRet ;
$tabInsert [ 'procedures' ] = serialize ( $tabRet [ 'procedures' ]);
$tabInsert [ 'dirigeants' ] = serialize ( $tabRet [ 'dirigeants' ]);
$tabInsert [ 'etablissements' ] = serialize ( $tabRet [ 'etablissements' ]);
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$iDb -> insert ( 'rncs_entrep' , $tabInsert );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
return $tabRet ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
private function partBilan ( $idBilanPart ) {
if ( $this -> curPage <> 'vitrine' )
$this -> partVitrine ();
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$url = $this -> urlRacine . '/' . $this -> weur . " /paie_abonnes_livraison_directe_informations.ow?flag_type_acces_direct_infos= $idBilanPart &WRNCSRV2= " . $this -> wrncsrv2 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
if ( preg_match ( '/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)"/i' , $this -> body , $matches ))
$this -> url = $matches [ 1 ];
else $this -> logEuridileError ( 'Erreur redir vers Bilan INPI' );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$page = getUrl ( $this -> url , '' , '' , $this -> referer , false );
$this -> referer = $this -> url ;
$this -> body = $page [ 'body' ];
$this -> codeRetour = $page [ 'code' ];
$this -> header = $page [ 'header' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$urlInpi = 'http://modules.euridile.inpi.fr' ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
// http://modules.euridile.inpi.fr/accesproduits.ow?MODUSRV1=2701291735122345
if ( preg_match ( '/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)"/i' , $this -> 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 ( '/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)"/i' , $this -> 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);
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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"><FONT SIZE=-1>([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"><FONT SIZE=-1>' . $poste , ' ' , '</TR>' ));
$strTmp2 = preg_replace ( '/bgcolor="#e6efff"><FONT SIZE=-1>(?:[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 ])) {
2012-12-17 16:35:12 +00:00
$tabPostes [ $poste . $indice ] = trim ( str_replace ( ' ' , '' ,
str_replace ( '-->' , '' ,
2010-11-04 11:21:31 +00:00
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 ]);
}
}
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$strTmp =@ getTextInHtml ( $this -> body , 'Montants exprimés en :<b> ' , '<TRANSLATE COD=1756>' , '</TRANSLATE>' );
//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 : </td>' , '<b> ' , '</b></td>' );
$tabBilan [ 'DUREE_MOIS' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b>' , '</b>' );
$tabBilan [ 'DUREE_MOIS_PRE' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b> ' , '</b></td>' );
$tabBilan [ 'POSTES' ] = $tabPostes ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Lecture et découpage du bilan
**/
$body = strtoupper ( $this -> body );
preg_match_all ( '/bgcolor="#e6efff"><FONT SIZE=-1>([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"><FONT SIZE=-1>' . $poste , ' ' , '</TR>' ));
$strTmp2 = preg_replace ( '/bgcolor="#e6efff"><FONT SIZE=-1>(?:[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 ])) {
2012-12-17 16:35:12 +00:00
$tabPostes [ $poste . $indice ] = trim ( str_replace ( ' ' , '' ,
str_replace ( '-->' , '' ,
2010-11-04 11:21:31 +00:00
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 :<b> ' , '<TRANSLATE COD=1756>' , '</TRANSLATE>' );
//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 : </td>' , '<td align=center width=80><b>' , '</b></td>' );
$tabBilan [ 'DUREE_MOIS' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=1 width=80>' , '<b>' , '</b>' );
$tabBilan [ 'DUREE_MOIS_PRE' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=1 width=80>' , '<b> ' , '</b></td>' );
$tabBilan [ 'POSTES' ] = $tabPostes ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Lecture et découpage du bilan
**/
$body = strtoupper ( $this -> body );
preg_match_all ( '/bgcolor="#e6efff"><FONT SIZE=-1>([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"><FONT SIZE=-1>' . $poste , ' ' , '</TR>' ));
$strTmp2 = preg_replace ( '/bgcolor="#e6efff"><FONT SIZE=-1>(?:[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 ])) {
2012-12-17 16:35:12 +00:00
$tabPostes [ $poste . $indice ] = trim ( str_replace ( ' ' , '' ,
str_replace ( '-->' , '' ,
2010-11-04 11:21:31 +00:00
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 ]);
}
}
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$strTmp =@ getTextInHtml ( $this -> body , 'Montants exprimés en :<b> ' , '<TRANSLATE COD=1756>' , '</TRANSLATE>' );
//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 : </td>' , '<td align=center width=100><FONT SIZE=-1><b>' , '</b><FONT></td>' );
$tabBilan [ 'DUREE_MOIS' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b>' , '</b>' );
$tabBilan [ 'DUREE_MOIS_PRE' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b> ' , '</b></font></td>' );
$tabBilan [ 'POSTES' ] = $tabPostes ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
break ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Lecture et découpage du bilan
**
$body = strtoupper ( $this -> body );
preg_match_all ( '/bgcolor="#e6efff"><FONT SIZE=-1>([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"><FONT SIZE=-1>' . $poste , ' ' , '</TR>' ));
$strTmp2 = preg_replace ( '/bgcolor="#e6efff"><FONT SIZE=-1>(?:[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 ])) {
2012-12-17 16:35:12 +00:00
$tabPostes [ $poste . $indice ] = trim ( str_replace ( ' ' , '' ,
str_replace ( '-->' , '' ,
2010-11-04 11:21:31 +00:00
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 ]);
}
}
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$strTmp =@ getTextInHtml ( $this -> body , 'Montants exprimés en :<b> ' , '<TRANSLATE COD=1756>' , '</TRANSLATE>' );
//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 : </td>' , '<td align=center width=100><FONT SIZE=-1><b>' , '</b><FONT></td>' );
$tabBilan [ 'DUREE_MOIS' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b>' , '</b>' );
$tabBilan [ 'DUREE_MOIS_PRE' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b> ' , '</b></font></td>' );
$tabBilan [ 'POSTES' ] = $tabPostes ;
break ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
/** Lecture et découpage du bilan
**
$body = strtoupper ( $this -> body );
preg_match_all ( '/bgcolor="#e6efff"><FONT SIZE=-1>([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"><FONT SIZE=-1>' . $poste , ' ' , '</TR>' ));
$strTmp2 = preg_replace ( '/bgcolor="#e6efff"><FONT SIZE=-1>(?:[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 ])) {
2012-12-17 16:35:12 +00:00
$tabPostes [ $poste . $indice ] = trim ( str_replace ( ' ' , '' ,
str_replace ( '-->' , '' ,
2010-11-04 11:21:31 +00:00
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 ]);
}
}
}
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$strTmp =@ getTextInHtml ( $this -> body , 'Montants exprimés en :<b> ' , '<TRANSLATE COD=1756>' , '</TRANSLATE>' );
//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 : </td>' , '<td align=center width=100><FONT SIZE=-1><b>' , '</b><FONT></td>' );
$tabBilan [ 'DUREE_MOIS' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b>' , '</b>' );
$tabBilan [ 'DUREE_MOIS_PRE' ] =@ getTextInHtml ( $this -> body , 'Durée des exercices : </td><td align=center colspan=2 width=100>' , '<b> ' , '</b></font></td>' );
$tabBilan [ 'POSTES' ] = $tabPostes ;
break ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
default :
return array ();
break ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
$this -> curPage = 'bilan' ;
$fp = fopen ( './euridile_bilan.log' , 'w' );
fwrite ( $fp , $this -> body );
fclose ( $fp );
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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' ];
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
return $bilanRN ;
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
private function partSaveSession () {
2011-06-10 10:08:21 +00:00
$fp = fopen ( REP_TEMP . 'php_rncs_session.id' , 'w' );
2010-11-04 11:21:31 +00:00
fwrite ( $fp , $this -> wrncsrv2 . '^' . $this -> timeOut . '^' . $this -> curPage . '^' . $this -> siren . '^' . $this -> url . '^' . $this -> referer );
fclose ( $fp );
}
private function partGetSession () {
2011-06-10 10:08:21 +00:00
$strTmp =@ file_get_contents ( REP_TEMP . 'php_rncs_session.id' );
2010-11-04 11:21:31 +00:00
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 ;
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
}
2012-12-17 16:35:12 +00:00
2010-11-04 11:21:31 +00:00
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 );
}
2011-09-22 13:00:18 +00:00
}
?>