Merge from branch 2.7

This commit is contained in:
Michael RICOIS 2014-10-14 07:48:51 +00:00
commit c5d2d359d3
3 changed files with 41 additions and 14 deletions

View File

@ -63,7 +63,7 @@ class MLiens2
if ( $type == 'siren' ) {
$this->siren = $id;
$refM = new Application_Model_JoLiensRef();
$sql = $refM->select()->where('siren=?', $id);
$sql = $refM->select()->where('siren=?', $id)->where('dateSuppr=0');
$result = $refM->fetchRow($sql);
if ( $result !== null ) {
$this->idRef = $result->id;

View File

@ -19,6 +19,18 @@ class Scores_Ws_Server
*/
protected $authMethod = null;
/**
* Nom de l'application d'ou provient la demande d'authentification
* @var string
*/
protected $authApp = null;
/**
* IP du client
* @var string
*/
protected $authIp = null;
/**
* Name of Service
* @var string
@ -508,8 +520,15 @@ class Scores_Ws_Server
* @todo : with proxy get the original IP
* $request->getClientIp(true);
*/
$ip = $_SERVER['REMOTE_ADDR'];
if ($this->authIp !== null) {
$ip = $this->authIp;
}
$this->authenticated = $this->checkAuth($username, $password, $_SERVER['REMOTE_ADDR']);
/**
* Check authentication from the database
*/
$this->authenticated = $this->checkAuth($username, $password, $ip);
if ( $this->authenticated === false ) {
$this->sendError('0900');
} elseif ( $this->authenticated !== true ) {
@ -614,9 +633,11 @@ class Scores_Ws_Server
* Get an array of IP and IP range
* 192.168.3.5-192.68.3.10;192.168.3.*;192.168.3.10
*/
if ( !empty($result->filtre_ip) ) {
$filtreIp = explode(';', $result->filtre_ip);
if ( count($filtreIp)>0 ) {
if ( !empty($result->filtre_ip) )
{
$filtreIp = explode(';', trim($result->filtre_ip, ';'));
if ( count($filtreIp)>0 )
{
// Extranet
if ( substr($password,0,7)=='iponly:' ) {
$ipToValidate = substr($password,7);
@ -625,12 +646,13 @@ class Scores_Ws_Server
else {
$ipToValidate = $ipConnexion;
}
//Validation
$overallIpValidate = false;
foreach ( $filtreIp as $filtre ) {
foreach ( $filtreIp as $filtre )
{
if ( strpos($filtre, '*') ) {
$filtre = str_replace('*', '0', $filtre) . '-' . str_replace('*', '255', $filtre);
}
// Is it a range ?
if ( strpos($filtre, '-') ) {
$validateIp = new Scores_Validate_IpInNetwork();
@ -667,7 +689,8 @@ class Scores_Ws_Server
if ( $result->password == $password //password sent in clear
|| md5($result->password) == $password //password sent with md5
|| md5($result->login.'|'.$result->password) == $password //password sent concat with login and crypt by md5
) {
|| substr($password,0,7)=='iponly:'
) {
//Timeout
$timeout = $result->timeout;

View File

@ -24,10 +24,15 @@ class Gestion extends Scores_Ws_Server
*/
public function getInfosLogin($login, $ipUtilisateur = '')
{
//Get User Ip
if (empty($ipUtilisateur)) {
$ipUtilisateur = $_SERVER['REMOTE_ADDR'];
}
$this->authIp = $ipUtilisateur;
//Authenticate
$this->authenticate();
//Initialisation
if (empty($ipUtilisateur)) $ipUtilisateur = $_SERVER['REMOTE_ADDR'];
$error = new ErrorType();
$result = new InfosLogin();
@ -41,10 +46,9 @@ class Gestion extends Scores_Ws_Server
debugLog('I',"getInfosLogin pour $login (IP=$ipUtilisateur)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
//L'utilisateur qui demande les informations est différent
if ( $this->User->login<>$login
&& in_array($this->User->profil, array('Administrateur', 'SuperAdministrateur') )
) {
/** Un administrateur veut il des infos sur un login ? **/
if ($this->User->login!=$login && in_array($this->User->profil, array('Administrateur', 'SuperAdministrateur')))
{
/** Un administrateur veut il des infos sur un login ? **/
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->select(
'utilisateurs u, clients c',