From cae4d4f051c41fd3770b715afc6f7308b87915f0 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Wed, 5 Jul 2023 01:08:00 +0100 Subject: [PATCH] use env vars for secrets --- docker-compose.yml | 1 + upload.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0b4279e..c50f6da 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: restart: always environment: - MAX_UPLOAD_SIZE=500M + - UPLOAD_SECRETS=set me # You can add multiple secrets. Format: secret1,secret2,secret3 ports: - 80:80 volumes: diff --git a/upload.php b/upload.php index b2a6113..5f1a1c4 100644 --- a/upload.php +++ b/upload.php @@ -10,7 +10,13 @@ header('Content-type:application/json;charset=utf-8'); // Set the response conte /** * Configuration */ -$uploadSecrets = array("set me"); // Your secret keys +$uploadSecrets; +// Check if the environment variable UPLOAD_SECRETS is set +if (getenv('UPLOAD_SECRETS')) { + $uploadSecrets = explode(",", getenv('UPLOAD_SECRETS')); +} else { + $uploadSecrets = array("set me"); // Use this if you are not using environment variables (eg: Not using Docker) +} $uploadDir = "./"; // The upload directory $useRandomFileNames = false; // Use random file names instead of the original file name $shouldConvertToWebp = true; // Should the script convert images to webp?