mirror of
https://github.com/ellite/Wallos.git
synced 2026-08-02 11:16:00 -04:00
feat: option for the week to start on sunday feat: redesign login / registration pages feat: more statistics feat: declarative oidc settings feat: grid view for subscriptions feat: subscription details popup feat: translate categories with ai feat: google image search with serpapi feat: selfh.st image search feat: dashboard icons image search fix: improve background removal feature for logos feat: v2.0 api - write endpoints fix: include todays subscriptions on amount due this month fix: calendar occurrences to respect subscription start date fix: honor configured outbound proxy for logo search without reopening httpoxy SSRF bypass fix: remove hardcode string from the admin page fix: ssrf via http proxy env var in payments logo search fix: require cron auth guard on storetotalyearlycost.php fix: validate per-user smtp host against ssrf fix: escape iCal property values to prevent crlf injection
86 lines
3.5 KiB
PHP
86 lines
3.5 KiB
PHP
<?php
|
|
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_mandatory_fields', $i18n)
|
|
];
|
|
echo json_encode($response);
|
|
} else {
|
|
$enabled = $data["enabled"];
|
|
$smtpAddress = $data["smtpaddress"];
|
|
$smtpPort = $data["smtpport"];
|
|
$encryption = "tls";
|
|
if (isset($data["encryption"])) {
|
|
$encryption = $data["encryption"];
|
|
}
|
|
$smtpUsername = $data["smtpusername"];
|
|
$smtpPassword = $data["smtppassword"];
|
|
$fromEmail = $data["fromemail"];
|
|
$otherEmails = $data["otheremails"];
|
|
|
|
if (!validate_smtp_host($smtpAddress, (int) $smtpPort, $db)) {
|
|
die(json_encode([
|
|
"success" => false,
|
|
"message" => "Security Error: SMTP host must not target link-local or loopback addresses."
|
|
]));
|
|
}
|
|
|
|
$query = "SELECT COUNT(*) FROM email_notifications WHERE user_id = :userId";
|
|
$stmt = $db->prepare($query);
|
|
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
|
$result = $stmt->execute();
|
|
|
|
if ($result === false) {
|
|
$response = [
|
|
"success" => false,
|
|
"message" => translate('error_saving_notifications', $i18n)
|
|
];
|
|
echo json_encode($response);
|
|
} else {
|
|
$row = $result->fetchArray();
|
|
$count = $row[0];
|
|
if ($count == 0) {
|
|
$query = "INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, other_emails, encryption, user_id)
|
|
VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :otherEmails, :encryption, :userId)";
|
|
} else {
|
|
$query = "UPDATE email_notifications
|
|
SET enabled = :enabled, smtp_address = :smtpAddress, smtp_port = :smtpPort,
|
|
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, other_emails = :otherEmails, encryption = :encryption WHERE user_id = :userId";
|
|
}
|
|
|
|
$stmt = $db->prepare($query);
|
|
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
|
$stmt->bindValue(':smtpAddress', $smtpAddress, SQLITE3_TEXT);
|
|
$stmt->bindValue(':smtpPort', $smtpPort, SQLITE3_INTEGER);
|
|
$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);
|
|
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
|
|
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
|
|
$stmt->bindValue(':otherEmails', $otherEmails, SQLITE3_TEXT);
|
|
$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);
|
|
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
|
|
|
if ($stmt->execute()) {
|
|
$response = [
|
|
"success" => true,
|
|
"message" => translate('notifications_settings_saved', $i18n)
|
|
];
|
|
echo json_encode($response);
|
|
} else {
|
|
$response = [
|
|
"success" => false,
|
|
"message" => translate('error_saving_notifications', $i18n)
|
|
];
|
|
echo json_encode($response);
|
|
}
|
|
}
|
|
} |