diff --git a/application/controllers/FichierController.php b/application/controllers/FichierController.php index 868ca9c0..8556c47c 100644 --- a/application/controllers/FichierController.php +++ b/application/controllers/FichierController.php @@ -62,7 +62,7 @@ class FichierController extends Zend_Controller_Action $file = $this->getRequest()->getParam('fichier'); $content_type = 'application/csv-tab-delimited-table'; $c = Zend_Registry::get('config'); - $path = APPLICATION_PATH . '/../data/files/'; + $path = $c->profil->path->files . '/'; //Envoi du fichier sur la sortie standard if ( file_exists($path.$file) ) { header('Content-Transfer-Encoding: none'); @@ -82,7 +82,7 @@ class FichierController extends Zend_Controller_Action $file = $this->getRequest()->getParam('fichier'); $content_type = 'application/csv-tab-delimited-table'; $c = Zend_Registry::get('config'); - $path = APPLICATION_PATH . '/../data/files/'; + $path = $c->profil->path->files . '/'; //Envoi du fichier sur la sortie standard if ( file_exists($path.$file) ) { header('Content-Transfer-Encoding: none'); @@ -122,7 +122,7 @@ class FichierController extends Zend_Controller_Action $file = $this->getRequest()->getParam('fichier'); $content_type = 'application/pdf'; $c = Zend_Registry::get('config'); - $path = APPLICATION_PATH . '/../data/files/associations/'; + $path = $c->profil->path->files . '/'; //Envoi du fichier sur la sortie standard if ( file_exists($path.$file) ) { header('Content-Transfer-Encoding: none'); @@ -142,7 +142,7 @@ class FichierController extends Zend_Controller_Action $file = $this->getRequest()->getParam('fichier'); $content_type = 'application/pdf'; $c = Zend_Registry::get('config'); - $path = APPLICATION_PATH . '/../data/files/greffes/'; + $path = $c->profil->path->files . '/'; //Envoi du fichier sur la sortie standard if ( file_exists($path.$file) ) { header('Content-Transfer-Encoding: none'); diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 7421111b..ad38f7cc 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -162,7 +162,7 @@ class ServiceController extends Zend_Controller_Action $server->setEncoding('UTF-8'); $server->registerFaultException(array('Scores_Ws_Exception')); $server->setWsiCompliant(true); - $server->setObject(new $serviceClassName()); + $server->setObject(new $serviceClassName()); $server->handle(); //Pour débuggage ultime diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 19e2b78b..afbde52c 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -72,6 +72,70 @@ class UserController extends Zend_Controller_Action $this->view->login = $login; $this->view->authorizationHeader = base64_encode($login.':'.$pass); + + $userM = new Application_Model_Sdv1Utilisateurs(); + $sql = $userM->select()->where('id=?', $identity->id); + $user = $userM->fetchRow($sql); + + $this->view->IdFullName = $user->civilite . ' ' . $user->nom . ' ' . $user->prenom; + $this->view->IdEmail = $user->email; + + //Liste des droits + $listdroit = explode(' ', $user->droits); + + //Association méthodes - droits + $assoc = array( + 'getAnnoncesAsso' => array('ANNONCES'), + 'getAnnoncesBalo' => array('ANNONCES'), + 'getAnnoncesBoamp' => array('ANNONCES'), + 'getAnnoncesLegales' => array('ANNONCES'), + 'getAnnoncesNum' => array('ANNONCES'), + 'getAvisRncs' => array('AVISRNCS'), + 'getBanques' => array('BANQUES'), + 'getBilan' => array('LIASSE'), + 'getDirigeants' => array('DIRIGEANTS'), + 'getIdentite' => array('IDENTITE'), + 'getIdentiteProcol' => array('IDPROCOL'), + 'getIndiScore' => array('INDISCORE1', 'INDISCORE2', 'INDISCORE3'), + 'getInfosBourse' => array('BOURSE'), + 'getInfosReg' => array('INFOSREG'), + 'getLiasseInfos' => array(), + 'getLienRef' => array('LIENS'), + 'getLiens' => array('LIENS'), + 'getLiensById' => array('LIENS'), + 'getListeBilans' => array('LIASSE'), + 'getListeCompetences' => array('COMPETENCES'), + 'getListeEtablissements' => array('ETABLISSEMENTS'), + 'getListeEvenements' => array('EVENINSEE'), + 'getRapport' => array('INDISCORE3'), + 'getRatios' => array('RATIOS'), + 'getSubventionDetail' => array(''), + 'getSubventionList' => array(''), + 'getTVA' => array(''), + 'getValo' => array('VALORISATION'), + 'isSirenExistant' => array(''), + 'searchAutreId' => array('SEARCHENT'), + 'searchDir' => array('SEARCHDIR'), + 'searchEntreprise' => array('SEARCHENT'), + 'searchNomAdr' => array('SEARCHENT'), + 'searchRefClient' => array(), + 'searchSiren' => array('SEARCHENT'), + 'searchTelFax' => array('SEARCHENT'), + ); + + $display = array(); + foreach ( $listdroit as $droit ) { + foreach ( $assoc as $l => $d ) { + if ( in_array(strtoupper($droit), $d) ) { + $display[] = array( + 'label' => $l, + 'droit' => $droit, + ); + } + } + } + $this->view->display = $display; + } } \ No newline at end of file diff --git a/application/views/scripts/user/params.phtml b/application/views/scripts/user/params.phtml index 015a6223..f388a1fc 100644 --- a/application/views/scripts/user/params.phtml +++ b/application/views/scripts/user/params.phtml @@ -1,9 +1,11 @@

