Inheritance diagram for ilBMFServer_Email:
Collaboration diagram for ilBMFServer_Email:Public Member Functions | |
| ilBMFServer_Email ($send_response=TRUE) | |
| _parseEmail (&$data) | |
| remove http headers from response | |
| client (&$data) | |
| service (&$data, $endpoint= '', $send_response=TRUE, $dump=FALSE) | |
Data Fields | |
| $headers = array() | |
Definition at line 44 of file class.ilBMFServer_Email.php.
| ilBMFServer_Email::_parseEmail | ( | &$ | data | ) |
remove http headers from response
TODO: use PEAR email classes
Definition at line 61 of file class.ilBMFServer_Email.php.
References $data, and ilBMFBase_Object::_raiseSoapFault().
Referenced by client(), ilBMFServer_Email_Gateway::service(), and service().
{
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $data, $match)) {
if (preg_match_all('/^(.*?):\s+(.*)$/m', $match[1], $matches)) {
$hc = count($matches[0]);
for ($i = 0; $i < $hc; $i++) {
$this->headers[strtolower($matches[1][$i])] = trim($matches[2][$i]);
}
}
if (!stristr($this->headers['content-type'],'text/xml')) {
$this->_raiseSoapFault('Invalid Content Type','','','Client');
return FALSE;
}
if (strcasecmp($this->headers['content-transfer-encoding'],'base64')==0) {
// join lines back together
$enctext = preg_replace("/[\r|\n]/", '', $match[2]);
$data = base64_decode($enctext);
#} else if (strcasecmp($this->headers['content-transfer-encoding'],'quoted-printable')==0) {
# $data = $match[2];
#} else {
# $this->_raiseSoapFault('Invalid Content-Transfer-Encoding','','','Client');
# return FALSE;
#}
} else {
$data = $match[2];
}
// if no content, return false
return strlen($this->request) > 0;
}
$this->_raiseSoapFault('Invalid Email Format','','','Client');
return FALSE;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilBMFServer_Email::client | ( | &$ | data | ) |
Definition at line 98 of file class.ilBMFServer_Email.php.
References $data, ilBMFBase::_decodeDIMEMessage(), ilBMFBase::_decodeMimeMessage(), ilBMFServer::_getContentEncoding(), _parseEmail(), and ilBMFBase_Object::_raiseSoapFault().
{
$attachments = array();
# if neither matches, we'll just try it anyway
if (stristr($data,'Content-Type: application/dime')) {
$this->_decodeDIMEMessage($data,$this->headers,$attachments);
$useEncoding = 'DIME';
} else if (stristr($data,'MIME-Version:')) {
// this is a mime message, lets decode it.
#$data = 'Content-Type: '.stripslashes($_SERVER['CONTENT_TYPE'])."\r\n\r\n".$data;
$this->_decodeMimeMessage($data,$this->headers,$attachments);
$useEncoding = 'Mime';
} else {
// the old fallback, but decodeMimeMessage handles things fine.
$this->_parseEmail($data);
}
// get the character encoding of the incoming request
// treat incoming data as UTF-8 if no encoding set
if (!$this->soapfault && !$this->_getContentEncoding($this->headers['content-type'])) {
$this->xml_encoding = SOAP_DEFAULT_ENCODING;
// an encoding we don't understand, return a fault
$this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8','','','Server');
}
if ($this->soapfault) {
return $this->soapfault->getFault();
}
$client =& new ilBMFClient(NULL);
return $client->__parse($data, $this->xml_encoding, $this->attachments);
}
Here is the call graph for this function:| ilBMFServer_Email::ilBMFServer_Email | ( | $ | send_response = TRUE |
) |
Definition at line 47 of file class.ilBMFServer_Email.php.
References ilBMFServer::ilBMFServer().
{
parent::ilBMFServer();
$this->send_response = $send_response;
}
Here is the call graph for this function:| ilBMFServer_Email::service | ( | &$ | data, | |
| $ | endpoint = '', |
|||
| $ | send_response = TRUE, |
|||
| $ | dump = FALSE | |||
| ) |
Definition at line 131 of file class.ilBMFServer_Email.php.
References $data, ilBMFServer::$endpoint, $headers, ilBMFBase::_decodeDIMEMessage(), ilBMFBase::_decodeMimeMessage(), ilBMFServer::_getContentEncoding(), ilBMFBase::_makeDIMEMessage(), ilBMFBase::_makeMimeMessage(), _parseEmail(), ilBMFBase_Object::_raiseSoapFault(), ilBMFTransport::getTransport(), and ilBMFServer::parseRequest().
{
$this->endpoint = $endpoint;
$attachments = array();
$headers = array();
# if neither matches, we'll just try it anyway
if (stristr($data,'Content-Type: application/dime')) {
$this->_decodeDIMEMessage($data,$this->headers,$attachments);
$useEncoding = 'DIME';
} else if (stristr($data,'MIME-Version:')) {
// this is a mime message, lets decode it.
#$data = 'Content-Type: '.stripslashes($_SERVER['CONTENT_TYPE'])."\r\n\r\n".$data;
$this->_decodeMimeMessage($data,$this->headers,$attachments);
$useEncoding = 'Mime';
} else {
// the old fallback, but decodeMimeMessage handles things fine.
$this->_parseEmail($data);
}
// get the character encoding of the incoming request
// treat incoming data as UTF-8 if no encoding set
if (!$response && !$this->_getContentEncoding($this->headers['content-type'])) {
$this->xml_encoding = SOAP_DEFAULT_ENCODING;
// an encoding we don't understand, return a fault
$this->_raiseSoapFault('Unsupported encoding, use one of ISO-8859-1, US-ASCII, UTF-8','','','Server');
$response = $this->getFaultMessage();
}
if ($this->soapfault) {
$response = $this->soapfault->message();
} else {
$soap_msg = $this->parseRequest($data,$attachments);
// handle Mime or DIME encoding
// XXX DIME Encoding should move to the transport, do it here for now
// and for ease of getting it done
if (count($this->__attachments)) {
if ($useEncoding == 'Mime') {
$soap_msg = $this->_makeMimeMessage($soap_msg);
} else {
// default is dime
$soap_msg = $this->_makeDIMEMessage($soap_msg);
$header['Content-Type'] = 'application/dime';
}
if (PEAR::isError($soap_msg)) {
return $this->raiseSoapFault($soap_msg);
}
}
if (is_array($soap_msg)) {
$response = $soap_msg['body'];
if (count($soap_msg['headers'])) {
$headers = $soap_msg['headers'];
}
} else {
$response = $soap_msg;
}
}
if ($this->send_response) {
if ($dump) {
print $response;
} else {
$from = array_key_exists('reply-to',$this->headers) ? $this->headers['reply-to']:$this->headers['from'];
# XXX what if no from?????
$soap_transport =& ilBMFTransport::getTransport('mailto:'.$from, $this->response_encoding);
$from = $this->endpoint ? $this->endpoint : $this->headers['to'];
$headers['In-Reply-To']=$this->headers['message-id'];
$options = array('from' => $from, 'subject'=> $this->headers['subject'], 'headers' => $headers);
$soap_transport->send($response, $options);
}
}
}
Here is the call graph for this function:| ilBMFServer_Email::$headers = array() |
Reimplemented from ilBMFServer.
Definition at line 45 of file class.ilBMFServer_Email.php.
Referenced by ilBMFServer_Email_Gateway::service(), and service().
1.7.1