McBane87 / htmlMimeMail5

Source: http://www.phpguru.org
GNU General Public License v2.0
1 stars 1 forks source link

depricated warnings #2

Open ChrisPrefect opened 10 months ago

ChrisPrefect commented 10 months ago

I know this is an old project, but it is still used in an active ERP system.

Would it be possible to fix the deprecated warnings that show up on PHP 8.2?

Deprecated: Creation of dynamic property fileEmbeddedImage::$cid is deprecated in /htmlMimeMail5/htmlMimeMail5.php on line 457

Warning: define(): Argument #3 ($case_insensitive) is ignored since declaration of case-insensitive constants is no longer supported in /htmlMimeMail5/htmlMimeMail5.php on line 186

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /htmlMimeMail5/htmlMimeMail5.php on line 713

I was able to fix a fatal error in one of the functions. Fixed function:

` private function quotedPrintableEncode($input , $line_max = 76) { $lines = preg_split("/\r?\n/", $input); $eol = MAIL_MIMEPART_CRLF; $escape = '='; $output = '';

foreach($lines as $line) {

    $linlen     = strlen($line);
    $newline = '';

    for ($i = 0; $i < $linlen; $i++) {
        $char = substr($line, $i, 1);
        $dec  = ord($char);

        if (($dec == 32) AND ($i == ($linlen - 1))){    // convert space at eol only
            $char = '=20';

        } elseif($dec == 9) {
            ; // Do nothing if a tab.
        } elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) {
            $char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
        }

        if ((strlen($newline) + strlen($char)) >= $line_max) {        // MAIL_MIMEPART_CRLF is not counted
            $output  .= $newline . $escape . $eol;                    // soft line break; " =\r\n" is okay
            $newline  = '';
        }
        $newline .= $char;
    } // end of for
    $output .= $newline . $eol;
}
$output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf
return $output;

} `

Thank you!

McBane87 commented 9 months ago

Hi, I've added some fixes for PHP8. Please test again.