Identité

-Rappel de l'identité + changement de mot de passe - - +
+

Login : login?>

+ IdFullName?>
+ IdEmail?> +

Authorization Header

@@ -14,4 +16,21 @@ Base64("login?>:*****") = "authorizationHeader;?>"
-Liste des droits \ No newline at end of file + + + + + + + + +display)>0 ) {?> +display as $d ) {?> + + + + + + + +
MéthodeDroit
\ No newline at end of file diff --git a/library/Application/Model/InseeDepartements.php b/library/Application/Model/InseeDepartements.php new file mode 100644 index 00000000..fc875da9 --- /dev/null +++ b/library/Application/Model/InseeDepartements.php @@ -0,0 +1,6 @@ + dirname(__FILE__) . '/Model/ExtractionCommandes.php', 'Application_Model_FedasoBilans' => dirname(__FILE__) . '/Model/FedasoBilans.php', 'Application_Model_HistoriquesBilans' => dirname(__FILE__) . '/Model/HistoriquesBilans.php', + 'Application_Model_InseeDepartements' => dirname(__FILE__) . '/Model/InseeDepartements.php', 'Application_Model_InseeTabVilles' => dirname(__FILE__) . '/Model/InseeTabVilles.php', 'Application_Model_JoAssoBilans' => dirname(__FILE__) . '/Model/JoAssoBilans.php', 'Application_Model_JoAssoSubventions' => dirname(__FILE__) . '/Model/JoAssoSubventions.php', diff --git a/library/Metier/Infogreffe/Infogreffe.php b/library/Metier/Infogreffe/Infogreffe.php index 655ab8d0..b9c77675 100644 --- a/library/Metier/Infogreffe/Infogreffe.php +++ b/library/Metier/Infogreffe/Infogreffe.php @@ -124,7 +124,11 @@ class Metier_Infogreffe public function __construct() { //Load configuration - $c = Zend_Registry::get('config'); + if ( Zend_Registry::isRegistered('config') ){ + $c = Zend_Registry::get('config'); + } else { + $c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production'); + } $this->config = $c->profil->infogreffe; if ( null === $this->config ) { throw new Exception('Unable to load configuration file.'); diff --git a/library/Metier/Infogreffe/InfogreffeAc.php b/library/Metier/Infogreffe/InfogreffeAc.php index af2148d4..bdda1c1b 100644 --- a/library/Metier/Infogreffe/InfogreffeAc.php +++ b/library/Metier/Infogreffe/InfogreffeAc.php @@ -7,6 +7,8 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Infogreffe.php'; class Metier_Infogreffe_Ac extends Metier_Infogreffe { + const INT = 1000; + /** * Db Adapter * @var Zend_Db_Adapter_Abstract @@ -209,7 +211,7 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe //Check if filename exist if ( !file_exists($this->config->storage->path . '/' . $filename) ) { - throw new Exception('File not found', 'INT'); + throw new Exception('File not found', self::INT); } } elseif ( file_exists($this->config->storage->path . '/' . $filename) ) { diff --git a/library/Metier/Infogreffe/InfogreffeBi.php b/library/Metier/Infogreffe/InfogreffeBi.php index df5579ed..0097de27 100644 --- a/library/Metier/Infogreffe/InfogreffeBi.php +++ b/library/Metier/Infogreffe/InfogreffeBi.php @@ -7,6 +7,8 @@ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Infogreffe.php'; class Metier_Infogreffe_Bi extends Metier_Infogreffe { + const INT = 1000; + /** * Db Adapter * @var Zend_Db_Adapter_Abstract @@ -127,6 +129,11 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe $item->ModeDiffusion = ''; } $item->DureeExercice = $row->duree_exercice; + + /** + * Following data are not as expected as the type and other data could change + * Only num depot don't change. + */ $item->SaisieDate = $row->saisie_date; $item->SaisieCode = $row->saisie_code; switch ( $row->saisie_code ) { @@ -220,7 +227,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe //Check if filename exist if ( !file_exists($this->config->storage->path . '/' . $filename) ) { - throw new Exception('File not found', 'INT'); + throw new Exception('File not found', self::INT); } } elseif ( file_exists($this->config->storage->path . '/' . $filename) ) { diff --git a/library/Metier/Infogreffe/InfogreffeSt.php b/library/Metier/Infogreffe/InfogreffeSt.php index b3d9bbc7..383a7663 100644 --- a/library/Metier/Infogreffe/InfogreffeSt.php +++ b/library/Metier/Infogreffe/InfogreffeSt.php @@ -1 +1,167 @@ type_document = 'ST'; + + //Set Siren + $this->siren = $siren; + + //Get defaut database adapter + if ($db === null) { + $this->db = Zend_Db_Table_Abstract::getDefaultAdapter(); + } else { + $this->db = $db; + } + } + + public function getList() + { + + } + + public function getCommandeT() + { + + $this->mode_diffusion = 'T'; + $this->reference_client = 'T'.date('YmdHis'); + + //Set the filename + $filename = $this->getFilePath($type, $dateCloture) . '/' . $this->getFileName($type, $dateCloture); + + try { + $xml = $this->callRequest(); + } catch(Exception $e) { + throw new Exception($e->getMessage(), $e->getCode()); + } + + $item = $this->formatItem($xml); + $url = $item['url_acces']; + if ( empty($url) ) { + throw new Exception('File url not given'); + } + + if ( $orderId !== null ) { + $commandeM = new Application_Model_Sdv1GreffeCommandesBi(); + $commandeM->update(array( + 'cmdUrl'=> $url, + 'dateCommande' => date('YmdHis'), + ), 'id='.$orderId); + } + + //Récupérer le fichier + $getfile = $this->download($url, $filename); + + //Analyser le fichier - Nombre de page et taille + $infos = $this->pdfInfos($getfile); + + //Enregistrer les infos du fichier dans la base de données + if (false !== $infos) { + $this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']); + } else { + $this->dbSetFile(basename($filename)); + } + + + return $filename; + } + + /** + * Name of file + * @param string $type + * @param string $dateCloture + * Format : AAAA-MM-JJ + * @return string + */ + public function getFileName($type, $dateCloture) + { + if ($type=='') { + $type = 'sociaux'; + } + $date = substr($dateCloture,0,4).substr($dateCloture,5,2).substr($dateCloture,8,2); + + return 'ST-' . $this->siren . '-' . $type . '-' . $date . '.pdf'; + } + + /** + * Path of file + * @param string $type + * @param string $dateCloture + * Format : AAAA-MM-JJ + * @return string + */ + public function getFilePath($type, $dateCloture) + { + if ($type=='') { + $type = 'sociaux'; + } + $dir = 'bilans' . '/' . $type . '/' . substr($dateCloture,0,4); + if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) { + mkdir($this->config->storage->path . '/' . $dir, 0777, true); + } + return $dir; + } + + /** + * Format XML to Array for a list of items + * @param string $xml + * @return array + */ + protected function formatList($xml) + { + + } + + /** + * Format XML to Array for one item + * @param string $xml + * @return array + */ + protected function formatItem($xml) + { + + } + + /** + * Update informations about an item in database + * @param array $list + * @return boolean + */ + protected function dbUpdateItem($list) + { + + } + + /** + * Set file informations in database + * @param string $filename + * @param int $size + * @param int $numberOfPage + * @param string $version + * @return boolean + */ + public function dbSetFile($filename, $size = 0, $numberOfPage = '', $version = '') + { + + } +} \ No newline at end of file diff --git a/library/Metier/insee/classMInsee.php b/library/Metier/insee/classMInsee.php index ddc631be..d9ad93a2 100644 --- a/library/Metier/insee/classMInsee.php +++ b/library/Metier/insee/classMInsee.php @@ -1658,7 +1658,7 @@ class MInsee } - // + //Vérification du SIREN if ($nbTot==0 && $actif==-1) { require_once 'Metier/sphinx/rechercheFonc.php'; @@ -1682,6 +1682,7 @@ class MInsee } } + //Affichage de la liste des établissements if ( count($listeEtab)>0 ) { foreach ($listeEtab as $etab) { $tel=sprintf('%010d', strtr($etab['tel'],array('-'=>'', '/'=>'','.'=>'',','=>''))); diff --git a/library/Metier/partenaires/classMLiens2.php b/library/Metier/partenaires/classMLiens2.php index a9e17ff7..fc26c113 100644 --- a/library/Metier/partenaires/classMLiens2.php +++ b/library/Metier/partenaires/classMLiens2.php @@ -207,7 +207,7 @@ class MLiens2 try { $directionsM = new Application_Model_JoRncsDirigeants(); $sql = $directionsM->select()->from($directionsM, array( - 'siren','raisonSociale', 'dirSiren', 'dirRS', 'civilite', 'nom', + 'LPAD(siren, 9, 000000000) AS siren','raisonSociale', 'dirSiren', 'dirRS', 'civilite', 'nom', 'prenom', 'naissance_date', 'naissance_lieu', 'fonction_code', 'fonction_lib' ))->where("typeDir IN ('PM', 'PP')")->where('dirSiren=?', $siren); diff --git a/library/Metier/partenaires/classMRncs.php b/library/Metier/partenaires/classMRncs.php index 5b8ff8c1..2b28cb3a 100644 --- a/library/Metier/partenaires/classMRncs.php +++ b/library/Metier/partenaires/classMRncs.php @@ -409,6 +409,7 @@ class MRncs 'nomCommercial' => strtoupper($entrep['nomCommercial']), 'adrNumVoie' => $entrep['adrNumVoie'], 'adrIndRep' => strtoupper($entrep['adrIndRep']), + 'adrLibVoie' => strtoupper($entrep['adrLibVoie']), 'adrTypeVoie' => strtoupper($entrep['adrTypeVoie']), 'adrVoie' => strtoupper($entrep['adrVoie']), 'adrComp' => strtoupper($entrep['adrComp']), @@ -520,60 +521,61 @@ class MRncs public function getListeJugements($siren) { $siren=$siren*1; - $rep=$this->iDb->select('rncs_jugements j, tabJugeRncs l, tabEvenements e', - 'siren, j.dateEffet, j.codeJugement, j.flux, l.libJugement, e.codEven, e.libEven, - adm1id, adm1codeFct, adm1type, adm1nom, adm1adrNum, adm1adrInd, adm1adrType, adm1adrLibVoie, adm1adrVoie, adm1adr1, adm1adr2, adm1adr3, adm1adrCP, adm1adrVille, - adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille', - "j.siren=$siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC", false, MYSQL_ASSOC); - /*adm1adrNum adm1adrInd adm1adrType adm1adrLibVoie adm1adrVoie adm1adr1 adm1adr2 adm1adr3 adm1adrCP adm1adrVille adm2codeFct adm2type adm2id adm2nom adm2adrNum adm2adrInd adm2adrType adm2adrLibVoie adm2adrVoie adm2adr1 adm2adr2 adm2adr3 adm2adrCP adm2adrVille flux dateSuppr dateInsert - Modifier Effacer 490524055 2010-12-20 11 1 1200 4000 A 0 ME TULIER 0000 IMM LE MAZIERE 4EME ETAGE Immeuble le Mazière - 4ème étage rue René Cassin */ + $rep=$this->iDb->select( + 'rncs_jugements j, tabJugeRncs l, tabEvenements e', + 'siren, j.dateEffet, j.codeJugement, j.flux, l.libJugement, e.codEven, e.libEven, + adm1id, adm1codeFct, adm1type, adm1nom, adm1adrNum, adm1adrInd, adm1adrType, adm1adrLibVoie, adm1adrVoie, adm1adr1, adm1adr2, adm1adr3, adm1adrCP, adm1adrVille, + adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille', + "j.siren=$siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC", false, MYSQL_ASSOC); $tabDepots=array(); foreach ($rep as $iDepot=>$depot) { - $tabDepots[]=array( 'codEven' => $depot['codEven'], - 'libEven' => $depot['libEven'], - 'dateEffet' => $depot['dateEffet'], - 'adm1id' => $depot['adm1id'], - 'adm1code' => $depot['adm1codeFct'], - 'adm1type' => $depot['adm1type'], - 'adm1fonction' => @$this->getLibFctDir($depot['adm1codeFct']), - 'adm1nom' => $depot['adm1nom'], - 'adm1adrNum' => $depot['adm1adrNum'], - 'adm1adrInd' => $depot['adm1adrInd'], - 'adm1adrType' => $depot['adm1adrType'], - 'adm1adrVoie' => $depot['adm1adrLibVoie'], // @todo : adm1adr1, , adm1adr3, - 'adm1adr2' => $depot['adm1adr2'], - 'adm1adrCP' => $depot['adm1adrCP'], - 'adm1adrVille' => $depot['adm1adrVille'], - 'adm2id' => $depot['adm2id'], - 'adm2code' => $depot['adm2codeFct'], - 'adm2type' => $depot['adm2type'], - 'adm2fonction' => @$this->getLibFctDir($depot['adm2codeFct']), - 'adm2nom' => $depot['adm2nom'], - 'adm2adrNum' => $depot['adm2adrNum'], - 'adm2adrInd' => $depot['adm2adrInd'], - 'adm2adrType' => $depot['adm2adrType'], - 'adm2adrVoie' => $depot['adm2adrLibVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3, - 'adm2adr2' => $depot['adm2adr2'], - 'adm2adrCP' => $depot['adm2adrCP'], - 'adm2adrVille' => $depot['adm2adrVille'], - ); + $tabDepots[]=array( + 'codEven' => $depot['codEven'], + 'libEven' => $depot['libEven'], + 'dateEffet' => $depot['dateEffet'], + 'adm1id' => $depot['adm1id'], + 'adm1code' => $depot['adm1codeFct'], + 'adm1type' => $depot['adm1type'], + 'adm1fonction' => @$this->getLibFctDir($depot['adm1codeFct']), + 'adm1nom' => $depot['adm1nom'], + 'adm1adrNum' => $depot['adm1adrNum'], + 'adm1adrInd' => $depot['adm1adrInd'], + 'adm1adrType' => $depot['adm1adrType'], + 'adm1adrVoie' => $depot['adm1adrLibVoie'], // @todo : adm1adr1, , adm1adr3, + 'adm1adr2' => $depot['adm1adr2'], + 'adm1adrCP' => $depot['adm1adrCP'], + 'adm1adrVille' => $depot['adm1adrVille'], + 'adm2id' => $depot['adm2id'], + 'adm2code' => $depot['adm2codeFct'], + 'adm2type' => $depot['adm2type'], + 'adm2fonction' => @$this->getLibFctDir($depot['adm2codeFct']), + 'adm2nom' => $depot['adm2nom'], + 'adm2adrNum' => $depot['adm2adrNum'], + 'adm2adrInd' => $depot['adm2adrInd'], + 'adm2adrType' => $depot['adm2adrType'], + 'adm2adrVoie' => $depot['adm2adrLibVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3, + 'adm2adr2' => $depot['adm2adr2'], + 'adm2adrCP' => $depot['adm2adrCP'], + 'adm2adrVille' => $depot['adm2adrVille'], + ); } return $tabDepots; } public function getEvenements($siren, $nic=0, $type='', $dateDeb='', $dateFin='') { - $tabEven=array( 'p120'=>'Réactivation de l\'entreprise', - 'p410'=>'Cessation juridique de l\'entreprise', - 'pCAP'=>'Modification du capital social', - 'pCAT'=>'Modification du type de capital', - 'pCJ' =>'Modification de la forme juridique', - 'pIMM'=>'Modification de la date d\'immatriculation', - 'pRAD'=>'Modification de la date de radiation', - 'pNTR'=>'Modification du greffe d\'enregistrement', - 'pNRC'=>'Modification du numéro du RC', - 'pNOM'=>'Modification de la dénomination', - ); + $tabEven=array( + 'p120'=>'Réactivation de l\'entreprise', + 'p410'=>'Cessation juridique de l\'entreprise', + 'pCAP'=>'Modification du capital social', + 'pCAT'=>'Modification du type de capital', + 'pCJ' =>'Modification de la forme juridique', + 'pIMM'=>'Modification de la date d\'immatriculation', + 'pRAD'=>'Modification de la date de radiation', + 'pNTR'=>'Modification du greffe d\'enregistrement', + 'pNRC'=>'Modification du numéro du RC', + 'pNOM'=>'Modification de la dénomination', + ); $tabRet=array(); $siren=$siren*1; if ($nic>0) $strNic =" AND nic=$nic "; @@ -581,9 +583,10 @@ class MRncs if ($dateDeb<>'') $strDateDeb=" AND flux>='$dateDeb' "; if ($dateFin<>'') $strDateFin=" AND flux<='$dateFin' "; - $rep=$this->iDb->select('rncs_modifs', - 'siren, nic, `table`, champs, valeur, flux, dateInsert', - "siren=$siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep' ORDER BY flux DESC", false, MYSQL_ASSOC); + $rep=$this->iDb->select( + 'rncs_modifs', + 'siren, nic, `table`, champs, valeur, flux, dateInsert', + "siren=$siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep' ORDER BY flux DESC", false, MYSQL_ASSOC); foreach ($rep as $iModif=>$modif) { $codEve=array(); switch($modif['champs']) { @@ -600,17 +603,19 @@ class MRncs case 'numGreffe': $codEve[]='NTR'; break; case 'numRC2': $codEve[]='NRC'; break; } - foreach ($codEve as $even) - $tabRet[]=array('codeEven' => 'P'.$even, - 'nic' => 0, - 'siretAssocie'=>0, - 'typeSiretAss'=>0, - 'siege' => 1, - 'libEven' => $tabEven['p'.trim($even)], - 'libEvenDet'=> '', - 'dateMAJ' => $modif['dateInsert'], - 'dateEven' => $modif['flux'], - ); + foreach ($codEve as $even) { + $tabRet[]=array( + 'codeEven' => 'P'.$even, + 'nic' => 0, + 'siretAssocie'=>0, + 'typeSiretAss'=>0, + 'siege' => 1, + 'libEven' => $tabEven['p'.trim($even)], + 'libEvenDet'=> '', + 'dateMAJ' => $modif['dateInsert'], + 'dateEven' => $modif['flux'], + ); + } } } diff --git a/library/Scores/Ws/Server.php b/library/Scores/Ws/Server.php index 6523fc62..38e7f5aa 100644 --- a/library/Scores/Ws/Server.php +++ b/library/Scores/Ws/Server.php @@ -18,7 +18,19 @@ class Scores_Ws_Server * User information * @var array */ - protected $tabInfoUser; + protected $User; + + /** + * Is user authenticated + * @var boolean + */ + protected $authenticated = false; + + /** + * Authenticated method (Basic, SoapHeader) + * @var string + */ + protected $authMethod = null; /** * Name of Service @@ -376,7 +388,7 @@ class Scores_Ws_Server protected function wsLog($service, $siret='', $ref='') { //Is it a test - if ( $this->tabInfoUser['clientTest']=='Oui' || $this->tabInfoUser['typeCompte']=='TEST' ) { + if ( $this->User->clientTest=='Oui' || $this->User->typeCompte=='TEST' ) { $test=1; } else { $test=0; @@ -386,19 +398,25 @@ class Scores_Ws_Server $siren = substr($siret,0,9); $nic = substr($siret,9,5); } elseif ( strlen($siret) == 9 ) { - $siren=$siret; - $nic=''; + $siren = $siret; + $nic = ''; } + // Set data by default $dataInsert = array( - 'login' => $this->tabInfoUser['login'], - 'idClient' => $this->tabInfoUser['idClient'], + 'login' => $this->User->login, 'page' => $service, 'siren' => $siren, 'nic' => $nic, 'params' => $ref, + 'idClient' => $this->User->idClient, 'test' => $test, - 'ipClient' => $this->tabInfoUser['ipConnexion'], + 'actifInsee' => 0, + 'source' => 0, + 'raisonSociale' => '', + 'cp' => '', + 'ville' => '', + 'ipClient' => $this->User->ipConnexion, ); $db = Zend_Db_Table_Abstract::getDefaultAdapter(); @@ -428,13 +446,10 @@ class Scores_Ws_Server } if ( $result !== null ) { - //file_put_contents('lecture.log', print_r($result,1)); - $dataInsert['raisonSociale'] = $result->raisonSociale; $dataInsert['cp'] = $result->adr_cp; $dataInsert['ville'] = $result->adr_ville; - $dataInsert['source'] = $result->source; if ( $result->actif == 0 ) { $dataInsert['actifInsee'] = 0; @@ -460,23 +475,56 @@ class Scores_Ws_Server } } - /** - * Retourne une erreur soap lors d'une mauvaise authentification - * @throws SoapFault - */ - protected function authenticate() + /** + * Authenticate with SoapHeader, Optional (Authentication could be done by sending HTTP Basic header - see the doc) + * @param string $username + * @param string $password + * @throws SoapFault + */ + public function authenticate($username = null, $password = null) { - /** - * @todo : Detect auth method - * Basic - Digest - Key - Cert - */ + if ( $this->authenticated === false ) { - $auth = $this->checkAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR']); - if ( $auth === false ) { - $this->sendError('0900'); - } elseif ( $auth !== true ) { - $this->sendError($auth); - } + if ( empty($username) ) { + /** + * @todo : Digest auth + */ + $this->authMethod = 'basic'; + $username = $_SERVER['PHP_AUTH_USER']; + $password = $_SERVER['PHP_AUTH_PW']; + + } else { + /** + * Auth Header in client + * $ns = 'auth'; + * //Create our Auth Object to pass to the SOAP service with our values + * $auth = new StdClass(); + * $auth->username = 'yourlogin'; + * $auth->password = 'yourpassword'; + * $creds = new SoapVar($auth, SOAP_ENC_OBJECT); + * + * //The 2nd variable, 'authenticate' is a method that exists inside of the SOAP service (you must create it, see next example) + * $authenticate = new SoapHeader($ns, 'authenticate', $creds, false); + * + * $client->__setSoapHeaders($authenticate); + * + */ + $this->authMethod = 'soapheader'; + } + + /** + * @todo : with proxy get the original IP + * $request->getClientIp(true); + */ + + $this->authenticated = $this->checkAuth($username, $password, $_SERVER['REMOTE_ADDR']); + if ( $this->authenticated === false ) { + $this->sendError('0900'); + } elseif ( $this->authenticated !== true ) { + $this->sendError($this->authenticated); + } + + } } /** @@ -497,7 +545,7 @@ class Scores_Ws_Server protected function checkAccesWS() { //Vérifier que l'utilisateur à le droit accesWS (clients/utilisateurs) - $accesWs = $this->tabInfoUser['accesWS']; + $accesWs = $this->User->accesWS; if ($accesWs){ $this->sendError('0901'); } @@ -510,7 +558,7 @@ class Scores_Ws_Server */ protected function checkPerm($perm) { - $droits = $this->tabInfoUser['droits']; + $droits = $this->User->droits; $output = false; if ( preg_match('/\b'.$perm.'\b/i', $droits) ){ $output = true; @@ -523,7 +571,7 @@ class Scores_Ws_Server */ protected function checkEdition() { - if ($this->tabInfoUser['idClient']==1) + if ($this->User->idClient==1) return true; if ($this->checkPerm('edition')) @@ -567,6 +615,14 @@ class Scores_Ws_Server return false; } + /** + * @todo : + * Check how password is check + * md5 => standard method md5 ( login | password ) + * key => get associated key with crypt method + * cert => get associated certificat + */ + // Check password with database informations if ( $result->password == $password //password sent in clear || md5($result->password) == $password //password sent with md5 @@ -581,40 +637,37 @@ class Scores_Ws_Server if ($timeout==0) $timeout = 1800; //Infos utilisateur - $this->tabInfoUser = array( - 'login' => $result->login, - 'id' => $result->id, - 'civilite' => $result->civilite, - 'nom' => $result->nom, - 'prenom' => $result->prenom, - 'tel' => $result->tel, - 'fax' => $result->fax, - 'mobile' => $result->mobile, - 'email' => $result->email, - 'typeCompte' => $result->typeCompte, - 'idClient' => $result->idClient, - 'Service' => $result->Service, - 'filtre_ip' => $result->filtre_ip, - 'ipConnexion' => $ipConnexion, - 'pref' => $result->pref, - 'rechRefType' => $result->rechRefType, - 'profil' => $result->profil, - 'nombreConnexions' => $result->nombreConnexions, - 'dateDerniereConnexion' => $result->dateDerniereConnexion, - 'droits' => $result->droits, - 'droitsClients' => $result->droitsClients, - 'timeout' => $timeout, - 'clientTest' => $result->clientTest, - 'typeScore' => $result->typeScore, - 'nbReponses' => $result->nbReponses, - 'lang' => $result->lang, - 'formatMail' => $result->formatMail, - 'referenceParDefaut' => $result->referenceParDefaut, - 'dateDebutCompte' => $result->dateDebutCompte, - 'dateFinCompte' => $result->dateFinCompte, - 'acceptationCGU' => $result->acceptationCGU - ); - debugLog('W',"CheckAuth $login/$password OK", __LINE__,__FILE__, __FUNCTION__, __CLASS__); + $this->User->login = $result->login; + $this->User->id = $result->id; + $this->User->civilite = $result->civilite; + $this->User->nom = $result->nom; + $this->User->prenom = $result->prenom; + $this->User->tel = $result->tel; + $this->User->fax = $result->fax; + $this->User->mobile = $result->mobile; + $this->User->email = $result->email; + $this->User->typeCompte = $result->typeCompte; + $this->User->idClient = $result->idClient; + $this->User->Service = $result->Service; + $this->User->filtre_ip = $result->filtre_ip; + $this->User->ipConnexion = $ipConnexion; + $this->User->pref = $result->pref; + $this->User->rechRefType = $result->rechRefType; + $this->User->profil = $result->profil; + $this->User->nombreConnexions = $result->nombreConnexions; + $this->User->dateDerniereConnexion = $result->dateDerniereConnexion; + $this->User->droits = $result->droits; + $this->User->droitsClients = $result->droitsClients; + $this->User->timeout = $timeout; + $this->User->clientTest = $result->clientTest; + $this->User->typeScore = $result->typeScore; + $this->User->nbReponses = $result->nbReponses; + $this->User->lang = $result->lang; + $this->User->formatMail = $result->formatMail; + $this->User->referenceParDefaut = $result->referenceParDefaut; + $this->User->dateDebutCompte = $result->dateDebutCompte; + $this->User->dateFinCompte = $result->dateFinCompte; + $this->User->acceptationCGU = $result->acceptationCGU; /** * Date de debut de compte @@ -657,9 +710,9 @@ class Scores_Ws_Server $wsClients[$params['idClient']] = $section; } } - if ( array_key_exists($this->tabInfoUser['idClient'], $wsClients) + if ( array_key_exists($result->idClient, $wsClients) && ( $this->serviceClient == false - || strtolower($this->serviceClientName)!=$wsClients[$this->tabInfoUser['idClient']] ) ){ + || strtolower($this->serviceClientName)!=$wsClients[$result->idClient] ) ){ return '0901'; } diff --git a/library/Vendors/geshi/.gitignore b/library/Vendors/geshi/.gitignore new file mode 100644 index 00000000..1377554e --- /dev/null +++ b/library/Vendors/geshi/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/library/Vendors/geshi/contrib/.gitignore b/library/Vendors/geshi/contrib/.gitignore new file mode 100644 index 00000000..1377554e --- /dev/null +++ b/library/Vendors/geshi/contrib/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/library/Vendors/geshi/contrib/aliased.php b/library/Vendors/geshi/contrib/aliased.php index 32bec923..49302236 100644 --- a/library/Vendors/geshi/contrib/aliased.php +++ b/library/Vendors/geshi/contrib/aliased.php @@ -13,7 +13,7 @@ * aliased.php/file.name.ext. * * @author Ross Golder - * @version $Id: aliased.php 785 2006-07-19 10:09:45Z oracleshinoda $ + * @version $Id$ */ // Your config here @@ -29,19 +29,18 @@ $path = SOURCE_ROOT.$_SERVER['PATH_INFO']; $base_path_len = strlen(SOURCE_ROOT); $real_path = realpath($path); if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) { - exit("Stop that."); + exit("Access outside acceptable path."); } // Check file exists if(!file_exists($path)) { - exit("File not found ($path)."); + exit("File not found ($path)."); } -// Gather contents -$contents = file_get_contents($path); - // Prepare GeSHi instance -$geshi =& new GeSHi($contents, "PHP"); +$geshi = new GeSHi(); +$geshi->set_language('text'); +$geshi->load_from_file($path); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_classes(); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); @@ -50,7 +49,7 @@ $geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monosp $geshi->set_code_style('color: #000020;', 'color: #000020;'); $geshi->set_link_styles(GESHI_LINK, 'color: #000060;'); $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); -$geshi->set_header_content('Source code viewer'); +$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name()); $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;'); $geshi->set_footer_content('Parsed in