Merge from 2.7

This commit is contained in:
Michael RICOIS 2015-05-25 14:16:33 +00:00
commit aef8f4d490
6 changed files with 126 additions and 101 deletions

View File

@ -46,10 +46,12 @@ class Application_Controller_Plugin_Menu extends Zend_Controller_Plugin_Abstract
// --- Secure demo mode
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
if ($user->idClient != 1) {
$toSecure = $container->findOneBy('Label', "Démonstration");
$container->removePage($toSecure);
if ($auth->hasIdentity()) {
$user = $auth->getIdentity();
if ($user->idClient != 1) {
$toSecure = $container->findOneBy('Label', "Démonstration");
$container->removePage($toSecure);
}
}
$view->navigation($container);

View File

@ -172,7 +172,7 @@ return array(
"DH" => "MAD",
"EUROS, CRÉATION L'AUTRE BRANCHE ACTIVITÉ" => "EUR",
"LEI ROUMAIN" => "RON",
"$HGK" => "HKD",
"HGK" => "HKD",
"EUROS, ÉTANT PRÉCISÉ QUE LE CÉDANT A CON" => "EUR",
"DZD" => "DZD",
"DON" => "VND",

View File

@ -1584,47 +1584,47 @@ class MInsee
if ($strLigneDAdresse=='') return $tabRet;
$tabLignes=explode(',', preg_replace('/,$/', '', $strLigneDAdresse));
foreach ($tabLignes as $strLigneDAdresse) {
$strLigneDAdresse=trimAccent($strLigneDAdresse);
$strLigneDAdresse=preg_replace('/[^0-9a-zA-Z]/', ' ', $strLigneDAdresse);
$strLigneDAdresse=trim(preg_replace('/ +/', ' ', $strLigneDAdresse));
//echo "1. Adresse nettoyées = $strLigneDAdresse".EOL;
$adrAvecCP=preg_match("/(.*)([0-9]{5,5}|[0-9][0-9] [0-9]{3,3})([\D]*)/", $strLigneDAdresse, $tabAdrTmp);
if ($adrAvecCP) {
//echo "Adresse avec Code Postal\n";
//print_r($tabAdrTmp);
$strLigneDAdresse=trim($tabAdrTmp[1]);
$tabRet['cp']=$tabAdrTmp[2];
$tabRet['ville']=trim(strtoupper($tabAdrTmp[3]));
}// else echo "Adresse sans Code Postal\n";
$adrAvecNum=preg_match("/^([0-9]{1,4})(.*)/", $strLigneDAdresse, $tabAdrTmp);
if ($adrAvecNum) {
//echo "Adresse avec Numéro de voie\n";
//print_r($tabAdrTmp);
$tabRet['num']=$tabAdrTmp[1];
if (preg_match("/^\s(B|BIS|T|TER|Q|a|c|d|e|f|g|h|i|j|k|l|m|n|o|p|s)\s(.*)/i", $tabAdrTmp[2], $tabAdrTmp2))
{ //echo "Adresse avec Bis, Ter, Q...\n";
//print_r($tabAdrTmp2);
$tabRet['indRep']=strtoupper(trim($tabAdrTmp2[1]));
$typeVoie=trim($tabAdrTmp2[2]);
} else {
$typeVoie=trim($tabAdrTmp[2]);
}
} else {
$typeVoie=trim($strLigneDAdresse);
}
// On récupère le type de voie si possible et le libellé de la voie
$voieTrouvee=false;
foreach ($this->tabCodeVoie as $code=>$voie) {
if (preg_match("/^($voie |$voie".'s '."|$code )(.*)/i", $typeVoie, $tabAdrTmp)) {
//echo "Adresse avec type de voie\n";
//print_r($tabAdrTmp);
$tabRet['typeVoie']=$code;
$tabRet['libVoie']=trim(strtoupper($tabAdrTmp[2]));
$voieTrouvee=true;
break;
}
}
if (!$voieTrouvee) $tabAdr[]=$typeVoie;
$strLigneDAdresse=trimAccent($strLigneDAdresse);
$strLigneDAdresse=preg_replace('/[^0-9a-zA-Z]/', ' ', $strLigneDAdresse);
$strLigneDAdresse=trim(preg_replace('/ +/', ' ', $strLigneDAdresse));
//echo "1. Adresse nettoyées = $strLigneDAdresse".EOL;
$adrAvecCP=preg_match("/(.*)([0-9]{5,5}|[0-9][0-9] [0-9]{3,3})([\D]*)/", $strLigneDAdresse, $tabAdrTmp);
if ($adrAvecCP) {
//echo "Adresse avec Code Postal\n";
//print_r($tabAdrTmp);
$strLigneDAdresse=trim($tabAdrTmp[1]);
$tabRet['cp']=$tabAdrTmp[2];
$tabRet['ville']=trim(strtoupper($tabAdrTmp[3]));
}// else echo "Adresse sans Code Postal\n";
$adrAvecNum=preg_match("/^([0-9]{1,4})(.*)/", $strLigneDAdresse, $tabAdrTmp);
if ($adrAvecNum) {
//echo "Adresse avec Numéro de voie\n";
//print_r($tabAdrTmp);
$tabRet['num']=$tabAdrTmp[1];
if (preg_match("/^\s(B|BIS|T|TER|Q|a|c|d|e|f|g|h|i|j|k|l|m|n|o|p|s)\s(.*)/i", $tabAdrTmp[2], $tabAdrTmp2))
{ //echo "Adresse avec Bis, Ter, Q...\n";
//print_r($tabAdrTmp2);
$tabRet['indRep']=strtoupper(trim($tabAdrTmp2[1]));
$typeVoie=trim($tabAdrTmp2[2]);
} else {
$typeVoie=trim($tabAdrTmp[2]);
}
} else {
$typeVoie=trim($strLigneDAdresse);
}
// On récupère le type de voie si possible et le libellé de la voie
$voieTrouvee=false;
foreach ($this->tabCodeVoie as $code=>$voie) {
if (preg_match("/^($voie |$voie".'s '."|$code )(.*)/i", $typeVoie, $tabAdrTmp)) {
//echo "Adresse avec type de voie\n";
//print_r($tabAdrTmp);
$tabRet['typeVoie']=$code;
$tabRet['libVoie']=trim(strtoupper($tabAdrTmp[2]));
$voieTrouvee=true;
break;
}
}
if (!$voieTrouvee) $tabAdr[]=$typeVoie;
}
foreach ($tabAdr as $k=>$ligne)
$tabRet['adrComp'.$k]=trim(strtoupper($ligne));

View File

@ -66,7 +66,7 @@ class Scores_Ws_Server
'127.0.0.1',
'192.168.33.1',
);
protected $listProxyIp = array(
'62.210.222.34',
);
@ -418,8 +418,6 @@ class Scores_Ws_Server
$dataInsert = array(
'login' => $this->User->login,
'page' => $service,
'siren' => $siren,
'nic' => $nic,
'params' => $ref,
'idClient' => $this->User->idClient,
'test' => $test,
@ -433,9 +431,28 @@ class Scores_Ws_Server
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
if ( in_array($service, array('identite', 'greffe_bilans', 'greffe_actes', 'liens',
'dirigeants', 'etablissements', 'dirigeantsOp', 'kbis', 'indiscore', 'indiscore2',
'indiscore3', 'rapport2', 'rapport3')) ) {
$pageRS = array(
'identite',
'greffe_bilans',
'greffe_actes',
'liens',
'dirigeants',
'etablissements',
'dirigeantsOp',
'kbis',
'indiscore',
'indiscore2',
'indiscore3',
'rapport2',
'rapport3'
);
if ( intval($siren)!=0 ) {
$dataInsert['siren'] = $siren;
$dataInsert['nic'] = $nic;
}
if ( intval($siren)!=0 && in_array($service, $pageRS) ) {
$sql = $db->select()->from('jo.etablissements', array('siren', 'nic', 'actif', 'siege', 'raisonSociale',
'adr_cp', 'adr_ville', 'source'))->where('siren=?', $siren);
@ -534,7 +551,7 @@ class Scores_Ws_Server
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
/**
* Lors d'une demande d'authentification depuis une application on garde l'IP en mémoire,
* c'est donc celle là qu'il faut utiliser.
@ -598,7 +615,7 @@ class Scores_Ws_Server
$output = true;
}
}
return $output;
}
@ -697,7 +714,7 @@ class Scores_Ws_Server
}
$this->authLog($login, $authResult, $ip);
return $authResult;
}
@ -1075,7 +1092,7 @@ class Scores_Ws_Server
} else if (is_string($result)) {
$authenticate = $result;
}
$data = array(
'login' => $login,
'authenticate' => $authenticate,
@ -1086,7 +1103,7 @@ class Scores_Ws_Server
$authLogM->insert($data);
} catch (Zend_Db_Exception $e) {}
}
/**
* Get Service Access List
* @param int $clientId

View File

@ -34,7 +34,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
$fields = implode(array_keys($toAdd), ',');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=checkaddslashes($array_values);
@ -81,7 +81,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
if ($low_priority) {
$query='UPDATE LOW_PRIORITY '.$table.' SET ';
} else {
@ -131,11 +131,11 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
if ($low_priority)
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
$query='DELETE LOW_PRIORITY QUICK FROM '.$table.' WHERE '.$where.' LIMIT 1;';
else
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
$query='DELETE FROM '.$table.' WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime_float();
@ -171,7 +171,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
$query="SELECT $fields FROM $table WHERE $where;";
if ($debug) $tdeb=microtime_float();
@ -241,7 +241,12 @@ class WDB
} else {
$duree = 'N/D';
}
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND);
if ($this->errorCode == 0) {
$msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
} else {
$msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
}
file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND);
}
/**
@ -251,7 +256,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
try {
$stmt = $this->db->query($query);
$this->result = $stmt;
@ -304,30 +309,28 @@ class WDB
if (!$fp) return false;
$res = $this->query($query);
$nbLignes = mysql_num_rows($res);
while ($ligne=$this->fetch(MYSQL_ASSOC)) {
$nbLignes = count($res);
for($i=0; $i<$nbLignes; $i++) {
$ligne = $res[$i];
//Header
if ($i==0) {
$nbCols = count($ligne);
$fields = array();
$header = array();
foreach ($ligne as $libCol=>$col) {
foreach ($ligne as $libCol => $col) {
$header[] = $libCol;
$fields[] = $col;
}
fputcsv($fp, $header, $sep, '"');
fputcsv($fp, $fields, $sep, '"');
}
//Content
else {
$fields = array();
foreach ($ligne as $libCol=>$col) {
$fields[] = $col;
}
fputcsv($fp, $fields, $sep, '"');
}
$i++;
$fields = array();
foreach ($ligne as $libCol => $col) {
$fields[] = $col;
}
fputcsv($fp, $fields, $sep, '"');
}
fclose($fp);
return $nbLignes;
}

View File

@ -34,7 +34,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
$fields = implode(array_keys($toAdd), ',');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=checkaddslashes($array_values);
@ -81,7 +81,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
if ($low_priority) {
$query='UPDATE LOW_PRIORITY '.$table.' SET ';
} else {
@ -131,11 +131,11 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
if ($low_priority)
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
$query='DELETE LOW_PRIORITY QUICK FROM '.$table.' WHERE '.$where.' LIMIT 1;';
else
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
$query='DELETE FROM '.$table.' WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime_float();
@ -171,7 +171,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
$query="SELECT $fields FROM $table WHERE $where;";
if ($debug) $tdeb=microtime_float();
@ -241,7 +241,12 @@ class WDB
} else {
$duree = 'N/D';
}
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND);
if ($this->errorCode == 0) {
$msg = date('Y-m-d H:i:s') ." - DEBUG - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
} else {
$msg = date('Y-m-d H:i:s') ." - ERROR - ".$this->errorCode.":".$this->errorMsg." - ".$query." - ".$duree;
}
file_put_contents(LOG_PATH . '/mysql.log', $msg . "\n", FILE_APPEND);
}
/**
@ -251,7 +256,7 @@ class WDB
{
$this->errorCode = 0;
$this->errorMsg = '';
try {
$stmt = $this->db->query($query);
$this->result = $stmt;
@ -304,30 +309,28 @@ class WDB
if (!$fp) return false;
$res = $this->query($query);
$nbLignes = mysql_num_rows($res);
while ($ligne=$this->fetch(MYSQL_ASSOC)) {
$nbLignes = count($res);
for($i=0; $i<$nbLignes; $i++) {
$ligne = $res[$i];
//Header
if ($i==0) {
$nbCols = count($ligne);
$fields = array();
$header = array();
foreach ($ligne as $libCol=>$col) {
foreach ($ligne as $libCol => $col) {
$header[] = $libCol;
$fields[] = $col;
}
fputcsv($fp, $header, $sep, '"');
fputcsv($fp, $fields, $sep, '"');
}
//Content
else {
$fields = array();
foreach ($ligne as $libCol=>$col) {
$fields[] = $col;
}
fputcsv($fp, $fields, $sep, '"');
}
$i++;
$fields = array();
foreach ($ligne as $libCol => $col) {
$fields[] = $col;
}
fputcsv($fp, $fields, $sep, '"');
}
fclose($fp);
return $nbLignes;
}