2009-02-25 15:54:28 +00:00
|
|
|
<?php
|
2009-02-25 17:36:36 +00:00
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* SoapError - Gè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
|
|
|
/**
|
2010-02-10 17:27:03 +00:00
|
|
|
* Recupère les erreurs SOAP et les traite.
|
2009-02-25 17:36:36 +00:00
|
|
|
* @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;
|
2010-03-22 12:50:08 +00:00
|
|
|
|
2009-12-18 15:05:44 +00:00
|
|
|
$message = 'Request : '. $clientSoap->__getLastRequest() . '\n\n' .
|
|
|
|
'Response : '.$clientSoap->__getLastResponse() . '\n\n';
|
2010-03-22 12:50:08 +00:00
|
|
|
|
2009-12-18 15:05:44 +00:00
|
|
|
logSoapFault($message);
|
2010-03-22 12:50:08 +00:00
|
|
|
|
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-03-22 12:50:08 +00:00
|
|
|
|
2010-01-11 10:27:24 +00:00
|
|
|
$firephp->log($clientSoap->__getLastRequest(),'getLastRequest');
|
|
|
|
$firephp->log($clientSoap->__getLastResponse(),'getLastResponse');
|
2010-03-22 12:50:08 +00:00
|
|
|
|
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>';
|
2010-03-22 12:50:08 +00:00
|
|
|
$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.= 'tabInfo : '.print_r($tabInfo, true).'<br/><br/>';
|
2009-02-26 14:27:19 +00:00
|
|
|
$message.= '</pre>';
|
2010-03-22 12:50:08 +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()
|
|
|
|
{
|
2010-03-22 12:50:08 +00:00
|
|
|
(defined('ERROR_SOAP')) ?
|
|
|
|
($message = ERROR_SOAP) :
|
2010-02-10 17:27:03 +00:00
|
|
|
($message = "Une erreur est survenue lors de votre requê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)
|
|
|
|
{
|
2010-03-01 11:29:38 +00:00
|
|
|
require_once 'mail/mail.php';
|
2010-03-22 12:50:08 +00:00
|
|
|
sendMail(
|
|
|
|
"Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")",
|
|
|
|
$message,
|
2010-03-01 11:29:38 +00:00
|
|
|
//From
|
2010-03-22 12:50:08 +00:00
|
|
|
array(
|
2010-03-01 11:29:38 +00:00
|
|
|
'email' => 'contact@scores-decisions.com',
|
|
|
|
'name' => 'Serveur SD-13408',
|
2010-03-22 12:50:08 +00:00
|
|
|
),
|
2010-03-01 11:29:38 +00:00
|
|
|
//TO
|
|
|
|
array(
|
|
|
|
0 => array(
|
2010-03-22 12:50:08 +00:00
|
|
|
'email'=> EMAIL_SUPPORTDEV,
|
2010-03-01 11:29:38 +00:00
|
|
|
'name' => 'Support'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|