Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 23 0 #509

Merged
merged 4 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions endpoints/cronjobs/sendcancellationnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$email['smtpUsername'] = $row["smtp_username"];
$email['smtpPassword'] = $row["smtp_password"];
$email['fromEmail'] = $row["from_email"] ? $row["from_email"] : "[email protected]";
$email['otherEmail'] = $row["other_email"];
$email['otherEmails'] = $row["other_emails"];
}

// Check if Discord notifications are enabled and get the settings
Expand Down Expand Up @@ -217,8 +217,15 @@
$mail->setFrom($email['fromEmail'], 'Wallos App');
$mail->addAddress($emailaddress, $name);

if (!empty($email['otherEmail'])) {
$list = explode(';', $email['otherEmail']);
if (!empty($email['otherEmails'])) {
$list = explode(';', $email['otherEmails']);

// Avoid duplicate emails
$list = array_unique($list);
$list = array_filter($list, function ($value) use ($emailaddress) {
return $value !== $emailaddress;
});

foreach($list as $value) {
$mail->addCC(trim($value));
}
Expand Down
13 changes: 10 additions & 3 deletions endpoints/cronjobs/sendnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$email['smtpUsername'] = $row["smtp_username"];
$email['smtpPassword'] = $row["smtp_password"];
$email['fromEmail'] = $row["from_email"] ? $row["from_email"] : "[email protected]";
$email['otherEmail'] = $row["other_email"];
$email['otherEmails'] = $row["other_emails"];
}

// Check if Discord notifications are enabled and get the settings
Expand Down Expand Up @@ -261,8 +261,15 @@
$mail->setFrom($email['fromEmail'], 'Wallos App');
$mail->addAddress($emailaddress, $name);

if (!empty($email['otherEmail'])) {
$list = explode(';', $email['otherEmail']);
if (!empty($email['otherEmails'])) {
$list = explode(';', $email['otherEmails']);

// Avoid duplicate emails
$list = array_unique($list);
$list = array_filter($list, function ($value) use ($emailaddress) {
return $value !== $emailaddress;
});

foreach($list as $value) {
$mail->addCC(trim($value));
}
Expand Down
10 changes: 5 additions & 5 deletions endpoints/notifications/saveemailnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$smtpUsername = $data["smtpusername"];
$smtpPassword = $data["smtppassword"];
$fromEmail = $data["fromemail"];
$otherEmail = $data["otheremail"];
$otherEmails = $data["otheremails"];

$query = "SELECT COUNT(*) FROM email_notifications WHERE user_id = :userId";
$stmt = $db->prepare($query);
Expand All @@ -51,12 +51,12 @@
$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_email, encryption, user_id)
VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :otherEmail, :encryption, :userId)";
$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_email = :otherEmail, encryption = :encryption WHERE user_id = :userId";
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, other_emails = :otherEmails, encryption = :encryption WHERE user_id = :userId";
}

$stmt = $db->prepare($query);
Expand All @@ -66,7 +66,7 @@
$stmt->bindValue(':smtpUsername', $smtpUsername, SQLITE3_TEXT);
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
$stmt->bindValue(':otherEmail', $otherEmail, SQLITE3_TEXT);
$stmt->bindValue(':otherEmails', $otherEmails, SQLITE3_TEXT);
$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);

Expand Down
34 changes: 34 additions & 0 deletions endpoints/settings/show_original_price.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
require_once '../../includes/connect_endpoint.php';

if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
die(json_encode([
"success" => false,
"message" => translate('session_expired', $i18n)
]));
}

if ($_SERVER["REQUEST_METHOD"] === "POST") {
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);

$show_original_price = $data['value'];

$stmt = $db->prepare('UPDATE settings SET show_original_price = :show_original_price WHERE user_id = :userId');
$stmt->bindParam(':show_original_price', $show_original_price, SQLITE3_INTEGER);
$stmt->bindParam(':userId', $userId, SQLITE3_INTEGER);

if ($stmt->execute()) {
die(json_encode([
"success" => true,
"message" => translate("success", $i18n)
]));
} else {
die(json_encode([
"success" => false,
"message" => translate("error", $i18n)
]));
}
}

