2009-05-04 16:59:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* Graydon Error - Gère les erreurs renvoyé par le webservice graydon
|
2009-05-04 16:59:18 +00:00
|
|
|
* @package GraydonError
|
|
|
|
* @author Michael RICOIS
|
|
|
|
* @copyright Scores&Decisions
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once 'phpmailer/class.phpmailer.php';
|
|
|
|
|
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* Recupère les erreurs SOAP et les traite.
|
2009-05-04 16:59:18 +00:00
|
|
|
* @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);
|
2009-06-10 16:14:11 +00:00
|
|
|
$message = graydon_messageSoapFault();
|
2009-05-04 16:59:18 +00:00
|
|
|
}
|
2009-06-10 16:14:11 +00:00
|
|
|
return $message;
|
2009-05-04 16:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Affiche un message d'erreur sympatique pour le client.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function graydon_messageSoapFault(){
|
2010-02-10 17:27:03 +00:00
|
|
|
(defined('ERROR_SOAP')) ? ($message = ERROR_SOAP) : ($message = "Une erreur est survenue lors de votre requête") ;
|
2009-05-04 16:59:18 +00:00
|
|
|
return $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Envoi de l'erreur Soap par mail.
|
|
|
|
* @param string $message
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function graydon_mailSoapFault($message){
|
|
|
|
$mail = new PHPMailer();
|
2010-02-15 10:17:47 +00:00
|
|
|
$mail->IsSendmail();
|
|
|
|
$body = $message;
|
|
|
|
$body = eregi_replace("[\]",'',$body);
|
|
|
|
$mail->AddReplyTo('contact@scores-decisions.com','Serveur SD-13408');
|
|
|
|
$mail->SetFrom('contact@scores-decisions.com','Serveur SD-13408');
|
|
|
|
$mail->AddAddress(EMAIL_SUPPORTDEV, 'Support');
|
|
|
|
$mail->Subject = "Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")";
|
|
|
|
$mail->MsgHTML($body);
|
2009-05-04 16:59:18 +00:00
|
|
|
if(!$mail->Send()) {
|
2009-10-23 14:49:08 +00:00
|
|
|
graydon_logSoapFault($mail->ErrorInfo);
|
2009-05-04 16:59:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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(
|
2009-05-14 16:44:01 +00:00
|
|
|
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" ),
|
2009-05-04 16:59:18 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$returnError = FALSE;
|
|
|
|
foreach($tabError as $error){
|
|
|
|
if($code == $error['Code']){
|
|
|
|
$returnError = $error;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $returnError;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|