Source for file Message.php
Documentation is available at Message.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
// +-----------------------------------------------------------------------+
// | http://www.heino.gehlsen.dk/software/license |
// +-----------------------------------------------------------------------+
// | This work (including software, documents, or other related items) is |
// | being provided by the copyright holders under the following license. |
// | By obtaining, using and/or copying this work, you (the licensee) |
// | agree that you have read, understood, and will comply with the |
// | following terms and conditions: |
// | Permission to use, copy, modify, and distribute this software and |
// | its documentation, with or without modification, for any purpose and |
// | without fee or royalty is hereby granted, provided that you include |
// | the following on ALL copies of the software and documentation or |
// | portions thereof, including modifications, that you make: |
// | 1. The full text of this NOTICE in a location viewable to users of |
// | the redistributed or derivative work. |
// | 2. Any pre-existing intellectual property disclaimers, notices, or |
// | terms and conditions. If none exist, a short notice of the |
// | following form (hypertext is preferred, text is permitted) should |
// | be used within the body of any redistributed or derivative code: |
// | http://www.heino.gehlsen.dk/software/license" |
// | 3. Notice of any changes or modifications to the files, including |
// | the date changes were made. (We recommend you provide URIs to |
// | the location from which the code is derived.) |
// | THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT |
// | HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, |
// | INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR |
// | FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE |
// | OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, |
// | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. |
// | COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE |
// | SOFTWARE OR DOCUMENTATION. |
// | The name and trademarks of copyright holders may NOT be used in |
// | advertising or publicity pertaining to the software without specific, |
// | written prior permission. Title to copyright in this software and any |
// | associated documentation will at all times remain with copyright |
// +-----------------------------------------------------------------------+
// | except for the references to the copyright holder, which has either |
// | been changes or removed. |
// +-----------------------------------------------------------------------+
// $Id: Message.php,v 1.8 2005/01/08 20:03:29 heino Exp $
require_once 'Net/NNTP/Header.php';
* The Net_NNTP_Message class
* @author Heino H. Gehlsen <heino@gehlsen.dk>
* @version $Id: Message.php,v 1.8 2005/01/08 20:03:29 heino Exp $
* @since Class available since Release 0.10.0
* Contains the message's header object
* Contains the body part of the message
* Resets the message object
* Create a new instance of Net_NNTP_Message
* @param optional mixed $input Can be any of the following:
* (string) RFC2822 message lines (RCLF included)
* (array) RFC2822 message lines (RCLF not included)
* (object) Net_NNTP_Header object
* (object) Net_NNTP_Message object
* @param optional mixed $input2 If given, $input will only be use for the message's
* header, while $input2 will be used for the body.
* (Disallowed when $input is a Net_NNTP_Message)
function & create($input = null , $input2 = null )
case is_a($input, 'net_nntp_header'):
$Object->setHeader ($input);
$Object->setBody ($input2);
case is_a($input, 'net_nntp_message'):
return PEAR ::throwError ('Second parameter not allowed!', null );
return PEAR ::throwError ('Unsupported object/class: '. get_class($input), null );
// Array & String (only 1st parameter)
$Object->setMessage ($input);
// Array & String (also 2nd parameter)
$Object->setHeader ($input);
$Object->body = implode("\r\n", $input2);
return PEAR ::throwError ('Unsupported object/class: '. get_class($input), null );
* Sets the header and body grom the given $message
* @param mixed $message Can be any of the following:
* (string) RFC2822 message lines (RCLF included)
* (array) RFC2822 message lines (RCLF not included)
* (object) Net_NNTP_Message object
case is_a($input, 'net_nntp_message'):
$this->setBody($message->getBody ());
return PEAR ::throwError ('Unsupported object/class: '. get_class($message), null );
return PEAR ::throwError ('Unsupported type: '. gettype($message), null );
// {{{ getMessageString()
* Get the complete transport-ready message as a string
return $this->header->getFieldsString (). "\r\n\r\n". $this->getBody();
* Get the complete transport-ready message as an array
$header = $this->header->getFieldsArray ();
// Merge with body, and return
* Sets the header's fields from the given $input
* @param mixed $input Can be any of the following:
* (string) RFC2822 message lines (RCLF included)
* (array) RFC2822 message lines (RCLF not included)
* (object) Net_NNTP_Header object
case is_a($input, 'net_nntp_header'):
return PEAR ::throwError ('Unsupported object/class: '. get_class($input), null );
$this->header->setFields ($input);
return PEAR ::throwError ('Unsupported type: '. gettype($input), null );
* @param mixed $body Array or string
* Splits the header and body given in $input apart (at the first
* blank line) and return them (in an array) with the same type as $input.
* @param mixed $input Message in form of eiter string or array
* @return array Contains separated header and body sections in same type as $input
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $matches)) {
return array ('header' => $matches[1 ], 'body' => $matches[2 ]);
return PEAR ::throwError ('Could not split header and body');
return array ('header' => &$header, 'body' => $input);
return PEAR ::throwError ('Unsupported type: '. gettype($input));
Documentation generated on Mon, 11 Mar 2019 14:30:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|