See Release Notes
Long Term Support Release
1 <?php 2 /** 3 * Copyright 2014-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file LICENSE for license information (LGPL). If you 6 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 7 * 8 * @category Horde 9 * @copyright 2014-2017 Horde LLC 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @package Mime 12 */ 13 14 /** 15 * Deprecated Horde_Mime_Headers methods. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @deprecated 19 * @category Horde 20 * @copyright 2014-2016 Horde LLC 21 * @internal 22 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 23 * @package Mime 24 * @since 2.5.0 25 */ 26 class Horde_Mime_Headers_Deprecated 27 { 28 /** 29 * Base headers object. 30 * 31 * @var Horde_Mime_Headers 32 */ 33 private $_headers; 34 35 /** 36 */ 37 public function __construct(Horde_Mime_Headers $headers) 38 { 39 $this->_headers = $headers; 40 } 41 42 /** 43 */ 44 public function addMessageIdHeader() 45 { 46 $this->_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create()); 47 } 48 49 /** 50 */ 51 public function addUserAgentHeader() 52 { 53 $this->_headers->addHeaderOb(Horde_Mime_Headers_UserAgent::create()); 54 } 55 56 /** 57 */ 58 public function getUserAgent() 59 { 60 return strval(Horde_Mime_Headers_UserAgent::create()); 61 } 62 63 /** 64 */ 65 public function setUserAgent($agent) 66 { 67 $this->_headers->addHeaderOb( 68 new Horde_Mime_Headers_UserAgent(null, $agent) 69 ); 70 } 71 72 /** 73 */ 74 public function addReceivedHeader(array $opts = array()) 75 { 76 $old_error = error_reporting(0); 77 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 78 /* This indicates the user is connecting through a proxy. */ 79 $remote_path = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); 80 $remote_addr = $remote_path[0]; 81 if (!empty($opts['dns'])) { 82 $remote = $remote_addr; 83 try { 84 if ($response = $opts['dns']->query($remote_addr, 'PTR')) { 85 foreach ($response->answer as $val) { 86 if (isset($val->ptrdname)) { 87 $remote = $val->ptrdname; 88 break; 89 } 90 } 91 } 92 } catch (Net_DNS2_Exception $e) {} 93 } else { 94 $remote = gethostbyaddr($remote_addr); 95 } 96 } else { 97 $remote_addr = $_SERVER['REMOTE_ADDR']; 98 if (empty($_SERVER['REMOTE_HOST'])) { 99 if (!empty($opts['dns'])) { 100 $remote = $remote_addr; 101 try { 102 if ($response = $opts['dns']->query($remote_addr, 'PTR')) { 103 foreach ($response->answer as $val) { 104 if (isset($val->ptrdname)) { 105 $remote = $val->ptrdname; 106 break; 107 } 108 } 109 } 110 } catch (Net_DNS2_Exception $e) {} 111 } else { 112 $remote = gethostbyaddr($remote_addr); 113 } 114 } else { 115 $remote = $_SERVER['REMOTE_HOST']; 116 } 117 } 118 error_reporting($old_error); 119 120 if (!empty($_SERVER['REMOTE_IDENT'])) { 121 $remote_ident = $_SERVER['REMOTE_IDENT'] . '@' . $remote . ' '; 122 } elseif ($remote != $_SERVER['REMOTE_ADDR']) { 123 $remote_ident = $remote . ' '; 124 } else { 125 $remote_ident = ''; 126 } 127 128 if (!empty($opts['server'])) { 129 $server_name = $opts['server']; 130 } elseif (!empty($_SERVER['SERVER_NAME'])) { 131 $server_name = $_SERVER['SERVER_NAME']; 132 } elseif (!empty($_SERVER['HTTP_HOST'])) { 133 $server_name = $_SERVER['HTTP_HOST']; 134 } else { 135 $server_name = 'unknown'; 136 } 137 138 $is_ssl = isset($_SERVER['HTTPS']) && 139 $_SERVER['HTTPS'] != 'off'; 140 141 if ($remote == $remote_addr) { 142 $remote = '[' . $remote . ']'; 143 } 144 145 $this->_headers->addHeaderOb(new Horde_Mime_Headers_Element_Multiple( 146 'Received', 147 'from ' . $remote . ' (' . $remote_ident . 148 '[' . $remote_addr . ']) ' . 149 'by ' . $server_name . ' (Horde Framework) with HTTP' . 150 ($is_ssl ? 'S' : '') . '; ' . date('r') 151 )); 152 } 153 154 /** 155 */ 156 public function getOb($field) 157 { 158 return ($h = $this->_headers[$field]) 159 ? $h->getAddressList(true) 160 : null; 161 } 162 163 /** 164 */ 165 public function getValue($header, $type = Horde_Mime_Headers::VALUE_STRING) 166 { 167 if (!($ob = $this->_headers[$header])) { 168 return null; 169 } 170 171 switch ($type) { 172 case Horde_Mime_Headers::VALUE_BASE: 173 $tmp = $ob->value; 174 break; 175 176 case Horde_Mime_Headers::VALUE_PARAMS: 177 return array_change_key_case($ob->params, CASE_LOWER); 178 179 case Horde_Mime_Headers::VALUE_STRING: 180 $tmp = $ob->full_value; 181 break; 182 } 183 184 return (is_array($tmp) && (count($tmp) === 1)) 185 ? reset($tmp) 186 : $tmp; 187 } 188 189 /** 190 */ 191 public function listHeaders() 192 { 193 $lhdrs = new Horde_ListHeaders(); 194 return $lhdrs->headers(); 195 } 196 197 /** 198 */ 199 public function listHeadersExist() 200 { 201 $lhdrs = new Horde_ListHeaders(); 202 return $lhdrs->listHeadersExist($this->_headers); 203 } 204 205 /** 206 */ 207 public function replaceHeader($header, $value, array $opts = array()) 208 { 209 $this->_headers->removeHeader($header); 210 $this->_headers->addHeader($header, $value, $opts); 211 } 212 213 /** 214 */ 215 public function getString($header) 216 { 217 return (($hdr = $this->_headers[$header]) === null) 218 ? null 219 : $this->_headers[$header]->name; 220 } 221 222 /** 223 */ 224 public function addressFields() 225 { 226 return array( 227 'from', 'to', 'cc', 'bcc', 'reply-to', 'resent-to', 'resent-cc', 228 'resent-bcc', 'resent-from', 'sender' 229 ); 230 } 231 232 /** 233 */ 234 public function singleFields($list = true) 235 { 236 $fields = array( 237 'to', 'from', 'cc', 'bcc', 'date', 'sender', 'reply-to', 238 'message-id', 'in-reply-to', 'references', 'subject', 239 'content-md5', 'mime-version', 'content-type', 240 'content-transfer-encoding', 'content-id', 'content-description', 241 'content-base', 'content-disposition', 'content-duration', 242 'content-location', 'content-features', 'content-language', 243 'content-alternative', 'importance', 'x-priority' 244 ); 245 246 $list_fields = array( 247 'list-help', 'list-unsubscribe', 'list-subscribe', 'list-owner', 248 'list-post', 'list-archive', 'list-id' 249 ); 250 251 return $list 252 ? array_merge($fields, $list_fields) 253 : $fields; 254 } 255 256 /** 257 */ 258 public function mimeParamFields() 259 { 260 return array('content-type', 'content-disposition'); 261 } 262 263 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body