extranet/includes/soaperror.php

89 lines
2.3 KiB
PHP
Raw Normal View History

2009-02-25 15:54:28 +00:00
<?php
2009-02-25 17:36:36 +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
*/
function processSoapFault($clientSoap, $fault, $tabInfo, $debug = FALSE){
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/>';
2009-07-21 07:17:54 +00:00
if(is_object($fault)){
}else{
foreach ($fault as $key => $value){ $message.= $key .' : '. $value . '<br/><br/>';}
}
$message.= '<br/>';
2009-03-02 10:32:08 +00:00
$message.= 'Informations de debug : <br/>';
$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.= 'ENV : '.print_r($_ENV,true).'<br/><br/>';
$message.= 'tabInfo : '.print_r($tabInfo,true).'<br/><br/>';
$message.= '</pre>';
2009-07-21 07:17:54 +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
*/
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
*/
function mailSoapFault($message){
2009-07-21 07:17:54 +00:00
$mail = new PHPMailer();
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Serveur SD-13408";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
2009-03-04 08:07:49 +00:00
$mail->Subject = "Erreur SOAP - (Date :".date("d")."/".date("m")."/".date("Y").")";
$body = $message;
2009-02-25 15:54:28 +00:00
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
2009-02-25 15:54:28 +00:00
if(!$mail->Send()) {
2009-08-18 06:52:44 +00:00
//logSoapFault($mail->ErrorInfo);
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
*/
function logSoapFault($message){
2009-07-21 07:17:54 +00:00
echo $message;
2009-02-25 15:54:28 +00:00
}
?>