1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-28 16:50:07 +02:00

fix(#5131): Accurate resource open check when using log file handle

Fixes: https://github.com/e107inc/e107/issues/5131
This commit is contained in:
Nick Liu
2023-12-03 21:20:43 -06:00
parent 1637707a03
commit 688ebdfea8
2 changed files with 54 additions and 11 deletions

View File

@@ -130,14 +130,10 @@ if (!defined('e107_INIT')) { exit; }
//define('MAIL_DEBUG',true);
//define('LOG_CALLER', true);
//require_once(e_HANDLER.'phpmailer/class.phpmailer.php');
//require_once(e_HANDLER.'phpmailer/class.smtp.php');
//require_once(e_HANDLER.'phpmailer/PHPMailerAutoload.php');
use PHPMailer\PHPMailer\PHPMailer;
// use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\POP3;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\POP3;
require_once(e_HANDLER.'vendor/autoload.php');
@@ -438,7 +434,7 @@ class e107Email extends PHPMailer
*/
protected function openLog($logInfo = true)
{
if ($this->logEnable && ($this->logHandle === false))
if ($this->logEnable && !is_resource($this->logHandle))
{
$logFileName = MAIL_LOG_PATH.'mailoutlog.log';
$this->logHandle = fopen($logFileName, 'a'); // Always append to file
@@ -487,7 +483,7 @@ class e107Email extends PHPMailer
*/
protected function logLine($text)
{
if ($this->logEnable && ($this->logHandle > 0))
if ($this->logEnable && is_resource($this->logHandle))
{
fwrite($this->logHandle,date('H:i:s y.m.d').' - '.$text."\r\n");
}
@@ -496,11 +492,12 @@ class e107Email extends PHPMailer
}
/**
* Close log
* Close log
* @return void
*/
protected function closeLog()
{
if ($this->logEnable && ($this->logHandle > 0))
if ($this->logEnable && is_resource($this->logHandle))
{
fclose($this->logHandle);
}