97ebb532b1fb3e4a624b9b715216adae4a55b1cc
4 * AddressStructure.class.php
6 * Copyright (c) 2003-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file contains functions needed to extract email address headers from
13 * @package squirrelmail
19 * Class used to work with email address headers
20 * @package squirrelmail
24 class AddressStructure
{
26 * Personal information
31 * @todo check use of this variable. var is not used in class.
46 * @todo check use of this variable. var is not used in class.
52 * Return address information from mime headers.
53 * @param boolean $full return full address (true) or only email (false)
54 * @param boolean $encoded (since 1.4.0) return rfc2047 encoded address (true) or plain text (false).
57 function getAddress($full = true, $encoded = false) {
59 if (is_object($this)) {
60 $email = ($this->host ?
$this->mailbox
.'@'.$this->host
62 $personal = trim($this->personal
);
64 if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) {
68 if ($encoded && !$is_encoded) {
69 $personal_encoded = encodeHeader($personal);
70 if ($personal !== $personal_encoded) {
71 $personal = $personal_encoded;
73 $personal = '"'.$this->personal
.'"';
77 $personal = '"'.$this->personal
.'"';
80 $addr = ($email ?
$personal . ' <' .$email.'>'
82 $best_dpl = $this->personal
;
87 $result = ($full ?
$addr : $best_dpl);
93 * Shorter version of getAddress() function
94 * Returns full encoded address.
98 function getEncodedAddress() {
99 return $this->getAddress(true, true);