Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build-faq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ jobs:
else
echo "created=false" >> "$GITHUB_OUTPUT"
fi
- name: Push changes to dev
- name: Push changes
if: steps.commit.outputs.created == 'true'
run: git push origin dev
run: git push origin HEAD:${{ github.ref_name }}
1 change: 1 addition & 0 deletions admin/debug/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
echo getNavItemDebug('remotebuzzerlog');
echo getNavItemDebug('synctodrivelog');
echo getNavItemDebug('remotestoragelog');
echo getNavItemDebug('uploadworkerlog');
echo getNavItemDebug('rembglog');
echo getNavItemDebug('devlog');
if (Environment::isLinux()) {
Expand Down
18 changes: 18 additions & 0 deletions api/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Photobooth\Service\DatabaseManagerService;
use Photobooth\Service\ImageMetadataCacheService;
use Photobooth\Service\LoggerService;
use Photobooth\Service\EncryptionService;
use Photobooth\Service\MailService;
use Photobooth\Service\PrintManagerService;
use Photobooth\Service\ProcessService;
Expand Down Expand Up @@ -182,6 +183,14 @@
$newConfig['login']['pin'] = $keepExistingSecret('pin', $newConfig['login']['pin'] ?? null, $config);
$newConfig['login']['rental_pin'] = $keepExistingSecret('rental_pin', $newConfig['login']['rental_pin'] ?? null, $config);

// Keep existing FTP/Mail passwords when the form sends an empty value
if (($newConfig['ftp']['password'] ?? '') === '' && !empty($config['ftp']['password'])) {
$newConfig['ftp']['password'] = $config['ftp']['password'];
}
if (($newConfig['mail']['password'] ?? '') === '' && !empty($config['mail']['password'])) {
$newConfig['mail']['password'] = $config['mail']['password'];
}

// Hash password early when a new value is provided
if (!empty($newConfig['login']['password']) && $newConfig['login']['password'] !== ($config['login']['password'] ?? null)) {
$newConfig['login']['password'] = password_hash($newConfig['login']['password'], PASSWORD_DEFAULT);
Expand Down Expand Up @@ -334,6 +343,15 @@
}
}

// Encrypt FTP and Mail passwords before saving to config file
$encryptionService = EncryptionService::getInstance();
if (!empty($newConfig['ftp']['password']) && !$encryptionService->isEncrypted($newConfig['ftp']['password'])) {
$newConfig['ftp']['password'] = $encryptionService->encrypt($newConfig['ftp']['password']);
}
if (!empty($newConfig['mail']['password']) && !$encryptionService->isEncrypted($newConfig['mail']['password'])) {
$newConfig['mail']['password'] = $encryptionService->encrypt($newConfig['mail']['password']);
}

if ($newConfig['logo']['enabled']) {
$logoPath = $newConfig['logo']['path'];

Expand Down
14 changes: 8 additions & 6 deletions api/applyEffects.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Photobooth\Service\DatabaseManagerService;
use Photobooth\Service\LoggerService;
use Photobooth\Service\RemoteStorageService;
use Photobooth\Service\UploadQueueService;
use Photobooth\Utility\ImageUtility;
use Photobooth\Utility\PathUtility;

Expand Down Expand Up @@ -336,13 +337,14 @@
}
}

// Store images on remote storage
// Queue images for async remote storage upload
if ($config['ftp']['enabled']) {
$remoteStorage->write($remoteStorage->getStorageFolder() . '/images/' . $vars['singleImageFile'], (string) file_get_contents($vars['resultFile']));
$remoteStorage->write($remoteStorage->getStorageFolder() . '/thumbs/' . $vars['singleImageFile'], (string) file_get_contents($vars['thumbFile']));
if ($config['ftp']['create_webpage']) {
$remoteStorage->createWebpage();
}
$uploadQueue = UploadQueueService::getInstance();
$uploadQueue->enqueue(
$vars['singleImageFile'],
$vars['singleImageFile'],
(bool) $config['ftp']['create_webpage']
);
}

// Change permissions
Expand Down
10 changes: 6 additions & 4 deletions api/deletePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
use Photobooth\Service\ImageMetadataCacheService;
use Photobooth\Service\LoggerService;
use Photobooth\Service\RemoteStorageService;
use Photobooth\Service\UploadQueueService;

header('Content-Type: application/json');

$logger = LoggerService::getInstance()->getLogger('main');
$logger->debug(basename($_SERVER['PHP_SELF']));

$remoteStorage = RemoteStorageService::getInstance();

