Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
mail: globally define email address database file name and allow to a…
Browse files Browse the repository at this point in the history
…djust it

Change-Id: I4b0b0b929ffaea22f5b32d2a77b508b1c3e74d6b
  • Loading branch information
andi34 committed Jun 3, 2020
1 parent 395259a commit d44ecf0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
7 changes: 2 additions & 5 deletions api/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
}

if($config['reset_remove_mailtxt']) {
$mailAddressesFile = $config['foldersAbs']['data'] . '/mail-addresses.txt';

// delete mail-addresses.txt
if(is_file($mailAddressesFile)){
unlink($mailAddressesFile);
if (is_file(MAIL_FILE)) {
unlink(MAIL_FILE); // delete file
}
}

Expand Down
8 changes: 3 additions & 5 deletions api/sendPic.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@
}

if (isset($_POST['send-link']) && $_POST['send-link'] === 'yes') {
$mailAddressesFile = $config['foldersAbs']['data'] . '/mail-addresses.txt';

if (!file_exists($mailAddressesFile)) {
if (!file_exists(MAIL_FILE)) {
$addresses = [];
} else {
$addresses = json_decode(file_get_contents($mailAddressesFile));
$addresses = json_decode(file_get_contents(MAIL_FILE));
}

if (!in_array($_POST['sendTo'], $addresses)) {
$addresses[] = $_POST['sendTo'];
}

file_put_contents($mailAddressesFile, json_encode($addresses));
file_put_contents(MAIL_FILE, json_encode($addresses));

die(json_encode([
'success' => true,
Expand Down
1 change: 1 addition & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
$config['rounded_corners'] = false;
$config['time_to_live'] = '90000';
$config['db_file'] = 'db';
$config['mail_file'] = 'mail-adresses';

// specify key id to use that key to take a picture or collage (e.g. 13 is the enter key)
// use for example https://keycode.info to get the key code
Expand Down
6 changes: 6 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@
'name' => 'send_all_later',
'value' => $config['send_all_later']
],
'file' => [
'type' => 'input',
'placeholder' => $defaultConfig['mail_file'],
'name' => 'mail_file',
'value' => $config['mail_file']
],
'host' => [
'type' => 'input',
'placeholder' => $defaultConfig['mail_host'],
Expand Down
1 change: 1 addition & 0 deletions lib/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_once(__DIR__ . '/config.php');

define('DB_FILE', $config['foldersAbs']['data'] . DIRECTORY_SEPARATOR . $config['db_file'] . '.txt');
define('MAIL_FILE', $config['foldersAbs']['data'] . DIRECTORY_SEPARATOR . $config['mail_file'] . '.txt');

function getImagesFromDB() {
// get data from db.txt
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"mailError": "Fehler beim Senden der E-Mail",
"mailSaved": "E-Mail-Adresse erfolgreich gespeichert",
"mailSent": "E-Mail gesendet",
"mail_file": "Name der E-Mail-Adressen-Datenbankdatei",
"mail_fromAddress": "Absende Adresse",
"mail_fromName": "Absender Name",
"mail_host": "E-Mail Host Adresse",
Expand Down Expand Up @@ -131,7 +132,7 @@
"reload": "Seite neu laden",
"remove_config": "Persönliche Konfiguration löschen (my.config.inc.php)",
"remove_images": "Bilder löschen",
"remove_mailtxt": "\"mail-addresses.txt\" löschen",
"remove_mailtxt": "E-Mail-Adressen-Datenbankdatei löschen",
"reset": "Zurücksetzen",
"rounded_corners": "Abgerundete Ecken",
"save": "Speichern",
Expand Down
4 changes: 3 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"mailError": "Error sending e-mail",
"mailSaved": "E-mail address saved successfully",
"mailSent": "E-mail sent",
"mail_file": "File name e-mail addresses database",
"mail_fromAddress": "Return address",
"mail_fromName": "Sender name",
"mail_host": "E-mail host adress",
Expand Down Expand Up @@ -152,6 +153,7 @@
"manual_login_enabled": "If enabled, a username and password will be needed to access the adminpage and/or start screen (depending on your setup).",
"manual_login_password": "Define your password used for login. Please note: after saving your password will only be visible as a hash inside adminpanel. For login don't enter the hash, enter the password you have set.",
"manual_login_username": "Define the username used to login into Photobooth.",
"manual_mail_file": "File name for the e-mail addresses database.",
"manual_mail_fromAddress": "Enter your return address which is used while sending pictures via email.",
"manual_mail_fromName": "Enter your sender name which is used while sending pictures via email.",
"manual_mail_host": "Enter your email host adress.",
Expand Down Expand Up @@ -249,7 +251,7 @@
"reload": "Reload Page",
"remove_config": "Delete personal configuration (my.config.inc.php)",
"remove_images": "Delete images",
"remove_mailtxt": "Delete \"mail-addresses.txt\"",
"remove_mailtxt": "Delete e-mail addresses database",
"reset": "Reset",
"rounded_corners": "Rounded corners",
"save": "Save",
Expand Down

0 comments on commit d44ecf0

Please sign in to comment.