Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../PHPMaile...
File: PHPMailer.php
* //Use your own custom converter
[4500] Fix | Delete
* $plain = $mail->html2text($html, function($html) {
[4501] Fix | Delete
* $converter = new MyHtml2text($html);
[4502] Fix | Delete
* return $converter->get_text();
[4503] Fix | Delete
* });
[4504] Fix | Delete
* ```
[4505] Fix | Delete
*
[4506] Fix | Delete
* @param string $html The HTML text to convert
[4507] Fix | Delete
* @param bool|callable $advanced Any boolean value to use the internal converter,
[4508] Fix | Delete
* or provide your own callable for custom conversion.
[4509] Fix | Delete
* *Never* pass user-supplied data into this parameter
[4510] Fix | Delete
*
[4511] Fix | Delete
* @return string
[4512] Fix | Delete
*/
[4513] Fix | Delete
public function html2text($html, $advanced = false)
[4514] Fix | Delete
{
[4515] Fix | Delete
if (is_callable($advanced)) {
[4516] Fix | Delete
return call_user_func($advanced, $html);
[4517] Fix | Delete
}
[4518] Fix | Delete
[4519] Fix | Delete
return html_entity_decode(
[4520] Fix | Delete
trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
[4521] Fix | Delete
ENT_QUOTES,
[4522] Fix | Delete
$this->CharSet
[4523] Fix | Delete
);
[4524] Fix | Delete
}
[4525] Fix | Delete
[4526] Fix | Delete
/**
[4527] Fix | Delete
* Get the MIME type for a file extension.
[4528] Fix | Delete
*
[4529] Fix | Delete
* @param string $ext File extension
[4530] Fix | Delete
*
[4531] Fix | Delete
* @return string MIME type of file
[4532] Fix | Delete
*/
[4533] Fix | Delete
public static function _mime_types($ext = '')
[4534] Fix | Delete
{
[4535] Fix | Delete
$mimes = [
[4536] Fix | Delete
'xl' => 'application/excel',
[4537] Fix | Delete
'js' => 'application/javascript',
[4538] Fix | Delete
'hqx' => 'application/mac-binhex40',
[4539] Fix | Delete
'cpt' => 'application/mac-compactpro',
[4540] Fix | Delete
'bin' => 'application/macbinary',
[4541] Fix | Delete
'doc' => 'application/msword',
[4542] Fix | Delete
'word' => 'application/msword',
[4543] Fix | Delete
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
[4544] Fix | Delete
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
[4545] Fix | Delete
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
[4546] Fix | Delete
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
[4547] Fix | Delete
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
[4548] Fix | Delete
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
[4549] Fix | Delete
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
[4550] Fix | Delete
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
[4551] Fix | Delete
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
[4552] Fix | Delete
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
[4553] Fix | Delete
'class' => 'application/octet-stream',
[4554] Fix | Delete
'dll' => 'application/octet-stream',
[4555] Fix | Delete
'dms' => 'application/octet-stream',
[4556] Fix | Delete
'exe' => 'application/octet-stream',
[4557] Fix | Delete
'lha' => 'application/octet-stream',
[4558] Fix | Delete
'lzh' => 'application/octet-stream',
[4559] Fix | Delete
'psd' => 'application/octet-stream',
[4560] Fix | Delete
'sea' => 'application/octet-stream',
[4561] Fix | Delete
'so' => 'application/octet-stream',
[4562] Fix | Delete
'oda' => 'application/oda',
[4563] Fix | Delete
'pdf' => 'application/pdf',
[4564] Fix | Delete
'ai' => 'application/postscript',
[4565] Fix | Delete
'eps' => 'application/postscript',
[4566] Fix | Delete
'ps' => 'application/postscript',
[4567] Fix | Delete
'smi' => 'application/smil',
[4568] Fix | Delete
'smil' => 'application/smil',
[4569] Fix | Delete
'mif' => 'application/vnd.mif',
[4570] Fix | Delete
'xls' => 'application/vnd.ms-excel',
[4571] Fix | Delete
'ppt' => 'application/vnd.ms-powerpoint',
[4572] Fix | Delete
'wbxml' => 'application/vnd.wap.wbxml',
[4573] Fix | Delete
'wmlc' => 'application/vnd.wap.wmlc',
[4574] Fix | Delete
'dcr' => 'application/x-director',
[4575] Fix | Delete
'dir' => 'application/x-director',
[4576] Fix | Delete
'dxr' => 'application/x-director',
[4577] Fix | Delete
'dvi' => 'application/x-dvi',
[4578] Fix | Delete
'gtar' => 'application/x-gtar',
[4579] Fix | Delete
'php3' => 'application/x-httpd-php',
[4580] Fix | Delete
'php4' => 'application/x-httpd-php',
[4581] Fix | Delete
'php' => 'application/x-httpd-php',
[4582] Fix | Delete
'phtml' => 'application/x-httpd-php',
[4583] Fix | Delete
'phps' => 'application/x-httpd-php-source',
[4584] Fix | Delete
'swf' => 'application/x-shockwave-flash',
[4585] Fix | Delete
'sit' => 'application/x-stuffit',
[4586] Fix | Delete
'tar' => 'application/x-tar',
[4587] Fix | Delete
'tgz' => 'application/x-tar',
[4588] Fix | Delete
'xht' => 'application/xhtml+xml',
[4589] Fix | Delete
'xhtml' => 'application/xhtml+xml',
[4590] Fix | Delete
'zip' => 'application/zip',
[4591] Fix | Delete
'mid' => 'audio/midi',
[4592] Fix | Delete
'midi' => 'audio/midi',
[4593] Fix | Delete
'mp2' => 'audio/mpeg',
[4594] Fix | Delete
'mp3' => 'audio/mpeg',
[4595] Fix | Delete
'm4a' => 'audio/mp4',
[4596] Fix | Delete
'mpga' => 'audio/mpeg',
[4597] Fix | Delete
'aif' => 'audio/x-aiff',
[4598] Fix | Delete
'aifc' => 'audio/x-aiff',
[4599] Fix | Delete
'aiff' => 'audio/x-aiff',
[4600] Fix | Delete
'ram' => 'audio/x-pn-realaudio',
[4601] Fix | Delete
'rm' => 'audio/x-pn-realaudio',
[4602] Fix | Delete
'rpm' => 'audio/x-pn-realaudio-plugin',
[4603] Fix | Delete
'ra' => 'audio/x-realaudio',
[4604] Fix | Delete
'wav' => 'audio/x-wav',
[4605] Fix | Delete
'mka' => 'audio/x-matroska',
[4606] Fix | Delete
'bmp' => 'image/bmp',
[4607] Fix | Delete
'gif' => 'image/gif',
[4608] Fix | Delete
'jpeg' => 'image/jpeg',
[4609] Fix | Delete
'jpe' => 'image/jpeg',
[4610] Fix | Delete
'jpg' => 'image/jpeg',
[4611] Fix | Delete
'png' => 'image/png',
[4612] Fix | Delete
'tiff' => 'image/tiff',
[4613] Fix | Delete
'tif' => 'image/tiff',
[4614] Fix | Delete
'webp' => 'image/webp',
[4615] Fix | Delete
'avif' => 'image/avif',
[4616] Fix | Delete
'heif' => 'image/heif',
[4617] Fix | Delete
'heifs' => 'image/heif-sequence',
[4618] Fix | Delete
'heic' => 'image/heic',
[4619] Fix | Delete
'heics' => 'image/heic-sequence',
[4620] Fix | Delete
'eml' => 'message/rfc822',
[4621] Fix | Delete
'css' => 'text/css',
[4622] Fix | Delete
'html' => 'text/html',
[4623] Fix | Delete
'htm' => 'text/html',
[4624] Fix | Delete
'shtml' => 'text/html',
[4625] Fix | Delete
'log' => 'text/plain',
[4626] Fix | Delete
'text' => 'text/plain',
[4627] Fix | Delete
'txt' => 'text/plain',
[4628] Fix | Delete
'rtx' => 'text/richtext',
[4629] Fix | Delete
'rtf' => 'text/rtf',
[4630] Fix | Delete
'vcf' => 'text/vcard',
[4631] Fix | Delete
'vcard' => 'text/vcard',
[4632] Fix | Delete
'ics' => 'text/calendar',
[4633] Fix | Delete
'xml' => 'text/xml',
[4634] Fix | Delete
'xsl' => 'text/xml',
[4635] Fix | Delete
'csv' => 'text/csv',
[4636] Fix | Delete
'wmv' => 'video/x-ms-wmv',
[4637] Fix | Delete
'mpeg' => 'video/mpeg',
[4638] Fix | Delete
'mpe' => 'video/mpeg',
[4639] Fix | Delete
'mpg' => 'video/mpeg',
[4640] Fix | Delete
'mp4' => 'video/mp4',
[4641] Fix | Delete
'm4v' => 'video/mp4',
[4642] Fix | Delete
'mov' => 'video/quicktime',
[4643] Fix | Delete
'qt' => 'video/quicktime',
[4644] Fix | Delete
'rv' => 'video/vnd.rn-realvideo',
[4645] Fix | Delete
'avi' => 'video/x-msvideo',
[4646] Fix | Delete
'movie' => 'video/x-sgi-movie',
[4647] Fix | Delete
'webm' => 'video/webm',
[4648] Fix | Delete
'mkv' => 'video/x-matroska',
[4649] Fix | Delete
];
[4650] Fix | Delete
$ext = strtolower($ext);
[4651] Fix | Delete
if (array_key_exists($ext, $mimes)) {
[4652] Fix | Delete
return $mimes[$ext];
[4653] Fix | Delete
}
[4654] Fix | Delete
[4655] Fix | Delete
return 'application/octet-stream';
[4656] Fix | Delete
}
[4657] Fix | Delete
[4658] Fix | Delete
/**
[4659] Fix | Delete
* Map a file name to a MIME type.
[4660] Fix | Delete
* Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
[4661] Fix | Delete
*
[4662] Fix | Delete
* @param string $filename A file name or full path, does not need to exist as a file
[4663] Fix | Delete
*
[4664] Fix | Delete
* @return string
[4665] Fix | Delete
*/
[4666] Fix | Delete
public static function filenameToType($filename)
[4667] Fix | Delete
{
[4668] Fix | Delete
//In case the path is a URL, strip any query string before getting extension
[4669] Fix | Delete
$qpos = strpos($filename, '?');
[4670] Fix | Delete
if (false !== $qpos) {
[4671] Fix | Delete
$filename = substr($filename, 0, $qpos);
[4672] Fix | Delete
}
[4673] Fix | Delete
$ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION);
[4674] Fix | Delete
[4675] Fix | Delete
return static::_mime_types($ext);
[4676] Fix | Delete
}
[4677] Fix | Delete
[4678] Fix | Delete
/**
[4679] Fix | Delete
* Multi-byte-safe pathinfo replacement.
[4680] Fix | Delete
* Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
[4681] Fix | Delete
*
[4682] Fix | Delete
* @see http://www.php.net/manual/en/function.pathinfo.php#107461
[4683] Fix | Delete
*
[4684] Fix | Delete
* @param string $path A filename or path, does not need to exist as a file
[4685] Fix | Delete
* @param int|string $options Either a PATHINFO_* constant,
[4686] Fix | Delete
* or a string name to return only the specified piece
[4687] Fix | Delete
*
[4688] Fix | Delete
* @return string|array
[4689] Fix | Delete
*/
[4690] Fix | Delete
public static function mb_pathinfo($path, $options = null)
[4691] Fix | Delete
{
[4692] Fix | Delete
$ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''];
[4693] Fix | Delete
$pathinfo = [];
[4694] Fix | Delete
if (preg_match('#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m', $path, $pathinfo)) {
[4695] Fix | Delete
if (array_key_exists(1, $pathinfo)) {
[4696] Fix | Delete
$ret['dirname'] = $pathinfo[1];
[4697] Fix | Delete
}
[4698] Fix | Delete
if (array_key_exists(2, $pathinfo)) {
[4699] Fix | Delete
$ret['basename'] = $pathinfo[2];
[4700] Fix | Delete
}
[4701] Fix | Delete
if (array_key_exists(5, $pathinfo)) {
[4702] Fix | Delete
$ret['extension'] = $pathinfo[5];
[4703] Fix | Delete
}
[4704] Fix | Delete
if (array_key_exists(3, $pathinfo)) {
[4705] Fix | Delete
$ret['filename'] = $pathinfo[3];
[4706] Fix | Delete
}
[4707] Fix | Delete
}
[4708] Fix | Delete
switch ($options) {
[4709] Fix | Delete
case PATHINFO_DIRNAME:
[4710] Fix | Delete
case 'dirname':
[4711] Fix | Delete
return $ret['dirname'];
[4712] Fix | Delete
case PATHINFO_BASENAME:
[4713] Fix | Delete
case 'basename':
[4714] Fix | Delete
return $ret['basename'];
[4715] Fix | Delete
case PATHINFO_EXTENSION:
[4716] Fix | Delete
case 'extension':
[4717] Fix | Delete
return $ret['extension'];
[4718] Fix | Delete
case PATHINFO_FILENAME:
[4719] Fix | Delete
case 'filename':
[4720] Fix | Delete
return $ret['filename'];
[4721] Fix | Delete
default:
[4722] Fix | Delete
return $ret;
[4723] Fix | Delete
}
[4724] Fix | Delete
}
[4725] Fix | Delete
[4726] Fix | Delete
/**
[4727] Fix | Delete
* Set or reset instance properties.
[4728] Fix | Delete
* You should avoid this function - it's more verbose, less efficient, more error-prone and
[4729] Fix | Delete
* harder to debug than setting properties directly.
[4730] Fix | Delete
* Usage Example:
[4731] Fix | Delete
* `$mail->set('SMTPSecure', static::ENCRYPTION_STARTTLS);`
[4732] Fix | Delete
* is the same as:
[4733] Fix | Delete
* `$mail->SMTPSecure = static::ENCRYPTION_STARTTLS;`.
[4734] Fix | Delete
*
[4735] Fix | Delete
* @param string $name The property name to set
[4736] Fix | Delete
* @param mixed $value The value to set the property to
[4737] Fix | Delete
*
[4738] Fix | Delete
* @return bool
[4739] Fix | Delete
*/
[4740] Fix | Delete
public function set($name, $value = '')
[4741] Fix | Delete
{
[4742] Fix | Delete
if (property_exists($this, $name)) {
[4743] Fix | Delete
$this->{$name} = $value;
[4744] Fix | Delete
[4745] Fix | Delete
return true;
[4746] Fix | Delete
}
[4747] Fix | Delete
$this->setError($this->lang('variable_set') . $name);
[4748] Fix | Delete
[4749] Fix | Delete
return false;
[4750] Fix | Delete
}
[4751] Fix | Delete
[4752] Fix | Delete
/**
[4753] Fix | Delete
* Strip newlines to prevent header injection.
[4754] Fix | Delete
*
[4755] Fix | Delete
* @param string $str
[4756] Fix | Delete
*
[4757] Fix | Delete
* @return string
[4758] Fix | Delete
*/
[4759] Fix | Delete
public function secureHeader($str)
[4760] Fix | Delete
{
[4761] Fix | Delete
return trim(str_replace(["\r", "\n"], '', $str));
[4762] Fix | Delete
}
[4763] Fix | Delete
[4764] Fix | Delete
/**
[4765] Fix | Delete
* Normalize line breaks in a string.
[4766] Fix | Delete
* Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
[4767] Fix | Delete
* Defaults to CRLF (for message bodies) and preserves consecutive breaks.
[4768] Fix | Delete
*
[4769] Fix | Delete
* @param string $text
[4770] Fix | Delete
* @param string $breaktype What kind of line break to use; defaults to static::$LE
[4771] Fix | Delete
*
[4772] Fix | Delete
* @return string
[4773] Fix | Delete
*/
[4774] Fix | Delete
public static function normalizeBreaks($text, $breaktype = null)
[4775] Fix | Delete
{
[4776] Fix | Delete
if (null === $breaktype) {
[4777] Fix | Delete
$breaktype = static::$LE;
[4778] Fix | Delete
}
[4779] Fix | Delete
//Normalise to \n
[4780] Fix | Delete
$text = str_replace([self::CRLF, "\r"], "\n", $text);
[4781] Fix | Delete
//Now convert LE as needed
[4782] Fix | Delete
if ("\n" !== $breaktype) {
[4783] Fix | Delete
$text = str_replace("\n", $breaktype, $text);
[4784] Fix | Delete
}
[4785] Fix | Delete
[4786] Fix | Delete
return $text;
[4787] Fix | Delete
}
[4788] Fix | Delete
[4789] Fix | Delete
/**
[4790] Fix | Delete
* Remove trailing whitespace from a string.
[4791] Fix | Delete
*
[4792] Fix | Delete
* @param string $text
[4793] Fix | Delete
*
[4794] Fix | Delete
* @return string The text to remove whitespace from
[4795] Fix | Delete
*/
[4796] Fix | Delete
public static function stripTrailingWSP($text)
[4797] Fix | Delete
{
[4798] Fix | Delete
return rtrim($text, " \r\n\t");
[4799] Fix | Delete
}
[4800] Fix | Delete
[4801] Fix | Delete
/**
[4802] Fix | Delete
* Strip trailing line breaks from a string.
[4803] Fix | Delete
*
[4804] Fix | Delete
* @param string $text
[4805] Fix | Delete
*
[4806] Fix | Delete
* @return string The text to remove breaks from
[4807] Fix | Delete
*/
[4808] Fix | Delete
public static function stripTrailingBreaks($text)
[4809] Fix | Delete
{
[4810] Fix | Delete
return rtrim($text, "\r\n");
[4811] Fix | Delete
}
[4812] Fix | Delete
[4813] Fix | Delete
/**
[4814] Fix | Delete
* Return the current line break format string.
[4815] Fix | Delete
*
[4816] Fix | Delete
* @return string
[4817] Fix | Delete
*/
[4818] Fix | Delete
public static function getLE()
[4819] Fix | Delete
{
[4820] Fix | Delete
return static::$LE;
[4821] Fix | Delete
}
[4822] Fix | Delete
[4823] Fix | Delete
/**
[4824] Fix | Delete
* Set the line break format string, e.g. "\r\n".
[4825] Fix | Delete
*
[4826] Fix | Delete
* @param string $le
[4827] Fix | Delete
*/
[4828] Fix | Delete
protected static function setLE($le)
[4829] Fix | Delete
{
[4830] Fix | Delete
static::$LE = $le;
[4831] Fix | Delete
}
[4832] Fix | Delete
[4833] Fix | Delete
/**
[4834] Fix | Delete
* Set the public and private key files and password for S/MIME signing.
[4835] Fix | Delete
*
[4836] Fix | Delete
* @param string $cert_filename
[4837] Fix | Delete
* @param string $key_filename
[4838] Fix | Delete
* @param string $key_pass Password for private key
[4839] Fix | Delete
* @param string $extracerts_filename Optional path to chain certificate
[4840] Fix | Delete
*/
[4841] Fix | Delete
public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '')
[4842] Fix | Delete
{
[4843] Fix | Delete
$this->sign_cert_file = $cert_filename;
[4844] Fix | Delete
$this->sign_key_file = $key_filename;
[4845] Fix | Delete
$this->sign_key_pass = $key_pass;
[4846] Fix | Delete
$this->sign_extracerts_file = $extracerts_filename;
[4847] Fix | Delete
}
[4848] Fix | Delete
[4849] Fix | Delete
/**
[4850] Fix | Delete
* Quoted-Printable-encode a DKIM header.
[4851] Fix | Delete
*
[4852] Fix | Delete
* @param string $txt
[4853] Fix | Delete
*
[4854] Fix | Delete
* @return string
[4855] Fix | Delete
*/
[4856] Fix | Delete
public function DKIM_QP($txt)
[4857] Fix | Delete
{
[4858] Fix | Delete
$line = '';
[4859] Fix | Delete
$len = strlen($txt);
[4860] Fix | Delete
for ($i = 0; $i < $len; ++$i) {
[4861] Fix | Delete
$ord = ord($txt[$i]);
[4862] Fix | Delete
if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord === 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
[4863] Fix | Delete
$line .= $txt[$i];
[4864] Fix | Delete
} else {
[4865] Fix | Delete
$line .= '=' . sprintf('%02X', $ord);
[4866] Fix | Delete
}
[4867] Fix | Delete
}
[4868] Fix | Delete
[4869] Fix | Delete
return $line;
[4870] Fix | Delete
}
[4871] Fix | Delete
[4872] Fix | Delete
/**
[4873] Fix | Delete
* Generate a DKIM signature.
[4874] Fix | Delete
*
[4875] Fix | Delete
* @param string $signHeader
[4876] Fix | Delete
*
[4877] Fix | Delete
* @throws Exception
[4878] Fix | Delete
*
[4879] Fix | Delete
* @return string The DKIM signature value
[4880] Fix | Delete
*/
[4881] Fix | Delete
public function DKIM_Sign($signHeader)
[4882] Fix | Delete
{
[4883] Fix | Delete
if (!defined('PKCS7_TEXT')) {
[4884] Fix | Delete
if ($this->exceptions) {
[4885] Fix | Delete
throw new Exception($this->lang('extension_missing') . 'openssl');
[4886] Fix | Delete
}
[4887] Fix | Delete
[4888] Fix | Delete
return '';
[4889] Fix | Delete
}
[4890] Fix | Delete
$privKeyStr = !empty($this->DKIM_private_string) ?
[4891] Fix | Delete
$this->DKIM_private_string :
[4892] Fix | Delete
file_get_contents($this->DKIM_private);
[4893] Fix | Delete
if ('' !== $this->DKIM_passphrase) {
[4894] Fix | Delete
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
[4895] Fix | Delete
} else {
[4896] Fix | Delete
$privKey = openssl_pkey_get_private($privKeyStr);
[4897] Fix | Delete
}
[4898] Fix | Delete
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
[4899] Fix | Delete
if (\PHP_MAJOR_VERSION < 8) {
[4900] Fix | Delete
openssl_pkey_free($privKey);
[4901] Fix | Delete
}
[4902] Fix | Delete
[4903] Fix | Delete
return base64_encode($signature);
[4904] Fix | Delete
}
[4905] Fix | Delete
if (\PHP_MAJOR_VERSION < 8) {
[4906] Fix | Delete
openssl_pkey_free($privKey);
[4907] Fix | Delete
}
[4908] Fix | Delete
[4909] Fix | Delete
return '';
[4910] Fix | Delete
}
[4911] Fix | Delete
[4912] Fix | Delete
/**
[4913] Fix | Delete
* Generate a DKIM canonicalization header.
[4914] Fix | Delete
* Uses the 'relaxed' algorithm from RFC6376 section 3.4.2.
[4915] Fix | Delete
* Canonicalized headers should *always* use CRLF, regardless of mailer setting.
[4916] Fix | Delete
*
[4917] Fix | Delete
* @see https://tools.ietf.org/html/rfc6376#section-3.4.2
[4918] Fix | Delete
*
[4919] Fix | Delete
* @param string $signHeader Header
[4920] Fix | Delete
*
[4921] Fix | Delete
* @return string
[4922] Fix | Delete
*/
[4923] Fix | Delete
public function DKIM_HeaderC($signHeader)
[4924] Fix | Delete
{
[4925] Fix | Delete
//Normalize breaks to CRLF (regardless of the mailer)
[4926] Fix | Delete
$signHeader = static::normalizeBreaks($signHeader, self::CRLF);
[4927] Fix | Delete
//Unfold header lines
[4928] Fix | Delete
//Note PCRE \s is too broad a definition of whitespace; RFC5322 defines it as `[ \t]`
[4929] Fix | Delete
//@see https://tools.ietf.org/html/rfc5322#section-2.2
[4930] Fix | Delete
//That means this may break if you do something daft like put vertical tabs in your headers.
[4931] Fix | Delete
$signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader);
[4932] Fix | Delete
//Break headers out into an array
[4933] Fix | Delete
$lines = explode(self::CRLF, $signHeader);
[4934] Fix | Delete
foreach ($lines as $key => $line) {
[4935] Fix | Delete
//If the header is missing a :, skip it as it's invalid
[4936] Fix | Delete
//This is likely to happen because the explode() above will also split
[4937] Fix | Delete
//on the trailing LE, leaving an empty line
[4938] Fix | Delete
if (strpos($line, ':') === false) {
[4939] Fix | Delete
continue;
[4940] Fix | Delete
}
[4941] Fix | Delete
list($heading, $value) = explode(':', $line, 2);
[4942] Fix | Delete
//Lower-case header name
[4943] Fix | Delete
$heading = strtolower($heading);
[4944] Fix | Delete
//Collapse white space within the value, also convert WSP to space
[4945] Fix | Delete
$value = preg_replace('/[ \t]+/', ' ', $value);
[4946] Fix | Delete
//RFC6376 is slightly unclear here - it says to delete space at the *end* of each value
[4947] Fix | Delete
//But then says to delete space before and after the colon.
[4948] Fix | Delete
//Net result is the same as trimming both ends of the value.
[4949] Fix | Delete
//By elimination, the same applies to the field name
[4950] Fix | Delete
$lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t");
[4951] Fix | Delete
}
[4952] Fix | Delete
[4953] Fix | Delete
return implode(self::CRLF, $lines);
[4954] Fix | Delete
}
[4955] Fix | Delete
[4956] Fix | Delete
/**
[4957] Fix | Delete
* Generate a DKIM canonicalization body.
[4958] Fix | Delete
* Uses the 'simple' algorithm from RFC6376 section 3.4.3.
[4959] Fix | Delete
* Canonicalized bodies should *always* use CRLF, regardless of mailer setting.
[4960] Fix | Delete
*
[4961] Fix | Delete
* @see https://tools.ietf.org/html/rfc6376#section-3.4.3
[4962] Fix | Delete
*
[4963] Fix | Delete
* @param string $body Message Body
[4964] Fix | Delete
*
[4965] Fix | Delete
* @return string
[4966] Fix | Delete
*/
[4967] Fix | Delete
public function DKIM_BodyC($body)
[4968] Fix | Delete
{
[4969] Fix | Delete
if (empty($body)) {
[4970] Fix | Delete
return self::CRLF;
[4971] Fix | Delete
}
[4972] Fix | Delete
//Normalize line endings to CRLF
[4973] Fix | Delete
$body = static::normalizeBreaks($body, self::CRLF);
[4974] Fix | Delete
[4975] Fix | Delete
//Reduce multiple trailing line breaks to a single one
[4976] Fix | Delete
return static::stripTrailingBreaks($body) . self::CRLF;
[4977] Fix | Delete
}
[4978] Fix | Delete
[4979] Fix | Delete
/**
[4980] Fix | Delete
* Create the DKIM header and body in a new message header.
[4981] Fix | Delete
*
[4982] Fix | Delete
* @param string $headers_line Header lines
[4983] Fix | Delete
* @param string $subject Subject
[4984] Fix | Delete
* @param string $body Body
[4985] Fix | Delete
*
[4986] Fix | Delete
* @throws Exception
[4987] Fix | Delete
*
[4988] Fix | Delete
* @return string
[4989] Fix | Delete
*/
[4990] Fix | Delete
public function DKIM_Add($headers_line, $subject, $body)
[4991] Fix | Delete
{
[4992] Fix | Delete
$DKIMsignatureType = 'rsa-sha256'; //Signature & hash algorithms
[4993] Fix | Delete
$DKIMcanonicalization = 'relaxed/simple'; //Canonicalization methods of header & body
[4994] Fix | Delete
$DKIMquery = 'dns/txt'; //Query method
[4995] Fix | Delete
$DKIMtime = time();
[4996] Fix | Delete
//Always sign these headers without being asked
[4997] Fix | Delete
//Recommended list from https://tools.ietf.org/html/rfc6376#section-5.4.1
[4998] Fix | Delete
$autoSignHeaders = [
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function