Index: plugins/blocks/mrbs/web/Mail/RFC822.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail/RFC822.php
diff -N plugins/blocks/mrbs/web/Mail/RFC822.php
--- plugins/blocks/mrbs/web/Mail/RFC822.php	5 Apr 2007 22:25:35 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,916 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Copyright (c) 2001-2002, Richard Heyes                                |
-// | All rights reserved.                                                  |
-// |                                                                       |
-// | Redistribution and use in source and binary forms, with or without    |
-// | modification, are permitted provided that the following conditions    |
-// | are met:                                                              |
-// |                                                                       |
-// | o Redistributions of source code must retain the above copyright      |
-// |   notice, this list of conditions and the following disclaimer.       |
-// | o Redistributions in binary form must reproduce the above copyright   |
-// |   notice, this list of conditions and the following disclaimer in the |
-// |   documentation and/or other materials provided with the distribution.|
-// | o The names of the authors may not be used to endorse or promote      |
-// |   products derived from this software without specific prior written  |
-// |   permission.                                                         |
-// |                                                                       |
-// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
-// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
-// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
-// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
-// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
-// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
-// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
-// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
-// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
-// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
-// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
-// |                                                                       |
-// +-----------------------------------------------------------------------+
-// | Authors: Richard Heyes <richard@phpguru.org>                          |
-// |          Chuck Hagenbuch <chuck@horde.org>                            |
-// +-----------------------------------------------------------------------+
-
-/**
-* RFC 822 Email address list validation Utility
-*
-* What is it?
-*
-* This class will take an address string, and parse it into it's consituent
-* parts, be that either addresses, groups, or combinations. Nested groups
-* are not supported. The structure it returns is pretty straight forward,
-* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
-* print_r() to view the structure.
-*
-* How do I use it?
-*
-* $address_string = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
-* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true)
-* print_r($structure);
-*
-* @author  Richard Heyes <richard@phpguru.org>
-* @author  Chuck Hagenbuch <chuck@horde.org>
-* @version $Revision: 1.1 $
-* @license BSD
-* @package Mail
-*/
-
-class Mail_RFC822 {
-
-    /**
-     * The address being parsed by the RFC822 object.
-     * @var string $address
-     */
-    var $address = '';
-
-    /**
-     * The default domain to use for unqualified addresses.
-     * @var string $default_domain
-     */
-    var $default_domain = 'localhost';
-
-    /**
-     * Should we return a nested array showing groups, or flatten everything?
-     * @var boolean $nestGroups
-     */
-    var $nestGroups = true;
-
-    /**
-     * Whether or not to validate atoms for non-ascii characters.
-     * @var boolean $validate
-     */
-    var $validate = true;
-
-    /**
-     * The array of raw addresses built up as we parse.
-     * @var array $addresses
-     */
-    var $addresses = array();
-
-    /**
-     * The final array of parsed address information that we build up.
-     * @var array $structure
-     */
-    var $structure = array();
-
-    /**
-     * The current error message, if any.
-     * @var string $error
-     */
-    var $error = null;
-
-    /**
-     * An internal counter/pointer.
-     * @var integer $index
-     */
-    var $index = null;
-
-    /**
-     * The number of groups that have been found in the address list.
-     * @var integer $num_groups
-     * @access public
-     */
-    var $num_groups = 0;
-
-    /**
-     * A variable so that we can tell whether or not we're inside a
-     * Mail_RFC822 object.
-     * @var boolean $mailRFC822
-     */
-    var $mailRFC822 = true;
-
-    /**
-    * A limit after which processing stops
-    * @var int $limit
-    */
-    var $limit = null;
-
-
-    /**
-     * Sets up the object. The address must either be set here or when
-     * calling parseAddressList(). One or the other.
-     *
-     * @access public
-     * @param string  $address         The address(es) to validate.
-     * @param string  $default_domain  Default domain/host etc. If not supplied, will be set to localhost.
-     * @param boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
-     * @param boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
-     *
-     * @return object Mail_RFC822 A new Mail_RFC822 object.
-     */
-    function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
-    {
-        if (isset($address))        $this->address        = $address;
-        if (isset($default_domain)) $this->default_domain = $default_domain;
-        if (isset($nest_groups))    $this->nestGroups     = $nest_groups;
-        if (isset($validate))       $this->validate       = $validate;
-        if (isset($limit))          $this->limit          = $limit;
-    }
-
-
-    /**
-     * Starts the whole process. The address must either be set here
-     * or when creating the object. One or the other.
-     *
-     * @access public
-     * @param string  $address         The address(es) to validate.
-     * @param string  $default_domain  Default domain/host etc.
-     * @param boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
-     * @param boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
-     *
-     * @return array A structured array of addresses.
-     */
-    function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
-    {
-
-        if (!isset($this->mailRFC822)) {
-            $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
-            return $obj->parseAddressList();
-        }
-
-        if (isset($address))        $this->address        = $address;
-        if (isset($default_domain)) $this->default_domain = $default_domain;
-        if (isset($nest_groups))    $this->nestGroups     = $nest_groups;
-        if (isset($validate))       $this->validate       = $validate;
-        if (isset($limit))          $this->limit          = $limit;
-
-        $this->structure  = array();
-        $this->addresses  = array();
-        $this->error      = null;
-        $this->index      = null;
-
-        while ($this->address = $this->_splitAddresses($this->address)) {
-            continue;
-        }
-
-        if ($this->address === false || isset($this->error)) {
-            require_once 'PEAR.php';
-            return PEAR::raiseError($this->error);
-        }
-
-        // Loop through all the addresses
-        for ($i = 0; $i < count($this->addresses); $i++) {
-            if (($return = $this->_validateAddress($this->addresses[$i])) === false
-                || isset($this->error)) {
-                require_once 'PEAR.php';
-                return PEAR::raiseError($this->error);
-            }
-
-            if (!$this->nestGroups) {
-                $this->structure = array_merge($this->structure, $return);
-            } else {
-                $this->structure[] = $return;
-            }
-        }
-
-        return $this->structure;
-    }
-
-    /**
-     * Splits an address into seperate addresses.
-     *
-     * @access private
-     * @param string $address The addresses to split.
-     * @return boolean Success or failure.
-     */
-    function _splitAddresses($address)
-    {
-
-        if (!empty($this->limit) AND count($this->addresses) == $this->limit) {
-            return '';
-        }
-
-        if ($this->_isGroup($address) && !isset($this->error)) {
-            $split_char = ';';
-            $is_group   = true;
-        } elseif (!isset($this->error)) {
-            $split_char = ',';
-            $is_group   = false;
-        } elseif (isset($this->error)) {
-            return false;
-        }
-
-        // Split the string based on the above ten or so lines.
-        $parts  = explode($split_char, $address);
-        $string = $this->_splitCheck($parts, $split_char);
-
-        // If a group...
-        if ($is_group) {
-            // If $string does not contain a colon outside of
-            // brackets/quotes etc then something's fubar.
-
-            // First check there's a colon at all:
-            if (strpos($string, ':') === false) {
-                $this->error = 'Invalid address: ' . $string;
-                return false;
-            }
-
-            // Now check it's outside of brackets/quotes:
-            if (!$this->_splitCheck(explode(':', $string), ':')) {
-                return false;
-            }
-
-            // We must have a group at this point, so increase the counter:
-            $this->num_groups++;
-        }
-
-        // $string now contains the first full address/group.
-        // Add to the addresses array.
-        $this->addresses[] = array(
-                                   'address' => trim($string),
-                                   'group'   => $is_group
-                                   );
-
-        // Remove the now stored address from the initial line, the +1
-        // is to account for the explode character.
-        $address = trim(substr($address, strlen($string) + 1));
-
-        // If the next char is a comma and this was a group, then
-        // there are more addresses, otherwise, if there are any more
-        // chars, then there is another address.
-        if ($is_group && substr($address, 0, 1) == ','){
-            $address = trim(substr($address, 1));
-            return $address;
-
-        } elseif (strlen($address) > 0) {
-            return $address;
-
-        } else {
-            return '';
-        }
-
-        // If you got here then something's off
-        return false;
-    }
-
-    /**
-     * Checks for a group at the start of the string.
-     *
-     * @access private
-     * @param string $address The address to check.
-     * @return boolean Whether or not there is a group at the start of the string.
-     */
-    function _isGroup($address)
-    {
-        // First comma not in quotes, angles or escaped:
-        $parts  = explode(',', $address);
-        $string = $this->_splitCheck($parts, ',');
-
-        // Now we have the first address, we can reliably check for a
-        // group by searching for a colon that's not escaped or in
-        // quotes or angle brackets.
-        if (count($parts = explode(':', $string)) > 1) {
-            $string2 = $this->_splitCheck($parts, ':');
-            return ($string2 !== $string);
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * A common function that will check an exploded string.
-     *
-     * @access private
-     * @param array $parts The exloded string.
-     * @param string $char  The char that was exploded on.
-     * @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
-     */
-    function _splitCheck($parts, $char)
-    {
-        $string = $parts[0];
-
-        for ($i = 0; $i < count($parts); $i++) {
-            if ($this->_hasUnclosedQuotes($string)
-                || $this->_hasUnclosedBrackets($string, '<>')
-                || $this->_hasUnclosedBrackets($string, '[]')
-                || $this->_hasUnclosedBrackets($string, '()')
-                || substr($string, -1) == '\\') {
-                if (isset($parts[$i + 1])) {
-                    $string = $string . $char . $parts[$i + 1];
-                } else {
-                    $this->error = 'Invalid address spec. Unclosed bracket or quotes';
-                    return false;
-                }
-            } else {
-                $this->index = $i;
-                break;
-            }
-        }
-
-        return $string;
-    }
-
-    /**
-     * Checks if a string has an unclosed quotes or not.
-     *
-     * @access private
-     * @param string $string The string to check.
-     * @return boolean True if there are unclosed quotes inside the string, false otherwise.
-     */
-    function _hasUnclosedQuotes($string)
-    {
-        $string     = explode('"', $string);
-        $string_cnt = count($string);
-
-        for ($i = 0; $i < (count($string) - 1); $i++)
-            if (substr($string[$i], -1) == '\\')
-                $string_cnt--;
-
-        return ($string_cnt % 2 === 0);
-    }
-
-    /**
-     * Checks if a string has an unclosed brackets or not. IMPORTANT:
-     * This function handles both angle brackets and square brackets;
-     *
-     * @access private
-     * @param string $string The string to check.
-     * @param string $chars  The characters to check for.
-     * @return boolean True if there are unclosed brackets inside the string, false otherwise.
-     */
-    function _hasUnclosedBrackets($string, $chars)
-    {
-        $num_angle_start = substr_count($string, $chars[0]);
-        $num_angle_end   = substr_count($string, $chars[1]);
-
-        $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
-        $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
-
-        if ($num_angle_start < $num_angle_end) {
-            $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
-            return false;
-        } else {
-            return ($num_angle_start > $num_angle_end);
-        }
-    }
-
-    /**
-     * Sub function that is used only by hasUnclosedBrackets().
-     *
-     * @access private
-     * @param string $string The string to check.
-     * @param integer &$num    The number of occurences.
-     * @param string $char   The character to count.
-     * @return integer The number of occurences of $char in $string, adjusted for backslashes.
-     */
-    function _hasUnclosedBracketsSub($string, &$num, $char)
-    {
-        $parts = explode($char, $string);
-        for ($i = 0; $i < count($parts); $i++){
-            if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
-                $num--;
-            if (isset($parts[$i + 1]))
-                $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
-        }
-
-        return $num;
-    }
-
-    /**
-     * Function to begin checking the address.
-     *
-     * @access private
-     * @param string $address The address to validate.
-     * @return mixed False on failure, or a structured array of address information on success.
-     */
-    function _validateAddress($address)
-    {
-        $is_group = false;
-        $addresses = array();
-
-        if ($address['group']) {
-            $is_group = true;
-
-            // Get the group part of the name
-            $parts     = explode(':', $address['address']);
-            $groupname = $this->_splitCheck($parts, ':');
-            $structure = array();
-
-            // And validate the group part of the name.
-            if (!$this->_validatePhrase($groupname)){
-                $this->error = 'Group name did not validate.';
-                return false;
-            } else {
-                // Don't include groups if we are not nesting
-                // them. This avoids returning invalid addresses.
-                if ($this->nestGroups) {
-                    $structure = new stdClass;
-                    $structure->groupname = $groupname;
-                }
-            }
-
-            $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
-        }
-
-        // If a group then split on comma and put into an array.
-        // Otherwise, Just put the whole address in an array.
-        if ($is_group) {
-            while (strlen($address['address']) > 0) {
-                $parts       = explode(',', $address['address']);
-                $addresses[] = $this->_splitCheck($parts, ',');
-                $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
-            }
-        } else {
-            $addresses[] = $address['address'];
-        }
-
-        // Check that $addresses is set, if address like this:
-        // Groupname:;
-        // Then errors were appearing.
-        if (!count($addresses)){
-            $this->error = 'Empty group.';
-            return false;
-        }
-
-        // Validate each mailbox.
-        // Format could be one of: name <geezer@domain.com>
-        //                         geezer@domain.com
-        //                         geezer
-        // ... or any other format valid by RFC 822.
-        for ($i = 0; $i < count($addresses); $i++) {
-            $addresses[$i] = trim($addresses[$i]);
-            if (!$this->validateMailbox($addresses[$i])) {
-                if (empty($this->error)) {
-                    $this->error = 'Validation failed for "' . $addresses[$i] . '"';
-                }
-                return false;
-            }
-        }
-
-        // Nested format
-        if ($this->nestGroups) {
-            if ($is_group) {
-                $structure->addresses = $addresses;
-            } else {
-                $structure = $addresses[0];
-            }
-
-        // Flat format
-        } else {
-            if ($is_group) {
-                $structure = array_merge($structure, $addresses);
-            } else {
-                $structure = $addresses;
-            }
-        }
-
-        return $structure;
-    }
-
-    /**
-     * Function to validate a phrase.
-     *
-     * @access private
-     * @param string $phrase The phrase to check.
-     * @return boolean Success or failure.
-     */
-    function _validatePhrase($phrase)
-    {
-        // Splits on one or more Tab or space.
-        $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
-
-        $phrase_parts = array();
-        while (count($parts) > 0){
-            $phrase_parts[] = $this->_splitCheck($parts, ' ');
-            for ($i = 0; $i < $this->index + 1; $i++)
-                array_shift($parts);
-        }
-
-        for ($i = 0; $i < count($phrase_parts); $i++) {
-            // If quoted string:
-            if (substr($phrase_parts[$i], 0, 1) == '"') {
-                if (!$this->_validateQuotedString($phrase_parts[$i])) {
-                    return false;
-                }
-                continue;
-            }
-
-            // Otherwise it's an atom:
-            if (!$this->_validateAtom($phrase_parts[$i])) return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Function to validate an atom which from rfc822 is:
-     * atom = 1*<any CHAR except specials, SPACE and CTLs>
-     *
-     * If validation ($this->validate) has been turned off, then
-     * validateAtom() doesn't actually check anything. This is so that you
-     * can split a list of addresses up before encoding personal names
-     * (umlauts, etc.), for example.
-     *
-     * @access private
-     * @param string $atom The string to check.
-     * @return boolean Success or failure.
-     */
-    function _validateAtom($atom)
-    {
-        if (!$this->validate) {
-            // Validation has been turned off; assume the atom is okay.
-            return true;
-        }
-
-        // Check for any char from ASCII 0 - ASCII 127
-        if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
-            return false;
-        }
-
-        // Check for specials:
-        if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
-            return false;
-        }
-
-        // Check for control characters (ASCII 0-31):
-        if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Function to validate quoted string, which is:
-     * quoted-string = <"> *(qtext/quoted-pair) <">
-     *
-     * @access private
-     * @param string $qstring The string to check
-     * @return boolean Success or failure.
-     */
-    function _validateQuotedString($qstring)
-    {
-        // Leading and trailing "
-        $qstring = substr($qstring, 1, -1);
-
-        // Perform check.
-        return !(preg_match('/(.)[\x0D\\\\"]/', $qstring, $matches) && $matches[1] != '\\');
-    }
-
-    /**
-     * Function to validate a mailbox, which is:
-     * mailbox =   addr-spec         ; simple address
-     *           / phrase route-addr ; name and route-addr
-     *
-     * @access public
-     * @param string &$mailbox The string to check.
-     * @return boolean Success or failure.
-     */
-    function validateMailbox(&$mailbox)
-    {
-        // A couple of defaults.
-        $phrase  = '';
-        $comment = '';
-        $comments = array();
-
-        // Catch any RFC822 comments and store them separately.
-        $_mailbox = $mailbox;
-        while (strlen(trim($_mailbox)) > 0) {
-            $parts = explode('(', $_mailbox);
-            $before_comment = $this->_splitCheck($parts, '(');
-            if ($before_comment != $_mailbox) {
-                // First char should be a (.
-                $comment    = substr(str_replace($before_comment, '', $_mailbox), 1);
-                $parts      = explode(')', $comment);
-                $comment    = $this->_splitCheck($parts, ')');
-                $comments[] = $comment;
-
-                // +1 is for the trailing )
-                $_mailbox   = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1);
-            } else {
-                break;
-            }
-        }
-
-        foreach ($comments as $comment) {
-            $mailbox = str_replace("($comment)", '', $mailbox);
-        }
-
-        $mailbox = trim($mailbox);
-
-        // Check for name + route-addr
-        if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
-            $parts  = explode('<', $mailbox);
-            $name   = $this->_splitCheck($parts, '<');
-
-            $phrase     = trim($name);
-            $route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
-
-            if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) {
-                return false;
-            }
-
-        // Only got addr-spec
-        } else {
-            // First snip angle brackets if present.
-            if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') {
-                $addr_spec = substr($mailbox, 1, -1);
-            } else {
-                $addr_spec = $mailbox;
-            }
-
-            if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
-                return false;
-            }
-        }
-
-        // Construct the object that will be returned.
-        $mbox = new stdClass();
-
-        // Add the phrase (even if empty) and comments
-        $mbox->personal = $phrase;
-        $mbox->comment  = isset($comments) ? $comments : array();
-
-        if (isset($route_addr)) {
-            $mbox->mailbox = $route_addr['local_part'];
-            $mbox->host    = $route_addr['domain'];
-            $route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
-        } else {
-            $mbox->mailbox = $addr_spec['local_part'];
-            $mbox->host    = $addr_spec['domain'];
-        }
-
-        $mailbox = $mbox;
-        return true;
-    }
-
-    /**
-     * This function validates a route-addr which is:
-     * route-addr = "<" [route] addr-spec ">"
-     *
-     * Angle brackets have already been removed at the point of
-     * getting to this function.
-     *
-     * @access private
-     * @param string $route_addr The string to check.
-     * @return mixed False on failure, or an array containing validated address/route information on success.
-     */
-    function _validateRouteAddr($route_addr)
-    {
-        // Check for colon.
-        if (strpos($route_addr, ':') !== false) {
-            $parts = explode(':', $route_addr);
-            $route = $this->_splitCheck($parts, ':');
-        } else {
-            $route = $route_addr;
-        }
-
-        // If $route is same as $route_addr then the colon was in
-        // quotes or brackets or, of course, non existent.
-        if ($route === $route_addr){
-            unset($route);
-            $addr_spec = $route_addr;
-            if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
-                return false;
-            }
-        } else {
-            // Validate route part.
-            if (($route = $this->_validateRoute($route)) === false) {
-                return false;
-            }
-
-            $addr_spec = substr($route_addr, strlen($route . ':'));
-
-            // Validate addr-spec part.
-            if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
-                return false;
-            }
-        }
-
-        if (isset($route)) {
-            $return['adl'] = $route;
-        } else {
-            $return['adl'] = '';
-        }
-
-        $return = array_merge($return, $addr_spec);
-        return $return;
-    }
-
-    /**
-     * Function to validate a route, which is:
-     * route = 1#("@" domain) ":"
-     *
-     * @access private
-     * @param string $route The string to check.
-     * @return mixed False on failure, or the validated $route on success.
-     */
-    function _validateRoute($route)
-    {
-        // Split on comma.
-        $domains = explode(',', trim($route));
-
-        for ($i = 0; $i < count($domains); $i++) {
-            $domains[$i] = str_replace('@', '', trim($domains[$i]));
-            if (!$this->_validateDomain($domains[$i])) return false;
-        }
-
-        return $route;
-    }
-
-    /**
-     * Function to validate a domain, though this is not quite what
-     * you expect of a strict internet domain.
-     *
-     * domain = sub-domain *("." sub-domain)
-     *
-     * @access private
-     * @param string $domain The string to check.
-     * @return mixed False on failure, or the validated domain on success.
-     */
-    function _validateDomain($domain)
-    {
-        // Note the different use of $subdomains and $sub_domains
-        $subdomains = explode('.', $domain);
-
-        while (count($subdomains) > 0) {
-            $sub_domains[] = $this->_splitCheck($subdomains, '.');
-            for ($i = 0; $i < $this->index + 1; $i++)
-                array_shift($subdomains);
-        }
-
-        for ($i = 0; $i < count($sub_domains); $i++) {
-            if (!$this->_validateSubdomain(trim($sub_domains[$i])))
-                return false;
-        }
-
-        // Managed to get here, so return input.
-        return $domain;
-    }
-
-    /**
-     * Function to validate a subdomain:
-     *   subdomain = domain-ref / domain-literal
-     *
-     * @access private
-     * @param string $subdomain The string to check.
-     * @return boolean Success or failure.
-     */
-    function _validateSubdomain($subdomain)
-    {
-        if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
-            if (!$this->_validateDliteral($arr[1])) return false;
-        } else {
-            if (!$this->_validateAtom($subdomain)) return false;
-        }
-
-        // Got here, so return successful.
-        return true;
-    }
-
-    /**
-     * Function to validate a domain literal:
-     *   domain-literal =  "[" *(dtext / quoted-pair) "]"
-     *
-     * @access private
-     * @param string $dliteral The string to check.
-     * @return boolean Success or failure.
-     */
-    function _validateDliteral($dliteral)
-    {
-        return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
-    }
-
-    /**
-     * Function to validate an addr-spec.
-     *
-     * addr-spec = local-part "@" domain
-     *
-     * @access private
-     * @param string $addr_spec The string to check.
-     * @return mixed False on failure, or the validated addr-spec on success.
-     */
-    function _validateAddrSpec($addr_spec)
-    {
-        $addr_spec = trim($addr_spec);
-
-        // Split on @ sign if there is one.
-        if (strpos($addr_spec, '@') !== false) {
-            $parts      = explode('@', $addr_spec);
-            $local_part = $this->_splitCheck($parts, '@');
-            $domain     = substr($addr_spec, strlen($local_part . '@'));
-
-        // No @ sign so assume the default domain.
-        } else {
-            $local_part = $addr_spec;
-            $domain     = $this->default_domain;
-        }
-
-        if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
-        if (($domain     = $this->_validateDomain($domain)) === false) return false;
-
-        // Got here so return successful.
-        return array('local_part' => $local_part, 'domain' => $domain);
-    }
-
-    /**
-     * Function to validate the local part of an address:
-     *   local-part = word *("." word)
-     *
-     * @access private
-     * @param string $local_part
-     * @return mixed False on failure, or the validated local part on success.
-     */
-    function _validateLocalPart($local_part)
-    {
-        $parts = explode('.', $local_part);
-        $words = array();
-
-        // Split the local_part into words.
-        while (count($parts) > 0){
-            $words[] = $this->_splitCheck($parts, '.');
-            for ($i = 0; $i < $this->index + 1; $i++) {
-                array_shift($parts);
-            }
-        }
-
-        // Validate each word.
-        for ($i = 0; $i < count($words); $i++) {
-            if ($this->_validatePhrase(trim($words[$i])) === false) return false;
-        }
-
-        // Managed to get here, so return the input.
-        return $local_part;
-    }
-
-    /**
-    * Returns an approximate count of how many addresses are
-    * in the given string. This is APPROXIMATE as it only splits
-    * based on a comma which has no preceding backslash. Could be
-    * useful as large amounts of addresses will end up producing
-    * *large* structures when used with parseAddressList().
-    *
-    * @param  string $data Addresses to count
-    * @return int          Approximate count
-    */
-    function approximateCount($data)
-    {
-        return count(preg_split('/(?<!\\\\),/', $data));
-    }
-
-    /**
-    * This is a email validating function seperate to the rest
-    * of the class. It simply validates whether an email is of
-    * the common internet form: <user>@<domain>. This can be
-    * sufficient for most people. Optional stricter mode can
-    * be utilised which restricts mailbox characters allowed
-    * to alphanumeric, full stop, hyphen and underscore.
-    *
-    * @param  string  $data   Address to check
-    * @param  boolean $strict Optional stricter mode
-    * @return mixed           False if it fails, an indexed array
-    *                         username/domain if it matches
-    */
-    function isValidInetAddress($data, $strict = false)
-    {
-        $regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';
-        if (preg_match($regex, trim($data), $matches)) {
-            return array($matches[1], $matches[2]);
-        } else {
-            return false;
-        }
-    }
-
-}
Index: plugins/blocks/mrbs/web/Mail/smtp.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail/smtp.php
diff -N plugins/blocks/mrbs/web/Mail/smtp.php
--- plugins/blocks/mrbs/web/Mail/smtp.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,185 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Authors: Chuck Hagenbuch <chuck@horde.org>                           |
-// |          Jon Parise <jon@php.net>                                    |
-// +----------------------------------------------------------------------+
-
-/**
- * SMTP implementation of the PEAR Mail:: interface. Requires the PEAR
- * Net_SMTP:: class.
- * @access public
- * @package Mail
- * @version $Revision: 1.1 $
- */
-class Mail_smtp extends Mail {
-
-    /**
-     * The SMTP host to connect to.
-     * @var string
-     */
-    var $host = 'localhost';
-
-    /**
-     * The port the SMTP server is on.
-     * @var integer
-     */
-    var $port = 25;
-
-    /**
-     * Should SMTP authentication be used?
-     *
-     * This value may be set to true, false or the name of a specific
-     * authentication method.
-     *
-     * If the value is set to true, the Net_SMTP package will attempt to use
-     * the best authentication method advertised by the remote SMTP server.
-     *
-     * @var mixed
-     */
-    var $auth = false;
-
-    /**
-     * The username to use if the SMTP server requires authentication.
-     * @var string
-     */
-    var $username = '';
-
-    /**
-     * The password to use if the SMTP server requires authentication.
-     * @var string
-     */
-    var $password = '';
-
-    /**
-     * Hostname or domain that will be sent to the remote SMTP server in the
-     * HELO / EHLO message.
-     *
-     * @var string
-     */
-    var $localhost = 'localhost';
-
-    /**
-     * Constructor.
-     *
-     * Instantiates a new Mail_smtp:: object based on the parameters
-     * passed in. It looks for the following parameters:
-     *     host        The server to connect to. Defaults to localhost.
-     *     port        The port to connect to. Defaults to 25.
-     *     auth        SMTP authentication.  Defaults to none.
-     *     username    The username to use for SMTP auth. No default.
-     *     password    The password to use for SMTP auth. No default.
-     *     localhost   The local hostname / domain. Defaults to localhost.
-     *
-     * If a parameter is present in the $params array, it replaces the
-     * default.
-     *
-     * @param array Hash containing any parameters different from the
-     *              defaults.
-     * @access public
-     */
-    function Mail_smtp($params)
-    {
-        if (isset($params['host'])) $this->host = $params['host'];
-        if (isset($params['port'])) $this->port = $params['port'];
-        if (isset($params['auth'])) $this->auth = $params['auth'];
-        if (isset($params['username'])) $this->username = $params['username'];
-        if (isset($params['password'])) $this->password = $params['password'];
-        if (isset($params['localhost'])) $this->localhost = $params['localhost'];
-    }
-
-    /**
-     * Implements Mail::send() function using SMTP.
-     *
-     * @param mixed $recipients Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid. This may contain recipients not
-     *              specified in the headers, for Bcc:, resending
-     *              messages, etc.
-     *
-     * @param array $headers The array of headers to send with the mail, in an
-     *              associative array, where the array key is the
-     *              header name (e.g., 'Subject'), and the array value
-     *              is the header value (e.g., 'test'). The header
-     *              produced from those values would be 'Subject:
-     *              test'.
-     *
-     * @param string $body The full text of the message body, including any
-     *               Mime parts, etc.
-     *
-     * @return mixed Returns true on success, or a PEAR_Error
-     *               containing a descriptive error message on
-     *               failure.
-     * @access public
-     */
-    function send($recipients, $headers, $body)
-    {
-        include_once 'Net/SMTP.php';
-
-        if (!($smtp = new Net_SMTP($this->host, $this->port, $this->localhost))) {
-            return new PEAR_Error('unable to instantiate Net_SMTP object');
-        }
-
-        if (PEAR::isError($smtp->connect())) {
-            return new PEAR_Error('unable to connect to smtp server ' .
-                                  $this->host . ':' . $this->port);
-        }
-
-        if ($this->auth) {
-            $method = is_string($this->auth) ? $this->auth : '';
-
-            if (PEAR::isError($smtp->auth($this->username, $this->password,
-                              $method))) {
-                return new PEAR_Error('unable to authenticate to smtp server');
-            }
-        }
-
-        list($from, $text_headers) = $this->prepareHeaders($headers);
-
-        /*
-         * Since few MTAs are going to allow this header to be forged unless
-         * it's in the MAIL FROM: exchange, we'll use Return-Path instead of
-         * From: if it's set.
-         */
-        if (!empty($headers['Return-Path'])) {
-            $from = $headers['Return-Path'];
-        }
-
-        if (!isset($from)) {
-            return new PEAR_Error('No from address given');
-        }
-
-        if (PEAR::isError($smtp->mailFrom($from))) {
-            return new PEAR_Error('unable to set sender to [' . $from . ']');
-        }
-
-        $recipients = $this->parseRecipients($recipients);
-        foreach($recipients as $recipient) {
-            if (PEAR::isError($res = $smtp->rcptTo($recipient))) {
-                return new PEAR_Error('unable to add recipient [' .
-                                      $recipient . ']: ' . $res->getMessage());
-            }
-        }
-
-        if (PEAR::isError($smtp->data($text_headers . "\r\n" . $body))) {
-            return new PEAR_Error('unable to send data');
-        }
-
-        $smtp->disconnect();
-        return true;
-    }
-}
-
-?>
Index: plugins/blocks/mrbs/web/Mail/null.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail/null.php
diff -N plugins/blocks/mrbs/web/Mail/null.php
--- plugins/blocks/mrbs/web/Mail/null.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,60 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Author: Phil Kernick <philk@rotfl.com.au>                            |
-// +----------------------------------------------------------------------+
-//
-// $Id: null.php,v 1.1 2007/04/05 22:25:36 arborrow Exp $
-//
-
-/**
- * Null implementation of the PEAR Mail:: interface.
- * @access public
- * @package Mail
- * @version $Revision: 1.1 $
- */
-class Mail_null extends Mail {
-
-    /**
-     * Implements Mail_null::send() function. Silently discards all
-     * mail.
-     *
-     * @param mixed $recipients Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid. This may contain recipients not
-     *              specified in the headers, for Bcc:, resending
-     *              messages, etc.
-     *
-     * @param array $headers The array of headers to send with the mail, in an
-     *              associative array, where the array key is the
-     *              header name (ie, 'Subject'), and the array value
-     *              is the header value (ie, 'test'). The header
-     *              produced from those values would be 'Subject:
-     *              test'.
-     *
-     * @param string $body The full text of the message body, including any
-     *               Mime parts, etc.
-     *
-     * @return mixed Returns true on success, or a PEAR_Error
-     *               containing a descriptive error message on
-     *               failure.
-     * @access public
-     */
-    function send($recipients, $headers, $body)
-    {
-        return true;
-    }
-
-}
Index: plugins/blocks/mrbs/web/Mail/mail.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail/mail.php
diff -N plugins/blocks/mrbs/web/Mail/mail.php
--- plugins/blocks/mrbs/web/Mail/mail.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,126 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Author: Chuck Hagenbuch <chuck@horde.org>                            |
-// +----------------------------------------------------------------------+
-//
-// $Id: mail.php,v 1.1 2007/04/05 22:25:36 arborrow Exp $
-
-/**
- * internal PHP-mail() implementation of the PEAR Mail:: interface.
- * @package Mail
- * @version $Revision: 1.1 $
- */
-class Mail_mail extends Mail
-{
-    /**
-     * Any arguments to pass to the mail() function.
-     * @var string
-     */
-    var $_params = '';
-
-    /**
-     * Constructor.
-     *
-     * Instantiates a new Mail_mail:: object based on the parameters
-     * passed in.
-     *
-     * @param string $params Extra arguments for the mail() function.
-     */
-    function Mail_mail($params = '')
-    {
-        /* The other mail implementations accept parameters as arrays.
-         * In the interest of being consistent, explode an array into
-         * a string of parameter arguments. */
-        if (is_array($params)) {
-            $this->_params = join(' ', $params);
-        } else {
-            $this->_params = $params;
-        }
-
-        /* Because the mail() function may pass headers as command
-         * line arguments, we can't guarantee the use of the standard
-         * "\r\n" separator.  Instead, we use the system's native line
-         * separator. */
-        $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n";
-    }
-
-	/**
-     * Implements Mail_mail::send() function using php's built-in mail()
-     * command.
-     *
-     * @param mixed $recipients Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid. This may contain recipients not
-     *              specified in the headers, for Bcc:, resending
-     *              messages, etc.
-     *
-     * @param array $headers The array of headers to send with the mail, in an
-     *              associative array, where the array key is the
-     *              header name (ie, 'Subject'), and the array value
-     *              is the header value (ie, 'test'). The header
-     *              produced from those values would be 'Subject:
-     *              test'.
-     *
-     * @param string $body The full text of the message body, including any
-     *               Mime parts, etc.
-     *
-     * @return mixed Returns true on success, or a PEAR_Error
-     *               containing a descriptive error message on
-     *               failure.
-     *
-     * @access public
-     */
-    function send($recipients, $headers, $body)
-    {
-        // If we're passed an array of recipients, implode it.
-        if (is_array($recipients)) {
-            $recipients = implode(', ', $recipients);
-        }
-
-        // Get the Subject out of the headers array so that we can
-        // pass it as a seperate argument to mail().
-        $subject = '';
-        if (isset($headers['Subject'])) {
-            $subject = $headers['Subject'];
-            unset($headers['Subject']);
-        }
-
-        // Flatten the headers out.
-        list(,$text_headers) = Mail::prepareHeaders($headers);
-
-        /*
-         * We only use mail()'s optional fifth parameter if the additional
-         * parameters have been provided and we're not running in safe mode.
-         */
-        if (empty($this->_params) || ini_get('safe_mode')) {
-            $result = @mail($recipients, $subject, $body, $text_headers);
-        } else {
-            $result = @mail($recipients, $subject, $body, $text_headers,
-                           $this->_params);
-        }
-
-        /*
-         * If the mail() function returned failure, we need to create a
-         * PEAR_Error object and return it instead of the boolean result.
-         */
-        if ($result === false) {
-            $result = PEAR::raiseError('mail() returned failure');
-        }
-
-        return $result;
-    }
-
-}
Index: plugins/blocks/mrbs/web/Mail/sendmail.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail/sendmail.php
diff -N plugins/blocks/mrbs/web/Mail/sendmail.php
--- plugins/blocks/mrbs/web/Mail/sendmail.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,131 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Author: Chuck Hagenbuch <chuck@horde.org>                            |
-// +----------------------------------------------------------------------+
-
-/**
- * Sendmail implementation of the PEAR Mail:: interface.
- * @access public
- * @package Mail
- * @version $Revision: 1.1 $
- */
-class Mail_sendmail extends Mail {
-    
-	/**
-     * The location of the sendmail or sendmail wrapper binary on the
-     * filesystem.
-     * @var string
-     */
-    var $sendmail_path = '/usr/sbin/sendmail';
-    
-	/**
-     * Any extra command-line parameters to pass to the sendmail or
-     * sendmail wrapper binary.
-     * @var string
-     */
-    var $sendmail_args = '';
-    
-	/**
-     * Constructor.
-     * 
-     * Instantiates a new Mail_sendmail:: object based on the parameters
-     * passed in. It looks for the following parameters:
-     *     sendmail_path    The location of the sendmail binary on the
-     *                      filesystem. Defaults to '/usr/sbin/sendmail'.
-     *
-     *     sendmail_args    Any extra parameters to pass to the sendmail
-     *                      or sendmail wrapper binary.
-     *
-     * If a parameter is present in the $params array, it replaces the
-     * default.
-     *
-     * @param array $params Hash containing any parameters different from the
-     *              defaults.
-     * @access public
-     */	
-    function Mail_sendmail($params)
-    {
-        if (isset($params['sendmail_path'])) $this->sendmail_path = $params['sendmail_path'];
-        if (isset($params['sendmail_args'])) $this->sendmail_args = $params['sendmail_args'];
-
-        /*
-         * Because we need to pass message headers to the sendmail program on
-         * the commandline, we can't guarantee the use of the standard "\r\n"
-         * separator.  Instead, we use the system's native line separator.
-         */
-        $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n";
-    }
-    
-	/**
-     * Implements Mail::send() function using the sendmail
-     * command-line binary.
-     * 
-     * @param mixed $recipients Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid. This may contain recipients not
-     *              specified in the headers, for Bcc:, resending
-     *              messages, etc.
-     *
-     * @param array $headers The array of headers to send with the mail, in an
-     *              associative array, where the array key is the
-     *              header name (ie, 'Subject'), and the array value
-     *              is the header value (ie, 'test'). The header
-     *              produced from those values would be 'Subject:
-     *              test'.
-     *
-     * @param string $body The full text of the message body, including any
-     *               Mime parts, etc.
-     *
-     * @return mixed Returns true on success, or a PEAR_Error
-     *               containing a descriptive error message on
-     *               failure.
-     * @access public
-     */	
-    function send($recipients, $headers, $body)
-    {
-        $recipients = escapeShellCmd(implode(' ', $this->parseRecipients($recipients)));
-        
-        list($from, $text_headers) = $this->prepareHeaders($headers);
-        if (!isset($from)) {
-            return new PEAR_Error('No from address given.');
-        } elseif (strstr($from, ' ') ||
-                  strstr($from, ';') ||
-                  strstr($from, '&') ||
-                  strstr($from, '`')) {
-            return new PEAR_Error('From address specified with dangerous characters.');
-        }
-        
-        $result = 0;
-        if (@is_executable($this->sendmail_path)) {
-            $from = escapeShellCmd($from);
-            $mail = popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w');
-            fputs($mail, $text_headers);
-            fputs($mail, $this->sep);  // newline to end the headers section
-            fputs($mail, $body);
-            $result = pclose($mail) >> 8 & 0xFF; // need to shift the pclose result to get the exit code
-        } else {
-            return new PEAR_Error('sendmail [' . $this->sendmail_path . '] not executable');
-        }
-        
-        if ($result != 0) {
-            return new PEAR_Error('sendmail returned error code ' . $result);
-        }
-        
-        return true;
-    }
-    
-}
-?>
Index: plugins/blocks/mrbs/lang/en_utf8/block_mrbs.php
===================================================================
RCS file: /cvsroot/moodle/contrib/plugins/blocks/mrbs/lang/en_utf8/block_mrbs.php,v
retrieving revision 1.10
diff -u -r1.10 block_mrbs.php
--- plugins/blocks/mrbs/lang/en_utf8/block_mrbs.php	5 Aug 2008 04:54:59 -0000	1.10
+++ plugins/blocks/mrbs/lang/en_utf8/block_mrbs.php	5 Aug 2008 06:03:54 -0000
@@ -1,4 +1,4 @@
-<?php // $Id: block_mrbs.php,v 1.10 2008/08/05 04:54:59 arborrow Exp $
+<?php // $Id: block_mrbs.php,v 1.9 2008/08/03 17:21:55 arborrow Exp $
 $string['about_mrbs']         = 'About MRBS';
 $string['accessdenied']       = 'Access Denied';
 $string['accessmrbs'] = 'Schedule a Resource (Computer Room)';
