CS PSR-2
This commit is contained in:
parent
a5e1276536
commit
73044d4ab0
@ -1,29 +1,29 @@
|
||||
<?php
|
||||
return array (
|
||||
return array(
|
||||
|
||||
//RECHERCHE
|
||||
'RECHCSV' => "Export des résultats de la recherche",
|
||||
'IPARI' => "Investigation par l'image IparI©",
|
||||
'HISTOBODACC' => "Historique des annonces bodacc",
|
||||
'INVESTIG' => "Investigation",
|
||||
'HISTOBODACC' => "Historique des annonces bodacc",
|
||||
'INVESTIG' => "Investigation",
|
||||
'SEARCHENT' => "Recherche Entreprise",
|
||||
'SEARCHDIR' => "Recherche Dirigeant",
|
||||
'SEARCHACT' => "Recherche Actionnaire",
|
||||
|
||||
//IDENTITE
|
||||
'IDENTITE' => "Fiche d'identité",
|
||||
'IDPROCOL' => 'Fiche procédure collective',
|
||||
'IDPROCOL' => 'Fiche procédure collective',
|
||||
'LIENS' => "Liens inter-entreprise",
|
||||
'ETABLISSEMENTS' => "Liste des établissements",
|
||||
'GROUPE' => "Informations et organigramme du groupe",
|
||||
'EVENINSEE' => 'Évènements INSEE',
|
||||
'AVISINSEE' => 'Avis de situation INSEE',
|
||||
'AVISRNCS' => 'Avis de situation RNCS',
|
||||
'GROUPE' => "Informations et organigramme du groupe",
|
||||
'EVENINSEE' => 'Évènements INSEE',
|
||||
'AVISINSEE' => 'Avis de situation INSEE',
|
||||
'AVISRNCS' => 'Avis de situation RNCS',
|
||||
'RNVP' => "Normalisation postale",
|
||||
|
||||
//DIRIGEANT
|
||||
'DIRIGEANTS' => "Liste des dirigeants",
|
||||
'DIRIGEANTSOP' => "Liste des dirigeants opérationnels",
|
||||
'DIRIGEANTS' => "Liste des dirigeants",
|
||||
'DIRIGEANTSOP' => "Liste des dirigeants opérationnels",
|
||||
|
||||
//FINANCE
|
||||
'SYNTHESE' => "Synthèse",
|
||||
@ -31,7 +31,7 @@ return array (
|
||||
'FLUX' => "Flux de trésorerie",
|
||||
'LIASSE' => "Liasse fiscale",
|
||||
'LIASSEXLS' => "Export des Liasses au format XLS",
|
||||
'UPLOADBILAN' => "Saisie de bilan",
|
||||
'UPLOADBILAN' => "Saisie de bilan",
|
||||
'BOURSE' => "Bourse & cotations",
|
||||
'BANQUE' => "Relations bancaires",
|
||||
|
||||
@ -40,46 +40,46 @@ return array (
|
||||
'INFOSREG' => "Informations réglementée",
|
||||
'COMPETENCES' => "Compétences territoriales",
|
||||
'CONVENTIONS' => "Conventions collectives",
|
||||
'MARQUES' => "Marques déposées",
|
||||
'MARQUES' => "Marques déposées",
|
||||
'CONTENTIEUX' => "Contentieux Judiciaires",
|
||||
|
||||
//EVALUATION
|
||||
'INDISCORE' => "indiScore©",
|
||||
'INDISCORE2' => "Rapport synthetique",
|
||||
'INDISCORE3' => "Rapport complet",
|
||||
'INDISCOREP' => "indiScore+",
|
||||
'INDISCORE2P' => "Rapport synthetique+",
|
||||
'INDISCORE3P' => "Rapport complet+",
|
||||
'VALORISATION' => "Valorisation",
|
||||
'SCORECSF' => "Score CSF",
|
||||
'ENQUETEC' => "Enquête commerciale",
|
||||
'AVISCREDIT' => "Avis de crédit personnalisé",
|
||||
'INDISCORE' => "indiScore©",
|
||||
'INDISCORE2' => "Rapport synthetique",
|
||||
'INDISCORE3' => "Rapport complet",
|
||||
'INDISCOREP' => "indiScore+",
|
||||
'INDISCORE2P' => "Rapport synthetique+",
|
||||
'INDISCORE3P' => "Rapport complet+",
|
||||
'VALORISATION' => "Valorisation",
|
||||
'SCORECSF' => "Score CSF",
|
||||
'ENQUETEC' => "Enquête commerciale",
|
||||
'AVISCREDIT' => "Avis de crédit personnalisé",
|
||||
|
||||
//PIECES
|
||||
'KBIS' => "Extrait RCS",
|
||||
'ACTES' => "Pièces officielles",
|
||||
'PRIVILEGES' => "Privilèges",
|
||||
'KBIS' => "Extrait RCS",
|
||||
'ACTES' => "Pièces officielles",
|
||||
'PRIVILEGES' => "Privilèges",
|
||||
|
||||
//SURVEILLANCES
|
||||
'SURVANNONCE' => "Surveillance des annonces légales",
|
||||
'SURVINSEE' => "Surveillance des événements INSEE",
|
||||
'SURVBILAN' => "Surveillance des bilans saisies (liasse fiscale)",
|
||||
'SURVSCORE' => "Surveillance des événements sur le score",
|
||||
'SURVACTES' => "Surveillance des pieces officielles (comptes annuels, actes)",
|
||||
'SURVDIRIGEANTS'=> "Surveillance des dirigeants",
|
||||
'SURVPAIEMENTS' => "Surveillance des paiements",
|
||||
'SURVLIENS' => "Surveillance des liens financiers",
|
||||
'SURVPRIV' => "Surveillance des privilèges",
|
||||
'SURVANNONCE' => "Surveillance des annonces légales",
|
||||
'SURVINSEE' => "Surveillance des événements INSEE",
|
||||
'SURVBILAN' => "Surveillance des bilans saisies (liasse fiscale)",
|
||||
'SURVSCORE' => "Surveillance des événements sur le score",
|
||||
'SURVACTES' => "Surveillance des pieces officielles (comptes annuels, actes)",
|
||||
'SURVDIRIGEANTS'=> "Surveillance des dirigeants",
|
||||
'SURVPAIEMENTS' => "Surveillance des paiements",
|
||||
'SURVLIENS' => "Surveillance des liens financiers",
|
||||
'SURVPRIV' => "Surveillance des privilèges",
|
||||
|
||||
//OPTIONS
|
||||
'MONPROFIL' => "Mon profil",
|
||||
'EDITION' => "Mode Edition",
|
||||
'PORTEFEUILLE' => "Portefeuille",
|
||||
'SURVLISTE' => "Liste des surveillances",
|
||||
'MONPROFIL' => "Mon profil",
|
||||
'EDITION' => "Mode Edition",
|
||||
'PORTEFEUILLE' => "Portefeuille",
|
||||
'SURVLISTE' => "Liste des surveillances",
|
||||
|
||||
//DIVERS
|
||||
'INTERNATIONAL' => "Recherche Internationale",
|
||||
'BDF' => "Banque de France",
|
||||
'WORLDCHECK' => "World-Check Risk Intelligence",
|
||||
'INTERNATIONAL' => "Recherche Internationale",
|
||||
'BDF' => "Banque de France",
|
||||
'WORLDCHECK' => "World-Check Risk Intelligence",
|
||||
|
||||
);
|
||||
);
|
||||
|
@ -109,4 +109,4 @@ return array(
|
||||
'BDF'
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
@ -1,124 +1,124 @@
|
||||
<?php
|
||||
class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
|
||||
{
|
||||
protected $_username;
|
||||
protected $_username;
|
||||
|
||||
protected $_password;
|
||||
protected $_password;
|
||||
|
||||
protected $_hash;
|
||||
protected $_hash;
|
||||
|
||||
protected $_timeout = 3600;
|
||||
protected $_timeout = 3600;
|
||||
|
||||
protected $checkWs = false;
|
||||
protected $checkWs = false;
|
||||
|
||||
protected $clients = array();
|
||||
protected $clients = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param boolean $checkWs
|
||||
*/
|
||||
public function __construct($username, $password, $checkWs = false)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
$this->_hash = md5($username.'|'.$password);
|
||||
$this->checkWs = $checkWs;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param boolean $checkWs
|
||||
*/
|
||||
public function __construct($username, $password, $checkWs = false)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
$this->_hash = md5($username.'|'.$password);
|
||||
$this->checkWs = $checkWs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit access to only client IDs
|
||||
* @param array $id
|
||||
*/
|
||||
public function limitClient($id = null)
|
||||
{
|
||||
if (is_array($id) && count($id)>0) {
|
||||
$this->clients = $id;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Limit access to only client IDs
|
||||
* @param array $id
|
||||
*/
|
||||
public function limitClient($id = null)
|
||||
{
|
||||
if (is_array($id) && count($id)>0) {
|
||||
$this->clients = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the timeout
|
||||
* @param integer $seconds
|
||||
*/
|
||||
public function setTimeout($seconds = null)
|
||||
{
|
||||
if ($seconds===null)
|
||||
return;
|
||||
/**
|
||||
* Override the timeout
|
||||
* @param integer $seconds
|
||||
*/
|
||||
public function setTimeout($seconds = null)
|
||||
{
|
||||
if ($seconds===null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_timeout = $seconds;
|
||||
}
|
||||
$this->_timeout = $seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Auth_Adapter_Interface::authenticate()
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
$userM = new Application_Model_Sdv1Utilisateurs();
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Auth_Adapter_Interface::authenticate()
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
$userM = new Application_Model_Sdv1Utilisateurs();
|
||||
|
||||
$sql = $userM->select()
|
||||
->setIntegrityCheck(false)
|
||||
->from(array('u'=>'sdv1.utilisateurs'), array('u.idClient', 'u.id', 'u.login', 'u.password'))
|
||||
->join(array('c'=>'sdv1.clients'), 'u.idClient = c.id', array('c.timeout'))
|
||||
->where('u.login=?', $this->_username)
|
||||
->where('u.actif=?', 1)
|
||||
->where('u.deleted=?', 0)
|
||||
->where('c.actif=?','Oui');
|
||||
$sql = $userM->select()
|
||||
->setIntegrityCheck(false)
|
||||
->from(array('u'=>'sdv1.utilisateurs'), array('u.idClient', 'u.id', 'u.login', 'u.password'))
|
||||
->join(array('c'=>'sdv1.clients'), 'u.idClient = c.id', array('c.timeout'))
|
||||
->where('u.login=?', $this->_username)
|
||||
->where('u.actif=?', 1)
|
||||
->where('u.deleted=?', 0)
|
||||
->where('c.actif=?', 'Oui');
|
||||
|
||||
if ( count($this->clients) > 0 ) {
|
||||
$sql->where('u.idClient IN('.join(',',$this->clients).')');
|
||||
}
|
||||
if (count($this->clients) > 0) {
|
||||
$sql->where('u.idClient IN('.join(',', $this->clients).')');
|
||||
}
|
||||
|
||||
if ($this->checkWs) {
|
||||
$sql->where('u.accesWS=?',1);
|
||||
}
|
||||
if ($this->checkWs) {
|
||||
$sql->where('u.accesWS=?', 1);
|
||||
}
|
||||
|
||||
$result = $userM->fetchRow($sql);
|
||||
$result = $userM->fetchRow($sql);
|
||||
|
||||
$identity = new stdClass();
|
||||
$identity->username = $this->_username;
|
||||
$identity->hash = $this->_hash;
|
||||
$identity = new stdClass();
|
||||
$identity->username = $this->_username;
|
||||
$identity->hash = $this->_hash;
|
||||
|
||||
if ( null === $result ) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity, array("Identifiant ou mot de passe invalid"));
|
||||
} else {
|
||||
if ( $this->_password == $result->password
|
||||
|| $this->_password == md5($result->login.'|'.$result->password) ) {
|
||||
if (null === $result) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity, array("Identifiant ou mot de passe invalid"));
|
||||
} else {
|
||||
if ($this->_password == $result->password
|
||||
|| $this->_password == md5($result->login.'|'.$result->password)) {
|
||||
|
||||
/**
|
||||
* Date de debut de compte
|
||||
*/
|
||||
if ( !empty($result->dateDebutCompte) && $result->dateDebutCompte!='0000-00-00' ) {
|
||||
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
||||
$dateDebutCompte = mktime(0, 0, 0, substr($result->dateDebutCompte,5,2), substr($result->dateDebutCompte,8,2), substr($result->dateDebutCompte,0,4));
|
||||
if ( $today < $dateDebutCompte ) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Date de debut de compte
|
||||
*/
|
||||
if (!empty($result->dateDebutCompte) && $result->dateDebutCompte!='0000-00-00') {
|
||||
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
||||
$dateDebutCompte = mktime(0, 0, 0, substr($result->dateDebutCompte, 5, 2), substr($result->dateDebutCompte, 8, 2), substr($result->dateDebutCompte, 0, 4));
|
||||
if ($today < $dateDebutCompte) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Date de fin de compte
|
||||
*/
|
||||
if ( !empty($result->dateFinCompte) && $result->dateFinCompte!='0000-00-00' ) {
|
||||
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
||||
$dateFinCompte = mktime(0, 0, 0, substr($result->dateFinCompte,5,2), substr($result->dateFinCompte,8,2), substr($result->dateFinCompte,0,4));
|
||||
if ( $today > $dateFinCompte ) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Date de fin de compte
|
||||
*/
|
||||
if (!empty($result->dateFinCompte) && $result->dateFinCompte!='0000-00-00') {
|
||||
$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
||||
$dateFinCompte = mktime(0, 0, 0, substr($result->dateFinCompte, 5, 2), substr($result->dateFinCompte, 8, 2), substr($result->dateFinCompte, 0, 4));
|
||||
if ($today > $dateFinCompte) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Date de validité dépassé"));
|
||||
}
|
||||
}
|
||||
|
||||
$identity->id = $result->id;
|
||||
$identity->idClient = $result->idClient;
|
||||
$timeout = (!empty($result->timeout)) ? $result->timeout : $this->_timeout;
|
||||
$identity->timeout = $timeout;
|
||||
$identity->time = time() + $timeout;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
||||
|
||||
} else {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Identification impossible"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$identity->id = $result->id;
|
||||
$identity->idClient = $result->idClient;
|
||||
$timeout = (!empty($result->timeout)) ? $result->timeout : $this->_timeout;
|
||||
$identity->timeout = $timeout;
|
||||
$identity->time = time() + $timeout;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
||||
} else {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array("Identification impossible"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,190 +1,189 @@
|
||||
<?php
|
||||
class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
|
||||
{
|
||||
/**
|
||||
* Identifiant de l'utilisateur
|
||||
* @var string
|
||||
*/
|
||||
protected $_username;
|
||||
/**
|
||||
* Identifiant de l'utilisateur
|
||||
* @var string
|
||||
*/
|
||||
protected $_username;
|
||||
|
||||
/**
|
||||
* Password
|
||||
* @var string
|
||||
*/
|
||||
protected $_password;
|
||||
/**
|
||||
* Password
|
||||
* @var string
|
||||
*/
|
||||
protected $_password;
|
||||
|
||||
/**
|
||||
* Timeout
|
||||
* @var int
|
||||
*/
|
||||
protected $_timeout = 1800;
|
||||
/**
|
||||
* Timeout
|
||||
* @var int
|
||||
*/
|
||||
protected $_timeout = 1800;
|
||||
|
||||
/**
|
||||
* Marqueur de vérification IP (en iponly)
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checkIp = false;
|
||||
/**
|
||||
* Marqueur de vérification IP (en iponly)
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checkIp = false;
|
||||
|
||||
/**
|
||||
* Marqueur de vérification de hach
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checkHach = false;
|
||||
/**
|
||||
* Marqueur de vérification de hach
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checkHach = false;
|
||||
|
||||
/**
|
||||
* Liste des IPs des frontends (proxy)
|
||||
* @var array
|
||||
*/
|
||||
protected $listProxyIp = array(
|
||||
'62.210.222.34',
|
||||
);
|
||||
/**
|
||||
* Liste des IPs des frontends (proxy)
|
||||
* @var array
|
||||
*/
|
||||
protected $listProxyIp = array(
|
||||
'62.210.222.34',
|
||||
);
|
||||
|
||||
/**
|
||||
* Authentification par WS
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $mode
|
||||
*/
|
||||
public function __construct($username, $password, $mode = null)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
/**
|
||||
* Authentification par WS
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $mode
|
||||
*/
|
||||
public function __construct($username, $password, $mode = null)
|
||||
{
|
||||
$this->_username = $username;
|
||||
$this->_password = $password;
|
||||
|
||||
if ($mode == 'hach') {
|
||||
$this->_checkHach = true;
|
||||
}
|
||||
if ($mode == 'hach') {
|
||||
$this->_checkHach = true;
|
||||
}
|
||||
|
||||
if ($mode == 'iponly'){
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
$this->_password = 'iponly:'.$ip;
|
||||
$this->_checkIp = true;
|
||||
}
|
||||
}
|
||||
if ($mode == 'iponly') {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
$this->_password = 'iponly:'.$ip;
|
||||
$this->_checkIp = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Auth_Adapter_Interface::authenticate()
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Auth_Adapter_Interface::authenticate()
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && in_array($ip, $this->listProxyIp)) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
|
||||
$ws = new Scores_Ws_Client('gestion', '0.3');
|
||||
$ws->setHttpLogin($this->_username);
|
||||
$ws->setHttpPassword($this->_password);
|
||||
$adressIp = $_SERVER['REMOTE_ADDR'];
|
||||
$parameters = new stdClass();
|
||||
$parameters->login = $this->_username;
|
||||
$parameters->ipUtilisateur = $ip;
|
||||
$parameters->from = 'auth';
|
||||
$InfosLogin = $ws->getInfosLogin($parameters);
|
||||
$ws = new Scores_Ws_Client('gestion', '0.3');
|
||||
$ws->setHttpLogin($this->_username);
|
||||
$ws->setHttpPassword($this->_password);
|
||||
$adressIp = $_SERVER['REMOTE_ADDR'];
|
||||
$parameters = new stdClass();
|
||||
$parameters->login = $this->_username;
|
||||
$parameters->ipUtilisateur = $ip;
|
||||
$parameters->from = 'auth';
|
||||
$InfosLogin = $ws->getInfosLogin($parameters);
|
||||
|
||||
// --- 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));
|
||||
}
|
||||
// --- Assignation identity
|
||||
elseif ( $InfosLogin !== false && !empty($InfosLogin->result->login)) {
|
||||
$identity = new stdClass();
|
||||
if ($this->_checkIp || $this->_checkHach) {
|
||||
Zend_Registry::get('firebug')->info("IN");
|
||||
$identity->password = $this->_password;
|
||||
} else {
|
||||
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
|
||||
}
|
||||
Zend_Registry::get('firebug')->info($identity->password);
|
||||
$identity->username = $InfosLogin->result->login;
|
||||
$identity->email = $InfosLogin->result->email;
|
||||
$identity->profil = $InfosLogin->result->profil;
|
||||
$identity->pref = $InfosLogin->result->pref;
|
||||
$identity->droits = $InfosLogin->result->droits;
|
||||
$identity->droitsClients = $InfosLogin->result->droitsClients;
|
||||
$identity->nom = $InfosLogin->result->nom;
|
||||
$identity->prenom = $InfosLogin->result->prenom;
|
||||
$identity->tel = $InfosLogin->result->tel;
|
||||
$identity->fax = $InfosLogin->result->fax;
|
||||
$identity->mobile = $InfosLogin->result->mobile;
|
||||
$identity->id = $InfosLogin->result->id;
|
||||
$identity->idClient = $InfosLogin->result->idClient;
|
||||
$identity->reference = $InfosLogin->result->reference;
|
||||
$identity->nbReponses = $InfosLogin->result->nbReponses;
|
||||
$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->acceptationCGU = $InfosLogin->result->acceptationCGU;
|
||||
$identity->ip = $ip;
|
||||
$identity->version = $InfosLogin->result->version;
|
||||
$identity->modeEdition = false;
|
||||
// --- 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));
|
||||
}
|
||||
// --- Assignation identity
|
||||
elseif ($InfosLogin !== false && !empty($InfosLogin->result->login)) {
|
||||
$identity = new stdClass();
|
||||
if ($this->_checkIp || $this->_checkHach) {
|
||||
Zend_Registry::get('firebug')->info("IN");
|
||||
$identity->password = $this->_password;
|
||||
} else {
|
||||
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
|
||||
}
|
||||
Zend_Registry::get('firebug')->info($identity->password);
|
||||
$identity->username = $InfosLogin->result->login;
|
||||
$identity->email = $InfosLogin->result->email;
|
||||
$identity->profil = $InfosLogin->result->profil;
|
||||
$identity->pref = $InfosLogin->result->pref;
|
||||
$identity->droits = $InfosLogin->result->droits;
|
||||
$identity->droitsClients = $InfosLogin->result->droitsClients;
|
||||
$identity->nom = $InfosLogin->result->nom;
|
||||
$identity->prenom = $InfosLogin->result->prenom;
|
||||
$identity->tel = $InfosLogin->result->tel;
|
||||
$identity->fax = $InfosLogin->result->fax;
|
||||
$identity->mobile = $InfosLogin->result->mobile;
|
||||
$identity->id = $InfosLogin->result->id;
|
||||
$identity->idClient = $InfosLogin->result->idClient;
|
||||
$identity->reference = $InfosLogin->result->reference;
|
||||
$identity->nbReponses = $InfosLogin->result->nbReponses;
|
||||
$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->acceptationCGU = $InfosLogin->result->acceptationCGU;
|
||||
$identity->ip = $ip;
|
||||
$identity->version = $InfosLogin->result->version;
|
||||
$identity->modeEdition = false;
|
||||
|
||||
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
|
||||
$identity->timeout = $timeout;
|
||||
$identity->time = time() + $timeout;
|
||||
$lang = in_array($InfosLogin->result->lang, array('fr','en')) ? $InfosLogin->result->lang : 'fr';
|
||||
$identity->lang = $lang;
|
||||
$identity->langtmp = $lang;
|
||||
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
|
||||
$identity->timeout = $timeout;
|
||||
$identity->time = time() + $timeout;
|
||||
$lang = in_array($InfosLogin->result->lang, array('fr', 'en')) ? $InfosLogin->result->lang : 'fr';
|
||||
$identity->lang = $lang;
|
||||
$identity->langtmp = $lang;
|
||||
|
||||
// --- Adresse Ip interdites
|
||||
$ipInterdites = array(
|
||||
'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
|
||||
'83.206.171.252', // FR-BASE-D-INFORMATIONS-LEGALES-BI
|
||||
'81.255.32.139',
|
||||
'212.155.191.100-212.155.191.199', // Satair A/S
|
||||
'212.37.196.156', // GENERALE-MULTIMEDIA-SUD
|
||||
'80.245.60.121', // Planete Marseille - Mailclub
|
||||
'213.246.57.101', // IKOULA
|
||||
'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
|
||||
);
|
||||
// --- Adresse Ip interdites
|
||||
$ipInterdites = array(
|
||||
'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
|
||||
'83.206.171.252', // FR-BASE-D-INFORMATIONS-LEGALES-BI
|
||||
'81.255.32.139',
|
||||
'212.155.191.100-212.155.191.199', // Satair A/S
|
||||
'212.37.196.156', // GENERALE-MULTIMEDIA-SUD
|
||||
'80.245.60.121', // Planete Marseille - Mailclub
|
||||
'213.246.57.101', // IKOULA
|
||||
'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
|
||||
);
|
||||
|
||||
// --- Validation IP
|
||||
$overallIpValidate = false;
|
||||
foreach ( $ipInterdites as $filtre ) {
|
||||
if ( strpos($filtre, '*') ) {
|
||||
foreach ($ipInterdites as $filtre) {
|
||||
if (strpos($filtre, '*')) {
|
||||
$filtre = str_replace('*', '0', $filtre) . '-' . str_replace('*', '255', $filtre);
|
||||
}
|
||||
// Is it a range ?
|
||||
if ( strpos($filtre, '-') ) {
|
||||
if (strpos($filtre, '-')) {
|
||||
$validateIp = new Scores_Validate_IpInNetwork();
|
||||
$validateIp->setNetworkNotation($filtre);
|
||||
$overallIpValidate = $validateIp->isValid($ipToValidate);
|
||||
}
|
||||
// Ip only
|
||||
else {
|
||||
if ( $filtre === $ipToValidate ) {
|
||||
if ($filtre === $ipToValidate) {
|
||||
$overallIpValidate = true;
|
||||
}
|
||||
}
|
||||
// Break foreach
|
||||
if ( $overallIpValidate === true ) {
|
||||
if ($overallIpValidate === true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit with error
|
||||
if ( $overallIpValidate === false ) {
|
||||
if ($overallIpValidate === false) {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
|
||||
}
|
||||
|
||||
// --- OK connecté
|
||||
$this->_username = $identity->username;
|
||||
$this->_password = $identity->password;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
||||
|
||||
} else {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity, array("Identification impossible"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// --- OK connecté
|
||||
$this->_username = $identity->username;
|
||||
$this->_password = $identity->password;
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
||||
} else {
|
||||
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity, array("Identification impossible"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,84 +4,85 @@
|
||||
*/
|
||||
class Scores_Locale_String
|
||||
{
|
||||
/**
|
||||
* Clean up a string value.
|
||||
*
|
||||
* Resulting string contains only alphanumerics and separators.
|
||||
*
|
||||
* @param $string
|
||||
* A string to clean.
|
||||
* @param $clean_slash
|
||||
* Whether to clean slashes from the given string.
|
||||
* @return
|
||||
* The cleaned string.
|
||||
*/
|
||||
public static function cleanstring($string)
|
||||
{
|
||||
$transliterate = TRUE;
|
||||
$reduce_ascii = FALSE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
|
||||
// Reduce to the subset of ASCII96 letters and numbers
|
||||
if ($reduce_ascii) {
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$output = preg_replace($pattern, $separator, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function cleanutf8($string)
|
||||
{
|
||||
$transliterate = TRUE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Fixes the encoding to uf8
|
||||
public static function fixEncoding($in_str)
|
||||
{
|
||||
$cur_encoding = mb_detect_encoding($in_str) ;
|
||||
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
|
||||
return $in_str;
|
||||
else
|
||||
return utf8_encode($in_str);
|
||||
} // fixEncoding
|
||||
|
||||
public static function cleanstring_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('self::cleanstring_deep', $value) :
|
||||
cleanstring($value);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Clean up a string value.
|
||||
*
|
||||
* Resulting string contains only alphanumerics and separators.
|
||||
*
|
||||
* @param $string
|
||||
* A string to clean.
|
||||
* @param $clean_slash
|
||||
* Whether to clean slashes from the given string.
|
||||
* @return
|
||||
* The cleaned string.
|
||||
*/
|
||||
public static function cleanstring($string)
|
||||
{
|
||||
$transliterate = true;
|
||||
$reduce_ascii = false;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
|
||||
// Reduce to the subset of ASCII96 letters and numbers
|
||||
if ($reduce_ascii) {
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$output = preg_replace($pattern, $separator, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function cleanutf8($string)
|
||||
{
|
||||
$transliterate = true;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Fixes the encoding to uf8
|
||||
public static function fixEncoding($in_str)
|
||||
{
|
||||
$cur_encoding = mb_detect_encoding($in_str) ;
|
||||
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) {
|
||||
return $in_str;
|
||||
} else {
|
||||
return utf8_encode($in_str);
|
||||
}
|
||||
} // fixEncoding
|
||||
|
||||
public static function cleanstring_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('self::cleanstring_deep', $value) :
|
||||
cleanstring($value);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,11 @@ class Scores_Logger_Sql implements SQLLogger
|
||||
$this->query['executionTotal'] = $this->total;
|
||||
$this->query['executionMS'] = $time;
|
||||
if ($this->nb == 0) {
|
||||
file_put_contents('logger.log', print_r($this->query,1));
|
||||
}
|
||||
else {
|
||||
file_put_contents('logger.log', print_r($this->query,1), FILE_APPEND);
|
||||
file_put_contents('logger.log', print_r($this->query, 1));
|
||||
} else {
|
||||
file_put_contents('logger.log', print_r($this->query, 1), FILE_APPEND);
|
||||
}
|
||||
$this->nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,130 +1,129 @@
|
||||
<?php
|
||||
class Scores_Mail_Method extends Zend_Mail
|
||||
{
|
||||
protected $config;
|
||||
protected $transport;
|
||||
protected $config;
|
||||
protected $transport;
|
||||
|
||||
/**
|
||||
* Gestion de l'envoi des mails en fonction de la configuration
|
||||
* Fournir un objet de configuration ou utiliser la configuration de l'application
|
||||
* method => smtp, sendmail, file
|
||||
* Si method = smtp
|
||||
* (host => IP, dns)
|
||||
*
|
||||
* Activer l'authentification
|
||||
* (auth => login, plain, ....)
|
||||
* (username => )
|
||||
* (password => )
|
||||
*/
|
||||
public function __construct( $config = null )
|
||||
{
|
||||
if ($config === null) {
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->config = $c->profil->mail;
|
||||
} else {
|
||||
/**
|
||||
* Gestion de l'envoi des mails en fonction de la configuration
|
||||
* Fournir un objet de configuration ou utiliser la configuration de l'application
|
||||
* method => smtp, sendmail, file
|
||||
* Si method = smtp
|
||||
* (host => IP, dns)
|
||||
*
|
||||
* Activer l'authentification
|
||||
* (auth => login, plain, ....)
|
||||
* (username => )
|
||||
* (password => )
|
||||
*/
|
||||
public function __construct($config = null)
|
||||
{
|
||||
if ($config === null) {
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->config = $c->profil->mail;
|
||||
} else {
|
||||
$this->config = $config;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_charset = 'ISO-8859-15';
|
||||
$this->_charset = 'ISO-8859-15';
|
||||
|
||||
// --- Configuration du transport SMTP
|
||||
if ( $this->config->method == 'smtp' ) {
|
||||
// --- Configuration du transport SMTP
|
||||
if ($this->config->method == 'smtp') {
|
||||
$config = array();
|
||||
|
||||
$config = array();
|
||||
|
||||
if ( isset($this->config->auth) ) {
|
||||
if (isset($this->config->auth)) {
|
||||
$config['auth'] = $this->config->auth;
|
||||
if ( isset($this->config->username) ) {
|
||||
if (isset($this->config->username)) {
|
||||
$config['username'] = $this->config->username;
|
||||
}
|
||||
if ( isset($this->config->password) ) {
|
||||
if (isset($this->config->password)) {
|
||||
$config['password'] = $this->config->password;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($this->config->port) ) {
|
||||
if (isset($this->config->port)) {
|
||||
$config['port'] = $this->config->port;
|
||||
}
|
||||
|
||||
$tr = new Zend_Mail_Transport_Smtp($this->config->host, $config);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Configuration transport Sendmail
|
||||
if ( $this->config->method == 'sendmail' ) {
|
||||
$tr = new Zend_Mail_Transport_Sendmail();
|
||||
}
|
||||
// --- Configuration transport Sendmail
|
||||
if ($this->config->method == 'sendmail') {
|
||||
$tr = new Zend_Mail_Transport_Sendmail();
|
||||
}
|
||||
|
||||
// --- Configuration transport File
|
||||
if ( $this->config->method == 'file' ) {
|
||||
$tr = new Zend_Mail_Transport_File(array('callback' => array($this, 'recipientFilename')));
|
||||
}
|
||||
// --- Configuration transport File
|
||||
if ($this->config->method == 'file') {
|
||||
$tr = new Zend_Mail_Transport_File(array('callback' => array($this, 'recipientFilename')));
|
||||
}
|
||||
|
||||
$this->transport = $tr;
|
||||
}
|
||||
$this->transport = $tr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Champ From en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
*/
|
||||
public function setFromKey($configKey)
|
||||
{
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->setFrom($email, ucfirst($configKey));
|
||||
}
|
||||
/**
|
||||
* Champ From en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
*/
|
||||
public function setFromKey($configKey)
|
||||
{
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->setFrom($email, ucfirst($configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* Champ To en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
*/
|
||||
public function addToKey($configKey)
|
||||
{
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->addTo($email, ucfirst($configKey));
|
||||
}
|
||||
/**
|
||||
* Champ To en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
*/
|
||||
public function addToKey($configKey)
|
||||
{
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->addTo($email, ucfirst($configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* Définit le sujet de l'email
|
||||
* @param string $texte
|
||||
*/
|
||||
public function setSubjectC($texte = '')
|
||||
{
|
||||
$this->setSubject($this->txtConvert($texte));
|
||||
}
|
||||
/**
|
||||
* Définit le sujet de l'email
|
||||
* @param string $texte
|
||||
*/
|
||||
public function setSubjectC($texte = '')
|
||||
{
|
||||
$this->setSubject($this->txtConvert($texte));
|
||||
}
|
||||
|
||||
/**
|
||||
* Définit le corps de l'email au format texte
|
||||
* @param string $texte
|
||||
*/
|
||||
public function setBodyTextC($texte = '')
|
||||
{
|
||||
$this->setBodyText($this->txtConvert($texte));
|
||||
}
|
||||
/**
|
||||
* Définit le corps de l'email au format texte
|
||||
* @param string $texte
|
||||
*/
|
||||
public function setBodyTextC($texte = '')
|
||||
{
|
||||
$this->setBodyText($this->txtConvert($texte));
|
||||
}
|
||||
|
||||
/**
|
||||
* Définit le corps de l'email au format html
|
||||
* @param string $html
|
||||
*/
|
||||
public function setBodyHtmlC($html = '')
|
||||
{
|
||||
$this->setBodyHtml($this->txtConvert($html));
|
||||
}
|
||||
/**
|
||||
* Définit le corps de l'email au format html
|
||||
* @param string $html
|
||||
*/
|
||||
public function setBodyHtmlC($html = '')
|
||||
{
|
||||
$this->setBodyHtml($this->txtConvert($html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Envoi de l'emai
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->send($this->transport);
|
||||
}
|
||||
/**
|
||||
* Envoi de l'emai
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->send($this->transport);
|
||||
}
|
||||
|
||||
//We suppose that character encoding of strings is UTF-8 on PHP script.
|
||||
protected function txtConvert($string)
|
||||
{
|
||||
return mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8');
|
||||
}
|
||||
//We suppose that character encoding of strings is UTF-8 on PHP script.
|
||||
protected function txtConvert($string)
|
||||
{
|
||||
return mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8');
|
||||
}
|
||||
|
||||
protected function recipientFilename($transport)
|
||||
protected function recipientFilename($transport)
|
||||
{
|
||||
return $transport->recipients . '_' . mt_rand() . '.tmp';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,13 +63,14 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = array()) {
|
||||
if ( !empty($options) && is_array($options) ) {
|
||||
if ( array_key_exists('throw',$options) ) {
|
||||
public function __construct($options = array())
|
||||
{
|
||||
if (!empty($options) && is_array($options)) {
|
||||
if (array_key_exists('throw', $options)) {
|
||||
$this->setThrow4Notation($options['throw']);
|
||||
unset($options['throw']);
|
||||
}
|
||||
if ( array_key_exists('network',$options) ) {
|
||||
if (array_key_exists('network', $options)) {
|
||||
$this->setNetworkNotation($options['network']);
|
||||
unset($options['network']);
|
||||
}
|
||||
@ -84,7 +85,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Validate_Abstract::setMessages()
|
||||
*/
|
||||
public function setMessages(array $messages) {
|
||||
public function setMessages(array $messages)
|
||||
{
|
||||
$newMessages = array(
|
||||
self::MISSING_NETWORK => 'No valid network has been given to validate against',
|
||||
self::INVALID_NETWORK => 'The network is not an accepted format',
|
||||
@ -93,10 +95,10 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
self::HIGH_IN_NETWORK => "The ip '%value%' is higher in range than the provided network",
|
||||
);
|
||||
|
||||
foreach ( $newMessages as $messageKey => $messageString ) {
|
||||
if ( !isset($this->_messageTemplates[$messageKey]) ) {
|
||||
foreach ($newMessages as $messageKey => $messageString) {
|
||||
if (!isset($this->_messageTemplates[$messageKey])) {
|
||||
$this->_messageTemplates[$messageKey] = $messageString;
|
||||
} elseif ( !empty($messages) && array_key_exists($messageKey,$messages) ) {
|
||||
} elseif (!empty($messages) && array_key_exists($messageKey, $messages)) {
|
||||
$this->_messageTemplates[$messageKey] = $messages[$messageKey];
|
||||
unset($messages[$messageKey]);
|
||||
}
|
||||
@ -111,24 +113,25 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* (non-PHPdoc)
|
||||
* @see Zend_Validate_Ip::isValid()
|
||||
*/
|
||||
public function isValid($value) {
|
||||
if ( true === parent::isValid($value) ) {
|
||||
public function isValid($value)
|
||||
{
|
||||
if (true === parent::isValid($value)) {
|
||||
$notation = $this->_getNotation();
|
||||
if ( !empty($notation) ) {
|
||||
if (!empty($notation)) {
|
||||
// a valid notation has been set
|
||||
$network = $this->_getNetwork();
|
||||
if ( !empty($network) ) {
|
||||
if ( true === $this->_validateIpInNetwork($value) ) {
|
||||
if (!empty($network)) {
|
||||
if (true === $this->_validateIpInNetwork($value)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ( true === $this->_validateIpInRange($value) ) {
|
||||
if (true === $this->_validateIpInRange($value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// NOTE: Errors are only available in regards to the value (ip address) and not the network/netmask (notation)
|
||||
$errors = $this->getErrors();
|
||||
if ( empty($errors) ) {
|
||||
if (empty($errors)) {
|
||||
$this->_error(self::NOT_IN_NETWORK);
|
||||
}
|
||||
} else {
|
||||
@ -150,14 +153,15 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $ip
|
||||
* @return bool
|
||||
*/
|
||||
protected function _validateIpInNetwork($ip) {
|
||||
protected function _validateIpInNetwork($ip)
|
||||
{
|
||||
$netmask = $this->getCidr();
|
||||
$network = $this->_getNetwork();
|
||||
|
||||
// lets get this out of the way first
|
||||
if ( 32 === $netmask ) {
|
||||
if (32 === $netmask) {
|
||||
// this network has to match the IP
|
||||
if ( $network === $ip ) {
|
||||
if ($network === $ip) {
|
||||
return true;
|
||||
} else {
|
||||
$this->_error(self::NOT_IN_NETWORK);
|
||||
@ -170,7 +174,7 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
$lNetwork_uDec = $this->_makeUnsignedAddress($network);
|
||||
|
||||
// let verify the IP against the lower end of the range
|
||||
if ( $ip_addr_uDec < $lNetwork_uDec ) {
|
||||
if ($ip_addr_uDec < $lNetwork_uDec) {
|
||||
// the ip is below the network range
|
||||
$this->_error(self::LOW_IN_NETWORK);
|
||||
return false;
|
||||
@ -183,7 +187,7 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
$netmask_uDec = pow(2, 32-$netmask) - 1 ;
|
||||
$uNetwork_uDec = $lNetwork_uDec + $netmask_uDec;
|
||||
|
||||
if ( $ip_addr_uDec > $uNetwork_uDec ) {
|
||||
if ($ip_addr_uDec > $uNetwork_uDec) {
|
||||
// the ip is above the network range
|
||||
$this->_error(self::HIGH_IN_NETWORK);
|
||||
return false;
|
||||
@ -203,17 +207,18 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $ip
|
||||
* @return bool
|
||||
*/
|
||||
protected function _validateIpInRange($ip) {
|
||||
protected function _validateIpInRange($ip)
|
||||
{
|
||||
$uInt_Ip = $this->_makeUnsignedAddress($ip);
|
||||
|
||||
if ( is_numeric($this->_rangeFrom) && $uInt_Ip >= $this->_rangeFrom ) {
|
||||
if ( $uInt_Ip <= $this->_rangeTo ) {
|
||||
if (is_numeric($this->_rangeFrom) && $uInt_Ip >= $this->_rangeFrom) {
|
||||
if ($uInt_Ip <= $this->_rangeTo) {
|
||||
return true;
|
||||
} elseif ( is_numeric($this->_rangeTo) ) {
|
||||
} elseif (is_numeric($this->_rangeTo)) {
|
||||
$this->_error(self::HIGH_IN_NETWORK);
|
||||
return false;
|
||||
}
|
||||
} elseif ( is_numeric($this->_rangeFrom) ) {
|
||||
} elseif (is_numeric($this->_rangeFrom)) {
|
||||
$this->_error(self::LOW_IN_NETWORK);
|
||||
return false;
|
||||
}
|
||||
@ -234,12 +239,13 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* string $notation network/address (128.0.0.0/24) (128.0.0.0/255.255.255.0) or (128.0.0.0-128.0.0.255)
|
||||
* @return object|false Awd_Validate_IpInNetwork
|
||||
*/
|
||||
public function setNetworkNotation($notation) {
|
||||
public function setNetworkNotation($notation)
|
||||
{
|
||||
$network = false !== strpos($notation, '/') ? $this->_evaluateNetmask($notation) : false ;
|
||||
if ( false !== $network) {
|
||||
if (false !== $network) {
|
||||
// a valid CIDR/netmask has been found
|
||||
if ( true === parent::isValid($network) ) {
|
||||
if ( $this->_validateNetwork($network) ) {
|
||||
if (true === parent::isValid($network)) {
|
||||
if ($this->_validateNetwork($network)) {
|
||||
$this->_network = $network;
|
||||
$this->_notation = $notation;
|
||||
|
||||
@ -248,9 +254,9 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
} else {
|
||||
$this->_invalidNetwork(__LINE__);
|
||||
}
|
||||
} elseif ( false !== strpos($notation, '-') ) {
|
||||
} elseif (false !== strpos($notation, '-')) {
|
||||
// the notation is looking like a from-to IP range
|
||||
if ( true === $this->_validateRange($notation) ) {
|
||||
if (true === $this->_validateRange($notation)) {
|
||||
$this->_notation = $notation;
|
||||
|
||||
return $this;
|
||||
@ -272,10 +278,11 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* bool $throw
|
||||
* @return object Awd_Validate_IpInNetwork
|
||||
*/
|
||||
public function setThrow4Notation($throw = false) {
|
||||
if ( !is_bool($throw) ) {
|
||||
public function setThrow4Notation($throw = false)
|
||||
{
|
||||
if (!is_bool($throw)) {
|
||||
$msg = '[AWD] Programming error: The argument is not a boolean value';
|
||||
trigger_error($msg,E_USER_WARNING);
|
||||
trigger_error($msg, E_USER_WARNING);
|
||||
}
|
||||
|
||||
|
||||
@ -293,7 +300,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* an error was found in the submitted network notation. The default is false.</p>
|
||||
* @return bool
|
||||
*/
|
||||
public function getThrow4Notation() {
|
||||
public function getThrow4Notation()
|
||||
{
|
||||
return (bool) $this->_throw;
|
||||
}
|
||||
|
||||
@ -307,7 +315,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* verify if setting a network range or notation was successful with the constructor.</p>
|
||||
* @return string
|
||||
*/
|
||||
public function getNetworkNotation() {
|
||||
public function getNetworkNotation()
|
||||
{
|
||||
return (string) $this->_getNotation();
|
||||
}
|
||||
|
||||
@ -323,7 +332,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* (protected) the same result as the public method getNetworkNotation().</p>
|
||||
* @return string|null
|
||||
*/
|
||||
protected function _getNotation() {
|
||||
protected function _getNotation()
|
||||
{
|
||||
return empty($this->_notation) ? null : (string) $this->_notation ;
|
||||
}
|
||||
|
||||
@ -338,7 +348,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* network range has been set this value will be empty.</p>
|
||||
* @return string
|
||||
*/
|
||||
protected function _getNetwork() {
|
||||
protected function _getNetwork()
|
||||
{
|
||||
return (string) $this->_network;
|
||||
}
|
||||
|
||||
@ -352,7 +363,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* network/CIDR. If the notation was not valid or a network range has been set this value will be empty.</p>
|
||||
* @return int
|
||||
*/
|
||||
public function getCidr() {
|
||||
public function getCidr()
|
||||
{
|
||||
return (int) $this->_cidr;
|
||||
}
|
||||
|
||||
@ -370,30 +382,31 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $notation
|
||||
* @return string|bool (false)
|
||||
*/
|
||||
protected function _evaluateNetmask($notation) {
|
||||
protected function _evaluateNetmask($notation)
|
||||
{
|
||||
// split the notation in network and netmask information
|
||||
list($network, $netmask) = explode('/', $notation, 2);
|
||||
if ( is_numeric($netmask) ) {
|
||||
if (is_numeric($netmask)) {
|
||||
// does look like a CIDR netmask
|
||||
$between = new Zend_Validate_Between(array('min'=>1,'max'=>32));
|
||||
if ( true === $between->isValid($netmask) ) {
|
||||
$between = new Zend_Validate_Between(array('min'=>1, 'max'=>32));
|
||||
if (true === $between->isValid($netmask)) {
|
||||
$this->_cidr = (int) $netmask;
|
||||
return $network;
|
||||
} else {
|
||||
$error_msgs = $between->getMessages();
|
||||
if ( !empty($error_msgs) && is_array($error_msgs) ) {
|
||||
if (!empty($error_msgs) && is_array($error_msgs)) {
|
||||
$msg = array_shift($error_msgs);
|
||||
} else {
|
||||
// fallback, should not really be an option
|
||||
$msg = sprintf('The netmask [ %s ] is not a valid option',$netmask);
|
||||
$msg = sprintf('The netmask [ %s ] is not a valid option', $netmask);
|
||||
}
|
||||
|
||||
// oops, this CIDR is not a valid range
|
||||
return $this->_invalidNetwork(__LINE__.' - '.$msg);
|
||||
}
|
||||
} elseif ( !empty($netmask) ) {
|
||||
} elseif (!empty($netmask)) {
|
||||
// looks more like 32-bit (like 255.255.255.0) format
|
||||
if ( true === ($line = $this->_validateNetmask($netmask)) ) {
|
||||
if (true === ($line = $this->_validateNetmask($netmask))) {
|
||||
return $network;
|
||||
}
|
||||
|
||||
@ -416,17 +429,19 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $netmask
|
||||
* @return true|string
|
||||
*/
|
||||
protected function _validateNetmask($netmask) {
|
||||
protected function _validateNetmask($netmask)
|
||||
{
|
||||
$classes = explode('.', $netmask);
|
||||
if ( 4 !== count($classes) ) {
|
||||
if (4 !== count($classes)) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
$cidr = 0; $end = false;
|
||||
foreach ( $classes as $index => $segment ) {
|
||||
if ( !is_numeric($segment) ) {
|
||||
$cidr = 0;
|
||||
$end = false;
|
||||
foreach ($classes as $index => $segment) {
|
||||
if (!is_numeric($segment)) {
|
||||
return __LINE__;
|
||||
} elseif ( 0 === (int) $segment ) {
|
||||
} elseif (0 === (int) $segment) {
|
||||
$end = true; // all following segment have to be 0 (zero) as well
|
||||
continue;
|
||||
}
|
||||
@ -434,19 +449,21 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
|
||||
// evaluate the binary representation of the segment
|
||||
$bin = decbin($segment);
|
||||
if ( 8 !== strlen($bin) || 0 === preg_match('/^([1]{1,8})([0]*)$/', decbin($segment), $matches) ) {
|
||||
if ( 8 !== strlen($bin) ) {
|
||||
if (8 !== strlen($bin) || 0 === preg_match('/^([1]{1,8})([0]*)$/', decbin($segment), $matches)) {
|
||||
if (8 !== strlen($bin)) {
|
||||
// this segment is not a complete byte (8 bits) i.e. a value below 128
|
||||
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
|
||||
}
|
||||
// this segment is a complete byte (8 bits), i.e. a value above 128, but not a valid binary mask (like 11110000)
|
||||
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
|
||||
} elseif ( true === $end ) {
|
||||
} elseif (true === $end) {
|
||||
// a mask was found in the previous segment; therefore, this segment should be 0 (zero)
|
||||
return __LINE__.':'.++$index; // NOTE: Index begins at 0 (zero)
|
||||
}
|
||||
$len = strlen($matches[1]);
|
||||
if ( $len < 8 ) { $end = true; }
|
||||
if ($len < 8) {
|
||||
$end = true;
|
||||
}
|
||||
$cidr += $len;
|
||||
}
|
||||
|
||||
@ -468,12 +485,13 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $network
|
||||
* @return true|string
|
||||
*/
|
||||
protected function _validateNetwork($network) {
|
||||
protected function _validateNetwork($network)
|
||||
{
|
||||
$cidr = $this->getCidr();
|
||||
$class = $cidr / 8;
|
||||
|
||||
// an integer indicates a classful (unicast) network
|
||||
if ( is_int($class) ) {
|
||||
if (is_int($class)) {
|
||||
$iClass = $class;
|
||||
$maskBits = 0;
|
||||
} else {
|
||||
@ -492,18 +510,18 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
for ($index = $iClass; $index < 4; $index++) {
|
||||
$subNetwork = (int) $segments[$index];
|
||||
|
||||
if ( 0 === $maskBits ) {
|
||||
if (0 === $maskBits) {
|
||||
// this class has no subnets (aka classful network)
|
||||
// all 0 (zero) are expected as (sub)network numbers
|
||||
if ( 0 !== $subNetwork ) {
|
||||
if (0 !== $subNetwork) {
|
||||
return $this->_invalidNetwork(__LINE__.':'.++$index); // NOTE: Index begins at 0 (zero)
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
// this class has subnets (aka a classless (subnetted) network)
|
||||
if ( true === $complete ) {
|
||||
if (true === $complete) {
|
||||
// for all following networks 0 (zero) is expected as (sub)network number
|
||||
if ( 0 !== $subNetwork ) {
|
||||
if (0 !== $subNetwork) {
|
||||
return $this->_invalidNetwork(__LINE__.':'.++$index); // NOTE: Index begins at 0 (zero)
|
||||
}
|
||||
continue;
|
||||
@ -512,7 +530,7 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
|
||||
// the (sub)network must be a fact or hosts(/subnets)
|
||||
$block = $subNetwork / $hosts;
|
||||
if ( is_int($block) ) {
|
||||
if (is_int($block)) {
|
||||
// all clear
|
||||
// NOTE: We do NOT return yet because we may have to verify any following segments
|
||||
continue;
|
||||
@ -536,14 +554,15 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $range
|
||||
* @return bool
|
||||
*/
|
||||
protected function _validateRange($range) {
|
||||
list($from,$to) = explode('-', $range); // Note: we do NOT care if more IP ranges have been set, i.e. the range would be invalid
|
||||
protected function _validateRange($range)
|
||||
{
|
||||
list($from, $to) = explode('-', $range); // Note: we do NOT care if more IP ranges have been set, i.e. the range would be invalid
|
||||
|
||||
if ( false === ($uInt_from = $this->_makeUnsignedAddress($from)) || false === ($uInt_to = $this->_makeUnsignedAddress($to)) ) {
|
||||
if (false === ($uInt_from = $this->_makeUnsignedAddress($from)) || false === ($uInt_to = $this->_makeUnsignedAddress($to))) {
|
||||
return $this->_invalidNetwork(__LINE__); // at least one of the addresses is not a valid IP address
|
||||
}
|
||||
|
||||
if ( $uInt_from <= $uInt_to ) {
|
||||
if ($uInt_from <= $uInt_to) {
|
||||
$this->_rangeFrom = $uInt_from;
|
||||
$this->_rangeTo = $uInt_to;
|
||||
} else {
|
||||
@ -567,8 +586,9 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string $ip
|
||||
* @return string
|
||||
*/
|
||||
private function _makeUnsignedAddress($ip) {
|
||||
if ( false === ($ip_addr_long = ip2long($ip)) ) {
|
||||
private function _makeUnsignedAddress($ip)
|
||||
{
|
||||
if (false === ($ip_addr_long = ip2long($ip))) {
|
||||
// not a valid IP address
|
||||
return false;
|
||||
}
|
||||
@ -581,7 +601,7 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
// 128.0.0.0 = -2147483648
|
||||
|
||||
// convert to unsigned decimal number
|
||||
return sprintf('%u',$ip_addr_long);
|
||||
return sprintf('%u', $ip_addr_long);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -597,18 +617,16 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
|
||||
* @param string|int $line
|
||||
* @return bool (false)
|
||||
*/
|
||||
private function _invalidNetwork($line) {
|
||||
private function _invalidNetwork($line)
|
||||
{
|
||||
$error_msg = 'The provided network information is not a recognized format [#'.$line.']';
|
||||
$this->_error(self::INVALID_NETWORK,$error_msg);
|
||||
$this->_error(self::INVALID_NETWORK, $error_msg);
|
||||
$msg = '[SCORES] Application error: '.$error_msg;
|
||||
if ( false === $this->_throw ) {
|
||||
trigger_error($msg,E_USER_WARNING);
|
||||
if (false === $this->_throw) {
|
||||
trigger_error($msg, E_USER_WARNING);
|
||||
return false;
|
||||
} else {
|
||||
throw new Exception($msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,92 +1,84 @@
|
||||
<?php
|
||||
class Scores_Ws_Discover
|
||||
{
|
||||
protected $serviceWsdl = null;
|
||||
protected $serviceOptions = array();
|
||||
protected $serviceStructure = array();
|
||||
protected $serviceStructureTypes = array();
|
||||
protected $serviceTypes;
|
||||
protected $serviceFunctions;
|
||||
protected $serviceWsdl = null;
|
||||
protected $serviceOptions = array();
|
||||
protected $serviceStructure = array();
|
||||
protected $serviceStructureTypes = array();
|
||||
protected $serviceTypes;
|
||||
protected $serviceFunctions;
|
||||
|
||||
|
||||
public function __construct($wsdl, $options = array())
|
||||
{
|
||||
$this->serviceWsdl = $wsdl;
|
||||
$this->serviceOptions = $options;
|
||||
$this->setStructure();
|
||||
}
|
||||
public function __construct($wsdl, $options = array())
|
||||
{
|
||||
$this->serviceWsdl = $wsdl;
|
||||
$this->serviceOptions = $options;
|
||||
$this->setStructure();
|
||||
}
|
||||
|
||||
public function getStructure()
|
||||
{
|
||||
return $this->serviceStructure;
|
||||
}
|
||||
public function getStructure()
|
||||
{
|
||||
return $this->serviceStructure;
|
||||
}
|
||||
|
||||
public function getStructureParam()
|
||||
{
|
||||
return $this->serviceStructureTypes;
|
||||
}
|
||||
public function getStructureParam()
|
||||
{
|
||||
return $this->serviceStructureTypes;
|
||||
}
|
||||
|
||||
protected function setStructure()
|
||||
{
|
||||
$client = new Zend_Soap_Client(
|
||||
$this->serviceWsdl,
|
||||
$this->serviceOptions
|
||||
);
|
||||
$this->serviceFunctions = $client->getFunctions();
|
||||
$this->serviceTypes = $client->getTypes();
|
||||
protected function setStructure()
|
||||
{
|
||||
$client = new Zend_Soap_Client(
|
||||
$this->serviceWsdl,
|
||||
$this->serviceOptions
|
||||
);
|
||||
$this->serviceFunctions = $client->getFunctions();
|
||||
$this->serviceTypes = $client->getTypes();
|
||||
|
||||
foreach($this->serviceFunctions as $func)
|
||||
{
|
||||
$this->setFunction($func);
|
||||
}
|
||||
foreach ($this->serviceFunctions as $func) {
|
||||
$this->setFunction($func);
|
||||
}
|
||||
|
||||
foreach($this->serviceTypes as $type){
|
||||
$this->setType($type);
|
||||
}
|
||||
}
|
||||
foreach ($this->serviceTypes as $type) {
|
||||
$this->setType($type);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setFunction($func)
|
||||
{
|
||||
if (preg_match('/[^\s]+\s([^\s]+)\((.*)\)/', $func, $matches))
|
||||
{
|
||||
$funcName = $matches[1];
|
||||
$funcParams = $matches[2];
|
||||
$this->serviceStructure[$funcName] = array();
|
||||
if (preg_match_all('/([^\s]+)\s([^\s]+),?/', $funcParams, $mParams))
|
||||
{
|
||||
$nbParams = count($mParams[0]);
|
||||
for($i=0;$i<$nbParams;$i++)
|
||||
{
|
||||
$type = $mParams[1][$i];
|
||||
$name = $mParams[2][$i];
|
||||
$this->serviceStructure[$funcName][$i] = array(
|
||||
'name' => $name,
|
||||
'type' => $type
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function setType($type)
|
||||
{
|
||||
$type = str_replace("\n", '', $type);
|
||||
if (preg_match('/struct\s([^\s]+)\s\{(.*)\}$/m', $type, $matches))
|
||||
{
|
||||
$struct = trim($matches[1]);
|
||||
$params = trim($matches[2]);
|
||||
preg_match_all('/([^\s]+)\s([^\s]+);/', $params, $paramsMatches);
|
||||
$nbParams = count($paramsMatches[0]);
|
||||
$this->serviceStructureTypes[$struct] = array();
|
||||
for($i=0; $i<$nbParams;$i++)
|
||||
{
|
||||
$this->serviceStructureTypes[$struct][$i] = array(
|
||||
'name' => $paramsMatches[2][$i],
|
||||
'type' => $paramsMatches[1][$i],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected function setFunction($func)
|
||||
{
|
||||
if (preg_match('/[^\s]+\s([^\s]+)\((.*)\)/', $func, $matches)) {
|
||||
$funcName = $matches[1];
|
||||
$funcParams = $matches[2];
|
||||
$this->serviceStructure[$funcName] = array();
|
||||
if (preg_match_all('/([^\s]+)\s([^\s]+),?/', $funcParams, $mParams)) {
|
||||
$nbParams = count($mParams[0]);
|
||||
for ($i=0;$i<$nbParams;$i++) {
|
||||
$type = $mParams[1][$i];
|
||||
$name = $mParams[2][$i];
|
||||
$this->serviceStructure[$funcName][$i] = array(
|
||||
'name' => $name,
|
||||
'type' => $type
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function setType($type)
|
||||
{
|
||||
$type = str_replace("\n", '', $type);
|
||||
if (preg_match('/struct\s([^\s]+)\s\{(.*)\}$/m', $type, $matches)) {
|
||||
$struct = trim($matches[1]);
|
||||
$params = trim($matches[2]);
|
||||
preg_match_all('/([^\s]+)\s([^\s]+);/', $params, $paramsMatches);
|
||||
$nbParams = count($paramsMatches[0]);
|
||||
$this->serviceStructureTypes[$struct] = array();
|
||||
for ($i=0; $i<$nbParams;$i++) {
|
||||
$this->serviceStructureTypes[$struct][$i] = array(
|
||||
'name' => $paramsMatches[2][$i],
|
||||
'type' => $paramsMatches[1][$i],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,187 +1,181 @@
|
||||
<?php
|
||||
class Scores_Ws_Doc
|
||||
{
|
||||
private $serviceClass;
|
||||
private $serviceClass;
|
||||
|
||||
private $classmap = array();
|
||||
private $classmap = array();
|
||||
|
||||
private $serviceMethods = array();
|
||||
private $serviceMethods = array();
|
||||
|
||||
private $serviceTypes = array();
|
||||
private $serviceTypes = array();
|
||||
|
||||
public function __construct($serviceClass = null, $classmap = null, $path)
|
||||
{
|
||||
$this->serviceClass = $serviceClass;
|
||||
$this->classmap = $classmap;
|
||||
require_once $path . 'Service.php';
|
||||
$this->parseService();
|
||||
$this->parseTypes();
|
||||
}
|
||||
public function __construct($serviceClass = null, $classmap = null, $path)
|
||||
{
|
||||
$this->serviceClass = $serviceClass;
|
||||
$this->classmap = $classmap;
|
||||
require_once $path . 'Service.php';
|
||||
$this->parseService();
|
||||
$this->parseTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des services et leurs paramètres
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceMethods()
|
||||
{
|
||||
return $this->serviceMethods;
|
||||
}
|
||||
/**
|
||||
* Retourne la liste des services et leurs paramètres
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceMethods()
|
||||
{
|
||||
return $this->serviceMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des types de données et leurs paramètres
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceTypes()
|
||||
{
|
||||
return $this->serviceTypes;
|
||||
}
|
||||
/**
|
||||
* Retourne la liste des types de données et leurs paramètres
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceTypes()
|
||||
{
|
||||
return $this->serviceTypes;
|
||||
}
|
||||
|
||||
private function parseService()
|
||||
{
|
||||
$class = new Zend_Server_Reflection();
|
||||
$methods = $class->reflectClass($this->serviceClass)
|
||||
->getMethods();
|
||||
$methodsElement = array();
|
||||
foreach ($methods as $method) {
|
||||
private function parseService()
|
||||
{
|
||||
$class = new Zend_Server_Reflection();
|
||||
$methods = $class->reflectClass($this->serviceClass)
|
||||
->getMethods();
|
||||
$methodsElement = array();
|
||||
foreach ($methods as $method) {
|
||||
$prototype = null;
|
||||
$maxNumArgumentsOfPrototype = -1;
|
||||
foreach ($method->getPrototypes() as $tmpPrototype) {
|
||||
$numParams = count($tmpPrototype->getParameters());
|
||||
if ($numParams > $maxNumArgumentsOfPrototype) {
|
||||
$maxNumArgumentsOfPrototype = $numParams;
|
||||
$prototype = $tmpPrototype;
|
||||
}
|
||||
}
|
||||
|
||||
$prototype = null;
|
||||
$maxNumArgumentsOfPrototype = -1;
|
||||
foreach ($method->getPrototypes() as $tmpPrototype) {
|
||||
$numParams = count($tmpPrototype->getParameters());
|
||||
if ($numParams > $maxNumArgumentsOfPrototype) {
|
||||
$maxNumArgumentsOfPrototype = $numParams;
|
||||
$prototype = $tmpPrototype;
|
||||
}
|
||||
}
|
||||
$paramsElement = array();
|
||||
foreach ($prototype->getParameters() as $param) {
|
||||
$paramElement = array(
|
||||
'type' => $param->getType(),
|
||||
'name' => $param->getName(),
|
||||
'description' => $param->getDescription(),
|
||||
|
||||
$paramsElement = array();
|
||||
foreach ($prototype->getParameters() as $param) {
|
||||
$paramElement = array(
|
||||
'type' => $param->getType(),
|
||||
'name' => $param->getName(),
|
||||
'description' => $param->getDescription(),
|
||||
);
|
||||
if ($param->isOptional()) {
|
||||
$paramElement['optional'] = $param->isOptional();
|
||||
$paramElement['defaultValue'] = $param->getDefaultValue();
|
||||
}
|
||||
$paramsElement[] = $paramElement;
|
||||
}
|
||||
|
||||
);
|
||||
if ($param->isOptional()){
|
||||
$paramElement['optional'] = $param->isOptional();
|
||||
$paramElement['defaultValue'] = $param->getDefaultValue();
|
||||
}
|
||||
$paramsElement[] = $paramElement;
|
||||
}
|
||||
$methodElement = array(
|
||||
'name' => $method->getName(),
|
||||
'desc' => $method->getDescription(),
|
||||
'params' => $paramsElement,
|
||||
'return' => $prototype->getReturnType(),
|
||||
);
|
||||
|
||||
$methodElement = array(
|
||||
'name' => $method->getName(),
|
||||
'desc' => $method->getDescription(),
|
||||
'params' => $paramsElement,
|
||||
'return' => $prototype->getReturnType(),
|
||||
);
|
||||
$methodsElement[] = $methodElement;
|
||||
}
|
||||
$this->serviceMethods = $methodsElement;
|
||||
}
|
||||
|
||||
$methodsElement[] = $methodElement;
|
||||
}
|
||||
$this->serviceMethods = $methodsElement;
|
||||
}
|
||||
private function parseTypes()
|
||||
{
|
||||
$typesElement = array();
|
||||
if (count($this->classmap)>0) {
|
||||
foreach ($this->classmap as $className) {
|
||||
$class = new ReflectionClass($className);
|
||||
$paramsElement = array();
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
|
||||
$name = $property->getName();
|
||||
$type = $matches[1][0];
|
||||
|
||||
private function parseTypes()
|
||||
{
|
||||
$typesElement = array();
|
||||
if (count($this->classmap)>0)
|
||||
{
|
||||
foreach ($this->classmap as $className)
|
||||
{
|
||||
$class = new ReflectionClass($className);
|
||||
$paramsElement = array();
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
|
||||
/**
|
||||
* Traitement éléments de documentation à placer dans le WSDL
|
||||
* Supprime les retours chariots.
|
||||
* Récupére les éléments de documentation
|
||||
*/
|
||||
$comment = '';
|
||||
$docBlock = preg_replace('/\n/', '', $property->getDocComment());
|
||||
if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) {
|
||||
$comment.= preg_replace(
|
||||
array('/\r/', '/\*/' ),
|
||||
array('', ''), $docBlockMatches[1]
|
||||
);
|
||||
}
|
||||
|
||||
$name = $property->getName();
|
||||
$type = $matches[1][0];
|
||||
|
||||
/**
|
||||
* Traitement éléments de documentation à placer dans le WSDL
|
||||
* Supprime les retours chariots.
|
||||
* Récupére les éléments de documentation
|
||||
*/
|
||||
$comment = '';
|
||||
$docBlock = preg_replace('/\n/', '', $property->getDocComment() );
|
||||
if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) {
|
||||
$comment.= preg_replace(
|
||||
array('/\r/', '/\*/' ),
|
||||
array('' , ''), $docBlockMatches[1]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement des @xsd (Provisoire)
|
||||
* Définition des longueurs dans la documentation
|
||||
* @xsd minLength=[\d]+ => (Longueur min = [\d]+)
|
||||
* @xsd maxLength=[\d]+ => (Longueur max = [\d]+)
|
||||
* @xsd enumeration=element,element
|
||||
*/
|
||||
if (preg_match_all('/@xsd\s+(minLength|maxLength)=([\d]+)\s+(?:\*|@)/m', $property->getDocComment(), $resMatches, PREG_SET_ORDER)){
|
||||
$comment.= '(';
|
||||
$parcourCpt = 0;
|
||||
foreach ($resMatches as $res ) {
|
||||
switch ($res[1]){
|
||||
case 'minLength':
|
||||
$comment.= 'Longueur min = '.$res[2];
|
||||
break;
|
||||
case 'maxLength':
|
||||
$comment.= 'Longueur max = '.$res[2];
|
||||
break;
|
||||
}
|
||||
$parcourCpt++;
|
||||
if ($parcourCpt>0 && $parcourCpt<count($resMatches)) {
|
||||
$comment.= ', ';
|
||||
}
|
||||
}
|
||||
$comment.= ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement des références
|
||||
* @ref fichier:titre:nom_du_fichier
|
||||
* => http://vhost/ref/fichier/
|
||||
* @ref mysql:titre:requete.sql
|
||||
* => http://vhost/ref/table/
|
||||
*/
|
||||
if (preg_match_all('/@ref\s+(fichier|mysql):(.*):(.*)\.(?:csv|sql)\s+(?:\*|@)/m', $property->getDocComment(), $refMatches, PREG_SET_ORDER)){
|
||||
$view = new Zend_View();
|
||||
$comment.= ', Référence(s) : ';
|
||||
foreach ($refMatches as $ref){
|
||||
switch ($ref[1]){
|
||||
case 'fichier':
|
||||
$urlFichier = $view->url(array(
|
||||
'controller' => 'ref',
|
||||
'action' => 'fichier',
|
||||
'q' => $ref[3],
|
||||
), null, true);
|
||||
$comment.= '<a href="'.$urlFichier.'">'.$ref[2].'</a>';
|
||||
break;
|
||||
case 'mysql':
|
||||
$urlMysql = $view->url(array(
|
||||
'controller' => 'ref',
|
||||
'action' => 'table',
|
||||
'q' => $ref[3],
|
||||
), null, true);
|
||||
$comment.= '<a href="'.$urlMysql.'">'.$ref[2].'</a>';
|
||||
break;
|
||||
}
|
||||
$comment.= ', ';
|
||||
}
|
||||
}
|
||||
$paramElement = array(
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'description' => trim($comment)
|
||||
);
|
||||
|
||||
}
|
||||
$paramsElement[] = $paramElement;
|
||||
}
|
||||
$typesElement[$className] = $paramsElement;
|
||||
}
|
||||
$this->serviceTypes = $typesElement;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Traitement des @xsd (Provisoire)
|
||||
* Définition des longueurs dans la documentation
|
||||
* @xsd minLength=[\d]+ => (Longueur min = [\d]+)
|
||||
* @xsd maxLength=[\d]+ => (Longueur max = [\d]+)
|
||||
* @xsd enumeration=element,element
|
||||
*/
|
||||
if (preg_match_all('/@xsd\s+(minLength|maxLength)=([\d]+)\s+(?:\*|@)/m', $property->getDocComment(), $resMatches, PREG_SET_ORDER)) {
|
||||
$comment.= '(';
|
||||
$parcourCpt = 0;
|
||||
foreach ($resMatches as $res) {
|
||||
switch ($res[1]) {
|
||||
case 'minLength':
|
||||
$comment.= 'Longueur min = '.$res[2];
|
||||
break;
|
||||
case 'maxLength':
|
||||
$comment.= 'Longueur max = '.$res[2];
|
||||
break;
|
||||
}
|
||||
$parcourCpt++;
|
||||
if ($parcourCpt>0 && $parcourCpt<count($resMatches)) {
|
||||
$comment.= ', ';
|
||||
}
|
||||
}
|
||||
$comment.= ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement des références
|
||||
* @ref fichier:titre:nom_du_fichier
|
||||
* => http://vhost/ref/fichier/
|
||||
* @ref mysql:titre:requete.sql
|
||||
* => http://vhost/ref/table/
|
||||
*/
|
||||
if (preg_match_all('/@ref\s+(fichier|mysql):(.*):(.*)\.(?:csv|sql)\s+(?:\*|@)/m', $property->getDocComment(), $refMatches, PREG_SET_ORDER)) {
|
||||
$view = new Zend_View();
|
||||
$comment.= ', Référence(s) : ';
|
||||
foreach ($refMatches as $ref) {
|
||||
switch ($ref[1]) {
|
||||
case 'fichier':
|
||||
$urlFichier = $view->url(array(
|
||||
'controller' => 'ref',
|
||||
'action' => 'fichier',
|
||||
'q' => $ref[3],
|
||||
), null, true);
|
||||
$comment.= '<a href="'.$urlFichier.'">'.$ref[2].'</a>';
|
||||
break;
|
||||
case 'mysql':
|
||||
$urlMysql = $view->url(array(
|
||||
'controller' => 'ref',
|
||||
'action' => 'table',
|
||||
'q' => $ref[3],
|
||||
), null, true);
|
||||
$comment.= '<a href="'.$urlMysql.'">'.$ref[2].'</a>';
|
||||
break;
|
||||
}
|
||||
$comment.= ', ';
|
||||
}
|
||||
}
|
||||
$paramElement = array(
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'description' => trim($comment)
|
||||
);
|
||||
}
|
||||
$paramsElement[] = $paramElement;
|
||||
}
|
||||
$typesElement[$className] = $paramsElement;
|
||||
}
|
||||
$this->serviceTypes = $typesElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
<?php
|
||||
class Scores_Ws_Exception extends Zend_Exception {}
|
||||
class Scores_Ws_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,24 +1,23 @@
|
||||
<?php
|
||||
class Scores_Ws_Form_GetIdentite extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setName('soapform');
|
||||
$this->setAction('/demo/requete');
|
||||
$this->setMethod('post');
|
||||
$this->addElement('text', 'siret', array(
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
array('stringLength',false,array(9,14)),
|
||||
array('NotEmpty', true),
|
||||
),
|
||||
'label' => 'Siret : ',
|
||||
'required' => 'true',
|
||||
)
|
||||
);
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'label' => 'Envoyez',
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
public function init()
|
||||
{
|
||||
$this->setName('soapform');
|
||||
$this->setAction('/demo/requete');
|
||||
$this->setMethod('post');
|
||||
$this->addElement('text', 'siret', array(
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
array('stringLength', false, array(9, 14)),
|
||||
array('NotEmpty', true),
|
||||
),
|
||||
'label' => 'Siret : ',
|
||||
'required' => 'true',
|
||||
)
|
||||
);
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'label' => 'Envoyez',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ class Scores_Ws_Trigger
|
||||
*/
|
||||
protected function hasTrigger()
|
||||
{
|
||||
if ( $this->userInfos['Service'] === null ) {
|
||||
if ($this->userInfos['Service'] === null) {
|
||||
$service = 'default';
|
||||
}
|
||||
|
||||
@ -28,8 +28,8 @@ class Scores_Ws_Trigger
|
||||
->where('service=?', $service)
|
||||
->where('login=? OR login=""', $login);
|
||||
$result = $model->fetchAll($sql);
|
||||
if ( count($result)>0 ) {
|
||||
foreach ( $result as $item ) {
|
||||
if (count($result)>0) {
|
||||
foreach ($result as $item) {
|
||||
$tmp->action = $item->action;
|
||||
$tmp->params = json_decode($item->actionParams, true);
|
||||
}
|
||||
@ -45,15 +45,15 @@ class Scores_Ws_Trigger
|
||||
*/
|
||||
protected function executeAllTrigger($args)
|
||||
{
|
||||
if ( count($this->events)>0 ) {
|
||||
foreach ( $this->events as $action ) {
|
||||
$args = array_merge($args, $action->params);
|
||||
switch ( $action->action ) {
|
||||
case 'surveillance':
|
||||
return $this->surveillance($args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count($this->events)>0) {
|
||||
foreach ($this->events as $action) {
|
||||
$args = array_merge($args, $action->params);
|
||||
switch ($action->action) {
|
||||
case 'surveillance':
|
||||
return $this->surveillance($args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,48 +65,47 @@ class Scores_Ws_Trigger
|
||||
*/
|
||||
protected function surveillance($args)
|
||||
{
|
||||
if ( !array_key_exists('source', $args) ) {
|
||||
if (!array_key_exists('source', $args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !array_key_exists('siren', $args) ) {
|
||||
if (!array_key_exists('siren', $args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !array_key_exists('nic', $args) ) {
|
||||
if (!array_key_exists('nic', $args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty(trim($this->userInfos['email'])) ) {
|
||||
if (empty(trim($this->userInfos['email']))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( array_key_exists('ref', $args)) {
|
||||
$ref = $args['ref'];
|
||||
if (array_key_exists('ref', $args)) {
|
||||
$ref = $args['ref'];
|
||||
}
|
||||
|
||||
try {
|
||||
$model = new Application_Model_JoSurveillancesSite();
|
||||
$data = array(
|
||||
'source' => $args['source'],
|
||||
'login' => $this->userInfos['login'],
|
||||
'email' => $this->userInfos['email'],
|
||||
'siren' => $args['siren'],
|
||||
'nic' => $args['nic'],
|
||||
'ref' => $ref,
|
||||
'encoursClient' => 0,
|
||||
'rs' => $args['Nom'],
|
||||
'cp' => $args['CP'],
|
||||
'ville' => $args['Ville'],
|
||||
'dateAjout' => date('Y-m-d'),
|
||||
'dateSuppr' => 0,
|
||||
);
|
||||
'source' => $args['source'],
|
||||
'login' => $this->userInfos['login'],
|
||||
'email' => $this->userInfos['email'],
|
||||
'siren' => $args['siren'],
|
||||
'nic' => $args['nic'],
|
||||
'ref' => $ref,
|
||||
'encoursClient' => 0,
|
||||
'rs' => $args['Nom'],
|
||||
'cp' => $args['CP'],
|
||||
'ville' => $args['Ville'],
|
||||
'dateAjout' => date('Y-m-d'),
|
||||
'dateSuppr' => 0,
|
||||
);
|
||||
$model->insert($data);
|
||||
return true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user