CodeIgniter 3.1.11 -> 3.4.5 (pocketarc fork) en PHP 8.3-fixes
- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+91
-163
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +30,7 @@
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/email.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/email.html
|
||||
*/
|
||||
class CI_Email {
|
||||
|
||||
@@ -147,7 +148,7 @@ class CI_Email {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $charset = 'UTF-8';
|
||||
public $charset = 'utf-8';
|
||||
|
||||
/**
|
||||
* Alternative message (for HTML messages only)
|
||||
@@ -161,7 +162,7 @@ class CI_Email {
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $validate = FALSE;
|
||||
public $validate = TRUE;
|
||||
|
||||
/**
|
||||
* X-Priority header value.
|
||||
@@ -174,7 +175,7 @@ class CI_Email {
|
||||
* Newline character sequence.
|
||||
* Use "\r\n" to comply with RFC 822.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc822.txt
|
||||
* @link https://www.ietf.org/rfc/rfc822.txt
|
||||
* @var string "\r\n" or "\n"
|
||||
*/
|
||||
public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
|
||||
@@ -188,7 +189,7 @@ class CI_Email {
|
||||
* switching to "\n", while improper, is the only solution
|
||||
* that seems to work for all environments.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc822.txt
|
||||
* @link https://www.ietf.org/rfc/rfc822.txt
|
||||
* @var string
|
||||
*/
|
||||
public $crlf = "\n";
|
||||
@@ -225,13 +226,6 @@ class CI_Email {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Whether PHP is running in safe mode. Initialized by the class constructor.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_safe_mode = FALSE;
|
||||
|
||||
/**
|
||||
* Subject header
|
||||
*
|
||||
@@ -395,9 +389,8 @@ class CI_Email {
|
||||
{
|
||||
$this->charset = config_item('charset');
|
||||
$this->initialize($config);
|
||||
$this->_safe_mode = ( ! is_php('5.4') && ini_get('safe_mode'));
|
||||
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
isset(self::$func_overload) OR self::$func_overload = ( ! is_php('8.0') && extension_loaded('mbstring') && @ini_get('mbstring.func_overload'));
|
||||
|
||||
log_message('info', 'Email Class Initialized');
|
||||
}
|
||||
@@ -675,18 +668,6 @@ class CI_Email {
|
||||
public function message($body)
|
||||
{
|
||||
$this->_body = rtrim(str_replace("\r", '', $body));
|
||||
|
||||
/* strip slashes only if magic quotes is ON
|
||||
if we do it with magic quotes OFF, it strips real, user-inputted chars.
|
||||
|
||||
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
|
||||
it will probably not exist in future versions at all.
|
||||
*/
|
||||
if ( ! is_php('5.4') && get_magic_quotes_gpc())
|
||||
{
|
||||
$this->_body = stripslashes($this->_body);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1032,16 +1013,15 @@ class CI_Email {
|
||||
*/
|
||||
public function valid_email($email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $email, $matches))
|
||||
{
|
||||
list($account, $domain) = explode('@', $email, 2);
|
||||
$domain = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)
|
||||
: idn_to_ascii($domain);
|
||||
? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46)
|
||||
: idn_to_ascii($matches[2]);
|
||||
|
||||
if ($domain !== FALSE)
|
||||
{
|
||||
$email = $account.'@'.$domain;
|
||||
$email = $matches[1].'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,7 +1241,7 @@ class CI_Email {
|
||||
/**
|
||||
* Build Final Body and attachments
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
protected function _build_message()
|
||||
{
|
||||
@@ -1428,8 +1408,6 @@ class CI_Email {
|
||||
$this->_finalbody = ($this->_get_protocol() === 'mail')
|
||||
? $body
|
||||
: $hdr.$this->newline.$this->newline.$body;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1490,7 +1468,7 @@ class CI_Email {
|
||||
* Prep Quoted Printable
|
||||
*
|
||||
* Prepares string for Quoted-Printable Content-Transfer-Encoding
|
||||
* Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
|
||||
* Refer to RFC 2045 https://www.ietf.org/rfc/rfc2045.txt
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
@@ -1499,7 +1477,7 @@ class CI_Email {
|
||||
{
|
||||
// ASCII code numbers for "safe" characters that can always be
|
||||
// used literally, without encoding, as described in RFC 2049.
|
||||
// http://www.ietf.org/rfc/rfc2049.txt
|
||||
// https://www.ietf.org/rfc/rfc2049.txt
|
||||
static $ascii_safe_chars = array(
|
||||
// ' ( ) + , - . / : = ?
|
||||
39, 40, 41, 43, 44, 45, 46, 47, 58, 61, 63,
|
||||
@@ -1691,8 +1669,8 @@ class CI_Email {
|
||||
$this->reply_to($this->_headers['From']);
|
||||
}
|
||||
|
||||
if ( ! isset($this->_recipients) && ! isset($this->_headers['To'])
|
||||
&& ! isset($this->_bcc_array) && ! isset($this->_headers['Bcc'])
|
||||
if (empty($this->_recipients) && ! isset($this->_headers['To'])
|
||||
&& empty($this->_bcc_array) && ! isset($this->_headers['Bcc'])
|
||||
&& ! isset($this->_headers['Cc']))
|
||||
{
|
||||
$this->_set_error_message('lang:email_no_recipients');
|
||||
@@ -1703,21 +1681,17 @@ class CI_Email {
|
||||
|
||||
if ($this->bcc_batch_mode && count($this->_bcc_array) > $this->bcc_batch_size)
|
||||
{
|
||||
$result = $this->batch_bcc_send();
|
||||
$this->batch_bcc_send();
|
||||
|
||||
if ($result && $auto_clear)
|
||||
if ($auto_clear)
|
||||
{
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($this->_build_message() === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->_build_message();
|
||||
$result = $this->_spool_email();
|
||||
|
||||
if ($result && $auto_clear)
|
||||
@@ -1776,11 +1750,7 @@ class CI_Email {
|
||||
$this->_bcc_array = $bcc;
|
||||
}
|
||||
|
||||
if ($this->_build_message() === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_build_message();
|
||||
$this->_spool_email();
|
||||
}
|
||||
}
|
||||
@@ -1857,7 +1827,7 @@ class CI_Email {
|
||||
*/
|
||||
protected function _validate_email_for_shell(&$email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
|
||||
{
|
||||
list($account, $domain) = explode('@', $email, 2);
|
||||
$domain = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
@@ -1891,16 +1861,14 @@ class CI_Email {
|
||||
// so this needs to be assigned to a variable
|
||||
$from = $this->clean_email($this->_headers['Return-Path']);
|
||||
|
||||
if ($this->_safe_mode === TRUE || ! $this->_validate_email_for_shell($from))
|
||||
if ( ! $this->_validate_email_for_shell($from))
|
||||
{
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
// most documentation of sendmail using the "-f" flag lacks a space after it, however
|
||||
// we've encountered servers that seem to require it to be in place.
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$from);
|
||||
}
|
||||
|
||||
// most documentation of sendmail using the "-f" flag lacks a space after it, however
|
||||
// we've encountered servers that seem to require it to be in place.
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$from);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1981,27 +1949,21 @@ class CI_Email {
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->_cc_array) > 0)
|
||||
foreach ($this->_cc_array as $val)
|
||||
{
|
||||
foreach ($this->_cc_array as $val)
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->_bcc_array) > 0)
|
||||
foreach ($this->_bcc_array as $val)
|
||||
{
|
||||
foreach ($this->_bcc_array as $val)
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2015,7 +1977,6 @@ class CI_Email {
|
||||
$this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody));
|
||||
|
||||
$this->_send_data('.');
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
$this->_set_error_message($reply);
|
||||
|
||||
@@ -2041,9 +2002,7 @@ class CI_Email {
|
||||
*/
|
||||
protected function _smtp_end()
|
||||
{
|
||||
($this->smtp_keepalive)
|
||||
? $this->_send_command('reset')
|
||||
: $this->_send_command('quit');
|
||||
$this->_send_command($this->smtp_keepalive ? 'reset' : 'quit');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -2062,11 +2021,13 @@ class CI_Email {
|
||||
|
||||
$ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : '';
|
||||
|
||||
$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
|
||||
$this->smtp_port,
|
||||
$errno,
|
||||
$errstr,
|
||||
$this->smtp_timeout);
|
||||
$this->_smtp_connect = fsockopen(
|
||||
$ssl.$this->smtp_host,
|
||||
$this->smtp_port,
|
||||
$errno,
|
||||
$errstr,
|
||||
$this->smtp_timeout
|
||||
);
|
||||
|
||||
if ( ! is_resource($this->_smtp_connect))
|
||||
{
|
||||
@@ -2119,57 +2080,49 @@ class CI_Email {
|
||||
{
|
||||
switch ($cmd)
|
||||
{
|
||||
case 'hello' :
|
||||
case 'hello':
|
||||
if ($this->_smtp_auth OR $this->_get_encoding() === '8bit')
|
||||
{
|
||||
$this->_send_data('EHLO '.$this->_get_hostname());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('HELO '.$this->_get_hostname());
|
||||
}
|
||||
|
||||
if ($this->_smtp_auth OR $this->_get_encoding() === '8bit')
|
||||
{
|
||||
$this->_send_data('EHLO '.$this->_get_hostname());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('HELO '.$this->_get_hostname());
|
||||
}
|
||||
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'starttls' :
|
||||
|
||||
$this->_send_data('STARTTLS');
|
||||
$resp = 220;
|
||||
break;
|
||||
case 'from' :
|
||||
|
||||
$this->_send_data('MAIL FROM:<'.$data.'>');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'to' :
|
||||
|
||||
if ($this->dsn)
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'>');
|
||||
}
|
||||
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'data' :
|
||||
|
||||
$this->_send_data('DATA');
|
||||
$resp = 354;
|
||||
break;
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'starttls':
|
||||
$this->_send_data('STARTTLS');
|
||||
$resp = 220;
|
||||
break;
|
||||
case 'from':
|
||||
$this->_send_data('MAIL FROM:<'.$data.'>');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'to':
|
||||
if ($this->dsn)
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'>');
|
||||
}
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'data':
|
||||
$this->_send_data('DATA');
|
||||
$resp = 354;
|
||||
break;
|
||||
case 'reset':
|
||||
|
||||
$this->_send_data('RSET');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'quit' :
|
||||
|
||||
$this->_send_data('QUIT');
|
||||
$resp = 221;
|
||||
break;
|
||||
$this->_send_data('RSET');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'quit':
|
||||
$this->_send_data('QUIT');
|
||||
$resp = 221;
|
||||
break;
|
||||
}
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
@@ -2211,7 +2164,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data('AUTH LOGIN');
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '503') === 0) // Already authenticated
|
||||
@@ -2225,7 +2177,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data(base64_encode($this->smtp_user));
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '334') !== 0)
|
||||
@@ -2235,7 +2186,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data(base64_encode($this->smtp_pass));
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '235') !== 0)
|
||||
@@ -2269,7 +2219,7 @@ class CI_Email {
|
||||
{
|
||||
break;
|
||||
}
|
||||
// See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
|
||||
// See https://bugs.php.net/bug.php?id=39598 and https://secure.php.net/manual/en/function.fwrite.php#96951
|
||||
elseif ($result === 0)
|
||||
{
|
||||
if ($timestamp === 0)
|
||||
@@ -2332,7 +2282,7 @@ class CI_Email {
|
||||
* (eg: "[1.2.3.4]").
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc5321#section-2.3.5
|
||||
* @link http://cbl.abuseat.org/namingproblems.html
|
||||
* @link https://cbl.abuseat.org/namingproblems.html
|
||||
* @return string
|
||||
*/
|
||||
protected function _get_hostname()
|
||||
@@ -2356,34 +2306,15 @@ class CI_Email {
|
||||
*/
|
||||
public function print_debugger($include = array('headers', 'subject', 'body'))
|
||||
{
|
||||
$msg = '';
|
||||
|
||||
if (count($this->_debug_msg) > 0)
|
||||
{
|
||||
foreach ($this->_debug_msg as $val)
|
||||
{
|
||||
$msg .= $val;
|
||||
}
|
||||
}
|
||||
$msg = implode('', $this->_debug_msg);
|
||||
|
||||
// Determine which parts of our raw data needs to be printed
|
||||
$raw_data = '';
|
||||
is_array($include) OR $include = array($include);
|
||||
|
||||
if (in_array('headers', $include, TRUE))
|
||||
{
|
||||
$raw_data = htmlspecialchars($this->_header_str)."\n";
|
||||
}
|
||||
|
||||
if (in_array('subject', $include, TRUE))
|
||||
{
|
||||
$raw_data .= htmlspecialchars($this->_subject)."\n";
|
||||
}
|
||||
|
||||
if (in_array('body', $include, TRUE))
|
||||
{
|
||||
$raw_data .= htmlspecialchars($this->_finalbody);
|
||||
}
|
||||
in_array('headers', $include, TRUE) && $raw_data = htmlspecialchars($this->_header_str)."\n";
|
||||
in_array('subject', $include, TRUE) && $raw_data .= htmlspecialchars($this->_subject)."\n";
|
||||
in_array('body', $include, TRUE) && $raw_data .= htmlspecialchars($this->_finalbody);
|
||||
|
||||
return $msg.($raw_data === '' ? '' : '<pre>'.$raw_data.'</pre>');
|
||||
}
|
||||
@@ -2477,9 +2408,6 @@ class CI_Email {
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user