@@ -105,6 +105,7 @@
 $string['database']           = 'Database';
 $string['dayafter']           = 'Go To Day After';
 $string['daybefore']          = 'Go To Day Before';
+$string['days']          = 'days'; //duplicated in moodle.php but needed for view_entry.php
 $string['delarea']            = 'You must delete all rooms in this area before you can delete it<p>';
 $string['delete_user']        = 'Delete this user';
 $string['deleteentry']        = 'Delete Entry';
@@ -156,6 +157,7 @@
 $string['match_entry']        = 'Match brief description';
 $string['match_room']         = 'Match room';
 $string['match_type']         = 'Match type';
+$string['minutes']          = 'minutes'; //duplicated in moodle.php but needed for view_entry.php
 $string['month']            = 'Month';
 $string['monthafter']         = 'Go To Month After';
 $string['monthbefore']        = 'Go To Month Before';
@@ -166,7 +168,7 @@
 $string['mustlogin'] = 'You must be logged in to Moodle before you can access the MRBS calendar block';
 $string['namebooker']         = 'Reservation for';
 $string['no_rooms_for_area']  = 'No rooms defined for this area';
-$string['no_user_with_email'] = 'No user found with an email address of: $a';
+$string['no_user_with_email'] = 'No Moodle users found with an email address of: $a. All MRBS related email(s) must be associated with a Moodle user account.';
 $string['no_users_create_first_admin'] = 'Create a user configured as administrator and then you can log in and create more users.';
 $string['no_users_initial']   = 'No users in database, allowing initial user creation';
 $string['noarea']             = 'No area selected';
