WebService Score en autoload
This commit is contained in:
parent
abfc928ee7
commit
69d2803b08
@ -2,11 +2,6 @@
|
||||
class UserController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
require_once 'Scores/WsScores.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestion de l'authentification
|
||||
*/
|
||||
|
@ -19,10 +19,9 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
public function authenticate()
|
||||
{
|
||||
$adressIp = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
require_once 'Scores/WsScores.php';
|
||||
$ws = new WsScores($this->_username, $this->_password);
|
||||
$InfosLogin = $ws->getInfosLogin($this->_username, $adressIp);
|
||||
|
||||
$ws = new Scores_Ws($this->_username, $this->_password);
|
||||
$InfosLogin = $ws->getInfosLogin($this->_username, $adressIp);
|
||||
$identity = new stdClass();
|
||||
$identity->username = $this->_username;
|
||||
$identity->password = $this->_password;
|
||||
@ -40,24 +39,24 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
$identity->idClient = $InfosLogin->result->idClient;
|
||||
$identity->reference = $InfosLogin->result->reference;
|
||||
$identity->nbReponses = $InfosLogin->result->nbReponses;
|
||||
$identity->typeScore = $InfosLogin->result->typeScore;
|
||||
$identity->typeScore = $InfosLogin->result->typeScore;
|
||||
$identity->dateValidation = $InfosLogin->result->dateValidation;
|
||||
$identity->nombreConnexions = $InfosLogin->result->nombreConnexions;
|
||||
$identity->dateDerniereConnexion = $InfosLogin->result->dateDerniereConnexion;
|
||||
$identity->dateDebutCompte = $InfosLogin->result->dateDebutCompte;
|
||||
$identity->dateFinCompte = $InfosLogin->result->dateFinCompte;
|
||||
$identity->dateFinCompte = $InfosLogin->result->dateFinCompte;
|
||||
$identity->ip = $adressIp;
|
||||
$identity->modeEdition = false;
|
||||
|
||||
$identity->modeEdition = false;
|
||||
|
||||
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
|
||||
$identity->timeout = $timeout;
|
||||
|
||||
|
||||
$identity->time = time() + $timeout;
|
||||
|
||||
|
||||
/*
|
||||
* Adresse Ip interdites
|
||||
*/
|
||||
$ipInterdites =
|
||||
$ipInterdites =
|
||||
'81.252.88.0-81.252.88.7' // CTE D AGGLOMERATION DE SOPHIA
|
||||
. ';' . '195.200.187.163' // PacWan
|
||||
. ';' . '213.11.81.41' // Verizon France SAS
|
||||
@ -71,13 +70,13 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
. ';' . '193.104.158.0-193.104.158.255' // Altares.fr
|
||||
. ';' . '195.6.3.0-195.6.3.255' // ORT
|
||||
. ';' . '217.144.112.0-217.144.116.63' // Coface
|
||||
;
|
||||
if ( $this->checkPlagesIp($ipInterdites, $adressIp) ) {
|
||||
;
|
||||
if ( $this->checkPlagesIp($ipInterdites, $adressIp) ) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
|
||||
}
|
||||
|
||||
// Renvoi
|
||||
if ( is_string($InfosLogin) || $InfosLogin->error->errnum!=0){
|
||||
|
||||
// Renvoi
|
||||
if ( is_string($InfosLogin) || $InfosLogin->error->errnum!=0){
|
||||
$message = $InfosLogin;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
|
||||
} elseif ($this->_username == $InfosLogin->result->login) {
|
||||
@ -86,18 +85,18 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Controle si une adresse IP est dans une liste des IP communiquées sous la forme 192.168.3.5-192.68.3.10;192.168.3.*;192.168.3.10
|
||||
* @param string $strPlageIP La plage d'adresses IP
|
||||
* @param string $adresseIP L'adresse IP à tester
|
||||
*/
|
||||
protected function checkPlagesIp($strPlageIP, $adresseIP)
|
||||
protected function checkPlagesIp($strPlageIP, $adresseIP)
|
||||
{
|
||||
$connected = false;
|
||||
$tabIpAllowed = explode(';', trim($strPlageIP));
|
||||
if (count($tabIpAllowed)==1 && $tabIpAllowed[0]=='') $tabIpAllowed = array();
|
||||
|
||||
|
||||
foreach ($tabIpAllowed as $ip) {
|
||||
$tabPlages = explode('-', $ip);
|
||||
// C'est une plage d'adresse '-'
|
||||
@ -116,7 +115,7 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enter description here ...
|
||||
* @param unknown_type $plage_1
|
||||
@ -132,8 +131,8 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Converti une IP en nombre
|
||||
* @param string $ip Adresse IP
|
||||
* @return integer
|
||||
@ -142,5 +141,5 @@ class Scores_AuthAdapter implements Zend_Auth_Adapter_Interface
|
||||
$tab=explode('.', $ip);
|
||||
return (($tab[0]*256*256*256) + ($tab[1]*256*256) + ($tab[2]*256) + ($tab[3]));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
<?php
|
||||
class WsScores
|
||||
class Scores_Ws
|
||||
{
|
||||
protected $webservices = array();
|
||||
protected $login = '';
|
||||
protected $password = '';
|
||||
protected $nbReponses = 20;
|
||||
protected $toNotCache = false;
|
||||
|
||||
|
||||
public function __construct($login = '', $password = '')
|
||||
{
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
$config = new Zend_Config_Ini(realpath(dirname(__FILE__)) . '/webservices.ini', $configuration->webservice->location);
|
||||
$config = new Zend_Config_Ini(realpath(dirname(__FILE__)) . '/webservices.ini', $configuration->webservice->location);
|
||||
$this->webservices = $config->webservices->toArray();
|
||||
if ( !empty($login) && !empty($password) ){
|
||||
$this->login = $login;
|
||||
$this->password = $password;
|
||||
} else {
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
$this->login = $user->getLogin();
|
||||
$this->password = $user->getPassword();
|
||||
@ -26,7 +26,7 @@ class WsScores
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setLog
|
||||
* @param string $page
|
||||
@ -50,7 +50,7 @@ class WsScores
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getDataCSV
|
||||
* @param string $key
|
||||
@ -63,12 +63,12 @@ class WsScores
|
||||
$client = $this->loadClient('exporter');
|
||||
$reponse = $client->getDataCSV($params);
|
||||
return $reponse->getDataCSVResult;
|
||||
} catch (SoapFault $fault) {
|
||||
} catch (SoapFault $fault) {
|
||||
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getInfosLogin
|
||||
* @param string $login
|
||||
@ -85,7 +85,7 @@ class WsScores
|
||||
return $reponse->getInfosLoginResult;
|
||||
} catch (SoapFault $fault) {
|
||||
if ($fault->faultcode=='0900'){
|
||||
return $fault->faultstring;
|
||||
return $fault->faultstring;
|
||||
} else {
|
||||
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
|
||||
return false;
|
||||
@ -111,7 +111,7 @@ class WsScores
|
||||
$message.= "Detail :\n".$fault->getTraceAsString();
|
||||
$message.= "\n\n";
|
||||
$message.= "Requete :\n ".$requete."\n";
|
||||
$message.= "Reponse :\n ".$reponse."\n";
|
||||
$message.= "Reponse :\n ".$reponse."\n";
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
require_once 'Scores/Mail.php';
|
||||
$mail = new Mail();
|
||||
@ -121,7 +121,7 @@ class WsScores
|
||||
$mail->addToKey('supportdev');
|
||||
$mail->send();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* loadClient
|
||||
* @param unknown_type $webservice
|
||||
@ -138,7 +138,7 @@ class WsScores
|
||||
$options['cache_wsdl'] = WSDL_CACHE_NONE;
|
||||
}
|
||||
$options['trace'] = true;
|
||||
$options['encoding'] = 'utf-8';
|
||||
$options['encoding'] = 'utf-8';
|
||||
$client = new SoapClient($wsdl, $options);
|
||||
return $client;
|
||||
}
|
Loading…
Reference in New Issue
Block a user