Changeset View
Changeset View
Standalone View
Standalone View
externals/phpmailer/class.phpmailer.php
Context not available. | |||||
* @access private | * @access private | ||||
*/ | */ | ||||
private function AddAnAddress($kind, $address, $name = '') { | private function AddAnAddress($kind, $address, $name = '') { | ||||
if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { | if (!@preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { | ||||
echo 'Invalid recipient array: ' . kind; | echo 'Invalid recipient array: ' . kind; | ||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
return false; | return false; | ||||
} | } | ||||
if ($kind != 'ReplyTo') { | if ($kind != 'ReplyTo') { | ||||
if (!isset($this->all_recipients[strtolower($address)])) { | if (!isset($this->all_recipients[@strtolower($address)])) { | ||||
array_push($this->$kind, array($address, $name)); | array_push($this->$kind, array($address, $name)); | ||||
$this->all_recipients[strtolower($address)] = true; | $this->all_recipients[@strtolower($address)] = true; | ||||
return true; | return true; | ||||
} | } | ||||
} else { | } else { | ||||
if (!array_key_exists(strtolower($address), $this->ReplyTo)) { | if (!array_key_exists(@strtolower($address), $this->ReplyTo)) { | ||||
$this->ReplyTo[strtolower($address)] = array($address, $name); | $this->ReplyTo[@strtolower($address)] = array($address, $name); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
return true; | return true; | ||||
} | } | ||||
} else { | } else { | ||||
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); | return @preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
protected function SendmailSend($header, $body) { | protected function SendmailSend($header, $body) { | ||||
if ($this->Sender != '') { | if ($this->Sender != '') { | ||||
$sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); | $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), @escapeshellarg($this->Sender)); | ||||
} else { | } else { | ||||
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); | $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); | ||||
} | } | ||||
Context not available. | |||||
$to = implode(', ', $toArr); | $to = implode(', ', $toArr); | ||||
$params = sprintf("-oi -f %s", $this->Sender); | $params = sprintf("-oi -f %s", $this->Sender); | ||||
if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { | if ($this->Sender != '' && @strlen(ini_get('safe_mode'))< 1) { | ||||
$old_from = ini_get('sendmail_from'); | $old_from = ini_get('sendmail_from'); | ||||
ini_set('sendmail_from', $this->Sender); | ini_set('sendmail_from', $this->Sender); | ||||
if ($this->SingleTo === true && count($toArr) > 1) { | if ($this->SingleTo === true && count($toArr) > 1) { | ||||
Context not available. | |||||
} | } | ||||
$this->smtp->do_debug = $this->SMTPDebug; | $this->smtp->do_debug = $this->SMTPDebug; | ||||
$hosts = explode(';', $this->Host); | $hosts = @explode(';', $this->Host); | ||||
$index = 0; | $index = 0; | ||||
$connection = $this->smtp->Connected(); | $connection = $this->smtp->Connected(); | ||||
Context not available. | |||||
try { | try { | ||||
while($index < count($hosts) && !$connection) { | while($index < count($hosts) && !$connection) { | ||||
$hostinfo = array(); | $hostinfo = array(); | ||||
if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { | if (@preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { | ||||
$host = $hostinfo[1]; | $host = $hostinfo[1]; | ||||
$port = $hostinfo[2]; | $port = $hostinfo[2]; | ||||
} else { | } else { | ||||
Context not available. | |||||
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; | $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; | ||||
// If utf-8 encoding is used, we will need to make sure we don't | // If utf-8 encoding is used, we will need to make sure we don't | ||||
// split multibyte characters when we wrap | // split multibyte characters when we wrap | ||||
$is_utf8 = (strtolower($this->CharSet) == "utf-8"); | $is_utf8 = (@strtolower($this->CharSet) == "utf-8"); | ||||
$message = $this->FixEOL($message); | $message = $this->FixEOL($message); | ||||
if (substr($message, -1) == $this->LE) { | if (@substr($message, -1) == $this->LE) { | ||||
$message = substr($message, 0, -1); | $message = @substr($message, 0, -1); | ||||
} | } | ||||
$line = explode($this->LE, $message); | $line = @explode($this->LE, $message); | ||||
$message = ''; | $message = ''; | ||||
for ($i=0 ;$i < count($line); $i++) { | for ($i=0 ;$i < count($line); $i++) { | ||||
$line_part = explode(' ', $line[$i]); | $line_part = @explode(' ', $line[$i]); | ||||
$buf = ''; | $buf = ''; | ||||
for ($e = 0; $e<count($line_part); $e++) { | for ($e = 0; $e<count($line_part); $e++) { | ||||
$word = $line_part[$e]; | $word = $line_part[$e]; | ||||
if ($qp_mode and (strlen($word) > $length)) { | if ($qp_mode and (@strlen($word) > $length)) { | ||||
$space_left = $length - strlen($buf) - 1; | $space_left = $length - @strlen($buf) - 1; | ||||
if ($e != 0) { | if ($e != 0) { | ||||
if ($space_left > 20) { | if ($space_left > 20) { | ||||
$len = $space_left; | $len = $space_left; | ||||
if ($is_utf8) { | if ($is_utf8) { | ||||
$len = $this->UTF8CharBoundary($word, $len); | $len = $this->UTF8CharBoundary($word, $len); | ||||
} elseif (substr($word, $len - 1, 1) == "=") { | } elseif (@substr($word, $len - 1, 1) == "=") { | ||||
$len--; | $len--; | ||||
} elseif (substr($word, $len - 2, 1) == "=") { | } elseif (@substr($word, $len - 2, 1) == "=") { | ||||
$len -= 2; | $len -= 2; | ||||
} | } | ||||
$part = substr($word, 0, $len); | $part = @substr($word, 0, $len); | ||||
$word = substr($word, $len); | $word = @substr($word, $len); | ||||
$buf .= ' ' . $part; | $buf .= ' ' . $part; | ||||
$message .= $buf . sprintf("=%s", $this->LE); | $message .= $buf . sprintf("=%s", $this->LE); | ||||
} else { | } else { | ||||
Context not available. | |||||
} | } | ||||
$buf = ''; | $buf = ''; | ||||
} | } | ||||
while (strlen($word) > 0) { | while (@strlen($word) > 0) { | ||||
$len = $length; | $len = $length; | ||||
if ($is_utf8) { | if ($is_utf8) { | ||||
$len = $this->UTF8CharBoundary($word, $len); | $len = $this->UTF8CharBoundary($word, $len); | ||||
} elseif (substr($word, $len - 1, 1) == "=") { | } elseif (@substr($word, $len - 1, 1) == "=") { | ||||
$len--; | $len--; | ||||
} elseif (substr($word, $len - 2, 1) == "=") { | } elseif (@substr($word, $len - 2, 1) == "=") { | ||||
$len -= 2; | $len -= 2; | ||||
} | } | ||||
$part = substr($word, 0, $len); | $part = @substr($word, 0, $len); | ||||
$word = substr($word, $len); | $word = @substr($word, $len); | ||||
if (strlen($word) > 0) { | if (@strlen($word) > 0) { | ||||
$message .= $part . sprintf("=%s", $this->LE); | $message .= $part . sprintf("=%s", $this->LE); | ||||
} else { | } else { | ||||
$buf = $part; | $buf = $part; | ||||
Context not available. | |||||
$buf_o = $buf; | $buf_o = $buf; | ||||
$buf .= ($e == 0) ? $word : (' ' . $word); | $buf .= ($e == 0) ? $word : (' ' . $word); | ||||
if (strlen($buf) > $length and $buf_o != '') { | if (@strlen($buf) > $length and $buf_o != '') { | ||||
$message .= $buf_o . $soft_break; | $message .= $buf_o . $soft_break; | ||||
$buf = $word; | $buf = $word; | ||||
} | } | ||||
Context not available. | |||||
$foundSplitPos = false; | $foundSplitPos = false; | ||||
$lookBack = 3; | $lookBack = 3; | ||||
while (!$foundSplitPos) { | while (!$foundSplitPos) { | ||||
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); | $lastChunk = @substr($encodedText, $maxLength - $lookBack, $lookBack); | ||||
$encodedCharPos = strpos($lastChunk, "="); | $encodedCharPos = @strpos($lastChunk, "="); | ||||
if ($encodedCharPos !== false) { | if ($encodedCharPos !== false) { | ||||
// Found start of encoded character byte within $lookBack block. | // Found start of encoded character byte within $lookBack block. | ||||
// Check the encoded byte value (the 2 chars after the '=') | // Check the encoded byte value (the 2 chars after the '=') | ||||
$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); | $hex = @substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); | ||||
$dec = hexdec($hex); | $dec = hexdec($hex); | ||||
if ($dec < 128) { // Single byte character. | if ($dec < 128) { // Single byte character. | ||||
// If the encoded char was found at pos 0, it will fit | // If the encoded char was found at pos 0, it will fit | ||||
Context not available. | |||||
* @return void | * @return void | ||||
*/ | */ | ||||
private function SetMessageType() { | private function SetMessageType() { | ||||
if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { | if(count($this->attachment) < 1 && @strlen($this->AltBody) < 1) { | ||||
$this->message_type = 'plain'; | $this->message_type = 'plain'; | ||||
} else { | } else { | ||||
if(count($this->attachment) > 0) { | if(count($this->attachment) > 0) { | ||||
$this->message_type = 'attachments'; | $this->message_type = 'attachments'; | ||||
} | } | ||||
if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { | if(@strlen($this->AltBody) > 0 && count($this->attachment) < 1) { | ||||
$this->message_type = 'alt'; | $this->message_type = 'alt'; | ||||
} | } | ||||
if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { | if(@strlen($this->AltBody) > 0 && count($this->attachment) > 0) { | ||||
$this->message_type = 'alt_attachments'; | $this->message_type = 'alt_attachments'; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
public function EncodeString ($str, $encoding = 'base64') { | public function EncodeString ($str, $encoding = 'base64') { | ||||
$encoded = ''; | $encoded = ''; | ||||
switch(strtolower($encoding)) { | switch(@strtolower($encoding)) { | ||||
case 'base64': | case 'base64': | ||||
$encoded = chunk_split(base64_encode($str), 76, $this->LE); | $encoded = chunk_split(base64_encode($str), 76, $this->LE); | ||||
break; | break; | ||||
Context not available. | |||||
case '8bit': | case '8bit': | ||||
$encoded = $this->FixEOL($str); | $encoded = $this->FixEOL($str); | ||||
//Make sure it ends with a line break | //Make sure it ends with a line break | ||||
if (substr($encoded, -(strlen($this->LE))) != $this->LE) | if (@substr($encoded, -(@strlen($this->LE))) != $this->LE) | ||||
$encoded .= $this->LE; | $encoded .= $this->LE; | ||||
break; | break; | ||||
case 'binary': | case 'binary': | ||||
Context not available. | |||||
public function EncodeHeader($str, $position = 'text') { | public function EncodeHeader($str, $position = 'text') { | ||||
$x = 0; | $x = 0; | ||||
switch (strtolower($position)) { | switch (@strtolower($position)) { | ||||
case 'phrase': | case 'phrase': | ||||
if (!preg_match('/[\200-\377]/', $str)) { | if (!@preg_match('/[\200-\377]/', $str)) { | ||||
// Can't use addslashes as we don't know what value has magic_quotes_sybase | // Can't use addslashes as we don't know what value has magic_quotes_sybase | ||||
$encoded = addcslashes($str, "\0..\37\177\\\""); | $encoded = addcslashes($str, "\0..\37\177\\\""); | ||||
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { | if (($str == $encoded) && !@preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { | ||||
return ($encoded); | return ($encoded); | ||||
} else { | } else { | ||||
return ("\"$encoded\""); | return ("\"$encoded\""); | ||||
Context not available. | |||||
return ($str); | return ($str); | ||||
} | } | ||||
$maxlen = 75 - 7 - strlen($this->CharSet); | $maxlen = 75 - 7 - @strlen($this->CharSet); | ||||
// Try to select the encoding which should produce the shortest output | // Try to select the encoding which should produce the shortest output | ||||
if (strlen($str)/3 < $x) { | if (@strlen($str)/3 < $x) { | ||||
$encoding = 'B'; | $encoding = 'B'; | ||||
if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { | if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { | ||||
// Use a custom function which correctly encodes and wraps long | // Use a custom function which correctly encodes and wraps long | ||||
Context not available. | |||||
*/ | */ | ||||
public function HasMultiBytes($str) { | public function HasMultiBytes($str) { | ||||
if (function_exists('mb_strlen')) { | if (function_exists('mb_strlen')) { | ||||
return (strlen($str) > mb_strlen($str, $this->CharSet)); | return (@strlen($str) > mbstrlen($str, $this->CharSet)); | ||||
} else { // Assume no multibytes (we can't handle without mbstring functions anyway) | } else { // Assume no multibytes (we can't handle without mbstring functions anyway) | ||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
$end = "?="; | $end = "?="; | ||||
$encoded = ""; | $encoded = ""; | ||||
$mb_length = mb_strlen($str, $this->CharSet); | $mb_length = mbstrlen($str, $this->CharSet); | ||||
// Each line must have length <= 75, including $start and $end | // Each line must have length <= 75, including $start and $end | ||||
$length = 75 - strlen($start) - strlen($end); | $length = 75 - @strlen($start) - @strlen($end); | ||||
// Average multi-byte ratio | // Average multi-byte ratio | ||||
$ratio = $mb_length / strlen($str); | $ratio = $mb_length / @strlen($str); | ||||
// Base64 has a 4:3 ratio | // Base64 has a 4:3 ratio | ||||
$offset = $avgLength = floor($length * $ratio * .75); | $offset = $avgLength = floor($length * $ratio * .75); | ||||
Context not available. | |||||
$chunk = base64_encode($chunk); | $chunk = base64_encode($chunk); | ||||
$lookBack++; | $lookBack++; | ||||
} | } | ||||
while (strlen($chunk) > $length); | while (@strlen($chunk) > $length); | ||||
$encoded .= $chunk . $this->LE; | $encoded .= $chunk . $this->LE; | ||||
} | } | ||||
// Chomp the last linefeed | // Chomp the last linefeed | ||||
$encoded = substr($encoded, 0, -strlen($this->LE)); | $encoded = @substr($encoded, 0, -@strlen($this->LE)); | ||||
return $encoded; | return $encoded; | ||||
} | } | ||||
Context not available. | |||||
$escape = '='; | $escape = '='; | ||||
$output = ''; | $output = ''; | ||||
while( list(, $line) = each($lines) ) { | while( list(, $line) = each($lines) ) { | ||||
$linlen = strlen($line); | $linlen = @strlen($line); | ||||
$newline = ''; | $newline = ''; | ||||
for($i = 0; $i < $linlen; $i++) { | for($i = 0; $i < $linlen; $i++) { | ||||
$c = substr( $line, $i, 1 ); | $c = @substr( $line, $i, 1 ); | ||||
$dec = ord( $c ); | $dec = ord( $c ); | ||||
if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E | if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E | ||||
$c = '=2E'; | $c = '=2E'; | ||||
Context not available. | |||||
$h1 = floor($dec%16); | $h1 = floor($dec%16); | ||||
$c = $escape.$hex[$h2].$hex[$h1]; | $c = $escape.$hex[$h2].$hex[$h1]; | ||||
} | } | ||||
if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted | if ( (@strlen($newline) + @strlen($c)) >= $line_max ) { // CRLF is not counted | ||||
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay | ||||
$newline = ''; | $newline = ''; | ||||
// check if newline first character will be point or not | // check if newline first character will be point or not | ||||
Context not available. | |||||
// There should not be any EOL in the string | // There should not be any EOL in the string | ||||
$encoded = preg_replace('/[\r\n]*/', '', $str); | $encoded = preg_replace('/[\r\n]*/', '', $str); | ||||
switch (strtolower($position)) { | switch (@strtolower($position)) { | ||||
case 'phrase': | case 'phrase': | ||||
$encoded = preg_replace_callback( | $encoded = preg_replace_callback( | ||||
"/([^A-Za-z0-9!*+\/ -])/", | "/([^A-Za-z0-9!*+\/ -])/", | ||||
Context not available. | |||||
*/ | */ | ||||
public function ClearAddresses() { | public function ClearAddresses() { | ||||
foreach($this->to as $to) { | foreach($this->to as $to) { | ||||
unset($this->all_recipients[strtolower($to[0])]); | unset($this->all_recipients[@strtolower($to[0])]); | ||||
} | } | ||||
$this->to = array(); | $this->to = array(); | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
public function ClearCCs() { | public function ClearCCs() { | ||||
foreach($this->cc as $cc) { | foreach($this->cc as $cc) { | ||||
unset($this->all_recipients[strtolower($cc[0])]); | unset($this->all_recipients[@strtolower($cc[0])]); | ||||
} | } | ||||
$this->cc = array(); | $this->cc = array(); | ||||
} | } | ||||
Context not available. | |||||
*/ | */ | ||||
public function ClearBCCs() { | public function ClearBCCs() { | ||||
foreach($this->bcc as $bcc) { | foreach($this->bcc as $bcc) { | ||||
unset($this->all_recipients[strtolower($bcc[0])]); | unset($this->all_recipients[@strtolower($bcc[0])]); | ||||
} | } | ||||
$this->bcc = array(); | $this->bcc = array(); | ||||
} | } | ||||
Context not available. | |||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function AddCustomHeader($custom_header) { | public function AddCustomHeader($custom_header) { | ||||
$this->CustomHeader[] = explode(':', $custom_header, 2); | $this->CustomHeader[] = @explode(':', $custom_header, 2); | ||||
} | } | ||||
/** | /** | ||||
Context not available. | |||||
if(isset($images[2])) { | if(isset($images[2])) { | ||||
foreach($images[2] as $i => $url) { | foreach($images[2] as $i => $url) { | ||||
// do not change urls for absolute images (thanks to corvuscorax) | // do not change urls for absolute images (thanks to corvuscorax) | ||||
if (!preg_match('#^[A-z]+://#',$url)) { | if (!@preg_match('#^[A-z]+://#',$url)) { | ||||
$filename = basename($url); | $filename = basename($url); | ||||
$directory = dirname($url); | $directory = dirname($url); | ||||
($directory == '.')?$directory='':''; | ($directory == '.')?$directory='':''; | ||||
$cid = 'cid:' . md5($filename); | $cid = 'cid:' . md5($filename); | ||||
$ext = pathinfo($filename, PATHINFO_EXTENSION); | $ext = pathinfo($filename, PATHINFO_EXTENSION); | ||||
$mimeType = self::_mime_types($ext); | $mimeType = self::_mime_types($ext); | ||||
if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } | if ( @strlen($basedir) > 1 && @substr($basedir,-1) != '/') { $basedir .= '/'; } | ||||
if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } | if ( @strlen($directory) > 1 && @substr($directory,-1) != '/') { $directory .= '/'; } | ||||
if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { | if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { | ||||
$message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); | $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); | ||||
} | } | ||||
Context not available. | |||||
'xl' => 'application/excel', | 'xl' => 'application/excel', | ||||
'eml' => 'message/rfc822' | 'eml' => 'message/rfc822' | ||||
); | ); | ||||
return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; | return (!isset($mimes[@strtolower($ext)])) ? 'application/octet-stream' : $mimes[@strtolower($ext)]; | ||||
} | } | ||||
/** | /** | ||||
Context not available. | |||||
public function DKIM_QP($txt) { | public function DKIM_QP($txt) { | ||||
$tmp=""; | $tmp=""; | ||||
$line=""; | $line=""; | ||||
for ($i=0;$i<strlen($txt);$i++) { | for ($i=0;$i<@strlen($txt);$i++) { | ||||
$ord=ord($txt[$i]); | $ord=ord($txt[$i]); | ||||
if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) { | if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) { | ||||
$line.=$txt[$i]; | $line.=$txt[$i]; | ||||
Context not available. | |||||
*/ | */ | ||||
public function DKIM_HeaderC($s) { | public function DKIM_HeaderC($s) { | ||||
$s=preg_replace("/\r\n\s+/"," ",$s); | $s=preg_replace("/\r\n\s+/"," ",$s); | ||||
$lines=explode("\r\n",$s); | $lines=@explode("\r\n",$s); | ||||
foreach ($lines as $key=>$line) { | foreach ($lines as $key=>$line) { | ||||
list($heading,$value)=explode(":",$line,2); | list($heading,$value)=@explode(":",$line,2); | ||||
$heading=strtolower($heading); | $heading=@strtolower($heading); | ||||
$value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces | $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces | ||||
$lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value | $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value | ||||
} | } | ||||
Context not available. | |||||
$body=str_replace("\r\n","\n",$body); | $body=str_replace("\r\n","\n",$body); | ||||
$body=str_replace("\n","\r\n",$body); | $body=str_replace("\n","\r\n",$body); | ||||
// END stabilize line endings | // END stabilize line endings | ||||
while (substr($body,strlen($body)-4,4) == "\r\n\r\n") { | while (@substr($body,@strlen($body)-4,4) == "\r\n\r\n") { | ||||
$body=substr($body,0,strlen($body)-2); | $body=@substr($body,0,@strlen($body)-2); | ||||
} | } | ||||
return $body; | return $body; | ||||
} | } | ||||
Context not available. | |||||
$DKIMquery = 'dns/txt'; // Query method | $DKIMquery = 'dns/txt'; // Query method | ||||
$DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) | $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) | ||||
$subject_header = "Subject: $subject"; | $subject_header = "Subject: $subject"; | ||||
$headers = explode("\r\n",$headers_line); | $headers = @explode("\r\n",$headers_line); | ||||
foreach($headers as $header) { | foreach($headers as $header) { | ||||
if (strpos($header,'From:') === 0) { | if (@strpos($header,'From:') === 0) { | ||||
$from_header=$header; | $from_header=$header; | ||||
} elseif (strpos($header,'To:') === 0) { | } elseif (@strpos($header,'To:') === 0) { | ||||
$to_header=$header; | $to_header=$header; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
$to = str_replace('|','=7C',$this->DKIM_QP($to_header)); | $to = str_replace('|','=7C',$this->DKIM_QP($to_header)); | ||||
$subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable | $subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable | ||||
$body = $this->DKIM_BodyC($body); | $body = $this->DKIM_BodyC($body); | ||||
$DKIMlen = strlen($body) ; // Length of body | $DKIMlen = @strlen($body) ; // Length of body | ||||
$DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body | $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body | ||||
$ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; | $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; | ||||
$dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". | $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0