本文整理汇总了PHP中Header::getHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Header::getHeader方法的具体用法?PHP Header::getHeader怎么用?PHP Header::getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::getHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHeader
public function getHeader()
{
$header = new Header();
return $header->getHeader();
}
示例2: encode
/**
* Encode and generate MDN from attributes and message (if exists)
*
* @param object $message The refering message
*/
public function encode($message = null)
{
// container
$container = new Horde_MIME_Part('multipart/report', ' ');
// first part
$text = new Horde_MIME_Part('text/plain', $this->getMessage(), MIME_DEFAULT_CHARSET, null, '7bit');
// add human readable message
$container->addPart($text);
// second part
$lines = new Header();
$lines->addHeader('Reporting-UA', 'AS2Secure - PHP Lib for AS2 message encoding / decoding');
if ($this->getPartnerFrom()) {
$lines->addHeader('Original-Recipient', 'rfc822; "' . $this->getPartnerFrom()->id . '"');
$lines->addHeader('Final-Recipient', 'rfc822; "' . $this->getPartnerFrom()->id . '"');
}
$lines->addHeader('Original-Message-ID', $this->getAttribute('original-message-id'));
$lines->addHeader('Disposition', $this->getAttribute('action-mode') . '/' . $this->getAttribute('sending-mode') . '; ' . $this->getAttribute('disposition-type'));
if ($this->getAttribute('disposition-type') != self::TYPE_PROCESSED) {
$lines->addHeader('Disposition', $lines->getHeader('Disposition') . ': ' . $this->getAttribute('disposition-modifier'));
}
if ($this->getAttribute('received-content-mic')) {
$lines->addHeader('Received-Content-MIC', $this->getAttribute('received-content-mic'));
}
// build computer readable message
$mdn = new Horde_MIME_Part('message/disposition-notification', $lines, MIME_DEFAULT_CHARSET, null, '7bit');
$container->addPart($mdn);
$this->setMessageId(self::generateMessageID($this->getPartnerFrom()));
// headers setup
$this->headers = new Header(array('AS2-Version' => '1.0', 'Message-ID' => $this->getMessageId(), 'Mime-Version' => '1.0', 'Server' => 'AS2Secure - PHP Lib for AS2 message encoding / decoding', 'User-Agent' => 'AS2Secure - PHP Lib for AS2 message encoding / decoding'));
$this->headers->addHeaders($container->header());
if ($this->getPartnerFrom()) {
$headers_from = array('AS2-From' => '"' . $this->getPartnerFrom()->id . '"', 'From' => $this->getPartnerFrom()->email, 'Subject' => $this->getPartnerFrom()->mdn_subject, 'Disposition-Notification-To' => $this->getPartnerFrom()->send_url);
$this->headers->addHeaders($headers_from);
}
if ($this->getPartnerTo()) {
$headers_to = array('AS2-To' => '"' . $this->getPartnerTo()->id . '"', 'Recipient-Address' => $this->getPartnerTo()->send_url);
$this->headers->addHeaders($headers_to);
}
if ($message && ($url = $message->getHeader('Receipt-Delivery-Option')) && $this->getPartnerFrom()) {
$this->url = $url;
$this->headers->addHeader('Recipient-Address', $this->getPartnerFrom()->send_url);
}
$this->path = Adapter::getTempFilename();
// signing if requested
if ($message && $message->getHeader('Disposition-Notification-Options')) {
file_put_contents($this->path, $container->toCanonicalString(true));
$this->path = $this->adapter->sign($this->path);
$content = file_get_contents($this->path);
$this->headers->addHeadersFromMessage($content);
// TODO : replace with futur AS2MimePart to separate content from header
if (strpos($content, "\n\n") !== false) {
$content = substr($content, strpos($content, "\n\n") + 2);
}
file_put_contents($this->path, ltrim($content));
} else {
file_put_contents($this->path, $container->toCanonicalString(false));
$content = $container->toString();
}
}