Init array
This commit is contained in:
parent
6101eff49e
commit
29a5948892
@ -44,7 +44,7 @@ try {
|
||||
if ( isset($opts->debug) ) {
|
||||
define('DEBUG', true);
|
||||
} else {
|
||||
define('DEBUG', false);
|
||||
define('DEBUG', false);
|
||||
}
|
||||
|
||||
//Usage
|
||||
@ -91,7 +91,7 @@ function getPage($url, $curl_data = '', $verbose=false)
|
||||
CURLOPT_SSL_VERIFYPEER => false, //
|
||||
CURLOPT_VERBOSE => $verbose , //
|
||||
//CURLOPT_COOKIESESSION => true,
|
||||
CURLOPT_COOKIEFILE => $ckfile,
|
||||
CURLOPT_COOKIEFILE => $ckfile,
|
||||
CURLOPT_COOKIEJAR => $ckfile, // Stockage du cookie de session
|
||||
);
|
||||
|
||||
@ -112,7 +112,7 @@ function getPage($url, $curl_data = '', $verbose=false)
|
||||
function infogreffeConnexion()
|
||||
{
|
||||
$url = "http://www.infogreffe.fr/infogreffe/index.jsp";
|
||||
$result = getPage($url);
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-connexion1.html', $result['content']);
|
||||
|
||||
$url = "http://www.infogreffe.fr/infogreffe/popupLog.jsp?type=0&url=index.jsp";
|
||||
@ -124,7 +124,7 @@ function infogreffeConnexion()
|
||||
// => http://www.infogreffe.fr/infogreffe/index.jsp
|
||||
$data = array(
|
||||
'codeAbo'=>'2559',
|
||||
'codeClt'=>'0041',
|
||||
'codeClt'=>'0041',
|
||||
'log'=>'',
|
||||
'pwd'=>'69873',
|
||||
);
|
||||
@ -132,14 +132,14 @@ function infogreffeConnexion()
|
||||
if (DEBUG) file_put_contents('kbis-connexion3.html', $result['content']);
|
||||
|
||||
/*
|
||||
We need to have
|
||||
We need to have
|
||||
<div style="margin-top:2px; *margin-top:0px;" class="identBar">
|
||||
|
||||
<span class="name">Abonné</span> |
|
||||
<a href="/infogreffe/jsp/information/monCompte.jsp">Mon compte</a> |
|
||||
<a href="/infogreffe/afficherMesAchats.do?refCde=N">Documents Commandés</a>
|
||||
| <a href="/infogreffe/deconnexion.do">Se déconnecter</a>
|
||||
</div>
|
||||
</div>
|
||||
*/
|
||||
}
|
||||
|
||||
@ -188,9 +188,9 @@ function infogreffeKbis($ref)
|
||||
$fichier = $identifiant . '-' . $ref . '.html';
|
||||
|
||||
$dir = DOC_WEB_LOCAL.'kbis/'.date('Ymd');
|
||||
if (!file_exists($dir)) mkdir($dir);
|
||||
if (!file_exists($dir)) mkdir($dir);
|
||||
file_put_contents($dir . '/' . $fichier, $output);
|
||||
return ($identifiant!='unknown') ? $identifiant : false;
|
||||
return ($identifiant!='unknown') ? $identifiant : false;
|
||||
}
|
||||
|
||||
function removeTag($balise, $content, $endOfTag = true, $removeContent = true)
|
||||
@ -252,7 +252,7 @@ function parseRef($document)
|
||||
'ref' => $ref,
|
||||
'rs' => $rs,
|
||||
'rcs' => $rcs,
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
//Define cookie file for storage
|
||||
@ -260,8 +260,8 @@ function parseRef($document)
|
||||
$ckfile = __DIR__.'/'.uniqid('cookie-');
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
|
||||
// Récupération de la liste des commandes et
|
||||
if ( $opts->commandes )
|
||||
// Récupération de la liste des commandes et
|
||||
if ( $opts->commandes )
|
||||
{
|
||||
$referer = '';
|
||||
|
||||
@ -281,10 +281,10 @@ if ( $opts->commandes )
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('documents.html', $result['content']);
|
||||
|
||||
//On parse le document pour trouver les références de commandes
|
||||
//On parse le document pour trouver les références de commandes
|
||||
$refs = array();
|
||||
|
||||
$tmp = parseRef($result['content']);
|
||||
$tmp = parseRef($result['content']);
|
||||
$refs[] = $tmp;
|
||||
|
||||
//Liste des commandes
|
||||
@ -296,23 +296,23 @@ if ( $opts->commandes )
|
||||
}
|
||||
|
||||
$listeRef = array();
|
||||
foreach($refs as $item){
|
||||
foreach($refs as $item){
|
||||
$listeRef[] = $item['ref'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $opts->visu && in_array($opts->visu, $listeRef) )
|
||||
if ( $opts->visu && in_array($opts->visu, $listeRef) )
|
||||
{
|
||||
//Pour toutes les commandes en dehors de la toute dernière
|
||||
if ( array_search($opts->visu, $listeRef)!=0 ){
|
||||
$url = "http://www.infogreffe.fr/infogreffe/chargerContenuCommande.do?refCde=".$opts->visu."&_=";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
|
||||
}
|
||||
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
|
||||
}
|
||||
|
||||
echo "Téléchargement du kbis...\n";
|
||||
echo "Téléchargement du kbis...\n";
|
||||
infogreffeKbis($opts->visu);
|
||||
|
||||
//Lancer WKHTMLTOPDF pour le PDF
|
||||
//Lancer WKHTMLTOPDF pour le PDF
|
||||
|
||||
} elseif ( !$opts->visu ) {
|
||||
|
||||
@ -332,20 +332,20 @@ if ( $opts->commandes )
|
||||
//@todo : Recup des informations
|
||||
$info = array();
|
||||
$info = parseRef($document);
|
||||
}
|
||||
}
|
||||
echo $ref['ref'];
|
||||
if ( $info['ref']==$ref['ref'] ) {
|
||||
if ( !empty($info['rs']) ) echo " ".$info['rs'];
|
||||
if ( !empty($info['rcs']) ) echo " ".$info['rcs'];
|
||||
}
|
||||
echo "\n";
|
||||
echo "\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commande d'un kbis
|
||||
if ( $opts->siren )
|
||||
if ( $opts->siren )
|
||||
{
|
||||
//Vérification du siren
|
||||
echo "Verfication du siren ...";
|
||||
@ -376,17 +376,17 @@ if ( $opts->siren )
|
||||
'denomination' => '',
|
||||
'departement' => '',
|
||||
'elargirRadie' => 'on',
|
||||
'siren' => $opts->siren,
|
||||
'siren' => $opts->siren,
|
||||
);
|
||||
$url = "http://www.infogreffe.fr/infogreffe/newRechercheEntreprise.xml";
|
||||
$url = "http://www.infogreffe.fr/infogreffe/newRechercheEntreprise.xml";
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis2.html', $result['content']);
|
||||
|
||||
// 302 Moved Temporarily
|
||||
// 302 Moved Temporarily
|
||||
$url='http://www.infogreffe.fr/infogreffe/entrepRech.do';
|
||||
if ( $result['header']['http_code']=='302' ) {
|
||||
//$url = $result['header']['redirect_url'];
|
||||
$url='http://www.infogreffe.fr/weblogic/infogreffe/entrepRech.do';
|
||||
$url='http://www.infogreffe.fr/weblogic/infogreffe/entrepRech.do';
|
||||
}
|
||||
/**************************************************
|
||||
Affichage identite entreprise
|
||||
@ -396,13 +396,13 @@ if ( $opts->siren )
|
||||
if (DEBUG) file_put_contents('kbis3.html', $result['content']);
|
||||
|
||||
// 302 Moved Temporarily
|
||||
//http://www.infogreffe.fr/infogreffe/entrepListe.do?index=rcs
|
||||
//http://www.infogreffe.fr/infogreffe/entrepListe.do?index=rcs
|
||||
if ( $result['header']['http_code']=='302' && array_key_exists('redirect_url', $result['header']) ) {
|
||||
$url = $result['header']['redirect_url'];
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-1.html', $result['content']);
|
||||
if (DEBUG) file_put_contents('kbis3-1.html', $result['content']);
|
||||
|
||||
// => /infogreffe/getEntrepDetail.do?docId=780308B042410000
|
||||
// => /infogreffe/getEntrepDetail.do?docId=780308B042410000
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@ -410,9 +410,9 @@ if ( $opts->siren )
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//a[@class='company']");
|
||||
foreach ($nodelist as $n) {
|
||||
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
|
||||
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
|
||||
} elseif ( $result['header']['http_code']=='302' ) {
|
||||
@ -432,7 +432,7 @@ if ( $opts->siren )
|
||||
}
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
|
||||
}
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
@ -442,14 +442,14 @@ if ( $opts->siren )
|
||||
|
||||
$fields = array();
|
||||
//Recherche des infos pour la validation du formulaire
|
||||
$nodelist = $xpath->query("//form[@name='FicheEntrepriseForm']/div[@id='conteneur']/input[@type='hidden']");
|
||||
foreach ($nodelist as $n) {
|
||||
$nodelist = $xpath->query("//form[@name='FicheEntrepriseForm']/div[@id='conteneur']/input[@type='hidden']");
|
||||
foreach ($nodelist as $n) {
|
||||
$key = $n->getAttribute('name');
|
||||
$value = $n->getAttribute('value');
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
$fields['montantTotalSelection'] = '5.44'; // 3.11 + 2.33
|
||||
$fields['extraitForm.visualisation'] = 'on'; // => Définit par javascript
|
||||
$fields['extraitForm.visualisation'] = 'on'; // => Définit par javascript
|
||||
|
||||
$fields['extraitForm.formVisible'] = 'true';
|
||||
$fields['extraitForm.envoiPeriodiqueForm.periodicite'] = '1';
|
||||
@ -474,6 +474,7 @@ if ( $opts->siren )
|
||||
Valider la commande
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/validerPanierAbonne.do?forcerSaisieCoordonnees=false";
|
||||
$fields = array();
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis5.html', $result['content']);
|
||||
|
||||
@ -481,15 +482,16 @@ if ( $opts->siren )
|
||||
Afficher mes achats et prendre la première commande
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/afficherMesAchats.do?refCde=N&pageAppel=validerPanier";
|
||||
$fields = array();
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis6.html', $result['content']);
|
||||
if (DEBUG) file_put_contents('kbis6.html', $result['content']);
|
||||
|
||||
$info = parseRef($result['content']);
|
||||
$ref = $info['ref'];
|
||||
|
||||
/**************************************************
|
||||
Visualiser
|
||||
**************************************************/
|
||||
**************************************************/
|
||||
$identifiant = infogreffeKbis($ref);
|
||||
|
||||
//Suppression fichier
|
||||
@ -497,7 +499,7 @@ if ( $opts->siren )
|
||||
|
||||
if ($identifiant===false || $identifiant!=$opts->siren) {
|
||||
echo "ERREUR";
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
echo $identifiant.'-'.$ref.'.html';
|
||||
echo $identifiant.'-'.$ref.'.html';
|
||||
}
|
Loading…
Reference in New Issue
Block a user