| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * AddressStructure.class.php |
| 5 | * |
| 6 | * Copyright (c) 2003 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This contains functions needed to handle mime messages. |
| 10 | * |
| 11 | * $Id$ |
| 12 | */ |
| 13 | |
| 14 | class AddressStructure { |
| 15 | var $personal = '', |
| 16 | $adl = '', |
| 17 | $mailbox = '', |
| 18 | $host = '', |
| 19 | $group = ''; |
| 20 | |
| 21 | function getAddress($full = true, $encoded = false) { |
| 22 | $result = ''; |
| 23 | if (is_object($this)) { |
| 24 | $email = ($this->host ? $this->mailbox.'@'.$this->host |
| 25 | : $this->mailbox); |
| 26 | $personal = trim($this->personal); |
| 27 | $is_encoded = false; |
| 28 | if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) { |
| 29 | $is_encoded = true; |
| 30 | } |
| 31 | if ($personal) { |
| 32 | if ($encoded && !$is_encoded) { |
| 33 | $personal_encoded = encodeHeader($personal); |
| 34 | if ($personal !== $personal_encoded) { |
| 35 | $personal = $personal_encoded; |
| 36 | } else { |
| 37 | $personal = '"'.$this->personal.'"'; |
| 38 | } |
| 39 | } else { |
| 40 | if (!$is_encoded) { |
| 41 | $personal = '"'.$this->personal.'"'; |
| 42 | } |
| 43 | } |
| 44 | $addr = ($email ? $personal . ' <' .$email.'>' |
| 45 | : $this->personal); |
| 46 | $best_dpl = $this->personal; |
| 47 | } else { |
| 48 | $addr = $email; |
| 49 | $best_dpl = $email; |
| 50 | } |
| 51 | $result = ($full ? $addr : $best_dpl); |
| 52 | } |
| 53 | return $result; |
| 54 | } |
| 55 | |
| 56 | function getEncodedAddress() { |
| 57 | return $this->getAddress(true, true); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | ?> |