This commit is contained in:
count-null 2025-02-25 19:21:31 -05:00
parent 27df1a73b5
commit a0cb5fb6b0
36 changed files with 1886 additions and 187 deletions

View file

@ -1,9 +1,7 @@
<?php
namespace app;
// for email
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
class app
{
@ -12,37 +10,12 @@ class app
public static function init_db()
{
try {
self::$db = new \PDO('sqlite:../' . $_ENV['SQLITE_DB']);
self::$db = new \PDO('sqlite:' . $_ENV['SQLITE_DB']);
self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
} catch (\PDOException $e) {
die("Database error: " . $e->getMessage());
}
}
public static function send_mail($to, $from, $from_name, $subject, $message, $HTML_message)
{
$mail = new PHPMailer(exceptions: true);
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = $_ENV['SMTP_HOST'];
$mail->SMTPAuth = true;
$mail->Username = $_ENV['SMTP_USER'];
$mail->Password = $_ENV['SMTP_PASS'];
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->isHTML(true);
$mail->setFrom($from, $from_name);
$mail->addAddress(address: $to);
$mail->Subject = $subject;
$mail->Body = $HTML_message;
$mail->AltBody = $message;
// Buffer the output
ob_start();
$mail->send();
ob_end_clean();
}
public static function sendJson($data, $status = 200)
{