This commit is contained in:
Michael RICOIS 2016-11-24 16:37:56 +01:00
parent a5e1276536
commit 73044d4ab0
15 changed files with 1997 additions and 2005 deletions

View File

@ -44,8 +44,9 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
*/
public function setTimeout($seconds = null)
{
if ($seconds===null)
if ($seconds===null) {
return;
}
$this->_timeout = $seconds;
}
@ -115,7 +116,6 @@ class Scores_Auth_Adapter_Db implements Zend_Auth_Adapter_Interface
$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"));
}

View File

@ -182,7 +182,6 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
$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"));
}

View File

@ -545,7 +545,9 @@ class Scores_Extract_Dict
),
);
public function __construct(){}
public function __construct()
{
}
//Vérifie que les entêtes du fichier sont correct
public function checkFileEntete($pathFile)
@ -553,8 +555,8 @@ class Scores_Extract_Dict
$posKeySiren = $posKeySiret = $posKeyNic = false;
$row = 0;
$error = array();
if (($handle = fopen($pathFile, 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 0, ',', '"')) !== FALSE) {
if (($handle = fopen($pathFile, 'r')) !== false) {
while (($data = fgetcsv($handle, 0, ',', '"')) !== false) {
$num = count($data);
//Traitement de la première ligne
if ($row == 0) {
@ -576,8 +578,7 @@ class Scores_Extract_Dict
default:
//Détection clé pour enrichissement
$values = false;
if (preg_match('/(.*)\((.*)\)/', $key, $matches))
{
if (preg_match('/(.*)\((.*)\)/', $key, $matches)) {
$key = $matches[1];
$values = $matches[2];
} else {
@ -588,7 +589,6 @@ class Scores_Extract_Dict
}
break;
}
}
if ($posKeySiren!==false && $posKeyNic!==false && $posKeySiret!==false || $posKeySiren!==false && $posKeySiret!==false) {
$error[] = "Trop de clé!";
@ -627,8 +627,7 @@ class Scores_Extract_Dict
$key = $matches[1];
}
if (array_key_exists($key, $this->tabDico))
{
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('lib', $element) && !empty($element['lib'])) {
return $element['lib'];
@ -641,8 +640,7 @@ class Scores_Extract_Dict
//Retourne le texte d'aide
public function getDicoHelp($key)
{
if (array_key_exists($key, $this->tabDico))
{
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('help', $element) && !empty($element['help'])) {
return $element['help'];
@ -655,8 +653,7 @@ class Scores_Extract_Dict
//Retourne les colonnes de sortie
public function getDicoColumns($key)
{
if (array_key_exists($key, $this->tabDico))
{
if (array_key_exists($key, $this->tabDico)) {
$element = $this->tabDico[$key];
if (array_key_exists('columns', $element)) {
return $element['columns'];
@ -665,5 +662,4 @@ class Scores_Extract_Dict
}
return false;
}
}

View File

@ -18,8 +18,8 @@ class Scores_Locale_String
*/
public static function cleanstring($string)
{
$transliterate = TRUE;
$reduce_ascii = FALSE;
$transliterate = true;
$reduce_ascii = false;
$output = $string;
// Remove accents and transliterate
@ -47,7 +47,7 @@ class Scores_Locale_String
public static function cleanutf8($string)
{
$transliterate = TRUE;
$transliterate = true;
$output = $string;
// Remove accents and transliterate
@ -71,10 +71,11 @@ class Scores_Locale_String
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"))
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) {
return $in_str;
else
} else {
return utf8_encode($in_str);
}
} // fixEncoding
public static function cleanstring_deep($value)

View File

@ -57,8 +57,7 @@ class Scores_Logger_Sql implements SQLLogger
$this->query['executionMS'] = $time;
if ($this->nb == 0) {
file_put_contents('logger.log', print_r($this->query, 1));
}
else {
} else {
file_put_contents('logger.log', print_r($this->query, 1), FILE_APPEND);
}
$this->nb++;

View File

@ -29,7 +29,6 @@ class Scores_Mail_Method extends Zend_Mail
// --- Configuration du transport SMTP
if ($this->config->method == 'smtp') {
$config = array();
if (isset($this->config->auth)) {

View File

@ -63,7 +63,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
* @param array $options
* @return void
*/
public function __construct($options = array()) {
public function __construct($options = array())
{
if (!empty($options) && is_array($options)) {
if (array_key_exists('throw', $options)) {
$this->setThrow4Notation($options['throw']);
@ -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',
@ -111,7 +113,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
* (non-PHPdoc)
* @see Zend_Validate_Ip::isValid()
*/
public function isValid($value) {
public function isValid($value)
{
if (true === parent::isValid($value)) {
$notation = $this->_getNotation();
if (!empty($notation)) {
@ -150,7 +153,8 @@ 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();
@ -203,7 +207,8 @@ 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) {
@ -234,7 +239,8 @@ 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) {
// a valid CIDR/netmask has been found
@ -272,7 +278,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
* bool $throw
* @return object Awd_Validate_IpInNetwork
*/
public function setThrow4Notation($throw = false) {
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);
@ -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,7 +382,8 @@ 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)) {
@ -416,13 +429,15 @@ 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)) {
return __LINE__;
}
$cidr = 0; $end = false;
$cidr = 0;
$end = false;
foreach ($classes as $index => $segment) {
if (!is_numeric($segment)) {
return __LINE__;
@ -446,7 +461,9 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
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,7 +485,8 @@ 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;
@ -536,7 +554,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
* @param string $range
* @return bool
*/
protected function _validateRange($range) {
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))) {
@ -567,7 +586,8 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
* @param string $ip
* @return string
*/
private function _makeUnsignedAddress($ip) {
private function _makeUnsignedAddress($ip)
{
if (false === ($ip_addr_long = ip2long($ip))) {
// not a valid IP address
return false;
@ -597,7 +617,8 @@ 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);
$msg = '[SCORES] Application error: '.$error_msg;
@ -608,7 +629,4 @@ class Scores_Validate_IpInNetwork extends Zend_Validate_Ip
throw new Exception($msg);
}
}
}

View File

@ -35,8 +35,7 @@ class Scores_Ws_Discover
$this->serviceFunctions = $client->getFunctions();
$this->serviceTypes = $client->getTypes();
foreach($this->serviceFunctions as $func)
{
foreach ($this->serviceFunctions as $func) {
$this->setFunction($func);
}
@ -47,16 +46,13 @@ class Scores_Ws_Discover
protected function setFunction($func)
{
if (preg_match('/[^\s]+\s([^\s]+)\((.*)\)/', $func, $matches))
{
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))
{
if (preg_match_all('/([^\s]+)\s([^\s]+),?/', $funcParams, $mParams)) {
$nbParams = count($mParams[0]);
for($i=0;$i<$nbParams;$i++)
{
for ($i=0;$i<$nbParams;$i++) {
$type = $mParams[1][$i];
$name = $mParams[2][$i];
$this->serviceStructure[$funcName][$i] = array(
@ -64,7 +60,6 @@ class Scores_Ws_Discover
'type' => $type
);
}
}
}
}
@ -72,15 +67,13 @@ class Scores_Ws_Discover
protected function setType($type)
{
$type = str_replace("\n", '', $type);
if (preg_match('/struct\s([^\s]+)\s\{(.*)\}$/m', $type, $matches))
{
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++)
{
for ($i=0; $i<$nbParams;$i++) {
$this->serviceStructureTypes[$struct][$i] = array(
'name' => $paramsMatches[2][$i],
'type' => $paramsMatches[1][$i],
@ -88,5 +81,4 @@ class Scores_Ws_Discover
}
}
}
}

View File

@ -43,7 +43,6 @@ class Scores_Ws_Doc
->getMethods();
$methodsElement = array();
foreach ($methods as $method) {
$prototype = null;
$maxNumArgumentsOfPrototype = -1;
foreach ($method->getPrototypes() as $tmpPrototype) {
@ -84,15 +83,12 @@ class Scores_Ws_Doc
private function parseTypes()
{
$typesElement = array();
if (count($this->classmap)>0)
{
foreach ($this->classmap as $className)
{
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];
@ -174,7 +170,6 @@ class Scores_Ws_Doc
'type' => $type,
'description' => trim($comment)
);
}
$paramsElement[] = $paramElement;
}
@ -183,5 +178,4 @@ class Scores_Ws_Doc
$this->serviceTypes = $typesElement;
}
}
}

View File

@ -1,2 +1,4 @@
<?php
class Scores_Ws_Exception extends Zend_Exception {}
class Scores_Ws_Exception extends Zend_Exception
{
}

View File

@ -19,6 +19,5 @@ class Scores_Ws_Form_GetIdentite extends Zend_Form
$this->addElement('submit', 'submit', array(
'label' => 'Envoyez',
));
}
}

View File

@ -286,8 +286,7 @@ class Scores_Ws_Server
if (strlen($siret) == 14) {
$siren = substr($siret, 0, 9);
$nic = substr($siret, 9, 5);
}
elseif (strlen($siret) == 9) {
} elseif (strlen($siret) == 9) {
$siren = $siret;
$nic = '';
}
@ -356,20 +355,21 @@ class Scores_Ws_Server
$dataInsert['source'] = $result->source;
if ($result->actif == 0) {
$dataInsert['actifInsee'] = 0;
}
elseif (intval($siren) > 1000) {
} elseif (intval($siren) > 1000) {
$dataInsert['actifInsee'] = 1;
if ($result->nb > 0) {
$dataInsert['source'] = 5;
}
}
}
} catch(\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
}
try {
$this->conn->insert('sdv1.logs', $dataInsert);
} catch(\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
}
/**
@ -388,8 +388,7 @@ class Scores_Ws_Server
$this->authMethod = 'basic';
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
}
else {
} else {
/**
* Auth Header in client
* $ns = 'auth';
@ -432,8 +431,7 @@ class Scores_Ws_Server
$this->authenticated = $this->checkAuth($username, $password, $ip);
if ($this->authenticated === false) {
$this->sendError('0900');
}
elseif ( is_string($this->authenticated) ) {
} elseif (is_string($this->authenticated)) {
$this->sendError($this->authenticated);
}
}
@ -476,8 +474,7 @@ class Scores_Ws_Server
if (in_array(strtolower($perm), $droits)) {
$output = true;
}
}
else {
} else {
if (preg_match('/\b'.$perm.'\b/i', $droits)) {
$output = true;
}
@ -548,7 +545,8 @@ class Scores_Ws_Server
$qb->andWhere('u.login = :login')->setParameter('login', $login);
}
$stmt = $qb->execute();
} catch (\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
/**
* No user, deleted or disable
@ -634,9 +632,7 @@ class Scores_Ws_Server
if ($userInfos->accesWS == 1 && $userInfos->idClient != 1) {
// --- Webservice user don't need access to others apps
if (in_array($ip, $this->listApplicationIp)) {
return '0901';
} elseif ($ip != '127.0.0.1') {
// --- For customized version, check user is in the good service
@ -655,7 +651,6 @@ class Scores_Ws_Server
|| strtolower($this->serviceClientName) != $wsClients[$userInfos->idClient])) {
return '0901';
}
}
}
@ -730,7 +725,9 @@ class Scores_Ws_Server
//Timeout
$timeout = $userInfos->timeout;
if ($timeout==0) $timeout = 1800;
if ($timeout==0) {
$timeout = 1800;
}
//Infos utilisateur
$this->User = new stdClass();
@ -760,8 +757,7 @@ class Scores_Ws_Server
foreach ($droits as $droits) {
$this->User->droits[] = $droits;
}
}
else {
} else {
//Inclure les droits du service ?
}
$this->User->droitsClients = $userInfos->droitsClients;
@ -803,7 +799,8 @@ class Scores_Ws_Server
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(\PDO::FETCH_OBJ);
}
} catch (\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
// Aucun service
if ($result === null) {
@ -988,7 +985,6 @@ class Scores_Ws_Server
{
//Check IP
if (!in_array($ip, $this->listApplicationIp)) {
try {
$sql = "SELECT IP FROM sdv1.clients_services_ip
WHERE IdClient = :client AND Service = :service";
@ -1024,10 +1020,9 @@ class Scores_Ws_Server
if ($overallIpValidate === false) {
return '0904';
}
}
} catch (\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
}
}
@ -1042,8 +1037,7 @@ class Scores_Ws_Server
$authenticate = null;
if ($result === false) {
$authenticate = 'KO';
}
elseif (is_string($result)) {
} elseif (is_string($result)) {
$authenticate = $result;
}
if ($authenticate !== null) {
@ -1055,7 +1049,8 @@ class Scores_Ws_Server
);
try {
$this->conn->insert('sdv1.utilisateurs_auth_log', $data);
} catch (\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
}
}
@ -1081,7 +1076,8 @@ class Scores_Ws_Server
$list[] = $row->Acces;
}
}
} catch (\Doctrine\DBAL\DBALException $e) {}
} catch (\Doctrine\DBAL\DBALException $e) {
}
return $list;
}
@ -1091,7 +1087,5 @@ class Scores_Ws_Server
//Est ce que l'utilisateur à un trigger
//Pour chaque trigger - Executer l'action
}
}

View File

@ -104,7 +104,6 @@ class Scores_Ws_Trigger
$model->insert($data);
return true;
} catch (Zend_Db_Exception $e) {
}
return false;