From 6c3d50fccf17a1a6b910eea8983635728de76ade Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 25 Feb 2026 08:16:09 +0000 Subject: [PATCH] Autosave: 20260225-081609 --- auth/forgot.php | 10 ++++++++-- auth/register.php | 10 ++++++++-- mail/MailService.php | 26 ++++++++++++-------------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/auth/forgot.php b/auth/forgot.php index 4e808ef..93f0f8b 100644 --- a/auth/forgot.php +++ b/auth/forgot.php @@ -28,7 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($is_universal || $verify_code === '123456') { $code_valid = true; } else { - if (session_status() === PHP_SESSION_NONE) session_start(); + if (session_status() === PHP_SESSION_NONE) @session_start(); $session_key = ($reg_type === 'email' ? 'reset_email_code' : 'reset_mobile_code'); if (isset($_SESSION[$session_key]) && $verify_code === $_SESSION[$session_key]) { $code_valid = true; @@ -253,10 +253,16 @@ function sendCode() { if (!res.ok) throw new Error('Network error: ' + res.status); return res.text().then(text => { try { + // Try to extract JSON if there are warnings/notices + const jsonStart = text.indexOf('{'); + const jsonEnd = text.lastIndexOf('}'); + if (jsonStart !== -1 && jsonEnd !== -1) { + return JSON.parse(text.substring(jsonStart, jsonEnd + 1)); + } return JSON.parse(text); } catch(e) { console.error('Raw response:', text); - throw new Error('Invalid JSON response'); + throw new Error('Invalid server response. Please check PHP 8.1 logs.'); } }); }) diff --git a/auth/register.php b/auth/register.php index 56a9162..9313aa3 100644 --- a/auth/register.php +++ b/auth/register.php @@ -59,7 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->execute([$username, $email, $hash, $uid, 80, $ip]); $userId = db()->lastInsertId(); - if (session_status() === PHP_SESSION_NONE) session_start(); + if (session_status() === PHP_SESSION_NONE) @session_start(); $_SESSION['user_id'] = $userId; $_SESSION['username'] = $username; $_SESSION['uid'] = $uid; @@ -308,10 +308,16 @@ function sendCode() { if (!res.ok) throw new Error('Network error: ' + res.status); return res.text().then(text => { try { + // Try to extract JSON if there are warnings/notices + const jsonStart = text.indexOf('{'); + const jsonEnd = text.lastIndexOf('}'); + if (jsonStart !== -1 && jsonEnd !== -1) { + return JSON.parse(text.substring(jsonStart, jsonEnd + 1)); + } return JSON.parse(text); } catch(e) { console.error('Raw response:', text); - throw new Error('Invalid JSON response'); + throw new Error('Invalid server response. Please check PHP 8.1 logs.'); } }); }) diff --git a/mail/MailService.php b/mail/MailService.php index 85a8a1a..1e9d487 100644 --- a/mail/MailService.php +++ b/mail/MailService.php @@ -19,21 +19,19 @@ class MailService require_once $autoload; } if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) { - @require_once 'libphp-phpmailer/autoload.php'; + // Local PHPMailer (Priority for portability) + @require_once __DIR__ . '/PHPMailer/src/Exception.php'; + @require_once __DIR__ . '/PHPMailer/src/SMTP.php'; + @require_once __DIR__ . '/PHPMailer/src/PHPMailer.php'; + + // System-wide fallback if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) { - @require_once 'libphp-phpmailer/src/Exception.php'; - @require_once 'libphp-phpmailer/src/SMTP.php'; - @require_once 'libphp-phpmailer/src/PHPMailer.php'; - } - if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) { - @require_once 'PHPMailer/src/Exception.php'; - @require_once 'PHPMailer/src/SMTP.php'; - @require_once 'PHPMailer/src/PHPMailer.php'; - } - if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) { - @require_once 'PHPMailer/Exception.php'; - @require_once 'PHPMailer/SMTP.php'; - @require_once 'PHPMailer/PHPMailer.php'; + @require_once 'libphp-phpmailer/autoload.php'; + if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) { + @require_once 'libphp-phpmailer/src/Exception.php'; + @require_once 'libphp-phpmailer/src/SMTP.php'; + @require_once 'libphp-phpmailer/src/PHPMailer.php'; + } } }