?>
3 changes: 2 additions & 1 deletion endpoints/subscription/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
if ($cloneStmt->execute()) {
$response = [
"success" => true,
"message" => translate('success', $i18n)
"message" => translate('success', $i18n),
"id" => $db->lastInsertRowID()
];
echo json_encode($response);
} else {
Expand Down
62 changes: 44 additions & 18 deletions endpoints/subscriptions/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,50 @@
$params = array();
$sql = "SELECT * FROM subscriptions WHERE user_id = :userId";

if (isset($_GET['category']) && $_GET['category'] != "") {
$sql .= " AND category_id = :category";
$params[':category'] = $_GET['category'];
}

if (isset($_GET['payments']) && $_GET['payments'] !== "") {
$sql .= " AND (";
$innerSql = [];
$idx = 0;
$allPayments = explode(',', $_GET['payments']);
foreach($allPayments as $payment) {
$innerSql[] = "payment_method_id = :payments{$idx}";
$params[':payments' . $idx] = $payment;
$idx++;
if (isset($_GET['categories']) && $_GET['categories'] != "") {
$allCategories = explode(',', $_GET['categories']);
$placeholders = array_map(function($idx) {
return ":categories{$idx}";
}, array_keys($allCategories));

$sql .= " AND (" . implode(' OR ', array_map(function($placeholder) {
return "category_id = {$placeholder}";
}, $placeholders)) . ")";

foreach ($allCategories as $idx => $category) {
$params[":categories{$idx}"] = $category;
}
$sql .= implode(' OR ', $innerSql) . ")";
}

if (isset($_GET['payments']) && $_GET['payments'] !== "") {
$allPayments = explode(',', $_GET['payments']);
$placeholders = array_map(function($idx) {
return ":payments{$idx}";
}, array_keys($allPayments));

$sql .= " AND (" . implode(' OR ', array_map(function($placeholder) {
return "payment_method_id = {$placeholder}";
}, $placeholders)) . ")";

foreach ($allPayments as $idx => $payment) {
$params[":payments{$idx}"] = $payment;
}
}

if (isset($_GET['members']) && $_GET['members'] != "") {
$allMembers = explode(',', $_GET['members']);
$placeholders = array_map(function($idx) {
return ":members{$idx}";
}, array_keys($allMembers));

$sql .= " AND (" . implode(' OR ', array_map(function($placeholder) {
return "payer_user_id = {$placeholder}";
}, $placeholders)) . ")";

if (isset($_GET['member']) && $_GET['member'] != "") {
$sql .= " AND payer_user_id = :member";
$params[':member'] = $_GET['member'];
foreach ($allMembers as $idx => $member) {
$params[":members{$idx}"] = $member;
}
}

if (isset($_GET['state']) && $_GET['state'] != "") {
$sql .= " AND inactive = :inactive";
Expand Down Expand Up @@ -141,6 +163,10 @@
if (isset($settings['showMonthlyPrice']) && $settings['showMonthlyPrice'] === 'true') {
$print[$id]['price'] = getPricePerMonth($cycle, $frequency, $print[$id]['price']);
}
if (isset($settings['showOriginalPrice']) && $settings['showOriginalPrice'] === 'true') {
$print[$id]['original_price'] = floatval($subscription['price']);
$print[$id]['original_currency_code'] = $currencies[$subscription['currency_id']]['code'];
}
}

if ($sortOrder == "alphanumeric") {
Expand Down
1 change: 1 addition & 0 deletions includes/getsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$settings['removeBackground'] = $settings['remove_background'] ? 'true': 'false';
$settings['hideDisabledSubscriptions'] = $settings['hide_disabled'] ? 'true': 'false';
$settings['disabledToBottom'] = $settings['disabled_to_bottom'] ? 'true': 'false';
$settings['showOriginalPrice'] = $settings['show_original_price'] ? 'true': 'false';
}

$query = "SELECT * FROM custom_colors WHERE user_id = :userId";
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "SMTP Benutzername",
"smtp_password" => "SMTP Passwort",
"from_email" => "Absender E-Mail Adresse (optional)",
"send_to_other_emails" => "Benachrichtigungen auch an die folgenden E-Mail-Adressen senden (verwende ; um sie zu trennen):",
"smtp_info" => "Das SMTP Passwort wird in Klartext übermittelt und gespeichert. Aus Sicherheitsgründen erstelle bitte einen gesonderten Account nur zu diesem Zweck.",
"telegram" => "Telegram",
"telegram_bot_token" => "Telegram Bot Token",
Expand Down Expand Up @@ -196,6 +197,8 @@
"reset_custom_colors" => "Benutzerdefinierte Farben zurücksetzen",
"calculate_monthly_price" => "Berechne und zeige monatlichen Preis für alle Abonnements an",
"convert_prices" => "Preise immer in meine Hauptwährung umrechnen und darin anzeigen (langsamer)",
"show_original_price" => "Originalpreis anzeigen, wenn Umrechnungen oder Berechnungen durchgeführt werden",
"disabled_subscriptions" => "Deaktivierte Abonnements",
"hide_disabled_subscriptions" => "Deaktivierte Abonnements verstecken",
"show_disabled_subscriptions_at_the_bottom" => "Deaktivierte Abonnements am Ende anzeigen",
"experimental_settings" => "Experimentelle Einstellungen",
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "SMTP χρήστης",
"smtp_password" => "SMTP κωδικός",
"from_email" => "Από (Προαιρετικό)",
"send_to_other_emails" => "Επίσης στείλτε ειδοποιήσεις στις ακόλουθες διευθύνσεις email (χρησιμοποιήστε ; για να τις διαχωρίσετε):",
"smtp_info" => "Ο κωδικός πρόσβασης SMTP μεταδίδεται και αποθηκεύεται σε απλό κείμενο. Για λόγους ασφαλείας, παρακαλούμε δημιούργησε έναν λογαριασμό μόνο γι' αυτό το σκοπό.",
"telegram" => "Telegram",
"telegram_bot_token" => "Τηλεγραφήματα Bot Token",
Expand Down Expand Up @@ -196,6 +197,8 @@
"save_custom_css" => "Αποθήκευση προσαρμοσμένου CSS",
"calculate_monthly_price" => "Υπολογισμός και εμφάνιση της μηνιαίας τιμής για όλες τις συνδρομές",
"convert_prices" => "Πάντα να μετατρέπει και να εμφανίζει τις τιμές στο κύριο νόμισμά μου (πιο αργό)",
"show_original_price" => "Εμφάνιση της αρχικής τιμής όταν γίνονται μετατροπές ή υπολογισμοί",
"disabled_subscriptions" => "Απενεργοποιημένες συνδρομές",
"hide_disabled_subscriptions" => "Απόκρυψη απενεργοποιημένων συνδρομών",
"show_disabled_subscriptions_at_the_bottom" => "Εμφάνιση απενεργοποιημένων συνδρομών στο τέλος",
"experimental_settings" => "Πειραματικές ρυθμίσεις",
Expand Down
5 changes: 4 additions & 1 deletion includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
"smtp_username" => "SMTP Username",
"smtp_password" => "SMTP Password",
"from_email" => "From email (Optional)",
"other_email" => "Other email (Use ; to separate)",
"send_to_other_emails" => "Also send notifications to the following email addresses (use ; to separate them):",
"other_emails_placeholder" => "[email protected];[email protected]",
"smtp_info" => "SMTP Password is transmitted and stored in plaintext. For security, please create an account just for this.",
"telegram" => "Telegram",
"telegram_bot_token" => "Telegram Bot Token",
Expand Down Expand Up @@ -197,6 +198,8 @@
"save_custom_css" => "Save Custom CSS",
"calculate_monthly_price" => "Calculate and show monthly price for all subscriptions",
"convert_prices" => "Always convert and show prices on my main currency (slower)",
"show_original_price" => "Also show original price when conversions or calculations are made",
"disabled_subscriptions" => "Disabled Subscriptions",
"hide_disabled_subscriptions" => "Hide disabled subscriptions",
"show_disabled_subscriptions_at_the_bottom" => "Show disabled subscriptions at the bottom",
"experimental_settings" => "Experimental Settings",
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "Nombre de usuario SMTP",
"smtp_password" => "Contraseña SMTP",
"from_email" => "Correo electrónico de origen (Opcional)",
"send_to_other_emails" => "También enviar notificaciones a las siguientes direcciones de correo electrónico (use ; para separarlas):",
"smtp_info" => "La contraseña SMTP se transmite y almacena en texto plano. Por seguridad, crea una cuenta solo para esto.",
"telegram" => "Telegram",
"telegram_bot_token" => "Token del Bot de Telegram",
Expand Down Expand Up @@ -196,6 +197,8 @@
"save_custom_css" => "Guardar CSS Personalizado",
"calculate_monthly_price" => "Calcular y mostrar el precio mensual de todas las suscripciones",
"convert_prices" => "Convertir y mostrar siempre los precios en mi moneda principal (más lento)",
"show_original_price" => "Mostrar también el precio original cuando se realicen conversiones o cálculos",
"disabled_subscriptions" => "Suscripciones Desactivadas",
"hide_disabled_subscriptions" => "Ocultar suscripciones desactivadas",
"show_disabled_subscriptions_at_the_bottom" => "Mostrar suscripciones desactivadas al final",
"experimental_settings" => "Configuraciones Experimentales",
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "Nom d'utilisateur SMTP",
"smtp_password" => "Mot de passe SMTP",
"from_email" => "De l'adresse courriel (facultatif)",
"send_to_other_emails" => "Envoyer également des notifications aux adresses courriel suivantes (utilisez ; pour les séparer):",
"smtp_info" => "Le mot de passe SMTP est transmis et stocké en texte brut. Pour des raisons de sécurité, veuillez créer un compte uniquement à cette fin.",
"telegram" => "Telegram",
"telegram_bot_token" => "Jeton du bot Telegram",
Expand Down Expand Up @@ -196,6 +197,8 @@
"save_custom_css" => "Enregistrer le CSS personnalisé",
"calculate_monthly_price" => "Calculer et afficher le prix mensuel pour tous les abonnements",
"convert_prices" => "Convertir toujours et afficher les prix dans ma devise principale (plus lent)",
"show_original_price" => "Afficher également le prix original lorsque des conversions ou des calculs sont effectués",
"disabled_subscriptions" => "Abonnements désactivés",
"hide_disabled_subscriptions" => "Masquer les abonnements désactivés",
"show_disabled_subscriptions_at_the_bottom" => "Afficher les abonnements désactivés en bas",
"experimental_settings" => "Paramètres expérimentaux",
Expand Down
3 changes: 2 additions & 1 deletion includes/i18n/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
'smtp_username' => 'Nome utente SMTP',
'smtp_password' => 'Password SMTP',
'from_email' => 'Da quale e-mail (Opzionale)',
"other_email" => "Altre e-mail (Usa ; per separare)",
'smtp_info' => 'La password SMTP viene memorizzata e trasmessa in chiaro. Per motivi di sicurezza, si prega di creare un account da utilizzare solo per questo.',
"telegram" => "Telegram",
"telegram_bot_token" => "Telegram Bot Token",
Expand Down Expand Up @@ -205,6 +204,8 @@
"save_custom_css" => "Salva CSS personalizzato",
'calculate_monthly_price' => 'Calcola e mostra il prezzo mensile per tutti gli abbonamenti',
'convert_prices' => 'Converti sempre e mostra i prezzi nella mia valuta principale (più lento)',
"show_original_price" => "Mostra anche il prezzo originale quando vengono effettuate conversioni o calcoli",
"disabled_subscriptions" => 'Abbonamenti disattivati',
"hide_disabled_subscriptions" => 'Nascondi gli abbonamenti disattivati',
"show_disabled_subscriptions_at_the_bottom" => 'Mostra gli abbonamenti disattivati in fondo',
'experimental_settings' => 'Impostazioni sperimentali',
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "SMTPユーザー名",
"smtp_password" => "SMTPパスワード",
"from_email" => "送信元アドレス (オプション)",
"send_to_other_emails" => "通知を以下のメールアドレスにも送信する(区切りには ; を使用):",
"smtp_info" => "SMTPパスワードは平文で送信および保存されます。セキュリティのため専用のアカウントを作成してください。",
"telegram" => "Telegram",
"telegram_bot_token" => "Telegramボットトークン",
Expand Down Expand Up @@ -196,6 +197,8 @@
"save_custom_css" => "カスタムCSSを保存",
"calculate_monthly_price" => "すべての定期購入の月額料金を計算して表示する",
"convert_prices" => "常にメイン通貨で価格を換算して表示する (遅い)",
"show_original_price" => "変換や計算が行われるときに元の価格も表示する",
"disabled_subscriptions" => "無効な定期購入",
"hide_disabled_subscriptions" => "無効な定期購入を非表示にする",
"show_disabled_subscriptions_at_the_bottom" => "無効な定期購入を一番下に表示する",
"experimental_settings" => "実験的な設定",
Expand Down
3 changes: 3 additions & 0 deletions includes/i18n/ko.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"smtp_username" => "SMTP 유저명",
"smtp_password" => "SMTP 비밀번호",
"from_email" => "발송 주소 (선택사항)",
"send_to_other_emails" => "알림을 다음 이메일 주소로도 보내기 (구분자는 ; 사용):",
"smtp_info" => "SMTP 비밀번호는 평문으로 저장되고 발송됩니다. 보안을 위해, 이 서비스를 위해서만 사용하는 계정을 생성해 주세요.",
"telegram" => "텔레그램",
"telegram_bot_token" => "텔레그램 봇 토큰",
Expand Down Expand Up @@ -197,6 +198,8 @@
"save_custom_css" => "커스텀 CSS 저장",
"calculate_monthly_price" => "모든 구독에 대한 월별 요금을 계산하고 표시",
"convert_prices" => "항상 기본 통화로 가격을 환산하고 표시 (느림)",
"show_original_price" => "변환이나 계산이 이루어질 때 원래 가격도 표시",
"disabled_subscriptions" => "비활성화된 구독",
"hide_disabled_subscriptions" => "비활성화된 구독 숨기기",
"show_disabled_subscriptions_at_the_bottom" => "비활성화된 구독을 하단에 표시",
"experimental_settings" => "실험적 설정",
Expand Down
Loading