mirror of
https://github.com/ellite/Wallos.git
synced 2026-08-02 11:16:00 -04:00
feat: add Arabic localization feat: add manual logo search box and png prioritization fix: pin discord notification action to a commit sha fix: service worker caching stale logo search results and broken images as logos fix: ai recommendations not handling varied provider responses fix: deleting orphaned logos not taking into account themed variants fix: stats page not using themed logo variants fix: email notification test rejecting non-admin users fix: notification test/send requests hanging on unreachable hosts fix: progress bar showing 100% when next payment is more than one cycle away
108 lines
3.2 KiB
PHP
108 lines
3.2 KiB
PHP
<?php
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
require_once '../../includes/connect_endpoint.php';
|
|
require_once '../../includes/validate_endpoint.php';
|
|
require_once '../../includes/ssrf_helper.php';
|
|
|
|
$postData = file_get_contents("php://input");
|
|
$data = json_decode($postData, true);
|
|
|
|
if (
|
|
!isset($data["smtpaddress"]) || $data["smtpaddress"] == "" ||
|
|
!isset($data["smtpport"]) || $data["smtpport"] == ""
|
|
) {
|
|
$response = [
|
|
"success" => false,
|
|
"message" => translate('fill_all_fields', $i18n)
|
|
];
|
|
die(json_encode($response));
|
|
} else {
|
|
$encryption = "none";
|
|
if (isset($data["encryption"])) {
|
|
$encryption = $data["encryption"];
|
|
}
|
|
|
|
$smtpAuth = (isset($data["smtpusername"]) && $data["smtpusername"] != "") || (isset($data["smtppassword"]) && $data["smtppassword"] != "");
|
|
|
|
require '../../libs/PHPMailer/PHPMailer.php';
|
|
require '../../libs/PHPMailer/SMTP.php';
|
|
require '../../libs/PHPMailer/Exception.php';
|
|
|
|
$smtpAddress = $data["smtpaddress"];
|
|
$smtpPort = (int) $data["smtpport"];
|
|
|
|
if (!validate_smtp_host($smtpAddress, $smtpPort, $db)) {
|
|
die(json_encode([
|
|
"success" => false,
|
|
"message" => "Security Error: SMTP host must not target link-local or loopback addresses."
|
|
]));
|
|
}
|
|
|
|
if ($smtpPort < 1 || $smtpPort > 65535) {
|
|
die(json_encode([
|
|
"success" => false,
|
|
"message" => translate('fill_all_fields', $i18n)
|
|
]));
|
|
}
|
|
$smtpUsername = $data["smtpusername"];
|
|
$smtpPassword = $data["smtppassword"];
|
|
$fromEmail = $data["fromemail"] ? $data['fromemail'] : "wallos@wallosapp.com";
|
|
|
|
$mail = new PHPMailer(true);
|
|
$mail->CharSet = "UTF-8";
|
|
$mail->isSMTP();
|
|
$mail->Timeout = 15;
|
|
|
|
$mail->Host = $smtpAddress;
|
|
$mail->SMTPAuth = $smtpAuth;
|
|
if ($smtpAuth) {
|
|
$mail->Username = $smtpUsername;
|
|
$mail->Password = $smtpPassword;
|
|
}
|
|
|
|
if ($encryption != "none") {
|
|
$mail->SMTPSecure = $encryption;
|
|
} else {
|
|
$mail->SMTPSecure = false;
|
|
$mail->SMTPAutoTLS = false;
|
|
}
|
|
|
|
$mail->Port = $smtpPort;
|
|
|
|
$getUser = "SELECT * FROM user WHERE id = $userId";
|
|
$user = $db->querySingle($getUser, true);
|
|
$email = $user['email'];
|
|
$name = $user['username'];
|
|
|
|
$mail->setFrom($fromEmail, 'Wallos App');
|
|
$mail->addAddress($email, $name);
|
|
|
|
$mail->Subject = translate('wallos_notification', $i18n);
|
|
$mail->Body = translate('test_notification', $i18n);
|
|
|
|
try {
|
|
if ($mail->send()) {
|
|
$response = [
|
|
"success" => true,
|
|
"message" => translate('notification_sent_successfuly', $i18n)
|
|
];
|
|
} else {
|
|
$response = [
|
|
"success" => false,
|
|
"message" => translate('email_error', $i18n) . $mail->ErrorInfo
|
|
];
|
|
}
|
|
} catch (Exception $e) {
|
|
$response = [
|
|
"success" => false,
|
|
"message" => translate('email_error', $i18n) . $e->getMessage()
|
|
];
|
|
}
|
|
|
|
die(json_encode($response));
|
|
|
|
} |