106 lines
2.7 KiB
PHP
106 lines
2.7 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/>';
|
|
$message.= 'Informations de debug : <br/>';
|
|
$message.= '<pre>';
|
|
$message.= 'REQUEST : '.print_r($_REQUEST,true).'<br/><br/>';
|
|
$message.= 'SERVER : '.print_r($_REQUEST,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(){
|
|
(defined('ERROR_SOAP')) ? ($message = ERROR_SOAP) : ($message = "Une erreur est survenue lors de votre requête") ;
|
|
return $message;
|
|
}
|
|
|
|
/**
|
|
* Envoi de l'erreur Soap par mail.
|
|
* @param string $message
|
|
* @return void
|
|
*/
|
|
function graydon_mailSoapFault($message){
|
|
$mail = new PHPMailer();
|
|
$mail->From = "contact@scores-decisions.com";
|
|
$mail->FromName = "Serveur SD-13408";
|
|
$mail->Host = "mail.scores-decisions.com";
|
|
$mail->Mailer = "smtp";
|
|
$mail->Subject = "Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")";
|
|
$body = $message;
|
|
$mail->MsgHTML($body);
|
|
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
|
|
if(!$mail->Send()) {
|
|
logSoapFault($mail->ErrorInfo);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
|
|
|
|
?>
|