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

Allow to adjust database #61

Merged
merged 2 commits into from
Jun 3, 2020
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
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
2 changes: 2 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
$config['webserver_ip'] = null;
$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
12 changes: 12 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
'name' => 'show_error_messages',
'value' => $config['show_error_messages']
],
'db_file' => [
'type' => 'input',
'placeholder' => $defaultConfig['db_file'],
'name' => 'db_file',
'value' => $config['db_file']
],
'file_format_date' => [
'type' => 'checkbox',
'name' => 'file_format_date',
Expand Down Expand Up @@ -682,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
3 changes: 2 additions & 1 deletion lib/db.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
require_once(__DIR__ . '/config.php');

define('DB_FILE', $config['foldersAbs']['data'] . '/db.txt');
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
4 changes: 3 additions & 1 deletion resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"general_cntdwn_time": "Countdown Timer:",
"general_collage_cntdwn_time": "Collage-Countdown Timer:",
"general_collage_key": "Tastencode welcher eine Collage auslöst",
"general_db_file": "Name der Datenbankdatei",
"general_default_imagefilter": "Standardbildfilter",
"general_disabled_filters": "Deaktivierte Bildfilter",
"general_ipCamPreviewRotation": "Vorschau von URL drehen",
Expand Down Expand Up @@ -84,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 @@ -130,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
6 changes: 5 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"general_cntdwn_time": "Countdown timer:",
"general_collage_cntdwn_time": "Collage-countdown timer:",
"general_collage_key": "Key code which triggers a collage",
"general_db_file": "Database file name",
"general_default_imagefilter": "Default image filter",
"general_disabled_filters": "Disabled image filters",
"general_ipCamPreviewRotation": "Rotate preview from URL",
Expand Down Expand Up @@ -86,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 @@ -125,6 +127,7 @@
"manual_general_cntdwn_time": "Set your countdown time.",
"manual_general_collage_cntdwn_time": "Set your countdown time between pictures while taking a collage.",
"manual_general_collage_key": "Specify the key id to use that key to take a collage (e.g. 13 is the enter key). For example use <a href=\"https://keycode.info\" target=\"_blank\">https://keycode.info</a> to find out the key id.",
"manual_general_db_file": "Name of the database file.",
"manual_general_default_imagefilter": "Choose an imagefilter which is applied by default after taking a picture.",
"manual_general_disabled_filters": "Choose filters which get removed from the available imagefilter.",
"manual_general_ipCamPreviewRotation": "Choose to rotate the preview from URL.",
Expand All @@ -150,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 @@ -247,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