2009-02-25 15:54:28 +00:00
|
|
|
|
<?php
|
2009-02-25 17:36:36 +00:00
|
|
|
|
/**
|
2009-02-26 14:27:19 +00:00
|
|
|
|
* SoapError - G<EFBFBD>re les erreurs SOAP
|
2009-02-25 17:36:36 +00:00
|
|
|
|
* @package SoapError
|
|
|
|
|
* @author Michael RICOIS
|
|
|
|
|
* @copyright Scores&Decisions
|
|
|
|
|
*/
|
2009-02-25 15:54:28 +00:00
|
|
|
|
|
2009-07-21 07:17:54 +00:00
|
|
|
|
require_once 'phpmailer/class.phpmailer.php';
|
2009-02-25 15:54:28 +00:00
|
|
|
|
|
2009-02-25 17:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Recup<EFBFBD>re les erreurs SOAP et les traite.
|
|
|
|
|
* @param string $lastRequest
|
|
|
|
|
* @param string $lastResponse
|
|
|
|
|
* @param array $fault
|
|
|
|
|
* @param bool $debug
|
|
|
|
|
* @return string
|
2009-02-25 15:54:28 +00:00
|
|
|
|
*/
|
2009-02-26 14:27:19 +00:00
|
|
|
|
function processSoapFault($clientSoap, $fault, $tabInfo, $debug = FALSE){
|
2009-07-21 07:17:54 +00:00
|
|
|
|
|
2009-10-16 15:21:58 +00:00
|
|
|
|
global $firephp;
|
2009-12-18 15:05:44 +00:00
|
|
|
|
|
|
|
|
|
$message = 'Request : '. $clientSoap->__getLastRequest() . '\n\n' .
|
|
|
|
|
'Response : '.$clientSoap->__getLastResponse() . '\n\n';
|
|
|
|
|
|
|
|
|
|
logSoapFault($message);
|
|
|
|
|
|
2009-07-21 07:17:54 +00:00
|
|
|
|
$message = 'Request : '. htmlspecialchars($clientSoap->__getLastRequest()) . '<br/><br/>' .
|
2009-03-02 10:32:08 +00:00
|
|
|
|
'Response : '. htmlspecialchars($clientSoap->__getLastResponse()) . '<br/><br/>';
|
2010-01-11 10:21:10 +00:00
|
|
|
|
|
2010-01-11 10:27:24 +00:00
|
|
|
|
$firephp->log($clientSoap->__getLastRequest(),'getLastRequest');
|
|
|
|
|
$firephp->log($clientSoap->__getLastResponse(),'getLastResponse');
|
|
|
|
|
|
2009-07-21 07:17:54 +00:00
|
|
|
|
if(is_object($fault)){
|
|
|
|
|
|
2009-04-20 16:32:11 +00:00
|
|
|
|
}else{
|
|
|
|
|
foreach ($fault as $key => $value){ $message.= $key .' : '. $value . '<br/><br/>';}
|
|
|
|
|
}
|
2009-02-26 14:27:19 +00:00
|
|
|
|
$message.= '<br/>';
|
2009-03-02 10:32:08 +00:00
|
|
|
|
$message.= 'Informations de debug : <br/>';
|
2009-02-26 14:27:19 +00:00
|
|
|
|
$message.= '<pre>';
|
2009-03-04 08:07:49 +00:00
|
|
|
|
$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.= 'tabInfo : '.print_r($tabInfo,true).'<br/><br/>';
|
2009-02-26 14:27:19 +00:00
|
|
|
|
$message.= '</pre>';
|
2009-12-18 09:23:57 +00:00
|
|
|
|
|
2009-02-25 15:54:28 +00:00
|
|
|
|
if($debug == TRUE){
|
|
|
|
|
print '<pre>';
|
|
|
|
|
print $message;
|
|
|
|
|
print '</pre>';
|
|
|
|
|
}else{
|
2009-07-21 07:17:54 +00:00
|
|
|
|
mailSoapFault($message);
|
2009-02-25 17:36:36 +00:00
|
|
|
|
print messageSoapFault();
|
2009-02-25 15:54:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-02-25 17:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Affiche un message d'erreur sympatique pour le client.
|
|
|
|
|
* @return string
|
2009-02-25 15:54:28 +00:00
|
|
|
|
*/
|
2010-01-12 14:44:26 +00:00
|
|
|
|
function messageSoapFault()
|
|
|
|
|
{
|
|
|
|
|
(defined('ERROR_SOAP')) ?
|
|
|
|
|
($message = ERROR_SOAP) :
|
|
|
|
|
($message = "Une erreur est survenue lors de votre requ<71>te");
|
2009-02-25 15:54:28 +00:00
|
|
|
|
return $message;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-25 17:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Envoi de l'erreur Soap par mail.
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @return void
|
2009-02-25 15:54:28 +00:00
|
|
|
|
*/
|
2009-12-18 09:23:57 +00:00
|
|
|
|
function mailSoapFault($message)
|
|
|
|
|
{
|
2009-12-18 16:04:19 +00:00
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
|
$mail->IsSendmail();
|
|
|
|
|
try
|
|
|
|
|
{
|
2010-01-12 14:44:26 +00:00
|
|
|
|
$body = $message;
|
|
|
|
|
$body = eregi_replace("[\]",'',$body);
|
|
|
|
|
$mail->AddReplyTo('contact@scores-decisions.com','Serveur SD-13408');
|
|
|
|
|
$mail->SetFrom('contact@scores-decisions.com','Serveur SD-13408');
|
2009-12-18 16:04:19 +00:00
|
|
|
|
$mail->AddAddress(EMAIL_SUPPORTDEV, 'Support');
|
2010-01-12 14:44:26 +00:00
|
|
|
|
$mail->Subject = "Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")";
|
|
|
|
|
$mail->MsgHTML($body);
|
2009-12-18 16:04:19 +00:00
|
|
|
|
$mail->Send();
|
|
|
|
|
}
|
|
|
|
|
catch (phpmailerException $e)
|
|
|
|
|
{
|
|
|
|
|
//echo $e->errorMessage();
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
//echo $e->getMessage();
|
|
|
|
|
}
|
2009-02-25 15:54:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-25 17:36:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* Fonction qui enregistre les messages d'erreur dans un log.
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @return void
|
2009-02-25 15:54:28 +00:00
|
|
|
|
*/
|
2009-12-18 09:23:57 +00:00
|
|
|
|
function logSoapFault($message)
|
|
|
|
|
{
|
|
|
|
|
$fichier = 'errorsoap-'.date('Y').date('m').date('d').date('H').date('i').date('s').'.txt';
|
|
|
|
|
file_put_contents(PATH_DATA.'/log/'.$fichier, $message);
|
2009-02-25 15:54:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|