// --- File-based debug logger ---
function debug_log($msg)
{
$f = __DIR__ . '/annie_api_debug.log';
$ts = date('Y-m-d H:i:s');
file_put_contents($f, "[$ts] $msg\n", FILE_APPEND);
}
// --- Global error/exception handler for debugging ---
set_exception_handler(function($e) {
http_response_code(500);
header('Content-Type: application/json');
echo json_encode([
'error' => 'uncaught exception',
'type' => get_class($e),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString()
]);
exit;
});
set_error_handler(function($errno, $errstr, $errfile, $errline) {
http_response_code(500);
header('Content-Type: application/json');
echo json_encode([
'error' => 'uncaught error',
'errno' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline
]);
exit;
});
// ...existing code...
// Minimal PHPMailer stub (inlined)
namespace PHPMailer\PHPMailer {
class PHPMailer {
public $isSMTP = false;
public $Host;
public $SMTPAuth;
public $Username;
public $Password;
public $SMTPSecure;
public $Port;
public $setFrom;
public $addAddress;
public $Subject;
public $Body;
public $AltBody;
public $ErrorInfo = '';
public function isSMTP() { $this->isSMTP = true; }
public function setFrom($from, $name = '') { $this->setFrom = [$from, $name]; }
public function addAddress($address) { $this->addAddress = $address; }
public function send() {
// Use PHP's mail() as a fallback for this stub, or implement SMTP if needed
$headers = "From: " . $this->setFrom[0] . "\r\n";
$subject = $this->Subject;
$body = $this->Body;
return mail($this->addAddress, $subject, $body, $headers);
}
}
class SMTP {}
class Exception extends \Exception {}
}
// End PHPMailer stub
Fatal error: Uncaught Error: Call to undefined function debug_log() in /srv/annie.aytict.fi/public/index.php:84
Stack trace:
#0 {main}
thrown in /srv/annie.aytict.fi/public/index.php on line 84