Index: plugins/blocks/mrbs/web/functions.php
===================================================================
RCS file: /cvsroot/moodle/contrib/plugins/blocks/mrbs/web/functions.php,v
retrieving revision 1.8
diff -u -r1.8 functions.php
--- plugins/blocks/mrbs/web/functions.php	5 Aug 2008 04:54:59 -0000	1.8
+++ plugins/blocks/mrbs/web/functions.php	5 Aug 2008 06:03:54 -0000
@@ -1,6 +1,6 @@
 <?php
 
-# $Id: functions.php,v 1.8 2008/08/05 04:54:59 arborrow Exp $
+# $Id: functions.php,v 1.7 2008/08/04 01:17:51 arborrow Exp $
 require_once("../../../config.php"); //for Moodle integration
 # probably a bad place to put this, but for error reporting purposes
 # $pview must be defined. if it's not then there's errors generated all
@@ -971,7 +971,6 @@
             }
         }
     }
-//    $result = sendMail($recipients, $subject, $body, $get_string('charset','block_mrbs') ,MAIL_CC);
     return $result;
 }
 
@@ -1121,9 +1120,7 @@
             }
         }
     }
-//    $result = sendMail($recipients, $subject, $body, $get_string('charset','block_mrbs') ,MAIL_CC);
     return $result;
