Security
This commit is contained in:
parent
f53cc64622
commit
7607963045
@ -5,6 +5,14 @@ require_once realpath(dirname(__FILE__)).'/Types.php';
|
||||
class Entreprise extends WsScore
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->serviceClient = true;
|
||||
$this->serviceClientName = 'Vwbank';
|
||||
$this->serviceName = 'Entreprise';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
|
||||
* @param string $siret Siren de l'entreprise ou siret de l'établissement
|
||||
@ -84,7 +92,7 @@ class Entreprise extends WsScore
|
||||
$identite->DateMajRCS = $entrep['DateMajRCS']; //@todo : date
|
||||
$identite->DateMajID = $entrep['dateMajIdentite']; //@todo : date
|
||||
$identite->SituationJuridique = $entrep['SituationJuridique'];
|
||||
|
||||
|
||||
//Présence de privilèges
|
||||
$identite->Privileges = false;
|
||||
$nbPrivileges = 0;
|
||||
@ -102,11 +110,11 @@ class Entreprise extends WsScore
|
||||
}
|
||||
}
|
||||
debugLog('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
$this->wsLog('identite',$siret,$id);
|
||||
return $identite;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recherche
|
||||
* @param EntrepriseCriteres $criteres
|
||||
@ -120,18 +128,18 @@ class Entreprise extends WsScore
|
||||
public function searchEntreprise($criteres, $position = 0, $nbRep = 20, $maxRep = 200, $pertinence = false, $avecSiren = false)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
if (empty($position)) { $position = 0;}
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
$typeId = '';
|
||||
|
||||
|
||||
//Detection autour de l'identifiant
|
||||
if ($identifiant!='') {
|
||||
$len = strlen($identifiant);
|
||||
@ -160,9 +168,9 @@ class Entreprise extends WsScore
|
||||
$typeId = 'S';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$adresse = trim($entCriteres->adresse);
|
||||
|
||||
|
||||
//Détection Tel/Fax uniquement
|
||||
if ( empty($typeId)
|
||||
&& empty($entCriteres->raisonSociale)
|
||||
@ -172,9 +180,9 @@ class Entreprise extends WsScore
|
||||
&& empty($entCriteres->naf) ){
|
||||
$typeId = 'TEL';
|
||||
}
|
||||
|
||||
|
||||
if (in_array($typeId, array('R', 'W', 'I'))){
|
||||
|
||||
|
||||
$O = $this->searchAutreId(
|
||||
$typeId,
|
||||
$identifiant,
|
||||
@ -189,9 +197,9 @@ class Entreprise extends WsScore
|
||||
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
||||
$output->result = $O->result;
|
||||
return $output;
|
||||
|
||||
|
||||
} elseif ($typeId == 'S'){
|
||||
|
||||
|
||||
$O = $this->searchSiren(
|
||||
$identifiant,
|
||||
$entCriteres->codePostal,
|
||||
@ -200,16 +208,16 @@ class Entreprise extends WsScore
|
||||
empty($nbRep) ? 20 : $nbRep,
|
||||
empty($maxRep) ? 200 : $maxRep
|
||||
);
|
||||
|
||||
|
||||
$output = new SearchEntrepriseReturn();
|
||||
$output->nbReponses = $O->nbReponses;
|
||||
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
||||
$output->result = $O->result;
|
||||
$output->info = $O->info;
|
||||
return $output;
|
||||
|
||||
|
||||
} elseif ($typeId == 'TEL'){
|
||||
|
||||
|
||||
$O = $this->searchTelFax(
|
||||
$entCriteres->telFax,
|
||||
($entCriteres->actif==false) ? 2 : 1,
|
||||
@ -217,15 +225,15 @@ class Entreprise extends WsScore
|
||||
empty($nbRep) ? 20 : $nbRep,
|
||||
empty($maxRep) ? 200 : $maxRep
|
||||
);
|
||||
|
||||
|
||||
$output = new SearchEntrepriseReturn();
|
||||
$output->nbReponses = $O->nbReponses;
|
||||
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
||||
$output->result = $O->result;
|
||||
return $output;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
@ -240,7 +248,7 @@ class Entreprise extends WsScore
|
||||
empty($avecSiren) ? false : $avecSiren,
|
||||
$entCriteres->naf
|
||||
);
|
||||
|
||||
|
||||
$output = new SearchEntrepriseReturn();
|
||||
$output->nbReponses = $O->nbReponses;
|
||||
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
||||
@ -248,7 +256,7 @@ class Entreprise extends WsScore
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recherche d'entreprise ou d'établissement par un autre Identifiant
|
||||
*
|
||||
@ -264,15 +272,15 @@ class Entreprise extends WsScore
|
||||
public function searchAutreId($typeId, $identifiant, $dep=0, $actif=2, $deb=0, $nbRep=20, $maxRep=200)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
if (empty($deb)) $deb = 0;
|
||||
if (empty($nbRep)) $nbRep = 0;
|
||||
if (empty($maxRep)) $maxRep = 0;
|
||||
if (empty($dep)) $dep = 0;
|
||||
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
||||
|
||||
|
||||
$typeId = substr(trim(strtoupper($typeId)),0,1);
|
||||
|
||||
|
||||
if ($typeId!='I' && $typeId!='W' && $typeId!='R') {
|
||||
debugLog('I',"Type d'identifiant $typeId inexistant",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1021');
|
||||
@ -323,8 +331,8 @@ class Entreprise extends WsScore
|
||||
return $this->searchSiren($siren, $dep, $actif, $deb, $nbRep, $maxRep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Recherche d'entreprise ou d'établissement par leur TEL FAX
|
||||
*
|
||||
@ -338,12 +346,12 @@ class Entreprise extends WsScore
|
||||
protected function searchTelFax($telFax, $actif=2, $deb=0, $nbRep=20, $maxRep=200)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
if (empty($deb)) $deb = 0;
|
||||
if (empty($nbRep)) $nbRep = 0;
|
||||
if (empty($maxRep)) $maxRep = 0;
|
||||
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
||||
|
||||
|
||||
$tabRet = array();
|
||||
debugLog('I',"Recherche par Tel/Fax de $telFax avec un maximum de $nbRep réponses",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
//$assocs=$this->iInsee->rechercheEtab($raisonSociale, $adresse, $codePostal, $ville, $siege, $nbRep, $pertinence);
|
||||
@ -352,7 +360,7 @@ class Entreprise extends WsScore
|
||||
debugLog('W', "Tel/Fax $telFax incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1011');
|
||||
}
|
||||
|
||||
|
||||
$iInsee = new MInsee();
|
||||
$rep = $iInsee->getEtablissementsParId('TEL', $telFax, $deb, $nbRep, $maxRep, 0, $actif);
|
||||
$etabs = $rep['reponses'];
|
||||
@ -384,15 +392,15 @@ class Entreprise extends WsScore
|
||||
$item->NafEntLib = prepareString($etab['NafEntLib']);
|
||||
$tabRet[] = $item;
|
||||
}
|
||||
|
||||
|
||||
$output = new SearchReturn();
|
||||
$output->nbReponses = $rep['nbReponses'];
|
||||
$output->nbReponsesTotal = $rep['nbReponsesTotal'];
|
||||
$output->result = $tabRet;
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Recherche entreprise par nom et adresse
|
||||
* @param string $raisonSociale Raison Sociale ou Enseigne ou Sigle
|
||||
@ -412,9 +420,9 @@ class Entreprise extends WsScore
|
||||
public function searchNomAdr($raisonSociale, $adresse='', $codePostal='', $ville='', $siege=false, $actif=2, $deb=0, $nbRep=20, $maxRep=200, $pertinence=false, $avecSiren=false, $ape_etab='')
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
debugLog('I',"Recherche Entreprise de $raisonSociale, $adresse, $codePostal $ville (Siège=$siege / Max Rep=$nbRep)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
if (empty($adresse)) $adresse = '';
|
||||
if (empty($codePostal)) $codePostal = '';
|
||||
if (empty($ville)) $ville = '';
|
||||
@ -426,10 +434,10 @@ class Entreprise extends WsScore
|
||||
if (empty($pertinence)) $pertinence = false;
|
||||
if (empty($avecSiren)) $avecSiren = false;
|
||||
if (empty($ape_etab)) $ape_etab = '';
|
||||
|
||||
|
||||
$iInsee = new MInsee();
|
||||
$etabs = $iInsee->rechercheEtab($raisonSociale, $adresse, $codePostal, $ville, $siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren, $ape_etab);
|
||||
|
||||
|
||||
$result = new SearchReturn();
|
||||
$tabRet = array();
|
||||
if (count($etabs['reponses'])) {
|
||||
@ -458,41 +466,41 @@ class Entreprise extends WsScore
|
||||
$reponse->NafEtabLib = $iInsee->getLibelleNaf($etab['NafEtab']); // Etablissement
|
||||
$reponse->NafEnt = $etab['NafEnt']; // Entreprise
|
||||
$reponse->NafEntLib = $iInsee->getLibelleNaf($etab['NafEnt']);
|
||||
|
||||
|
||||
$tabRet[] = $reponse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$fp=fopen(LOG_PATH.'/recherches.log','a');
|
||||
|
||||
|
||||
$siretTrouve = 0;
|
||||
if ($etabs['nbReponses']==0) {
|
||||
|
||||
|
||||
$str="NbRep=0, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab, ($deb, $nbRep, $maxRep, $siege, $actif, $pertinence, $avecSiren), SiretTrouve=$siretTrouve";
|
||||
fwrite($fp, $str.EOL);
|
||||
fclose($fp);
|
||||
debugLog('I', "rechercheEtab : AUCUN RESULTAT, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab ($siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
$result->nbReponses = count($tabRet);
|
||||
$result->nbReponsesTotal = $etabs['nbReponsesTotal'];
|
||||
$result->result = $tabRet;
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($etabs['nbReponses']==1) $siretTrouve=$etabs['reponses'][0]['Siret'];
|
||||
$str="NbRep=".$etabs['nbReponses'].", S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab, ($deb, $nbRep, $maxRep, $siege, $actif, $pertinence, $avecSiren), SiretTrouve=$siretTrouve";
|
||||
fwrite($fp, $str.EOL);
|
||||
fclose($fp);
|
||||
debugLog('I', "rechercheEtab : ".$etabs['nbReponses']." RESULTATS, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab ($siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
$result->nbReponses = $etabs['nbReponses'];
|
||||
$result->nbReponsesTotal = $etabs['nbReponsesTotal'];
|
||||
$result->result = $tabRet;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recherche d'entreprise ou d'établissement par leur identifiant SIREN ou SIRET
|
||||
* @param string $siret Siren ou Siret de l'entreprise ou de l'établissement sur 9 ou 14 chiffres significatifs
|
||||
@ -507,30 +515,30 @@ class Entreprise extends WsScore
|
||||
public function searchSiren($siret, $dep=0, $actif=2, $siege=null, $deb=0, $nbRep=20, $maxRep=200)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
debugLog('I',"Recherche par Siret de $siret (dep=$dep) avec un maximum de $maxRep réponses pour la tranche $deb à $nbRep",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
if ( strlen($siret)!=14 && strlen($siret)!=9 ){
|
||||
debugLog('W', "Siren/Siret $siret incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
|
||||
if (empty($deb)) $deb = 0;
|
||||
if (empty($nbRep)) $nbRep = 20;
|
||||
if (empty($maxRep)) $maxRep = 200;
|
||||
if (empty($dep)) $dep = 0;
|
||||
|
||||
|
||||
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
||||
if ( $actif==2 ) $actif = -1;
|
||||
|
||||
|
||||
$nbReponsesTotal = $nbReponses = 0;
|
||||
|
||||
|
||||
$siren = substr($siret,0,9);
|
||||
if (strlen($siret)==14) $nic = substr($siret,9,5);
|
||||
elseif (strlen($siret)== 9) $nic = '';
|
||||
|
||||
|
||||
$iInsee = new MInsee();
|
||||
|
||||
|
||||
$rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, $dep, $actif, $siege);
|
||||
if ( count($rep['reponses'])==0 && $dep>0 ) {
|
||||
$rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, 0, $actif, $siege);
|
||||
@ -568,7 +576,7 @@ class Entreprise extends WsScore
|
||||
}
|
||||
$nbReponsesTotal = $rep['nbReponsesTotal'];
|
||||
$nbReponses = $rep['nbReponses'];
|
||||
|
||||
|
||||
if (count($tabRet)==0)
|
||||
{
|
||||
if ($siege===null || $actif==2)
|
||||
@ -602,11 +610,11 @@ class Entreprise extends WsScore
|
||||
$reponse->NafEtabLib = $etab['NafEtabLib'];
|
||||
$reponse->NafEnt = $etab['NafEnt'];
|
||||
$reponse->NafEntLib = $etab['NafEntLib'];
|
||||
|
||||
|
||||
$tabRet[] = $reponse;
|
||||
$nbReponses = 1;
|
||||
$nbReponsesTotal = 1;
|
||||
|
||||
|
||||
} else {
|
||||
$iDb = new WDB();
|
||||
$iDb->insert('siren_inexistants', array(
|
||||
@ -626,18 +634,18 @@ class Entreprise extends WsScore
|
||||
$info = 'Aucun ';
|
||||
if ( $siege == 1 ) $info.= 'siege';
|
||||
else $info.= 'etablissement';
|
||||
|
||||
|
||||
if ( $actif == 0 ) $info.= ' inactif';
|
||||
elseif ( $actif == 1) $info.= ' actif';
|
||||
|
||||
|
||||
$rep['info'] = $info;
|
||||
|
||||
|
||||
} else {
|
||||
$rep['info'] = 'Siren inexistant';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$output = new SearchReturn();
|
||||
$output->nbReponses = $nbReponses;
|
||||
$output->nbReponsesTotal = $nbReponsesTotal;
|
||||
@ -645,7 +653,7 @@ class Entreprise extends WsScore
|
||||
$output->info = $rep['info'];
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne les liens financiers pour une entreprise.
|
||||
*
|
||||
@ -655,12 +663,12 @@ class Entreprise extends WsScore
|
||||
public function getLiens($siren)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
|
||||
//Initialisation
|
||||
$actifsUniquement = true;
|
||||
|
||||
$tabAct = $tabPar = array();
|
||||
|
||||
|
||||
debugLog('I',"Liens entreprises demandés pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
if (strlen($siren)<>9){
|
||||
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
@ -669,7 +677,7 @@ class Entreprise extends WsScore
|
||||
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
|
||||
$mLiens = new MLiens($siren);
|
||||
$tabA = $mLiens->getActionnaires($siren, $actifsUniquement);
|
||||
$nbA = count($tabA);
|
||||
@ -689,7 +697,7 @@ class Entreprise extends WsScore
|
||||
$actionnaire->Source = $lien['Source'];
|
||||
$actionnaire->DateLien = $lien['DateLien']; //@todo : date
|
||||
$actionnaire->DateMaj = $lien['DateMaj']; //@todo : date
|
||||
|
||||
|
||||
$actionnaire->Identite = new ActionnaireIdentite();
|
||||
if (!empty($lien['Siren'])) {
|
||||
$iInsee = new MInsee();
|
||||
@ -706,19 +714,19 @@ class Entreprise extends WsScore
|
||||
$actionnaire->Identite->FJ = $identite['FJ'];
|
||||
$actionnaire->Identite->FJ_Lib = $identite['FJ_Lib'];
|
||||
}
|
||||
|
||||
|
||||
//Si actionnaire majoritaire > 50 % alors on arrete tout
|
||||
if ($lien['Pmin']>50) {
|
||||
$tabAct = array();
|
||||
$tabAct[] = $actionnaire;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$tabAct[] = $actionnaire;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->wsLog('liens',$siren);
|
||||
return $tabAct;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user