Source for file AddressStructure.class.php

Documentation is available at AddressStructure.class.php

  1. <?php
  2.  
  3. /**
  4.  * AddressStructure.class.php
  5.  *
  6.  * This file contains functions needed to extract email address headers from
  7.  * mime messages.
  8.  *
  9.  * @copyright 2003-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: AddressStructure.class.php 14845 2020-01-07 08:09:34Z pdontthink $
  12.  * @package squirrelmail
  13.  * @subpackage mime
  14.  * @since 1.3.2
  15.  */
  16.  
  17. /**
  18.  * Class used to work with email address headers
  19.  * @package squirrelmail
  20.  * @subpackage mime
  21.  * @since 1.3.2
  22.  */
  23.     /**
  24.      * Personal information
  25.      * @var string 
  26.      */
  27.     var $personal = '';
  28.     /**
  29.      * @todo check use of this variable. var is not used in class.
  30.      * @var string 
  31.      */
  32.     var $adl      = '';
  33.     /**
  34.      * Mailbox name.
  35.      * @var string 
  36.      */
  37.     var $mailbox  = '';
  38.     /**
  39.      * Server address.
  40.      * @var string 
  41.      */
  42.     var $host     = '';
  43.     /**
  44.      * @todo check use of this variable. var is not used in class.
  45.      * @var string 
  46.      */
  47.     var $group    = '';
  48.  
  49.     /**
  50.      * Return address information from mime headers.
  51.      * @param boolean $full return full address (true) or only personal if it exists, otherwise email (false)
  52.      * @param boolean $encoded (since 1.4.0) return rfc2047 encoded address (true) or plain text (false).
  53.      * @param boolean $unconditionally_quote (since 1.4.21/1.5.2) when TRUE, always quote the personal part, whether or not it is encoded, otherwise quoting is only added if the personal part is not encoded
  54.      *
  55.      * @return string 
  56.      */
  57.     function getAddress($full true$encoded false$unconditionally_quote FALSE{
  58.         $result '';
  59.         if (is_object($this)) {
  60.             $email ($this->host ? $this->mailbox.'@'.$this->host
  61.                                   : $this->mailbox);
  62.             $personal trim($this->personal);
  63.             $is_encoded false;
  64.             if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/i',$personal,$reg)) {
  65.                 $is_encoded true;
  66.             }
  67.             if ($personal{
  68.                 if ($encoded && !$is_encoded{
  69.                     $personal_encoded encodeHeader('"' $personal '"');
  70.                     if ($personal !== $personal_encoded{
  71.                         $personal $personal_encoded;
  72.                     else {
  73.                         //FIXME: this probably adds quotes around an encoded string which itself is already quoted
  74.                         $personal '"' $this->personal . '"';
  75.                     }
  76.                 else {
  77.                     if (!$is_encoded || $unconditionally_quote{
  78.                         $personal '"' $this->personal . '"';
  79.                     }
  80.                 }
  81.                 $addr ($email $personal ' <' .$email.'>'
  82.                         : $this->personal);
  83.                 $best_dpl $this->personal;
  84.             else {
  85.                 $addr $email;
  86.                 $best_dpl $email;
  87.             }
  88.             $result ($full $addr $best_dpl);
  89.         }
  90.         return $result;
  91.     }
  92.  
  93.     /**
  94.      * Shorter version of getAddress() function
  95.      * Returns full encoded address.
  96.      * @param boolean $unconditionally_quote (since 1.4.21/1.5.2) when TRUE, always quote the personal part, whether or not it is encoded, otherwise quoting is only added if the personal part is not encoded
  97.      *
  98.      * @return string 
  99.      * @since 1.4.0
  100.      */
  101.     function getEncodedAddress($unconditionally_quote=FALSE{
  102.         return $this->getAddress(truetrue$unconditionally_quote);
  103.     }
  104.     
  105.     /**
  106.      * Return just the email portion of this address
  107.      * @return string 
  108.      * @since 1.5.2
  109.      */
  110.     function getEmail ({
  111.         $r '';
  112.         if (is_object($this)) {
  113.             $r $this->host ? $this->mailbox.'@'.$this->host : $this->mailbox;
  114.         }
  115.         return $r;
  116.     }
  117. }

Documentation generated on Mon, 13 Jan 2020 04:22:00 +0100 by phpDocumentor 1.4.3