-    
 }
 
 // }}}
@@ -1365,88 +1362,6 @@
     return($new_value . $suffix);
 }
 
-// }}}
-// {{{ sendMail()
-
-/**
- * Send emails using PEAR::Mail class.
- * How to use this class -> http://www.pear.php.net/package/Mail then link
- * "View documentation".
- * Currently implemented version: Mail 1.1.3 and its dependancies
- * Net_SMTP 1.2.6 and Net_Socket 1.0.2
- *
- * @param string  $recipients       comma separated list of recipients or array
- * @param string  $subject          email subject
- * @param string  $body             text message
- * @param string  $charset          character set used in body
- * @param string  $cc               Carbon Copy
- * @param string  $bcc              Blind Carbon Copy
- * @param string  $from             from field
- * @param string  $backend          'mail', 'smtp' or 'sendmail'
- * @param string  $sendmail_path    ie. "/usr/bin/sendmail"
- * @param string  $sendmail_args    ie. "-t -i"
- * @param string  $host             smtp server hostname
- * @param string  $port             smtp server port
- * @param string  $auth             smtp server authentication, TRUE/FALSE
- * @param string  $username         smtp server username
- * @param string  $password         smtp server password
- * @return bool                     TRUE or PEAR error object if fails
- */
-function sendMail($recipients, $subject, $body, $charset = 'us-ascii',
-    $cc = NULL, $bcc = NULL, $from = MAIL_FROM, $backend = MAIL_ADMIN_BACKEND,
-    $sendmail_path = SENDMAIL_PATH, $sendmail_args = SENDMAIL_ARGS,
-    $host = SMTP_HOST, $port = SMTP_PORT, $auth = SMTP_AUTH,
-    $username = SMTP_USERNAME, $password = SMTP_PASSWORD)
-{
-    require_once "Mail.php";
-
-    // Headers part
-    $headers['From']         = $from;
-    if( $backend != 'mail' ) {
-        $headers['To']           = $recipients;
-    }
-    (NULL != $cc) ? $headers['Cc'] = $cc : '';
-    (NULL != $bcc) ? $headers['Bcc'] = $bcc : '';
-    $headers['Subject']      = $subject;
-    $headers['MIME-Version'] = '1.0';
-    $headers['Content-Type'] = 'text/plain; charset=' . $charset;
-
-    // Parameters part
-    if( $backend == 'sendmail' ) {
-        $params['sendmail_path'] = $sendmail_path;
-        $params['sendmail_args'] = $sendmail_args;
-    }
-    if( $backend == "smtp" ) {
-        $params['host']          = $host;
-        $params['port']          = $port;
-        $params['auth']          = $auth;
-        $params['username']      = $username;
-        $params['password']      = $password;
-    }
-
-    // Call to the PEAR::Mail class
-    $mail_object =& Mail::factory($backend, $params);
-    $result = $mail_object->send($recipients, $headers, $body);
-
-    if (is_object($result))
-    {
-      error_log("Error sending email: ".$result->getMessage());
-    }
-    return $result;
-}
-
-// }}}
-// {{{ unHtmlEntities()
-
-/**
- * Convert all HTML entities to their applicable characters.
- * Added to remove HTML entities that are not suitable for plain text emails.
- * May be replaced by PHP function 'html_entity_decode()' but this function
- * only exist since PHP 4.3.0 and is buggy before PHP5.
- *
- * @param  string   $string     string to decode
- * @return string               decoded string
- */
 function unHtmlEntities($string)
 {
     $trans_tbl = get_html_translation_table(HTML_ENTITIES);
Index: plugins/blocks/mrbs/web/edit_area_room.php
===================================================================
RCS file: /cvsroot/moodle/contrib/plugins/blocks/mrbs/web/edit_area_room.php,v
retrieving revision 1.4
diff -u -r1.4 edit_area_room.php
--- plugins/blocks/mrbs/web/edit_area_room.php	1 Aug 2008 04:02:10 -0000	1.4
+++ plugins/blocks/mrbs/web/edit_area_room.php	5 Aug 2008 06:03:54 -0000
@@ -52,19 +52,16 @@
 
 <?php
 if($room>0) {
-    include_once 'Mail/RFC822.php';
     (!isset($room_admin_email)) ? $room_admin_email = '': '';
     $emails = explode(',', $room_admin_email);
     $valid_email = TRUE;
-    $email_validator = new Mail_RFC822();
     foreach ($emails as $email)
     {
         // if no email address is entered, this is OK, even if isValidInetAddress
         // does not return TRUE
-        if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
-            && ('' != $room_admin_email) )
-        {
+        if (!get_user_by_email($email) && ('' != $room_admin_email)) {
             $valid_email = FALSE;
+            notice(get_string('no_user_with_email','block_mrbs',$email));
         }
     }
     //
@@ -111,19 +108,16 @@
 <?php
 if(!empty($area))
 {
-    include_once 'Mail/RFC822.php';
     (!isset($area_admin_email)) ? $area_admin_email = '': '';
     $emails = explode(',', $area_admin_email);
     $valid_email = TRUE;
-    $email_validator = new Mail_RFC822();
     foreach ($emails as $email)
     {
         // if no email address is entered, this is OK, even if isValidInetAddress
         // does not return TRUE
-        if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
-            && ('' != $area_admin_email) )
-        {
+        if (!get_user_by_email($email) && ('' != $area_admin_email)) {
             $valid_email = FALSE;
+            notice(get_string('no_user_with_email','block_mrbs',$email));
         }
     }
     //
Index: plugins/blocks/mrbs/web/Mail.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Mail.php
diff -N plugins/blocks/mrbs/web/Mail.php
--- plugins/blocks/mrbs/web/Mail.php	28 Dec 2007 05:53:06 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,194 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Author: Chuck Hagenbuch <chuck@horde.org>                            |
-// +----------------------------------------------------------------------+
-//
-// $Id: Mail.php,v 1.2 2007/12/28 05:53:06 arborrow Exp $
-require_once("../../../config.php"); //for Moodle integration
-require_once 'PEAR.php';
-
-/**
- * PEAR's Mail:: interface. Defines the interface for implementing
- * mailers under the PEAR hierarchy, and provides supporting functions
- * useful in multiple mailer backends.
- *
- * @access public
- * @version $Revision: 1.2 $
- * @package Mail
- */
-class Mail
-{
-    /**
-     * Line terminator used for separating header lines.
-     * @var string
-     */
-    var $sep = "\r\n";
-
-    /**
-     * Provides an interface for generating Mail:: objects of various
-     * types
-     *
-     * @param string $driver The kind of Mail:: object to instantiate.
-     * @param array  $params The parameters to pass to the Mail:: object.
-     * @return object Mail a instance of the driver class or if fails a PEAR Error
-     * @access public
-     */
-    function factory($driver, $params = array())
-    {
-        $driver = strtolower($driver);
-        @include_once 'Mail/' . $driver . '.php';
-        $class = 'Mail_' . $driver;
-        if (class_exists($class)) {
-            return new $class($params);
-        } else {
-            return PEAR::raiseError('Unable to find class for driver ' . $driver);
-        }
-    }
-
-    /**
-     * Implements Mail::send() function using php's built-in mail()
-     * command.
-     *
-     * @param mixed $recipients Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid. This may contain recipients not
-     *              specified in the headers, for Bcc:, resending
-     *              messages, etc.
-     *
-     * @param array $headers The array of headers to send with the mail, in an
-     *              associative array, where the array key is the
-     *              header name (ie, 'Subject'), and the array value
-     *              is the header value (ie, 'test'). The header
-     *              produced from those values would be 'Subject:
-     *              test'.
-     *
-     * @param string $body The full text of the message body, including any
-     *               Mime parts, etc.
-     *
-     * @return mixed Returns true on success, or a PEAR_Error
-     *               containing a descriptive error message on
-     *               failure.
-     * @access public
-     * @deprecated use Mail_mail::send instead
-     */
-    function send($recipients, $headers, $body)
-    {
-        // if we're passed an array of recipients, implode it.
-        if (is_array($recipients)) {
-            $recipients = implode(', ', $recipients);
-        }
-
-        // get the Subject out of the headers array so that we can
-        // pass it as a seperate argument to mail().
-        $subject = '';
-        if (isset($headers['Subject'])) {
-            $subject = $headers['Subject'];
-            unset($headers['Subject']);
-        }
-
-        // flatten the headers out.
-        list(,$text_headers) = Mail::prepareHeaders($headers);
-
-        return mail($recipients, $subject, $body, $text_headers);
-
-    }
-
-    /**
-     * Take an array of mail headers and return a string containing
-     * text usable in sending a message.
-     *
-     * @param array $headers The array of headers to prepare, in an associative
-     *              array, where the array key is the header name (ie,
-     *              'Subject'), and the array value is the header
-     *              value (ie, 'test'). The header produced from those
-     *              values would be 'Subject: test'.
-     *
-     * @return mixed Returns false if it encounters a bad address,
-     *               otherwise returns an array containing two
-     *               elements: Any From: address found in the headers,
-     *               and the plain text version of the headers.
-     * @access private
-     */
-    function prepareHeaders($headers)
-    {
-        $lines = array();
-        $from = null;
-
-        foreach ($headers as $key => $value) {
-            if ($key === 'From') {
-                include_once 'Mail/RFC822.php';
-
-                $addresses = Mail_RFC822::parseAddressList($value, 'localhost',
-                                                           false);
-                $from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
-
-                // Reject envelope From: addresses with spaces.
-                if (strstr($from, ' ')) {
-                    return false;
-                }
-
-                $lines[] = $key . ': ' . $value;
-            } elseif ($key === 'Received') {
-                // Put Received: headers at the top.  Spam detectors often
-                // flag messages with Received: headers after the Subject:
-                // as spam.
-                array_unshift($lines, $key . ': ' . $value);
-            } else {
-                $lines[] = $key . ': ' . $value;
-            }
-        }
-
-        return array($from, join($this->sep, $lines) . $this->sep);
-    }
-
-    /**
-     * Take a set of recipients and parse them, returning an array of
-     * bare addresses (forward paths) that can be passed to sendmail
-     * or an smtp server with the rcpt to: command.
-     *
-     * @param mixed Either a comma-seperated list of recipients
-     *              (RFC822 compliant), or an array of recipients,
-     *              each RFC822 valid.
-     *
-     * @return array An array of forward paths (bare addresses).
-     * @access private
-     */
-    function parseRecipients($recipients)
-    {
-        include_once 'Mail/RFC822.php';
-
-        // if we're passed an array, assume addresses are valid and
-        // implode them before parsing.
-        if (is_array($recipients)) {
-            $recipients = implode(', ', $recipients);
-        }
-
-        // Parse recipients, leaving out all personal info. This is
-        // for smtp recipients, etc. All relevant personal information
-        // should already be in the headers.
-        $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
-        $recipients = array();
-        if (is_array($addresses)) {
-            foreach ($addresses as $ob) {
-                $recipients[] = $ob->mailbox . '@' . $ob->host;
-            }
-        }
-
-        return $recipients;
-    }
-
-}
-?>
\ No newline at end of file
Index: plugins/blocks/mrbs/web/PEAR.php
===================================================================
RCS file: plugins/blocks/mrbs/web/PEAR.php
diff -N plugins/blocks/mrbs/web/PEAR.php
--- plugins/blocks/mrbs/web/PEAR.php	5 Apr 2007 22:25:23 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,975 +0,0 @@
-<?php
-//
-// +--------------------------------------------------------------------+
-// | PEAR, the PHP Extension and Application Repository                 |
-// +--------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group                              |
-// +--------------------------------------------------------------------+
-// | This source file is subject to version 2.0 of the PHP license,     |
-// | that is bundled with this package in the file LICENSE, and is      |
-// | available through the world-wide-web at the following url:         |
-// | http://www.php.net/license/3_0.txt.                                |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to        |
-// | license@php.net so we can mail you a copy immediately.             |
-// +--------------------------------------------------------------------+
-// | Authors: Sterling Hughes <sterling@php.net>                        |
-// |          Stig Bakken <ssb@php.net>                                 |
-// |          Tomas V.V.Cox <cox@idecnet.com>                           |
-// +--------------------------------------------------------------------+
-//
-// $Id: PEAR.php,v 1.1 2007/04/05 22:25:23 arborrow Exp $
-//
-require_once("../../../config.php"); //for Moodle integration
-define('PEAR_ERROR_RETURN',     1);
-define('PEAR_ERROR_PRINT',      2);
-define('PEAR_ERROR_TRIGGER',    4);
-define('PEAR_ERROR_DIE',        8);
-define('PEAR_ERROR_CALLBACK',  16);
-/**
- * WARNING: obsolete
- * @deprecated
- */
-define('PEAR_ERROR_EXCEPTION', 32);
-define('PEAR_ZE2', (function_exists('version_compare') &&
-                    version_compare(zend_version(), "2-dev", "ge")));
-
-if (substr(PHP_OS, 0, 3) == 'WIN') {
-    define('OS_WINDOWS', true);
-    define('OS_UNIX',    false);
-    define('PEAR_OS',    'Windows');
-} else {
-    define('OS_WINDOWS', false);
-    define('OS_UNIX',    true);
-    define('PEAR_OS',    'Unix'); // blatant assumption
-}
-
-// instant backwards compatibility
-if (!defined('PATH_SEPARATOR')) {
-    if (OS_WINDOWS) {
-        define('PATH_SEPARATOR', ';');
-    } else {
-        define('PATH_SEPARATOR', ':');
-    }
-}
-
-$GLOBALS['_PEAR_default_error_mode']     = PEAR_ERROR_RETURN;
-$GLOBALS['_PEAR_default_error_options']  = E_USER_NOTICE;
-$GLOBALS['_PEAR_destructor_object_list'] = array();
-$GLOBALS['_PEAR_shutdown_funcs']         = array();
-$GLOBALS['_PEAR_error_handler_stack']    = array();
-
-ini_set('track_errors', true);
-
-/**
- * Base class for other PEAR classes.  Provides rudimentary
- * emulation of destructors.
- *
- * If you want a destructor in your class, inherit PEAR and make a
- * destructor method called _yourclassname (same name as the
- * constructor, but with a "_" prefix).  Also, in your constructor you
- * have to call the PEAR constructor: $this->PEAR();.
- * The destructor method will be called without parameters.  Note that
- * at in some SAPI implementations (such as Apache), any output during
- * the request shutdown (in which destructors are called) seems to be
- * discarded.  If you need to get any debug information from your
- * destructor, use error_log(), syslog() or something similar.
- *
- * IMPORTANT! To use the emulated destructors you need to create the
- * objects by reference: $obj =& new PEAR_child;
- *
- * @since PHP 4.0.2
- * @author Stig Bakken <ssb@php.net>
- * @see http://pear.php.net/manual/
- */
-class PEAR
-{
-    // {{{ properties
-
-    /**
-     * Whether to enable internal debug messages.
-     *
-     * @var     bool
-     * @access  private
-     */
-    var $_debug = false;
-
-    /**
-     * Default error mode for this object.
-     *
-     * @var     int
-     * @access  private
-     */
-    var $_default_error_mode = null;
-
-    /**
-     * Default error options used for this object when error mode
-     * is PEAR_ERROR_TRIGGER.
-     *
-     * @var     int
-     * @access  private
-     */
-    var $_default_error_options = null;
-
-    /**
-     * Default error handler (callback) for this object, if error mode is
-     * PEAR_ERROR_CALLBACK.
-     *
-     * @var     string
-     * @access  private
-     */
-    var $_default_error_handler = '';
-
-    /**
-     * Which class to use for error objects.
-     *
-     * @var     string
-     * @access  private
-     */
-    var $_error_class = 'PEAR_Error';
-
-    /**
-     * An array of expected errors.
-     *
-     * @var     array
-     * @access  private
-     */
-    var $_expected_errors = array();
-
-    // }}}
-
-    // {{{ constructor
-
-    /**
-     * Constructor.  Registers this object in
-     * $_PEAR_destructor_object_list for destructor emulation if a
-     * destructor object exists.
-     *
-     * @param string $error_class  (optional) which class to use for
-     *        error objects, defaults to PEAR_Error.
-     * @access public
-     * @return void
-     */
-    function PEAR($error_class = null)
-    {
-        $classname = get_class($this);
-        if ($this->_debug) {
-            print "PEAR constructor called, class=$classname\n";
-        }
-        if ($error_class !== null) {
-            $this->_error_class = $error_class;
-        }
-        while ($classname) {
-            $destructor = "_$classname";
-            if (method_exists($this, $destructor)) {
-                global $_PEAR_destructor_object_list;
-                $_PEAR_destructor_object_list[] = &$this;
-                break;
-            } else {
-                $classname = get_parent_class($classname);
-            }
-        }
-    }
-
-    // }}}
-    // {{{ destructor
-
-    /**
-     * Destructor (the emulated type of...).  Does nothing right now,
-     * but is included for forward compatibility, so subclass
-     * destructors should always call it.
-     *
-     * See the note in the class desciption about output from
-     * destructors.
-     *
-     * @access public
-     * @return void
-     */
-    function _PEAR() {
-        if ($this->_debug) {
-            printf("PEAR destructor called, class=%s\n", get_class($this));
-        }
-    }
-
-    // }}}
-    // {{{ getStaticProperty()
-
-    /**
-    * If you have a class that's mostly/entirely static, and you need static
-    * properties, you can use this method to simulate them. Eg. in your method(s)
-    * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
-    * You MUST use a reference, or they will not persist!
-    *
-    * @access public
-    * @param  string $class  The calling classname, to prevent clashes
-    * @param  string $var    The variable to retrieve.
-    * @return mixed   A reference to the variable. If not set it will be
-    *                 auto initialised to NULL.
-    */
-    function &getStaticProperty($class, $var)
-    {
-        static $properties;
-        return $properties[$class][$var];
-    }
-
-    // }}}
-    // {{{ registerShutdownFunc()
-
-    /**
-    * Use this function to register a shutdown method for static
-    * classes.
-    *
-    * @access public
-    * @param  mixed $func  The function name (or array of class/method) to call
-    * @param  mixed $args  The arguments to pass to the function
-    * @return void
-    */
-    function registerShutdownFunc($func, $args = array())
-    {
-        $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
-    }
-
-    // }}}
-    // {{{ isError()
-
-    /**
-     * Tell whether a value is a PEAR error.
-     *
-     * @param   mixed $data   the value to test
-     * @param   int   $code   if $data is an error object, return true
-     *                        only if $code is a string and
-     *                        $obj->getMessage() == $code or
-     *                        $code is an integer and $obj->getCode() == $code
-     * @access  public
-     * @return  bool    true if parameter is an error
-     */
-    function isError($data, $code = null)
-    {
-        if (is_a($data, 'PEAR_Error')) {
-            if (is_null($code)) {
-                return true;
-            } elseif (is_string($code)) {
-                return $data->getMessage() == $code;
-            } else {
-                return $data->getCode() == $code;
-            }
-        }
-        return false;
-    }
-
-    // }}}
-    // {{{ setErrorHandling()
-
-    /**
-     * Sets how errors generated by this object should be handled.
-     * Can be invoked both in objects and statically.  If called
-     * statically, setErrorHandling sets the default behaviour for all
-     * PEAR objects.  If called in an object, setErrorHandling sets
-     * the default behaviour for that object.
-     *
-     * @param int $mode
-     *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
-     *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
-     *        PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
-     *
-     * @param mixed $options
-     *        When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
-     *        of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
-     *
-     *        When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
-     *        to be the callback function or method.  A callback
-     *        function is a string with the name of the function, a
-     *        callback method is an array of two elements: the element
-     *        at index 0 is the object, and the element at index 1 is
-     *        the name of the method to call in the object.
-     *
-     *        When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
-     *        a printf format string used when printing the error
-     *        message.
-     *
-     * @access public
-     * @return void
-     * @see PEAR_ERROR_RETURN
-     * @see PEAR_ERROR_PRINT
-     * @see PEAR_ERROR_TRIGGER
-     * @see PEAR_ERROR_DIE
-     * @see PEAR_ERROR_CALLBACK
-     * @see PEAR_ERROR_EXCEPTION
-     *
-     * @since PHP 4.0.5
-     */
-
-    function setErrorHandling($mode = null, $options = null)
-    {
-        if (isset($this) && is_a($this, 'PEAR')) {
-            $setmode     = &$this->_default_error_mode;
-            $setoptions  = &$this->_default_error_options;
-        } else {
-            $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
-            $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
-        }
-
-        switch ($mode) {
-            case PEAR_ERROR_EXCEPTION:
-            case PEAR_ERROR_RETURN:
-            case PEAR_ERROR_PRINT:
-            case PEAR_ERROR_TRIGGER:
-            case PEAR_ERROR_DIE:
-            case null:
-                $setmode = $mode;
-                $setoptions = $options;
-                break;
-
-            case PEAR_ERROR_CALLBACK:
-                $setmode = $mode;
-                // class/object method callback
-                if (is_callable($options)) {
-                    $setoptions = $options;
-                } else {
-                    trigger_error("invalid error callback", E_USER_WARNING);
-                }
-                break;
-
-            default:
-                trigger_error("invalid error mode", E_USER_WARNING);
-                break;
-        }
-    }
-
-    // }}}
-    // {{{ expectError()
-
-    /**
-     * This method is used to tell which errors you expect to get.
-     * Expected errors are always returned with error mode
-     * PEAR_ERROR_RETURN.  Expected error codes are stored in a stack,
-     * and this method pushes a new element onto it.  The list of
-     * expected errors are in effect until they are popped off the
-     * stack with the popExpect() method.
-     *
-     * Note that this method can not be called statically
-     *
-     * @param mixed $code a single error code or an array of error codes to expect
-     *
-     * @return int     the new depth of the "expected errors" stack
-     * @access public
-     */
-    function expectError($code = '*')
-    {
-        if (is_array($code)) {
-            array_push($this->_expected_errors, $code);
-        } else {
-            array_push($this->_expected_errors, array($code));
-        }
-        return sizeof($this->_expected_errors);
-    }
-
-    // }}}
-    // {{{ popExpect()
-
-    /**
-     * This method pops one element off the expected error codes
-     * stack.
-     *
-     * @return array   the list of error codes that were popped
-     */
-    function popExpect()
-    {
-        return array_pop($this->_expected_errors);
-    }
-
-    // }}}
-    // {{{ _checkDelExpect()
-
-    /**
-     * This method checks unsets an error code if available
-     *
-     * @param mixed error code
-     * @return bool true if the error code was unset, false otherwise
-     * @access private
-     * @since PHP 4.3.0
-     */
-    function _checkDelExpect($error_code)
-    {
-        $deleted = false;
-
-        foreach ($this->_expected_errors AS $key => $error_array) {
-            if (in_array($error_code, $error_array)) {
-                unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
-                $deleted = true;
-            }
-
-            // clean up empty arrays
-            if (0 == count($this->_expected_errors[$key])) {
-                unset($this->_expected_errors[$key]);
-            }
-        }
-        return $deleted;
-    }
-
-    // }}}
-    // {{{ delExpect()
-
-    /**
-     * This method deletes all occurences of the specified element from
-     * the expected error codes stack.
-     *
-     * @param  mixed $error_code error code that should be deleted
-     * @return mixed list of error codes that were deleted or error
-     * @access public
-     * @since PHP 4.3.0
-     */
-    function delExpect($error_code)
-    {
-        $deleted = false;
-
-        if ((is_array($error_code) && (0 != count($error_code)))) {
-            // $error_code is a non-empty array here;
-            // we walk through it trying to unset all
-            // values
-            foreach($error_code as $key => $error) {
-                if ($this->_checkDelExpect($error)) {
-                    $deleted =  true;
-                } else {
-                    $deleted = false;
-                }
-            }
-            return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
-        } elseif (!empty($error_code)) {
-            // $error_code comes alone, trying to unset it
-            if ($this->_checkDelExpect($error_code)) {
-                return true;
-            } else {
-                return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
-            }
-        } else {
-            // $error_code is empty
-            return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
-        }
-    }
-
-    // }}}
-    // {{{ raiseError()
-
-    /**
-     * This method is a wrapper that returns an instance of the
-     * configured error class with this object's default error
-     * handling applied.  If the $mode and $options parameters are not
-     * specified, the object's defaults are used.
-     *
-     * @param mixed $message a text error message or a PEAR error object
-     *
-     * @param int $code      a numeric error code (it is up to your class
-     *                  to define these if you want to use codes)
-     *
-     * @param int $mode      One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
-     *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
-     *                  PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
-     *
-     * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
-     *                  specifies the PHP-internal error level (one of
-     *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
-     *                  If $mode is PEAR_ERROR_CALLBACK, this
-     *                  parameter specifies the callback function or
-     *                  method.  In other error modes this parameter
-     *                  is ignored.
-     *
-     * @param string $userinfo If you need to pass along for example debug
-     *                  information, this parameter is meant for that.
-     *
-     * @param string $error_class The returned error object will be
-     *                  instantiated from this class, if specified.
-     *
-     * @param bool $skipmsg If true, raiseError will only pass error codes,
-     *                  the error message parameter will be dropped.
-     *
-     * @access public
-     * @return object   a PEAR error object
-     * @see PEAR::setErrorHandling
-     * @since PHP 4.0.5
-     */
-    function raiseError($message = null,
-                         $code = null,
-                         $mode = null,
-                         $options = null,
-                         $userinfo = null,
-                         $error_class = null,
-                         $skipmsg = false)
-    {
-        // The error is yet a PEAR error object
-        if (is_object($message)) {
-            $code        = $message->getCode();
-            $userinfo    = $message->getUserInfo();
-            $error_class = $message->getType();
-            $message->error_message_prefix = '';
-            $message     = $message->getMessage();
-        }
-
-        if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
-            if ($exp[0] == "*" ||
-                (is_int(reset($exp)) && in_array($code, $exp)) ||
-                (is_string(reset($exp)) && in_array($message, $exp))) {
-                $mode = PEAR_ERROR_RETURN;
-            }
-        }
-        // No mode given, try global ones
-        if ($mode === null) {
-            // Class error handler
-            if (isset($this) && isset($this->_default_error_mode)) {
-                $mode    = $this->_default_error_mode;
-                $options = $this->_default_error_options;
-            // Global error handler
-            } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
-                $mode    = $GLOBALS['_PEAR_default_error_mode'];
-                $options = $GLOBALS['_PEAR_default_error_options'];
-            }
-        }
-
-        if ($error_class !== null) {
-            $ec = $error_class;
-        } elseif (isset($this) && isset($this->_error_class)) {
-            $ec = $this->_error_class;
-        } else {
-            $ec = 'PEAR_Error';
-        }
-        if ($skipmsg) {
-            return new $ec($code, $mode, $options, $userinfo);
-        } else {
-            return new $ec($message, $code, $mode, $options, $userinfo);
-        }
-    }
-
-    // }}}
-    // {{{ throwError()
-
-    /**
-     * Simpler form of raiseError with fewer options.  In most cases
-     * message, code and userinfo are enough.
-     *
-     * @param string $message
-     *
-     */
-    function throwError($message = null,
-                         $code = null,
-                         $userinfo = null)
-    {
-        if (isset($this) && is_a($this, 'PEAR')) {
-            return $this->raiseError($message, $code, null, null, $userinfo);
-        } else {
-            return PEAR::raiseError($message, $code, null, null, $userinfo);
-        }
-    }
-
-    // }}}
-    // {{{ pushErrorHandling()
-
-    /**
-     * Push a new error handler on top of the error handler options stack. With this
-     * you can easily override the actual error handler for some code and restore
-     * it later with popErrorHandling.
-     *
-     * @param mixed $mode (same as setErrorHandling)
-     * @param mixed $options (same as setErrorHandling)
-     *
-     * @return bool Always true
-     *
-     * @see PEAR::setErrorHandling
-     */
-    function pushErrorHandling($mode, $options = null)
-    {
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
-        if (isset($this) && is_a($this, 'PEAR')) {
-            $def_mode    = &$this->_default_error_mode;
-            $def_options = &$this->_default_error_options;
-        } else {
-            $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
-            $def_options = &$GLOBALS['_PEAR_default_error_options'];
-        }
-        $stack[] = array($def_mode, $def_options);
-
-        if (isset($this) && is_a($this, 'PEAR')) {
-            $this->setErrorHandling($mode, $options);
-        } else {
-            PEAR::setErrorHandling($mode, $options);
-        }
-        $stack[] = array($mode, $options);
-        return true;
-    }
-
-    // }}}
-    // {{{ popErrorHandling()
-
-    /**
-    * Pop the last error handler used
-    *
-    * @return bool Always true
-    *
-    * @see PEAR::pushErrorHandling
-    */
-    function popErrorHandling()
-    {
-        $stack = &$GLOBALS['_PEAR_error_handler_stack'];
-        array_pop($stack);
-        list($mode, $options) = $stack[sizeof($stack) - 1];
-        array_pop($stack);
-        if (isset($this) && is_a($this, 'PEAR')) {
-            $this->setErrorHandling($mode, $options);
-        } else {
-            PEAR::setErrorHandling($mode, $options);
-        }
-        return true;
-    }
-
-    // }}}
-    // {{{ loadExtension()
-
-    /**
-    * OS independant PHP extension load. Remember to take care
-    * on the correct extension name for case sensitive OSes.
-    *
-    * @param string $ext The extension name
-    * @return bool Success or not on the dl() call
-    */
-    function loadExtension($ext)
-    {
-        if (!extension_loaded($ext)) {
-            // if either returns true dl() will produce a FATAL error, stop that
-            if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
-                return false;
-            }
-            if (OS_WINDOWS) {
-                $suffix = '.dll';
-            } elseif (PHP_OS == 'HP-UX') {
-                $suffix = '.sl';
-            } elseif (PHP_OS == 'AIX') {
-                $suffix = '.a';
-            } elseif (PHP_OS == 'OSX') {
-                $suffix = '.bundle';
-            } else {
-                $suffix = '.so';
-            }
-            return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
-        }
-        return true;
-    }
-
-    // }}}
-}
-
-// {{{ _PEAR_call_destructors()
-
-function _PEAR_call_destructors()
-{
-    global $_PEAR_destructor_object_list;
-    if (is_array($_PEAR_destructor_object_list) &&
-        sizeof($_PEAR_destructor_object_list))
-    {
-        reset($_PEAR_destructor_object_list);
-        while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
-            $classname = get_class($objref);
-            while ($classname) {
-                $destructor = "_$classname";
-                if (method_exists($objref, $destructor)) {
-                    $objref->$destructor();
-                    break;
-                } else {
-                    $classname = get_parent_class($classname);
-                }
-            }
-        }
-        // Empty the object list to ensure that destructors are
-        // not called more than once.
-        $_PEAR_destructor_object_list = array();
-    }
-
-    // Now call the shutdown functions
-    if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
-        foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
-            call_user_func_array($value[0], $value[1]);
-        }
-    }
-}
-
-// }}}
-
-class PEAR_Error
-{
-    // {{{ properties
-
-    var $error_message_prefix = '';
-    var $mode                 = PEAR_ERROR_RETURN;
-    var $level                = E_USER_NOTICE;
-    var $code                 = -1;
-    var $message              = '';
-    var $userinfo             = '';
-    var $backtrace            = null;
-
-    // }}}
-    // {{{ constructor
-
-    /**
-     * PEAR_Error constructor
-     *
-     * @param string $message  message
-     *
-     * @param int $code     (optional) error code
-     *
-     * @param int $mode     (optional) error mode, one of: PEAR_ERROR_RETURN,
-     * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
-     * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
-     *
-     * @param mixed $options   (optional) error level, _OR_ in the case of
-     * PEAR_ERROR_CALLBACK, the callback function or object/method
-     * tuple.
-     *
-     * @param string $userinfo (optional) additional user/debug info
-     *
-     * @access public
-     *
-     */
-    function PEAR_Error($message = 'unknown error', $code = null,
-                        $mode = null, $options = null, $userinfo = null)
-    {
-        if ($mode === null) {
-            $mode = PEAR_ERROR_RETURN;
-        }
-        $this->message   = $message;
-        $this->code      = $code;
-        $this->mode      = $mode;
-        $this->userinfo  = $userinfo;
-        if (function_exists("debug_backtrace")) {
-            $this->backtrace = debug_backtrace();
-        }
-        if ($mode & PEAR_ERROR_CALLBACK) {
-            $this->level = E_USER_NOTICE;
-            $this->callback = $options;
-        } else {
-            if ($options === null) {
-                $options = E_USER_NOTICE;
-            }
-            $this->level = $options;
-            $this->callback = null;
-        }
-        if ($this->mode & PEAR_ERROR_PRINT) {
-            if (is_null($options) || is_int($options)) {
-                $format = "%s";
-            } else {
-                $format = $options;
-            }
-            printf($format, $this->getMessage());
-        }
-        if ($this->mode & PEAR_ERROR_TRIGGER) {
-            trigger_error($this->getMessage(), $this->level);
-        }
-        if ($this->mode & PEAR_ERROR_DIE) {
-            $msg = $this->getMessage();
-            if (is_null($options) || is_int($options)) {
-                $format = "%s";
-                if (substr($msg, -1) != "\n") {
-                    $msg .= "\n";
-                }
-            } else {
-                $format = $options;
-            }
-            die(sprintf($format, $msg));
-        }
-        if ($this->mode & PEAR_ERROR_CALLBACK) {
-            if (is_callable($this->callback)) {
-                call_user_func($this->callback, $this);
-            }
-        }
-        if ($this->mode & PEAR_ERROR_EXCEPTION) {
-            trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_ErrorStack for exceptions", E_USER_WARNING);
-            eval('$e = new Exception($this->message, $this->code);$e->PEAR_Error = $this;throw($e);');
-        }
-    }
-
-    // }}}
-    // {{{ getMode()
-
-    /**
-     * Get the error mode from an error object.
-     *
-     * @return int error mode
-     * @access public
-     */
-    function getMode() {
-        return $this->mode;
-    }
-
-    // }}}
-    // {{{ getCallback()
-
-    /**
-     * Get the callback function/method from an error object.
-     *
-     * @return mixed callback function or object/method array
-     * @access public
-     */
-    function getCallback() {
-        return $this->callback;
-    }
-
-    // }}}
-    // {{{ getMessage()
-
-
-    /**
-     * Get the error message from an error object.
-     *
-     * @return  string  full error message
-     * @access public
-     */
-    function getMessage()
-    {
-        return ($this->error_message_prefix . $this->message);
-    }
-
-
-    // }}}
-    // {{{ getCode()
-
-    /**
-     * Get error code from an error object
-     *
-     * @return int error code
-     * @access public
-     */
-     function getCode()
-     {
-        return $this->code;
-     }
-
-    // }}}
-    // {{{ getType()
-
-    /**
-     * Get the name of this error/exception.
-     *
-     * @return string error/exception name (type)
-     * @access public
-     */
-    function getType()
-    {
-        return get_class($this);
-    }
-
-    // }}}
-    // {{{ getUserInfo()
-
-    /**
-     * Get additional user-supplied information.
-     *
-     * @return string user-supplied information
-     * @access public
-     */
-    function getUserInfo()
-    {
-        return $this->userinfo;
-    }
-
-    // }}}
-    // {{{ getDebugInfo()
-
-    /**
-     * Get additional debug information supplied by the application.
-     *
-     * @return string debug information
-     * @access public
-     */
-    function getDebugInfo()
-    {
-        return $this->getUserInfo();
-    }
-
-    // }}}
-    // {{{ getBacktrace()
-
-    /**
-     * Get the call backtrace from where the error was generated.
-     * Supported with PHP 4.3.0 or newer.
-     *
-     * @param int $frame (optional) what frame to fetch
-     * @return array Backtrace, or NULL if not available.
-     * @access public
-     */
-    function getBacktrace($frame = null)
-    {
-        if ($frame === null) {
-            return $this->backtrace;
-        }
-        return $this->backtrace[$frame];
-    }
-
-    // }}}
-    // {{{ addUserInfo()
-
-    function addUserInfo($info)
-    {
-        if (empty($this->userinfo)) {
-            $this->userinfo = $info;
-        } else {
-            $this->userinfo .= " ** $info";
-        }
-    }
-
-    // }}}
-    // {{{ toString()
-
-    /**
-     * Make a string representation of this object.
-     *
-     * @return string a string with an object summary
-     * @access public
-     */
-    function toString() {
-        $modes = array();
-        $levels = array(E_USER_NOTICE  => 'notice',
-                        E_USER_WARNING => 'warning',
-                        E_USER_ERROR   => 'error');
-        if ($this->mode & PEAR_ERROR_CALLBACK) {
-            if (is_array($this->callback)) {
-                $callback = get_class($this->callback[0]) . '::' .
-                    $this->callback[1];
-            } else {
-                $callback = $this->callback;
-            }
-            return sprintf('[%s: message="%s" code=%d mode=callback '.
-                           'callback=%s prefix="%s" info="%s"]',
-                           get_class($this), $this->message, $this->code,
-                           $callback, $this->error_message_prefix,
-                           $this->userinfo);
-        }
-        if ($this->mode & PEAR_ERROR_PRINT) {
-            $modes[] = 'print';
-        }
-        if ($this->mode & PEAR_ERROR_TRIGGER) {
-            $modes[] = 'trigger';
-        }
-        if ($this->mode & PEAR_ERROR_DIE) {
-            $modes[] = 'die';
-        }
-        if ($this->mode & PEAR_ERROR_RETURN) {
-            $modes[] = 'return';
-        }
-        return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
-                       'prefix="%s" info="%s"]',
-                       get_class($this), $this->message, $this->code,
-                       implode("|", $modes), $levels[$this->level],
-                       $this->error_message_prefix,
-                       $this->userinfo);
-    }
-
-    // }}}
-}
-
-register_shutdown_function("_PEAR_call_destructors");
-
-/*
- * Local Variables:
- * mode: php
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
-?>
Index: plugins/blocks/mrbs/web/Net/Socket.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Net/Socket.php
diff -N plugins/blocks/mrbs/web/Net/Socket.php
--- plugins/blocks/mrbs/web/Net/Socket.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,456 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.0 of the PHP license,       |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Authors: Stig Bakken <ssb@php.net>                                   |
-// |          Chuck Hagenbuch <chuck@horde.org>                           |
-// +----------------------------------------------------------------------+
-//
-// $Id: Socket.php,v 1.1 2007/04/05 22:25:36 arborrow Exp $
-//
-
-require_once 'PEAR.php';
-
-/**
- * Generalized Socket class. More docs to be written.
- *
- * @version 1.0
- * @author Stig Bakken <ssb@php.net>
- * @author Chuck Hagenbuch <chuck@horde.org>
- */
-class Net_Socket extends PEAR {
-    // {{{ properties
-
-    /** Socket file pointer. */
-    var $fp = null;
-
-    /** Whether the socket is blocking. */
-    var $blocking = true;
-
-    /** Whether the socket is persistent. */
-    var $persistent = false;
-
-    /** The IP address to connect to. */
-    var $addr = '';
-
-    /** The port number to connect to. */
-    var $port = 0;
-
-    /** Number of seconds to wait on socket connections before
-        assuming there's no more data. */
-    var $timeout = false;
-
-    /** Number of bytes to read at a time in readLine() and
-        readAll(). */
-    var $lineLength = 2048;
-    // }}}
-
-    // {{{ constructor
-    /**
-     * Constructs a new Net_Socket object.
-     *
-     * @access public
-     */
-    function Net_Socket()
-    {
-        $this->PEAR();
-    }
-    // }}}
-
-    // {{{ connect()
-    /**
-     * Connect to the specified port. If called when the socket is
-     * already connected, it disconnects and connects again.
-     *
-     * @param $addr string IP address or host name
-     * @param $port int TCP port number
-     * @param $persistent bool (optional) whether the connection is
-     *        persistent (kept open between requests by the web server)
-     * @param $timeout int (optional) how long to wait for data
-     * @param $options array see options for stream_context_create
-     * @access public
-     * @return mixed true on success or error object
-     */
-    function connect($addr, $port, $persistent = null, $timeout = null, $options = null)
-    {
-        if (is_resource($this->fp)) {
-            @fclose($this->fp);
-            $this->fp = null;
-        }
-
-        if (strspn($addr, '.0123456789') == strlen($addr)) {
-            $this->addr = $addr;
-        } else {
-            $this->addr = gethostbyname($addr);
-        }
-        $this->port = $port % 65536;
-        if ($persistent !== null) {
-            $this->persistent = $persistent;
-        }
-        if ($timeout !== null) {
-            $this->timeout = $timeout;
-        }
-        $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
-        $errno = 0;
-        $errstr = '';
-        if ($options && function_exists('stream_context_create')) {
-            if ($this->timeout) {
-                $timeout = $this->timeout;
-            } else {
-                $timeout = 0;
-            }
-            $context = stream_context_create($options);
-            $fp = $openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context);
-        } else {
-            if ($this->timeout) {
-                $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
-            } else {
-                $fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
-            }
-        }
-
-        if (!$fp) {
-            return $this->raiseError($errstr, $errno);
-        }
-
-        $this->fp = $fp;
-
-        return $this->setBlocking($this->blocking);
-    }
-    // }}}
-
-    // {{{ disconnect()
-    /**
-     * Disconnects from the peer, closes the socket.
-     *
-     * @access public
-     * @return mixed true on success or an error object otherwise
-     */
-    function disconnect()
-    {
-        if (is_resource($this->fp)) {
-            fclose($this->fp);
-            $this->fp = null;
-            return true;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ isBlocking()
-    /**
-     * Find out if the socket is in blocking mode.
-     *
-     * @access public
-     * @return bool the current blocking mode.
-     */
-    function isBlocking()
-    {
-        return $this->blocking;
-    }
-    // }}}
-
-    // {{{ setBlocking()
-    /**
-     * Sets whether the socket connection should be blocking or
-     * not. A read call to a non-blocking socket will return immediately
-     * if there is no data available, whereas it will block until there
-     * is data for blocking sockets.
-     *
-     * @param $mode bool true for blocking sockets, false for nonblocking
-     * @access public
-     * @return mixed true on success or an error object otherwise
-     */
-    function setBlocking($mode)
-    {
-        if (is_resource($this->fp)) {
-            $this->blocking = $mode;
-            socket_set_blocking($this->fp, $this->blocking);
-            return true;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ setTimeout()
-    /**
-     * Sets the timeout value on socket descriptor,
-     * expressed in the sum of seconds and microseconds
-     *
-     * @param $seconds int seconds
-     * @param $microseconds int microseconds
-     * @access public
-     * @return mixed true on success or an error object otherwise
-     */
-    function setTimeout($seconds, $microseconds)
-    {
-        if (is_resource($this->fp)) {
-            socket_set_timeout($this->fp, $seconds, $microseconds);
-            return true;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ getStatus()
-    /**
-     * Returns information about an existing socket resource.
-     * Currently returns four entries in the result array:
-     *
-     * <p>
-     * timed_out (bool) - The socket timed out waiting for data<br>
-     * blocked (bool) - The socket was blocked<br>
-     * eof (bool) - Indicates EOF event<br>
-     * unread_bytes (int) - Number of bytes left in the socket buffer<br>
-     * </p>
-     *
-     * @access public
-     * @return mixed Array containing information about existing socket resource or an error object otherwise
-     */
-    function getStatus()
-    {
-        if (is_resource($this->fp)) {
-            return socket_get_status($this->fp);
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ gets()
-    /**
-     * Get a specified line of data
-     *
-     * @access public
-     * @return $size bytes of data from the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function gets($size)
-    {
-        if (is_resource($this->fp)) {
-            return fgets($this->fp, $size);
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ read()
-    /**
-     * Read a specified amount of data. This is guaranteed to return,
-     * and has the added benefit of getting everything in one fread()
-     * chunk; if you know the size of the data you're getting
-     * beforehand, this is definitely the way to go.
-     *
-     * @param $size The number of bytes to read from the socket.
-     * @access public
-     * @return $size bytes of data from the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function read($size)
-    {
-        if (is_resource($this->fp)) {
-            return fread($this->fp, $size);
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ write()
-    /**
-     * Write a specified amount of data.
-     *
-     * @access public
-     * @return mixed true on success or an error object otherwise
-     */
-    function write($data)
-    {
-        if (is_resource($this->fp)) {
-            return fwrite($this->fp, $data);
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ writeLine()
-    /**
-     * Write a line of data to the socket, followed by a trailing "\r\n".
-     *
-     * @access public
-     * @return mixed fputs result, or an error
-     */
-    function writeLine ($data)
-    {
-        if (is_resource($this->fp)) {
-            return $this->write($data . "\r\n");
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ eof()
-    /**
-     * Tests for end-of-file on a socket descriptor
-     *
-     * @access public
-     * @return bool
-     */
-    function eof()
-    {
-        return (is_resource($this->fp) && feof($this->fp));
-    }
-    // }}}
-
-    // {{{ readByte()
-    /**
-     * Reads a byte of data
-     *
-     * @access public
-     * @return 1 byte of data from the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function readByte()
-    {
-        if (is_resource($this->fp)) {
-            return ord($this->read(1));
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readWord()
-    /**
-     * Reads a word of data
-     *
-     * @access public
-     * @return 1 word of data from the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function readWord()
-    {
-        if (is_resource($this->fp)) {
-            $buf = $this->read(2);
-            return (ord($buf[0]) + (ord($buf[1]) << 8));
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readInt()
-    /**
-     * Reads an int of data
-     *
-     * @access public
-     * @return 1 int of data from the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function readInt()
-    {
-        if (is_resource($this->fp)) {
-            $buf = $this->read(4);
-            return (ord($buf[0]) + (ord($buf[1]) << 8) +
-                    (ord($buf[2]) << 16) + (ord($buf[3]) << 24));
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readString()
-    /**
-     * Reads a zeroterminated string of data
-     *
-     * @access public
-     * @return string, or a PEAR_Error if
-     *         not connected.
-     */
-    function readString()
-    {
-        if (is_resource($this->fp)) {
-            $string = '';
-            while (($char = $this->read(1)) != "\x00")  {
-                $string .= $char;
-            }
-            return $string;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readIPAddress()
-    /**
-     * Reads an IP Address and returns it in a dot formated string
-     *
-     * @access public
-     * @return Dot formated string, or a PEAR_Error if
-     *         not connected.
-     */
-    function readIPAddress()
-    {
-        if (is_resource($this->fp)) {
-            $buf = $this->read(4);
-            return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]),
-                           ord($buf[2]), ord($buf[3]));
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readLine()
-    /**
-     * Read until either the end of the socket or a newline, whichever
-     * comes first. Strips the trailing newline from the returned data.
-     *
-     * @access public
-     * @return All available data up to a newline, without that
-     *         newline, or until the end of the socket, or a PEAR_Error if
-     *         not connected.
-     */
-    function readLine()
-    {
-        if (is_resource($this->fp)) {
-            $line = '';
-            $timeout = time() + $this->timeout;
-            while (!$this->eof() && (!$this->timeout || time() < $timeout)) {
-                $line .= $this->gets($this->lineLength);
-                if (substr($line, -2) == "\r\n" ||
-                    substr($line, -1) == "\n") {
-                    return rtrim($line, "\r\n");
-                }
-            }
-            return $line;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-    // {{{ readAll()
-    /**
-     * Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the
-     * socket is in blocking mode until the socket closes.
-     *
-     * @access public
-     * @return All data until the socket closes, or a PEAR_Error if
-     *         not connected.
-     */
-    function readAll()
-    {
-        if (is_resource($this->fp)) {
-            $data = '';
-            while (!$this->eof())
-                $data .= $this->read($this->lineLength);
-            return $data;
-        }
-        return $this->raiseError("not connected");
-    }
-    // }}}
-
-}
Index: plugins/blocks/mrbs/web/Net/SMTP.php
===================================================================
RCS file: plugins/blocks/mrbs/web/Net/SMTP.php
diff -N plugins/blocks/mrbs/web/Net/SMTP.php
--- plugins/blocks/mrbs/web/Net/SMTP.php	5 Apr 2007 22:25:36 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,970 +0,0 @@
-<?php
-/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4                                                        |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group                                |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license,      |
-// | that is bundled with this package in the file LICENSE, and is        |
-// | available at through the world-wide-web at                           |
-// | http://www.php.net/license/2_02.txt.                                 |
-// | If you did not receive a copy of the PHP license and are unable to   |
-// | obtain it through the world-wide-web, please send a note to          |
-// | license@php.net so we can mail you a copy immediately.               |
-// +----------------------------------------------------------------------+
-// | Authors: Chuck Hagenbuch <chuck@horde.org>                           |
-// |          Jon Parise <jon@php.net>                                    |
-// |          Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>      |
-// +----------------------------------------------------------------------+
-
-require_once 'PEAR.php';
-require_once 'Net/Socket.php';
-
-/**
- * Provides an implementation of the SMTP protocol using PEAR's
- * Net_Socket:: class.
- *
- * @package Net_SMTP
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Jon Parise <jon@php.net>
- * @author  Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>
- *
- * @example basic.php   A basic implementation of the Net_SMTP package.
- */
-class Net_SMTP
-{
-    /**
-     * The server to connect to.
-     * @var string
-     * @access public
-     */
-    var $host = 'localhost';
-
-    /**
-     * The port to connect to.
-     * @var int
-     * @access public
-     */
-    var $port = 25;
-
-    /**
-     * The value to give when sending EHLO or HELO.
-     * @var string
-     * @access public
-     */
-    var $localhost = 'localhost';
-
-    /**
-     * List of supported authentication methods, in preferential order.
-     * @var array
-     * @access public
-     */
-    var $auth_methods = array('DIGEST-MD5', 'CRAM-MD5', 'LOGIN', 'PLAIN');
-
-    /**
-     * Should debugging output be enabled?
-     * @var boolean
-     * @access private
-     */
-    var $_debug = false;
-
-    /**
-     * The socket resource being used to connect to the SMTP server.
-     * @var resource
-     * @access private
-     */
-    var $_socket = null;
-
-    /**
-     * The most recent server response code.
-     * @var int
-     * @access private
-     */
-    var $_code = -1;
-
-    /**
-     * The most recent server response arguments.
-     * @var array
-     * @access private
-     */
-    var $_arguments = array();
-
-    /**
-     * Stores detected features of the SMTP server.
-     * @var array
-     * @access private
-     */
-    var $_esmtp = array();
-
-    /**
-     * Instantiates a new Net_SMTP object, overriding any defaults
-     * with parameters that are passed in.
-     *
-     * @param string The server to connect to.
-     * @param int The port to connect to.
-     * @param string The value to give when sending EHLO or HELO.
-     *
-     * @access  public
-     * @since   1.0
-     */
-    function Net_SMTP($host = null, $port = null, $localhost = null)
-    {
-        if (isset($host)) $this->host = $host;
-        if (isset($port)) $this->port = $port;
-        if (isset($localhost)) $this->localhost = $localhost;
-
-        $this->_socket = new Net_Socket();
-
-        /*
-         * Include the Auth_SASL package.  If the package is not available,
-         * we disable the authentication methods that depend upon it.
-         */
-        if ((@include_once 'Auth/SASL.php') === false) {
-            $pos = array_search('DIGEST-MD5', $this->auth_methods);
-            unset($this->auth_methods[$pos]);
-            $pos = array_search('CRAM-MD5', $this->auth_methods);
-            unset($this->auth_methods[$pos]);
-        }
-    }
-
-    /**
-     * Set the value of the debugging flag.
-     *
-     * @param   boolean $debug      New value for the debugging flag.
-     *
-     * @access  public
-     * @since   1.1.0
-     */
-    function setDebug($debug)
-    {
-        $this->_debug = $debug;
-    }
-
-    /**
-     * Send the given string of data to the server.
-     *
-     * @param   string  $data       The string of data to send.
-     *
-     * @return  mixed   True on success or a PEAR_Error object on failure.
-     *
-     * @access  private
-     * @since   1.1.0
-     */
-    function _send($data)
-    {
-        if ($this->_debug) {
-            echo "DEBUG: Send: $data\n";
-        }
-
-        if (PEAR::isError($error = $this->_socket->write($data))) {
-            return new PEAR_Error('Failed to write to socket: ' .
-                                  $error->getMessage());
-        }
-
-        return true;
-    }
-
-    /**
-     * Send a command to the server with an optional string of arguments.
-     * A carriage return / linefeed (CRLF) sequence will be appended to each
-     * command string before it is sent to the SMTP server.
-     *
-     * @param   string  $command    The SMTP command to send to the server.
-     * @param   string  $args       A string of optional arguments to append
-     *                              to the command.
-     *
-     * @return  mixed   The result of the _send() call.
-     *
-     * @access  private
-     * @since   1.1.0
-     */
-    function _put($command, $args = '')
-    {
-        if (!empty($args)) {
-            return $this->_send($command . ' ' . $args . "\r\n");
-        }
-
-        return $this->_send($command . "\r\n");
-    }
-
-    /**
-     * Read a reply from the SMTP server.  The reply consists of a response
-     * code and a response message.
-     *
-     * @param   mixed   $valid      The set of valid response codes.  These
-     *                              may be specified as an array of integer
-     *                              values or as a single integer value.
-     *
-     * @return  mixed   True if the server returned a valid response code or
-     *                  a PEAR_Error object is an error condition is reached.
-     *
-     * @access  private
-     * @since   1.1.0
-     *
-     * @see     getResponse
-     */
-    function _parseResponse($valid)
-    {
-        $this->_code = -1;
-        $this->_arguments = array();
-
-        while ($line = $this->_socket->readLine()) {
-            if ($this->_debug) {
-                echo "DEBUG: Recv: $line\n";
-            }
-
-            /* If we receive an empty line, the connection has been closed. */
-            if (empty($line)) {
-                $this->disconnect();
-                return new PEAR_Error("Connection was unexpectedly closed");
-            }
-
-            /* Read the code and store the rest in the arguments array. */
-            $code = substr($line, 0, 3);
-            $this->_arguments[] = trim(substr($line, 4));
-
-            /* Check the syntax of the response code. */
-            if (is_numeric($code)) {
-                $this->_code = (int)$code;
-            } else {
-                $this->_code = -1;
-                break;
-            }
-
-            /* If this is not a multiline response, we're done. */
-            if (substr($line, 3, 1) != '-') {
-                break;
-            }
-        }
-
-        /* Compare the server's response code with the valid code. */
-        if (is_int($valid) && ($this->_code === $valid)) {
-            return true;
-        }
-
-        /* If we were given an array of valid response codes, check each one. */
-        if (is_array($valid)) {
-            foreach ($valid as $valid_code) {
-                if ($this->_code === $valid_code) {
-                    return true;
-                }
-            }
-        }
-
-        return new PEAR_Error("Invalid response code received from server");
-    }
-
-    /**
-     * Return a 2-tuple containing the last response from the SMTP server.
-     *
-     * @return  array   A two-element array: the first element contains the
-     *                  response code as an integer and the second element
-     *                  contains the response's arguments as a string.
-     *
-     * @access  public
-     * @since   1.1.0
-     */
-    function getResponse()
-    {
-        return array($this->_code, join("\n", $this->_arguments));
-    }
-
-    /**
-     * Attempt to connect to the SMTP server.
-     *
-     * @param   int     $timeout    The timeout value (in seconds) for the
-     *                              socket connection.
-     * @param   bool    $persistent Should a persistent socket connection
-     *                              be used?
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function connect($timeout = null, $persistent = false)
-    {
-        $result = $this->_socket->connect($this->host, $this->port,
-                                          $persistent, $timeout);
-        if (PEAR::isError($result)) {
-            return new PEAR_Error('Failed to connect socket: ' .
-                                  $result->getMessage());
-        }
-
-        if (PEAR::isError($error = $this->_parseResponse(220))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_negotiate())) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Attempt to disconnect from the SMTP server.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function disconnect()
-    {
-        if (PEAR::isError($error = $this->_put('QUIT'))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(221))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_socket->disconnect())) {
-            return new PEAR_Error('Failed to disconnect socket: ' .
-                                  $error->getMessage());
-        }
-
-        return true;
-    }
-
-    /**
-     * Attempt to send the EHLO command and obtain a list of ESMTP
-     * extensions available, and failing that just send HELO.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     *
-     * @access private
-     * @since  1.1.0
-     */
-    function _negotiate()
-    {
-        if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) {
-            return $error;
-        }
-
-        if (PEAR::isError($this->_parseResponse(250))) {
-            /* If we receive a 503 response, we're already authenticated. */
-            if ($this->_code === 503) {
-                return true;
-            }
-
-            /* If the EHLO failed, try the simpler HELO command. */
-            if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) {
-                return $error;
-            }
-            if (PEAR::isError($this->_parseResponse(250))) {
-                return new PEAR_Error('HELO was not accepted: ', $this->_code);
-            }
-
-            return true;
-        }
-
-        foreach ($this->_arguments as $argument) {
-            $verb = strtok($argument, ' ');
-            $arguments = substr($argument, strlen($verb) + 1,
-                                strlen($argument) - strlen($verb) - 1);
-            $this->_esmtp[$verb] = $arguments;
-        }
-
-        return true;
-    }
-
-    /**
-     * Returns the name of the best authentication method that the server
-     * has advertised.
-     *
-     * @return mixed    Returns a string containing the name of the best
-     *                  supported authentication method or a PEAR_Error object
-     *                  if a failure condition is encountered.
-     * @access private
-     * @since  1.1.0
-     */
-    function _getBestAuthMethod()
-    {
-        $available_methods = explode(' ', $this->_esmtp['AUTH']);
-
-        foreach ($this->auth_methods as $method) {
-            if (in_array($method, $available_methods)) {
-                return $method;
-            }
-        }
-
-        return new PEAR_Error('No supported authentication methods');
-    }
-
-    /**
-     * Attempt to do SMTP authentication.
-     *
-     * @param string The userid to authenticate as.
-     * @param string The password to authenticate with.
-     * @param string The requested authentication method.  If none is
-     *               specified, the best supported method will be used.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function auth($uid, $pwd , $method = '')
-    {
-        if (empty($this->_esmtp['AUTH'])) {
-            return new PEAR_Error('SMTP server does no support authentication');
-        }
-
-        /*
-         * If no method has been specified, get the name of the best supported
-         * method advertised by the SMTP server.
-         */
-        if (empty($method)) {
-            if (PEAR::isError($method = $this->_getBestAuthMethod())) {
-                /* Return the PEAR_Error object from _getBestAuthMethod(). */
-                return $method;
-            }
-        } else {
-            $method = strtoupper($method);
-            if (!in_array($method, $this->auth_methods)) {
-                return new PEAR_Error("$method is not a supported authentication method");
-            }
-        }
-
-        switch ($method) {
-            case 'DIGEST-MD5':
-                $result = $this->_authDigest_MD5($uid, $pwd);
-                break;
-            case 'CRAM-MD5':
-                $result = $this->_authCRAM_MD5($uid, $pwd);
-                break;
-            case 'LOGIN':
-                $result = $this->_authLogin($uid, $pwd);
-                break;
-            case 'PLAIN':
-                $result = $this->_authPlain($uid, $pwd);
-                break;
-            default:
-                $result = new PEAR_Error("$method is not a supported authentication method");
-                break;
-        }
-
-        /* If an error was encountered, return the PEAR_Error object. */
-        if (PEAR::isError($result)) {
-            return $result;
-        }
-
-        /* RFC-2554 requires us to re-negotiate ESMTP after an AUTH. */
-        if (PEAR::isError($error = $this->_negotiate())) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Authenticates the user using the DIGEST-MD5 method.
-     *
-     * @param string The userid to authenticate as.
-     * @param string The password to authenticate with.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access private
-     * @since  1.1.0
-     */
-    function _authDigest_MD5($uid, $pwd)
-    {
-        if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) {
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            /* 503: Error: already authenticated */
-            if ($this->_code === 503) {
-                return true;
-            }
-            return $error;
-        }
-
-        $challenge = base64_decode($this->_arguments[0]);
-        $digest = &Auth_SASL::factory('digestmd5');
-        $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge,
-                                                       $this->host, "smtp"));
-
-        if (PEAR::isError($error = $this->_put($auth_str))) {
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            return $error;
-        }
-
-        /*
-         * We don't use the protocol's third step because SMTP doesn't allow
-         * subsequent authentication, so we just silently ignore it.
-         */
-        if (PEAR::isError($error = $this->_put(' '))) {
-            return $error;
-        }
-        /* 235: Authentication successful */
-        if (PEAR::isError($error = $this->_parseResponse(235))) {
-            return $error;
-        }
-    }
-
-    /**
-     * Authenticates the user using the CRAM-MD5 method.
-     *
-     * @param string The userid to authenticate as.
-     * @param string The password to authenticate with.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access private
-     * @since  1.1.0
-     */
-    function _authCRAM_MD5($uid, $pwd)
-    {
-        if (PEAR::isError($error = $this->_put('AUTH', 'CRAM-MD5'))) {
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            /* 503: Error: already authenticated */
-            if ($this->_code === 503) {
-                return true;
-            }
-            return $error;
-        }
-
-        $challenge = base64_decode($this->_arguments[0]);
-        $cram = &Auth_SASL::factory('crammd5');
-        $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
-
-        if (PEAR::isError($error = $this->_put($auth_str))) {
-            return $error;
-        }
-
-        /* 235: Authentication successful */
-        if (PEAR::isError($error = $this->_parseResponse(235))) {
-            return $error;
-        }
-    }
-
-    /**
-     * Authenticates the user using the LOGIN method.
-     *
-     * @param string The userid to authenticate as.
-     * @param string The password to authenticate with.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access private
-     * @since  1.1.0
-     */
-    function _authLogin($uid, $pwd)
-    {
-        if (PEAR::isError($error = $this->_put('AUTH', 'LOGIN'))) { 
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            /* 503: Error: already authenticated */
-            if ($this->_code === 503) {
-                return true;
-            }
-            return $error;
-        }
-
-        if (PEAR::isError($error = $this->_put(base64_encode($uid)))) {
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            return $error;
-        }
-
-        if (PEAR::isError($error = $this->_put(base64_encode($pwd)))) {
-            return $error;
-        }
-
-        /* 235: Authentication successful */
-        if (PEAR::isError($error = $this->_parseResponse(235))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Authenticates the user using the PLAIN method.
-     *
-     * @param string The userid to authenticate as.
-     * @param string The password to authenticate with.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access private
-     * @since  1.1.0
-     */
-    function _authPlain($uid, $pwd)
-    {
-        if (PEAR::isError($error = $this->_put('AUTH', 'PLAIN'))) {
-            return $error;
-        }
-        /* 334: Continue authentication request */
-        if (PEAR::isError($error = $this->_parseResponse(334))) {
-            /* 503: Error: already authenticated */
-            if ($this->_code === 503) {
-                return true;
-            }
-            return $error;
-        }
-
-        $auth_str = base64_encode(chr(0) . $uid . chr(0) . $pwd);
-
-        if (PEAR::isError($error = $this->_put($auth_str))) {
-            return $error;
-        }
-
-        /* 235: Authentication successful */
-        if (PEAR::isError($error = $this->_parseResponse(235))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the HELO command.
-     *
-     * @param string The domain name to say we are.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function helo($domain)
-    {
-        if (PEAR::isError($error = $this->_put('HELO', $domain))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the MAIL FROM: command.
-     *
-     * @param string The sender (reverse path) to set.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function mailFrom($sender)
-    {
-        if (PEAR::isError($error = $this->_put('MAIL', "FROM:<$sender>"))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the RCPT TO: command.
-     *
-     * @param string The recipient (forward path) to add.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function rcptTo($recipient)
-    {
-        if (PEAR::isError($error = $this->_put('RCPT', "TO:<$recipient>"))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(array(250, 251)))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Quote the data so that it meets SMTP standards.
-     *
-     * This is provided as a separate public function to facilitate easier
-     * overloading for the cases where it is desirable to customize the
-     * quoting behavior.
-     *
-     * @param string The message text to quote.  The string must be passed
-     *               by reference, and the text will be modified in place.
-     *
-     * @access public
-     * @since  1.2
-     */
-    function quotedata(&$data)
-    {
-        /*
-         * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF
-         * (\r\n) linefeeds.
-         */
-        $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data);
-        $data = preg_replace("/\n\n/", "\n\r\n", $data);
-
-        /*
-         * Because a single leading period (.) signifies an end to the data,
-         * legitimate leading periods need to be "doubled" (e.g. '..').
-         */
-        $data = preg_replace("/\n\./", "\n..", $data);
-    }
-
-    /**
-     * Send the DATA command.
-     *
-     * @param string The message body to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function data($data)
-    {
-        /*
-         * RFC 1870, section 3, subsection 3 states "a value of zero indicates
-         * that no fixed maximum message size is in force".  Furthermore, it
-         * says that if "the parameter is omitted no information is conveyed
-         * about the server's fixed maximum message size".
-         */
-        if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) {
-            if (strlen($data) >= $this->_esmtp['SIZE']) {
-                $this->disconnect();
-                return new PEAR_Error('Message size excedes the server limit');
-            }
-        }
-
-        /* Quote the data based on the SMTP standards. */
-        $this->quotedata($data);
-
-        if (PEAR::isError($error = $this->_put('DATA'))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(354))) {
-            return $error;
-        }
-
-        if (PEAR::isError($this->_send($data . "\r\n.\r\n"))) {
-            return new PEAR_Error('write to socket failed');
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the SEND FROM: command.
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.2.6
-     */
-    function sendFrom($path)
-    {
-        if (PEAR::isError($error = $this->_put('SEND', "FROM:<$path>"))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Backwards-compatibility wrapper for sendFrom().
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     *
-     * @access      public
-     * @since       1.0
-     * @deprecated  1.2.6
-     */
-    function send_from($path)
-    {
-        return sendFrom($path);
-    }
-
-    /**
-     * Send the SOML FROM: command.
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.2.6
-     */
-    function somlFrom($path)
-    {
-        if (PEAR::isError($error = $this->_put('SOML', "FROM:<$path>"))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Backwards-compatibility wrapper for somlFrom().
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     *
-     * @access      public
-     * @since       1.0
-     * @deprecated  1.2.6
-     */
-    function soml_from($path)
-    {
-        return somlFrom($path);
-    }
-
-    /**
-     * Send the SAML FROM: command.
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.2.6
-     */
-    function samlFrom($path)
-    {
-        if (PEAR::isError($error = $this->_put('SAML', "FROM:<$path>"))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Backwards-compatibility wrapper for samlFrom().
-     *
-     * @param string The reverse path to send.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     *
-     * @access      public
-     * @since       1.0
-     * @deprecated  1.2.6
-     */
-    function saml_from($path)
-    {
-        return samlFrom($path);
-    }
-
-    /**
-     * Send the RSET command.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function rset()
-    {
-        if (PEAR::isError($error = $this->_put('RSET'))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the VRFY command.
-     *
-     * @param string The string to verify
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function vrfy($string)
-    {
-        /* Note: 251 is also a valid response code */
-        if (PEAR::isError($error = $this->_put('VRFY', $string))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Send the NOOP command.
-     *
-     * @return mixed Returns a PEAR_Error with an error message on any
-     *               kind of failure, or true on success.
-     * @access public
-     * @since  1.0
-     */
-    function noop()
-    {
-        if (PEAR::isError($error = $this->_put('NOOP'))) {
-            return $error;
-        }
-        if (PEAR::isError($error = $this->_parseResponse(250))) {
-            return $error;
-        }
-
-        return true;
-    }
-
-    /**
-     * Backwards-compatibility method.  identifySender()'s functionality is
-     * now handled internally.
-     *
-     * @return  boolean     This method always return true.
-     *
-     * @access  public
-     * @since   1.0
-     */
-    function identifySender()
-    {
-        return true;
-    }
-}
-
-?>