try {
if (empty($_POST['file'])) {
throw new \Exception('No file provided');
Expand Down Expand Up @@ -81,8 +80,11 @@
}

if ($config['ftp']['enabled'] && $config['ftp']['delete']) {
$remoteStorage->delete($remoteStorage->getStorageFolder() . '/images/' . $fileName);
$remoteStorage->delete($remoteStorage->getStorageFolder() . '/thumbs/' . $fileName);
$remoteStorage = RemoteStorageService::getInstance();
$uploadQueue = UploadQueueService::getInstance();
$remoteFilename = $uploadQueue->getRemoteFilename($fileName) ?? $fileName;
$remoteStorage->delete('images/' . $remoteFilename);
$remoteStorage->delete('thumbs/' . $remoteFilename);
}
}

Expand Down
44 changes: 44 additions & 0 deletions api/ftpListFolders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require_once '../lib/boot.php';

use Photobooth\Service\ConfigurationService;
use Photobooth\Service\RemoteStorageService;

header('Content-Type: application/json');
checkCsrfOrFail($_POST);

$ftpData = $_POST['ftp'] ?? [];

$type = (string) ($ftpData['type'] ?? 'ftp');
$host = (string) ($ftpData['baseURL'] ?? '');
$port = (int) ($ftpData['port'] ?? 21);
$username = (string) ($ftpData['username'] ?? '');
$password = (string) ($ftpData['password'] ?? '');
$path = (string) ($_POST['path'] ?? '/');

if ($host === '' || $username === '') {
echo json_encode(['error' => 'Missing connection parameters']);
exit();
}

// If password is empty, use the saved (decrypted) config password
if ($password === '') {
$savedConfig = ConfigurationService::getInstance()->getConfiguration();
$password = (string) ($savedConfig['ftp']['password'] ?? '');
}

try {
$folders = RemoteStorageService::listFolders([
'type' => $type,
'baseURL' => $host,
'port' => $port,
'username' => $username,
'password' => $password,
], $path);

echo json_encode(['folders' => $folders]);
} catch (\Throwable $e) {
echo json_encode(['error' => $e->getMessage()]);
}
exit();
8 changes: 5 additions & 3 deletions api/print.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Photobooth\Service\LoggerService;
use Photobooth\Service\PrintManagerService;
use Photobooth\Service\RemoteStorageService;
use Photobooth\Service\UploadQueueService;
use Photobooth\Utility\PathUtility;

header('Content-Type: application/json');
Expand Down Expand Up @@ -156,10 +157,11 @@
$remoteStorageService = RemoteStorageService::getInstance();
$url = $remoteStorageService->getWebpageUri();
if ($config['qr']['append_filename']) {
$url .= '/images/';
$uploadQueue = UploadQueueService::getInstance();
$remoteFilename = $uploadQueue->getRemoteFilename($vars['fileName']) ?? $vars['fileName'];
$url .= '/?img=' . rawurlencode($remoteFilename);
}
}
if ($config['qr']['append_filename']) {
} elseif ($config['qr']['append_filename']) {
$url .= $vars['fileName'];
}
$imageHandler->qrUrl = PathUtility::getPublicPath($url, true);
Expand Down
12 changes: 8 additions & 4 deletions api/qrcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/** @var array $config */

use Photobooth\Service\RemoteStorageService;
use Photobooth\Service\UploadQueueService;
use Photobooth\Utility\PathUtility;
use Photobooth\Utility\QrCodeUtility;

Expand All @@ -20,12 +21,15 @@
if ($config['ftp']['enabled'] && $config['ftp']['useForQr']) {
$remoteStorageService = RemoteStorageService::getInstance();
$url = $remoteStorageService->getWebpageUri();
if ($config['qr']['append_filename']) {
$url .= '/images/';
}
}
if ($config['qr']['append_filename']) {
$url .= $filename;
if ($config['ftp']['enabled'] && $config['ftp']['useForQr']) {
$uploadQueue = UploadQueueService::getInstance();
$remoteFilename = $uploadQueue->getRemoteFilename($filename) ?? $filename;
$url .= '/?img=' . rawurlencode($remoteFilename);
} else {
$url .= $filename;
}
}
$url = PathUtility::getPublicPath($url, true);
try {
Expand Down
2 changes: 2 additions & 0 deletions api/serverInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function handleDebugPanel(string $content, array $config): string|false
return readFileContents(PathUtility::getAbsolutePath('var/log/synctodrive.log'));
case 'nav-remotestoragelog':
return readFileContents(PathUtility::getAbsolutePath('var/log/remotestorage.log'));
case 'nav-uploadworkerlog':
return readFileContents(PathUtility::getAbsolutePath('var/log/uploadworker.log'));
case 'nav-rembglog':
return readFileContents(PathUtility::getAbsolutePath('var/log/rembg.log'));
case 'nav-myconfig':
Expand Down
Loading
Loading