2012-10-16 07:44:31 +00:00
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
< ? php
include_once ( FWK_PATH . 'common/chiffres.php' );
include_once ( FWK_PATH . 'common/dates.php' );
include_once ( FWK_PATH . 'common/curl.php' );
include_once ( FWK_PATH . 'mail/sendMail.php' );
$tabGages = array ( 1 => 'Animaux' ,
2 => 'Horlogerie et Bijoux' ,
3 => 'Instruments de musique' ,
2013-06-19 08:24:49 +00:00
4 => 'Mat<61> riels, mobiliers et produits <20> usage professionnel non vis<69> s dans les autres cat<61> gories' ,
5 => 'Mat<61> riels <20> usage non professionnel autres qu\'informatiques' ,
6 => 'Mat<61> riels li<6C> s au sport' ,
7 => 'Mat<61> riels informatiques et accessoires' ,
2012-10-16 07:44:31 +00:00
8 => 'Meubles meublants' ,
9 => 'Meubles incorporels autres que parts sociales' ,
10 => 'Monnaies' ,
2013-06-19 08:24:49 +00:00
11 => 'Objets d\'art, de collection ou d\'antiquit<69> ' ,
2012-10-16 07:44:31 +00:00
12 => 'Parts sociales' ,
2013-06-19 08:24:49 +00:00
13 => 'Produits de l\'<27> dition, de la presse ou d\'autres industries graphiques' ,
2012-10-16 07:44:31 +00:00
14 => 'Produits liquides non comestibles' ,
15 => 'Produits textiles' ,
16 => 'Produits alimentaires' ,
17 => 'Autres' ,
);
$tabSiren = array (
331477158 ,
512460809 ,
417951233 ,
479031288 ,
477798995 ,
310836614 ,
);
foreach ( $tabSiren as $siren ) {
foreach ( $tabGages as $i => $libGage ) {
getGages ( $siren , $i );
}
}
die ();
foreach ( $tabGages as $i => $libGage ) {
$cookie = $post = $referer = '' ;
$timeout = 5 ;
$url = 'http://www.infogreffe.fr/infogreffe/afficherGageSansDepossession.do?pageAppel=new' ;
$page = getUrl ( $url , $cookie , $post , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$cookie = $page [ 'header' ][ 'Set-Cookie' ];
$referer = $url ;
$url = " http://www.infogreffe.fr/infogreffe/attenteGageSansDepossession.xml?step=start&search=gagesansdepo&oups=/rechercherGageSansDepossession.do " ;
$post = array ( 'numeroGreffe' => '' ,
'categorie' => $i ,
'constituant' => 'PM' ,
'denominationPM' => 'A' ,
'numIdentificationPM' => 552144503 ,
'denominationNM' => '' ,
'denominationPP' => '' ,
'prenomPP' => '' ,
'numIdentificationPP' => '' ,
'datePP' => '' ,
'paysPP' => 'FR' ,
'communePP' => '' ,
'denominationNP' => '' ,
'prenomNP' => '' ,
'dateNP' => '' ,
'paysNP' => 'FR' ,
'communeNP' => '' ,
);
$page = getUrl ( $url , $cookie , $post , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$referer = $url ;
usleep ( 300 );
$url = 'http://www.infogreffe.fr/infogreffe/rechercherGageSansDepossession.do' ;
$page = getUrl ( $url , $cookie , '' , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$body = $page [ 'body' ];
if ( preg_match ( '/RESULTAT DE LA RECHERCHE<\/td><\/tr><\/table>(.*)<span class="text-std">Rappel de vos critères de sélection \: <br\/>(?:.*)Catégorie du bien gagé \: (.*)<br\/>(?:.*)Type de constituant \: (?:.*)Dénomination \: (.*)<br\/>(?:.*)Numéro d\'identification \: (.*)<br\/>(?:.*)<\/span>/Uis' , $body , $matches )) {
$gages = trim ( html_entity_decode ( strip_tags ( $matches [ 1 ])));
$type = $matches [ 2 ];
$rs = $matches [ 3 ];
$sirenLu = str_replace ( ' ' , '' , $matches [ 4 ]);
echo " $sirenLu ( $type ) : $rs\t $gages " . EOL ;
//print_r($matches);
//die();
}
//print_r($page);
}
die ();
function getGages ( $siren , $numGage ) {
$cookie = $post = $referer = '' ;
$timeout = 5 ;
$url = 'http://www.infogreffe.fr/infogreffe/afficherGageSansDepossession.do?pageAppel=new' ;
$page = getUrl ( $url , $cookie , $post , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$cookie = $page [ 'header' ][ 'Set-Cookie' ];
$referer = $url ;
$url = " http://www.infogreffe.fr/infogreffe/attenteGageSansDepossession.xml?step=start&search=gagesansdepo&oups=/rechercherGageSansDepossession.do " ;
$post = array ( 'numeroGreffe' => '' ,
'categorie' => $numGage ,
'constituant' => 'PM' ,
'denominationPM' => 'A' ,
'numIdentificationPM' => $siren ,
'denominationNM' => '' ,
'denominationPP' => '' ,
'prenomPP' => '' ,
'numIdentificationPP' => '' ,
'datePP' => '' ,
'paysPP' => 'FR' ,
'communePP' => '' ,
'denominationNP' => '' ,
'prenomNP' => '' ,
'dateNP' => '' ,
'paysNP' => 'FR' ,
'communeNP' => '' ,
);
$page = getUrl ( $url , $cookie , $post , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$referer = $url ;
usleep ( 300 );
$url = 'http://www.infogreffe.fr/infogreffe/rechercherGageSansDepossession.do' ;
$page = getUrl ( $url , $cookie , '' , $referer , false , 'www.infogreffe.fr' , '' , $timeout );
$body = $page [ 'body' ];
if ( preg_match ( '/RESULTAT DE LA RECHERCHE<\/td><\/tr><\/table>(.*)<span class="text-std">Rappel de vos critères de sélection \: <br\/>(?:.*)Catégorie du bien gagé \: (.*)<br\/>(?:.*)Type de constituant \: (?:.*)Dénomination \: (.*)<br\/>(?:.*)Numéro d\'identification \: (.*)<br\/>(?:.*)<\/span>/Uis' , $body , $matches ))
{
$gages = trim ( html_entity_decode ( strip_tags ( $matches [ 1 ])));
$type = $matches [ 2 ];
$rs = $matches [ 3 ];
$sirenLu = str_replace ( ' ' , '' , $matches [ 4 ]);
echo " $sirenLu ( $type ) : $rs\t $gages " . EOL ;
2013-06-19 08:24:49 +00:00
if ( $gages <> " Aucune inscription n'a <20> t<EFBFBD> trouv<75> e dans le fichier national " ) die ( 'OUI / OUI / OUI / OUI / OUI / OUI / OUI / OUI / OUI / OUI / OUI / OUI' . EOL );
2012-10-16 07:44:31 +00:00
return ( array ( 'siren' => $sirenLu ,
'gageNum' => $numGage ,
'gageLib' => $type ,
'gageInfos' => $gages ,));
}
return false ;
}
die ();
$bodyGages = array ();
$tabGages = array ( 1 => 'Animaux' ,
2 => 'Horlogerie et Bijoux' ,
/* 3 => 'Instruments de musique' ,
2013-06-19 08:24:49 +00:00
4 => 'Mat<61> riels, mobiliers et produits <20> usage professionnel non vis<69> s dans les autres cat<61> gories' ,
5 => 'Mat<61> riels <20> usage non professionnel autres qu\'informatiques' ,
6 => 'Mat<61> riels li<6C> s au sport' ,
7 => 'Mat<61> riels informatiques et accessoires' ,
2012-10-16 07:44:31 +00:00
8 => 'Meubles meublants' ,
9 => 'Meubles incorporels autres que parts sociales' ,
10 => 'Monnaies' ,
2013-06-19 08:24:49 +00:00
11 => 'Objets d\'art, de collection ou d\'antiquit<69> ' ,
2012-10-16 07:44:31 +00:00
12 => 'Parts sociales' ,
2013-06-19 08:24:49 +00:00
13 => 'Produits de l\'<27> dition, de la presse ou d\'autres industries graphiques' ,
2012-10-16 07:44:31 +00:00
14 => 'Produits liquides non comestibles' ,
15 => 'Produits textiles' ,
16 => 'Produits alimentaires' ,
17 => 'Autres' , */
);
foreach ( $tabGages as $i => $libGage ) {
// create both cURL resources
$ch [ $i ] = curl_init ();
// set URL and other appropriate options
curl_setopt ( $ch [ $i ], CURLOPT_URL , " http://www.infogreffe.fr/infogreffe/attenteGageSansDepossession.xml?step=start&search=gagesansdepo&oups=/rechercherGageSansDepossession.do " );
curl_setopt ( $ch [ $i ], CURLOPT_HEADER , 0 );
curl_setopt ( $ch [ $i ], CURLOPT_RETURNTRANSFER , 1 );
curl_setopt ( $ch [ $i ], CURLOPT_SSL_VERIFYPEER , false );
$postData = array ( 'numeroGreffe' => '' ,
'categorie' => $i ,
'constituant' => 'PM' ,
'denominationPM' => 'AUTOMOBILES+PEUGEOT' ,
'numIdentificationPM' => 552144503 ,
'denominationNM' => '' ,
'denominationPP' => '' ,
'prenomPP' => '' ,
'numIdentificationPP' => '' ,
'datePP' => '' ,
'paysPP' => 'FR' ,
'communePP' => '' ,
'denominationNP' => '' ,
'prenomNP' => '' ,
'dateNP' => '' ,
'paysNP' => 'FR' ,
'communeNP' => '' ,
);
if ( $postData != '' ) {
if ( is_array ( $postData ))
$post_data = $postData ;
$o = " " ;
foreach ( $post_data as $k => $v )
{
$o .= " $k = " . utf8_encode ( $v ) . " & " ;
}
$post_data = substr ( $o , 0 , - 1 );
curl_setopt ( $ch [ $i ], CURLOPT_POST , 1 );
curl_setopt ( $ch [ $i ], CURLOPT_POSTFIELDS , $post_data );
//if in_array('',$this_header
/* array_push ( $this_header , " Content-type: application/x-www-form-urlencoded " );
array_push ( $this_header , " Content-Length: 44 " ); */
}
/*
if ( $host == '' )
$this_header = array ( 'Host: ' . parse_url ( $url , PHP_URL_HOST ));
else
$this_header = array ( 'Host: ' . $host );
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HEADER , 1 );
curl_setopt ( $ch , CURLOPT_TIMEOUT , ( int ) $timeout );
curl_setopt ( $ch , CURLOPT_CONNECTTIMEOUT , ( int ) $timeout );
//curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); // New
//curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' ;
curl_setopt ( $ch , CURLOPT_USERAGENT , $user_agent );
curl_setopt ( $ch , CURLOPT_REFERER , $referer );
// Add each cookie that has been returned in the response
// If cookies need to be added/deleted or value changed, then add code here
if ( $strCookies != '' ) {
//die('"'.$strCookies.'"');
//echo $strCookies."\r\n";
$cookies = explode ( " \n " , $strCookies );
// Create the basic header
foreach ( $cookies as $this_cookie ) {
if ( trim ( $this_cookie ) <> '' )
array_push ( $this_header , 'Cookie: ' . $this_cookie );
}
}
/* curl_setopt ( $ch , CURLOPT_STDERR , '/var/www/log/curlerror.log' );
curl_setopt ( $ch , CURLOPT_VERBOSE , true );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $this_header );
*/
}
//create the multiple cURL handle
$mh = curl_multi_init ();
// add the handles
foreach ( $tabGages as $i => $libGage )
curl_multi_add_handle ( $mh , $ch [ $i ]);
$active = null ;
//execute the handles
do {
$mrc = curl_multi_exec ( $mh , $active );
} while ( $mrc == CURLM_CALL_MULTI_PERFORM );
while ( $active && $mrc == CURLM_OK ) {
if ( curl_multi_select ( $mh ) != - 1 ) {
do {
$mrc = curl_multi_exec ( $mh , $active );
} while ( $mrc == CURLM_CALL_MULTI_PERFORM );
}
}
//close the handles
foreach ( $tabGages as $i => $libGage ) {
$bodyGages [ $i ] = curl_multi_getcontent ( $ch [ $i ]);
curl_multi_remove_handle ( $mh , $ch [ $i ]);
}
curl_multi_close ( $mh );
print_r ( $bodyGages );
?>