115 lines
2.8 KiB
PHP
115 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* Graydon Error - Gère les erreurs renvoyé par le webservice graydon
|
|
* @package GraydonError
|
|
* @author Michael RICOIS
|
|
* @copyright Scores&Decisions
|
|
*/
|
|
|
|
require_once 'phpmailer/class.phpmailer.php';
|
|
|
|
/**
|
|
* Recupère les erreurs SOAP et les traite.
|
|
* @param string $lastRequest
|
|
* @param string $lastResponse
|
|
* @param array $fault
|
|
* @param bool $debug
|
|
* @return string
|
|
*/
|
|
function graydon_processSoapFault($clientSoap, $fault, $tabInfo, $debug = false)
|
|
{
|
|
$message = 'Request : '.htmlspecialchars($clientSoap->__getLastRequest()).
|
|
'<br/><br/>'.'Response : '.
|
|
htmlspecialchars($clientSoap->__getLastResponse()).'<br/><br/>';
|
|
|
|
$message .= '<br/><br/>';
|
|
$message .= 'Informations de debug : <br/><br/>';
|
|
$message .= '<pre>';
|
|
$message .= 'REQUEST : '.print_r($_REQUEST, true).'<br/><br/>';
|
|
$message .= 'SERVER : ' .print_r($_SERVER, true).'<br/><br/>';
|
|
$message .= 'SESSION : '.print_r($_SESSION, true).'<br/><br/>';
|
|
$message .= 'ENV : ' .print_r($_ENV, true).'<br/><br/>';
|
|
$message .= 'tabInfo : '.print_r($tabInfo, true).'<br/><br/>';
|
|
$message .= '</pre>';
|
|
|
|
if ($debug == true) {
|
|
print '<pre>';
|
|
print $message;
|
|
print '</pre>';
|
|
} else {
|
|
graydon_mailSoapFault($message);
|
|
$message = graydon_messageSoapFault();
|
|
}
|
|
return $message;
|
|
}
|
|
|
|
/**
|
|
* Affiche un message d'erreur sympatique pour le client.
|
|
* @return string
|
|
*/
|
|
function graydon_messageSoapFault()
|
|
{
|
|
return (defined('ERROR_SOAP')) ? ERROR_SOAP :
|
|
"Une erreur est survenue lors de votre requête";
|
|
}
|
|
|
|
/**
|
|
* Envoi de l'erreur Soap par mail.
|
|
* @param string $message
|
|
* @return void
|
|
*/
|
|
function graydon_mailSoapFault($message)
|
|
{
|
|
require_once 'mail/mail.php';
|
|
sendMail(
|
|
"Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")",
|
|
$message,
|
|
//From
|
|
array(
|
|
'email' => 'contact@scores-decisions.com',
|
|
'name' => 'Serveur SD-13408',
|
|
),
|
|
//TO
|
|
array(
|
|
0 => array(
|
|
'email'=> EMAIL_SUPPORTDEV,
|
|
'name' => 'Support'
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Fonction qui enregistre les messages d'erreur dans un log.
|
|
* @param string $message
|
|
* @return void
|
|
*/
|
|
function graydon_logSoapFault($message){
|
|
echo $message;
|
|
}
|
|
|
|
function graydon_error($code, $text)
|
|
{
|
|
$tabError =
|
|
array(0 =>
|
|
array("Code" => "CWS0112",
|
|
"Text" => "Country or Countries specified not valid"),
|
|
1 =>
|
|
array("Code" => "CWS0113",
|
|
"Text" => "Country is not enabled for matchByIdentifier"),
|
|
2 =>
|
|
array("Code" => "CWS5000",
|
|
"Text" => "No match results found for subject company"),
|
|
);
|
|
|
|
$returnError = false;
|
|
foreach ($tabError as $error) {
|
|
if ($code == $error['Code']) {
|
|
$returnError = $error;
|
|
break;
|
|
}
|
|
}
|
|
return $returnError;
|
|
}
|
|
?>
|